@@ -36,11 +36,14 @@ def add_round(self, guess: tuple[int, ...], feedback: tuple[int, int]) -> None:
3636 feedback (tuple[int, int]): A tuple containing the number of correct and misplaced pegs.
3737
3838 Examples:
39+ >>> from mastermind.core.models.game import create_new_game
40+ >>> from mastermind.core.models.game_configuration import GameConfiguration
41+ >>> from mastermind.core.models.game_mode import GameMode
3942 >>> game = create_new_game(GameConfiguration(NUMBER_OF_COLORS=3, NUMBER_OF_DOTS=4, ATTEMPTS_ALLOWED=5, GAME_MODE=GameMode.PVP))
4043 >>> service = GameService(game)
4144 >>> service.add_round((1, 2, 3, 4), (1, 0))
42- >>> service .game_rounds
43- [GameRound(GUESS=(1, 2, 3, 4), FEEDBACK=(1, 0))]
45+ >>> game.game_board .game_rounds
46+ deque( [GameRound(GUESS=(1, 2, 3, 4), FEEDBACK=(1, 0))])
4447
4548 Raises:
4649 GameEndedException: When trying to add a round to a game that has ended.
@@ -62,14 +65,17 @@ def undo(self) -> None:
6265 """Undo the most recent game round.
6366
6467 Examples:
68+ >>> from mastermind.core.models.game import create_new_game
69+ >>> from mastermind.core.models.game_configuration import GameConfiguration
70+ >>> from mastermind.core.models.game_mode import GameMode
6571 >>> game = create_new_game(GameConfiguration(NUMBER_OF_COLORS=3, NUMBER_OF_DOTS=4, ATTEMPTS_ALLOWED=5, GAME_MODE=GameMode.PVP))
6672 >>> service = GameService(game)
6773 >>> service.add_round((1, 2, 3, 4), (1, 0))
6874 >>> game.game_board.game_rounds
69- [GameRound(GUESS=(1, 2, 3, 4), FEEDBACK=(1, 0))]
75+ deque( [GameRound(GUESS=(1, 2, 3, 4), FEEDBACK=(1, 0))])
7076 >>> service.undo()
7177 >>> game.game_board.game_rounds
72- []
78+ deque([])
7379
7480 Raises:
7581 GameNotStartedException: When trying to undo game rounds before the game has started.
@@ -81,7 +87,7 @@ def undo(self) -> None:
8187 "Cannot undo game rounds before game has started."
8288 )
8389
84- if not self ._game_state .game_over :
90+ if self ._game_state .game_over :
8591 raise GameEndedException ("Cannot undo game rounds after game has ended." )
8692
8793 self ._gameboard_service .undo ()
@@ -90,13 +96,16 @@ def redo(self) -> None:
9096 """Restores the most recently undone game round.
9197
9298 Examples:
99+ >>> from mastermind.core.models.game import create_new_game
100+ >>> from mastermind.core.models.game_configuration import GameConfiguration
101+ >>> from mastermind.core.models.game_mode import GameMode
93102 >>> game = create_new_game(GameConfiguration(NUMBER_OF_COLORS=3, NUMBER_OF_DOTS=4, ATTEMPTS_ALLOWED=5, GAME_MODE=GameMode.PVP))
94103 >>> service = GameService(game)
95104 >>> service.add_round((1, 2, 3, 4), (1, 0))
96105 >>> service.undo()
97106 >>> service.redo()
98- >>> service .game_rounds
99- [GameRound(GUESS=(1, 2, 3, 4), FEEDBACK=(1, 0))]
107+ >>> game.game_board .game_rounds
108+ deque( [GameRound(GUESS=(1, 2, 3, 4), FEEDBACK=(1, 0))])
100109
101110 Raises:
102111 GameNotStartedException: When trying to redo game rounds before the game has started.
0 commit comments