added the logic for ensuring the player had fired a missle and the flow of the game in terms of the players' turns (#2)

master
Evan Powell 4 years ago
parent fda50ad037
commit ce030c346e

@ -278,8 +278,31 @@ export class GameStateService {
throw new InvalidAdvanceStateError("Player Two has a problem with the number of boats selected");
}
}
}
if (this.current_state === GameState.PlayerTurn && this.current_player === Player.One) {
if (this.current_turn_had_missile_attempt === true) {
this.current_player = Player.Two;
this.current_opponent = Player.One;
}
else {
throw new InvalidAdvanceStateError("the player has not fired a missle");
}
}
if (this.current_state === GameState.PlayerTurn && this.current_player === Player.Two) {
if (this.current_turn_had_missile_attempt === true) {
this.current_player = Player.One;
this.current_opponent = Player.Two;
}
else {
throw new InvalidAdvanceStateError("the player has not fired a missle");
}
}
}
/**

Loading…
Cancel
Save