Skip to content

Commit

Permalink
Fix issue in GamePhaseController
Browse files Browse the repository at this point in the history
  • Loading branch information
Robert Lukoťka committed Nov 29, 2024
1 parent b22cc06 commit 599b182
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
3 changes: 2 additions & 1 deletion stone_age/game_phase_controller/game_phase_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,8 @@ def _try_to_do_further_actions(self) -> None:
first_unsuccesful_player = None
self._progress_state_after_succesfull_action()
case HasAction.NO_ACTION_POSSIBLE:
if first_unsuccesful_player is None:
game_phase_match: bool = unsuccesful_game_phase == self._game_phase
if first_unsuccesful_player is None or not game_phase_match:
first_unsuccesful_player = player
unsuccesful_game_phase = self._game_phase
self._progress_state_after_no_action_possible()
Expand Down
18 changes: 18 additions & 0 deletions test/game_phase_controller/test_game_phase_contoller.py
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,24 @@ def test_all_players_take_a_reward(self) -> None:
self.assertTrue(self.make_all_players_take_a_reward_choice(1))
self.check_state_string("GamePhase.MAKE_ACTION,0/1/None")

def test_no_tools_last_action(self) -> None:
self.mock_setup("pDNN mW")
self.assertTrue(self.place_figures(0))
self.check_state_string("GamePhase.MAKE_ACTION,0/0/None")

self.mock_setup("mT wN mNN fW")
self.assertTrue(self.make_action(0))
self.check_state_string("GamePhase.FEED_TRIBE,0/0/None")

def test_all_players_take_a_reward_last_action(self) -> None:
self.mock_setup("pDNN mW")
self.assertTrue(self.place_figures(0))
self.check_state_string("GamePhase.MAKE_ACTION,0/0/None")

self.mock_setup("mR aN mNN fW")
self.assertTrue(self.make_action(0))
self.check_state_string("GamePhase.FEED_TRIBE,0/0/None")


if __name__ == "__main__":
unittest.main()

0 comments on commit 599b182

Please sign in to comment.