in src/app/pages/game/game.component.ts [170:196]
private incrementCountdown() {
this.countdown.update((countdown) => --countdown);
if (this.countdown() > 0) {
this.audioHandler.playAudio('countdown');
// Ask Gemini two seconds before the end of the countdown for the proposed sign.
// Reason: to receive a response from the API before the countdown ends
// It will be displayed on `Scissors` message in countdown.
if (this.countdown() === Countdown.SCISSORS) {
this.computerStrategy.getAiSign().then((sign) => {
this.nextComputerSign.set(sign);
});
}
setTimeout(() => this.incrementCountdown(), 1000);
} else {
this.freezeVideo.set(true);
const playerGesture = lookForGesture(this.gameHandler.latestPosition());
if (playerGesture) {
this.playerSign.set(playerGesture);
} else {
// Reset game if player doesn't show Rock, Paper or Scissors
this.reset();
}
}
}