Skip to content

Commit 599b182

Browse files
author
Robert Lukoťka
committed
Fix issue in GamePhaseController
1 parent b22cc06 commit 599b182

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

stone_age/game_phase_controller/game_phase_controller.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,8 @@ def _try_to_do_further_actions(self) -> None:
123123
first_unsuccesful_player = None
124124
self._progress_state_after_succesfull_action()
125125
case HasAction.NO_ACTION_POSSIBLE:
126-
if first_unsuccesful_player is None:
126+
game_phase_match: bool = unsuccesful_game_phase == self._game_phase
127+
if first_unsuccesful_player is None or not game_phase_match:
127128
first_unsuccesful_player = player
128129
unsuccesful_game_phase = self._game_phase
129130
self._progress_state_after_no_action_possible()

test/game_phase_controller/test_game_phase_contoller.py

+18
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,24 @@ def test_all_players_take_a_reward(self) -> None:
301301
self.assertTrue(self.make_all_players_take_a_reward_choice(1))
302302
self.check_state_string("GamePhase.MAKE_ACTION,0/1/None")
303303

304+
def test_no_tools_last_action(self) -> None:
305+
self.mock_setup("pDNN mW")
306+
self.assertTrue(self.place_figures(0))
307+
self.check_state_string("GamePhase.MAKE_ACTION,0/0/None")
308+
309+
self.mock_setup("mT wN mNN fW")
310+
self.assertTrue(self.make_action(0))
311+
self.check_state_string("GamePhase.FEED_TRIBE,0/0/None")
312+
313+
def test_all_players_take_a_reward_last_action(self) -> None:
314+
self.mock_setup("pDNN mW")
315+
self.assertTrue(self.place_figures(0))
316+
self.check_state_string("GamePhase.MAKE_ACTION,0/0/None")
317+
318+
self.mock_setup("mR aN mNN fW")
319+
self.assertTrue(self.make_action(0))
320+
self.check_state_string("GamePhase.FEED_TRIBE,0/0/None")
321+
304322

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

0 commit comments

Comments
 (0)