Improve history overview

This commit is contained in:
Tim 2021-07-28 21:14:38 +02:00
parent f91f7ea7ed
commit c3e203e9d4
3 changed files with 91 additions and 36 deletions

View File

@ -1,11 +1,20 @@
<template> <template>
<table v-if="round.loser"> <md-app v-if="round.loser">
<md-app-content>
<div class="md-layout">
<div class="md-layout-item centered">
<h3>Round {{ round.number + 1 }}, {{ round.loser.name }} lost</h3>
</div>
</div>
<div class="md-layout">
<div class="md-layout-item">
<table>
<tr> <tr>
<td>Round: {{ round.number + 1 }}</td> <td></td>
<td>Loser: {{ round.loser.name }}</td> <td>Throws</td>
</tr> </tr>
<tr v-for="(playerRoll, pId) in round.rolls"> <tr v-for="(playerRoll, pId) in round.rolls">
<td>{{ players[pId].name }}:</td> <td>{{ players[pId].name }}</td>
<td> <td>
<template v-for="(count, number) in playerRoll"> <template v-for="(count, number) in playerRoll">
<die v-for="n in count" :number="number" :key="'r'+pId+round.number+n+number"></die> <die v-for="n in count" :number="number" :key="'r'+pId+round.number+n+number"></die>
@ -13,17 +22,32 @@
</td> </td>
</tr> </tr>
</table> </table>
</div>
<div class="md-layout-item">
<round-turns :round="round" />
</div>
</div>
</md-app-content>
</md-app>
</template> </template>
<script lang="ts"> <script lang="ts">
import {Component, Prop, Vue} from 'vue-property-decorator' import {Component, Prop, Vue} from 'vue-property-decorator'
import {RoundObject, PlayerObject} from "@/objects/objects"; import {RoundObject, PlayerObject} from "@/objects/objects";
import Die from "@/components/Die.vue"; import Die from "@/components/Die.vue";
import RoundTurns from "@/components/RoundTurns.vue";
@Component({ @Component({
components: {Die} components: {RoundTurns, Die}
}) })
export default class Round extends Vue { export default class Round extends Vue {
@Prop() private round!: RoundObject; @Prop() private round!: RoundObject;
@Prop() private players!: Record<string, PlayerObject>; @Prop() private players!: Record<string, PlayerObject>;
} }
</script> </script>
<style scoped lang="scss">
.centered {
text-align: center;
}
</style>

View File

@ -0,0 +1,29 @@
<template>
<table>
<tr>
<td></td>
<td>Guesses</td>
</tr>
<tr v-for="turn in round.turns">
<td>
{{ turn.number + 1 }} - {{ turn.player.name }}
</td>
<td>
<die v-for="n in turn.diceCount" :number="turn.dieValue" :key="'g'+n+turn.dieValue"></die>
</td>
</tr>
</table>
</template>
<script lang="ts">
import {Component, Prop, Vue} from 'vue-property-decorator'
import {RoundObject} from "@/objects/objects";
import Die from "@/components/Die.vue";
@Component({
components: {Die}
})
export default class RoundTurns extends Vue {
@Prop() private round!: RoundObject;
}
</script>

View File

@ -74,14 +74,7 @@
<br><br> <br><br>
<template v-if="lastTurn"> <template v-if="lastTurn">
Last guesses: <br> Last guesses: <br>
<table> <round-turns :round="currentRound" />
<tr v-for="turn in currentRound.turns">
<td>{{ turn.player.name }} ({{ turn.number + 1 }}):</td>
<td>
<die v-for="n in turn.diceCount" :number="turn.dieValue" :key="'g'+n+turn.dieValue"></die>
</td>
</tr>
</table>
</template> </template>
<br> <br>
<template v-if="!myTurn">Someone else is playing, waiting for your turn<br></template> <template v-if="!myTurn">Someone else is playing, waiting for your turn<br></template>
@ -100,16 +93,13 @@
</div> </div>
</div> </div>
<br> <br>
<md-app>
<md-app-content>
<template v-if="gameStateObject && gameStarted"> <template v-if="gameStateObject && gameStarted">
History: <br> History: <br>
<template v-for="round in gameStateObject.rounds.slice().reverse()"> <template v-for="round in gameStateObject.rounds.slice().reverse()">
<round :round="round" :players="playersKeyedById" /> <round :round="round" :players="playersKeyedById"/>
<br>
</template> </template>
</template> </template>
</md-app-content>
</md-app>
</div> </div>
</template> </template>
@ -117,11 +107,23 @@
import {Component, Vue} from 'vue-property-decorator' import {Component, Vue} from 'vue-property-decorator'
import PerudoApi from "@/services/PerudoApi"; import PerudoApi from "@/services/PerudoApi";
import Die from "@/components/Die.vue"; import Die from "@/components/Die.vue";
import {ApiObject, GameState, GameStateObject, IsStartedObject, JoinCreateGameObject, MyTurnObject, RoundObject, TurnObject, GameStateState, PlayerObject} from "@/objects/objects"; import {
import Round from "@/components/Round.vue"; // @ is an alias to /src ApiObject,
GameState,
GameStateObject,
IsStartedObject,
JoinCreateGameObject,
MyTurnObject,
RoundObject,
TurnObject,
GameStateState,
PlayerObject
} from "@/objects/objects";
import Round from "@/components/Round.vue";
import RoundTurns from "@/components/RoundTurns.vue";
@Component({ @Component({
components: {Round, Die} components: {RoundTurns, Round, Die}
}) })
export default class Home extends Vue { export default class Home extends Vue {
private gameState: GameState = GameState.Setup; private gameState: GameState = GameState.Setup;