Update code to work with new api version

This commit is contained in:
Tim 2021-11-23 18:06:21 +01:00
parent 300819bc07
commit 14cc278a41
3 changed files with 15898 additions and 20 deletions

15908
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -57,6 +57,7 @@ export interface TurnObject {
export interface PlayerObject { export interface PlayerObject {
id: string, id: string,
hash: string,
name: string, name: string,
} }

View File

@ -70,7 +70,7 @@
</template> </template>
<template v-if="gameStateObject && gameRunning"> <template v-if="gameStateObject && gameRunning">
<span v-if="previousRound && previousRound.loser.name === name">You lost the previous round!<br></span> <span v-if="previousRound && previousRound.loser.hash === playerHash">You lost the previous round!<br></span>
Round: {{ currentRound.number + 1 }} <br> Round: {{ currentRound.number + 1 }} <br>
Turn: {{ lastTurn ? lastTurn.number + 2 : 1 }} <br> Turn: {{ lastTurn ? lastTurn.number + 2 : 1 }} <br>
@ -87,7 +87,7 @@
<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>
Players: <br> Players: <br>
<template v-for="player in gameStateObject.players"> <template v-for="player in gameStateObject.players">
-{{ player.id === gameStateObject.currentPlayer.id ? '>' : '-' }}{{ player.name }}<br> -{{ player.hash === gameStateObject.currentPlayer.hash ? '>' : '-' }}{{ player.name }}<br>
</template> </template>
<br> <br>
</template> </template>
@ -142,6 +142,7 @@ export default class Home extends Vue {
private owner: boolean = false; private owner: boolean = false;
private playerId: string | null = null; private playerId: string | null = null;
private playerHash: string | null = null;
private gameTimer: number | null = null; private gameTimer: number | null = null;
private diceCount: string = '1'; private diceCount: string = '1';
@ -172,7 +173,7 @@ export default class Home extends Vue {
if (this.gameStateObject) { if (this.gameStateObject) {
let players = this.gameStateObject.players; let players = this.gameStateObject.players;
for (let key in players) { for (let key in players) {
newPlayers[players[key].id] = players[key]; newPlayers[players[key].hash] = players[key];
} }
} }
return newPlayers; return newPlayers;
@ -200,6 +201,7 @@ export default class Home extends Vue {
} }
PerudoApi.instance.createGame(this.name).then((response: JoinCreateGameObject) => { PerudoApi.instance.createGame(this.name).then((response: JoinCreateGameObject) => {
this.playerId = response.player.id; this.playerId = response.player.id;
this.playerHash = response.player.hash;
this.code = response.code; this.code = response.code;
this.owner = true; this.owner = true;
@ -223,6 +225,7 @@ export default class Home extends Vue {
} }
PerudoApi.instance.joinGame(this.name, this.code).then((response: JoinCreateGameObject) => { PerudoApi.instance.joinGame(this.name, this.code).then((response: JoinCreateGameObject) => {
this.playerId = response.player.id; this.playerId = response.player.id;
this.playerHash = response.player.hash;
this.gameTimer = setInterval(() => { this.gameTimer = setInterval(() => {
this.checkStarted(); this.checkStarted();
}, 1000); }, 1000);