Highscore shows ranking, not position in list.
This commit is contained in:
@@ -7,7 +7,7 @@
|
|||||||
</h3>
|
</h3>
|
||||||
<ol>
|
<ol>
|
||||||
<li v-for="person in highscore" :key="person">
|
<li v-for="person in highscore" :key="person">
|
||||||
{{ person.name }} - {{ person.wins.length }}
|
<b>{{ person.rank }}.</b> {{ person.name }} - {{ person.wins.length }}
|
||||||
</li>
|
</li>
|
||||||
</ol>
|
</ol>
|
||||||
</div>
|
</div>
|
||||||
@@ -23,13 +23,26 @@ export default {
|
|||||||
},
|
},
|
||||||
async mounted() {
|
async mounted() {
|
||||||
let response = await highscoreStatistics();
|
let response = await highscoreStatistics();
|
||||||
response.sort((a, b) => {
|
response.sort((a, b) => a.wins.length < b.wins.length ? 1 : -1)
|
||||||
return a.wins.length > b.wins.length ? -1 : 1;
|
this.highscore = this.generateScoreBoard(response.slice(0, 10));
|
||||||
});
|
},
|
||||||
response = response.filter(
|
methods: {
|
||||||
person => person.name != null && person.name != ""
|
generateScoreBoard(highscore=this.highscore) {
|
||||||
);
|
let place = 0;
|
||||||
this.highscore = response.slice(0, 10);
|
let highestWinCount = -1;
|
||||||
|
|
||||||
|
return highscore.map(win => {
|
||||||
|
const wins = win.wins.length
|
||||||
|
if (wins != highestWinCount) {
|
||||||
|
place += 1
|
||||||
|
highestWinCount = wins
|
||||||
|
}
|
||||||
|
|
||||||
|
const placeString = place.toString().padStart(2, "0");
|
||||||
|
win.rank = placeString;
|
||||||
|
return win
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
@@ -67,19 +80,8 @@ ol {
|
|||||||
counter-reset: item;
|
counter-reset: item;
|
||||||
& > li {
|
& > li {
|
||||||
padding: 2.5px 0;
|
padding: 2.5px 0;
|
||||||
width: max-content;
|
|
||||||
margin: 0 0 0 -1.25rem;
|
margin: 0 0 0 -1.25rem;
|
||||||
padding: 0;
|
|
||||||
list-style-type: none;
|
list-style-type: none;
|
||||||
counter-increment: item;
|
|
||||||
&:before {
|
|
||||||
display: inline-block;
|
|
||||||
width: 1em;
|
|
||||||
padding-right: 0.5rem;
|
|
||||||
font-weight: bold;
|
|
||||||
text-align: right;
|
|
||||||
content: counter(item) ".";
|
|
||||||
}
|
|
||||||
|
|
||||||
@include mobile {
|
@include mobile {
|
||||||
padding: 5px 0;
|
padding: 5px 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user