Skip to content

Commit

Permalink
feat: add sorted scoreboard feature to display player scores on game …
Browse files Browse the repository at this point in the history
…board
  • Loading branch information
ehippy committed Dec 16, 2024
1 parent 17e647d commit 8caadc3
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions src/views/gameBoard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,15 @@ export default {
lightningLocations: []
}
},
computed: {
sortedScoreboard() {
const playersWithPoints = this.game.GamePlayers.filter(player => player.stats.gamePoint !== undefined && player.stats.gamePoint > 0);
return playersWithPoints.sort((a, b) => {
return b.stats.gamePoint - a.stats.gamePoint
})
}
},
methods: {
handleKeypress(event) {
//console.log('Key pressed:', event.key);
Expand Down Expand Up @@ -556,6 +565,21 @@ export default {
</button>
</div>
</div>
<div class="row" v-if="game.status == 'active'">
<div class="col-lg-6 offset-lg-3">
<h2 class="mt-5">Scores</h2>
<p class="small">Points are earned by holding the goal square when the game ticks. First player to <strong>five points</strong> wins!</p>
<ol v-if="sortedScoreboard.length > 0">
<li v-for="gp in sortedScoreboard">
<strong>{{ gp.Player.name }}</strong> {{ gp.stats.gamePoint }} points{{ gp.stats.killedSomeone? `, ${gp.stats.killedSomeone} kills`:`` }}
</li>
</ol>
<div v-else class="alert alert-info">
No points yet! Get to that goal square!
</div>
</div>
</div>
</div>
</main>
</template>
Expand Down

0 comments on commit 8caadc3

Please sign in to comment.