Skip to content

Commit

Permalink
Merge pull request #81 from saffron-lockdown/roundfix
Browse files Browse the repository at this point in the history
properly refer to round
  • Loading branch information
tjperr authored Dec 4, 2020
2 parents b18765d + 0f45ab4 commit 44fc36b
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/server/game.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,13 @@ export class Game {

// get the current drawing to be either captioned or guessed for the current turn
getViewDrawing() {
if (this.getCurrentRound()) {
return this.getCurrentTurn().getDrawing();
this.log('getViewDrawing');
const round = this.getCurrentRound();
if (!round) {
this.log('getViewDrawing:getCurrentRound returned null');
return null;
}
return null;
return round.getCurrentTurn().getDrawing();
}

// get the captions from the current turn
Expand Down Expand Up @@ -254,6 +257,10 @@ export class Game {

startCaptionPhase() {
this.cancelCountdown();

if (!this.getCurrentRound().allDrawingsIn()) {
this.log('Caption phase started but not all drawings in');
}
this._phase = PHASES.CAPTION;
this.startCountdown(this.startGuessPhase);
}
Expand Down Expand Up @@ -360,6 +367,7 @@ export class Game {
sync() {
this.log('syncing all players, current game plan:');
this.log(this._gameplan);

this._players.forEach((player) => {
player.sync();
});
Expand Down
5 changes: 5 additions & 0 deletions src/server/player.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,11 @@ export class Player {
...playerState,
};

if (gameState.timeRemaining === gameState.timerDuration) {
this.log(this._game && this._game.gameplan);
this.log(gameState);
}

this.emit('sync', state);
}

Expand Down
5 changes: 5 additions & 0 deletions src/server/turn.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,15 @@ export class Turn {
}

submitDrawing(drawing) {
if (drawing === null) {
this.log('null drawing submitted to turn');
}

// only allow one drawing to be submitted
if (this._drawingSubmitted) {
return;
}

this._drawing = drawing;
this._drawingSubmitted = true;
}
Expand Down

0 comments on commit 44fc36b

Please sign in to comment.