-
-
- Errors:
- {{ error }}
+
+
+
+
+
+ Errors:
+ {{ error }}
+
+
+
+
+
+
+
+
+
+
+ Create
+ Join
+
+
+
+ Start
+
+
+
+ It is your turn, make a guess:
+
+
+
+
+ Die value:
+
+
+
+ Guess
+ Call
+
+
+
-
-
-
-
-
-
-
-
-
- Create
- Join
-
-
- Game created!
- Game joined, now waiting or game to start
-
- PlayerId: {{ playerId }}
-
- Start
-
-
-
- The game has started, lets go!
-
-
-
- You lost the previous round!
- Round: {{ currentRound.number + 1 }}
- Turn: {{ lastTurn ? lastTurn.number + 2 : 1 }}
-
- Last guess:
- {{ lastTurn.diceCount }} dice of value {{ lastTurn.dieValue }}
-
-
-
-
- Your throw:
-
-
-
-
- Someone else is playing, waiting for your turn
- Players:
-
- - {{ player.name }} <--
-
-
-
-
-
- It is your turn, make a guess:
-
-
-
-
- Die value:
-
-
-
- Guess
- Call
-
-
-
- The game is over, the winner is: {{ gameStateObject.currentPlayer.name }}
-
-
-
-
- History:
-
-
-
- Round: {{ round.number + 1 }} |
- Loser: {{ round.loser.name }} |
-
-
- {{ playersKeyedById[pId].name }}: |
-
-
-
+
+
+
+
+ Game created!
+ Game joined, now waiting or game to start
+
+ PlayerId: {{ playerId }}
+
+ Players:
+
+ - {{ player.name }}
- |
-
-
-
-
-
+
+
+
+
+ The game has started, lets go!
+
+
+
+ You lost the previous round!
+ Round: {{ currentRound.number + 1 }}
+ Turn: {{ lastTurn ? lastTurn.number + 2 : 1 }}
+
+ Your throw:
+
+
+
+
+
+ Last guesses:
+
+
+ {{ turn.player.name }} ({{ turn.number + 1 }}): |
+
+
+ |
+
+
+
+
+ Someone else is playing, waiting for your turn
+ Players:
+
+ -{{ player.id === gameStateObject.currentPlayer.id ? '>' : '-' }}{{ player.name }}
+
+
+
+
+
+ The game is over, the winner is: {{ gameStateObject.currentPlayer.name }}
+
+
+
+
+
+
+
+
+ History:
+
+
+
+
+
+
@@ -102,10 +117,11 @@
import {Component, Vue} from 'vue-property-decorator'
import PerudoApi from "@/services/PerudoApi";
import Die from "@/components/Die.vue";
-import {ApiObject, GameState, GameStateObject, IsStartedObject, JoinCreateGameObject, MyTurnObject, RoundObject, TurnObject, GameStateState, PlayerObject} from "@/objects/objects"; // @ is an alias to /src
+import {ApiObject, GameState, GameStateObject, IsStartedObject, JoinCreateGameObject, MyTurnObject, RoundObject, TurnObject, GameStateState, PlayerObject} from "@/objects/objects";
+import Round from "@/components/Round.vue"; // @ is an alias to /src
@Component({
- components: {Die}
+ components: {Round, Die}
})
export default class Home extends Vue {
private gameState: GameState = GameState.Setup;
@@ -130,6 +146,10 @@ export default class Home extends Vue {
return this.gameState >= GameState.Started;
}
+ private get gameRunning(): boolean {
+ return this.gameStarted && !this.gameEnded;
+ }
+
private get gameEnded(): boolean {
return this.gameState === GameState.Ended;
}
@@ -175,6 +195,9 @@ export default class Home extends Vue {
this.owner = true;
this.gameState = GameState.Joined;
+ this.gameTimer = setInterval(() => {
+ this.checkStarted();
+ }, 1000);
}).catch((reason => {
this.error = reason;
}));
@@ -205,9 +228,7 @@ export default class Home extends Vue {
if (this.gameJoined && this.playerId) {
PerudoApi.instance.startGame(this.playerId).then((response: ApiObject) => {
this.gameState = GameState.Started;
- this.gameTimer = setInterval(() => {
- this.checkTurn();
- }, 1000);
+ this.gameStateObject = null; // Bug fix because checkStarted gameStateObject misses some properties
}).catch((reason => {
this.error = reason;
}));
@@ -224,6 +245,7 @@ export default class Home extends Vue {
this.gameTimer = setInterval(() => {
this.checkTurn();
}, 1000);
+ this.checkTurn();
}).catch((reason => {
this.error = reason;
}));
@@ -237,6 +259,7 @@ export default class Home extends Vue {
this.gameTimer = setInterval(() => {
this.checkTurn();
}, 1000);
+ this.checkTurn();
}).catch((reason => {
this.error = reason;
}));
@@ -247,8 +270,10 @@ export default class Home extends Vue {
console.log("Check started");
if (this.gameJoined && this.playerId) {
PerudoApi.instance.gameStarted(this.playerId).then((response: IsStartedObject) => {
+ this.gameStateObject = response.gameState;
if (response.started) {
this.gameState = GameState.Started;
+
this.clearGameTimer();
this.gameTimer = setInterval(() => {
this.checkTurn();