diff --git a/src/components/TopLevel.component.js b/src/components/TopLevel.component.js index e47d87c..2b8611d 100644 --- a/src/components/TopLevel.component.js +++ b/src/components/TopLevel.component.js @@ -162,6 +162,12 @@ export default class TopLevelComponent extends Component { this.ships_to_place = game_service.get_possible_boats() } + if ( next_state === GameState.PlayerVictory ) { + const [victor_state, loser_state] = game_service.get_player_victory_state() + this.player_rows = victor_state + this.opponent_rows = loser_state + } + this.instructions = instructions[this.current_state] }) } diff --git a/src/services/GameState.service.js b/src/services/GameState.service.js index 6e94f99..b84a3ea 100644 --- a/src/services/GameState.service.js +++ b/src/services/GameState.service.js @@ -203,6 +203,11 @@ export class GameStateService { }) } + /** + * Get the states that should be shown on the victory screen. + * First element is the winner's state, second element is the loser's state. + * @return {object[][][]} + */ get_player_victory_state(){ return [clone(this.player_x_game_board[this.current_player]), clone(this.player_x_game_board[this.current_opponent])] }