From 47a099d6248ab3d54ae0db7249f1b84aae272bff Mon Sep 17 00:00:00 2001 From: Alberto Xamin Date: Sun, 5 Mar 2023 17:46:26 +0000 Subject: [PATCH] add wild-west-show endgame --- backend/bang/deck.py | 2 +- backend/bang/game.py | 3 +++ backend/tests/wild_west_show_events_test.py | 10 +++++++++- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/backend/bang/deck.py b/backend/bang/deck.py index 547d55c..2b77836 100644 --- a/backend/bang/deck.py +++ b/backend/bang/deck.py @@ -57,7 +57,7 @@ class Deck: print(f'Deck initialized with {len(self.cards)} cards') def flip_event(self): - if len(self.event_cards) > 0 and not (isinstance(self.event_cards[0], ce.PerUnPugnoDiCarte) or isinstance(self.event_cards[0], ceh.MezzogiornoDiFuoco)): + if len(self.event_cards) > 0 and not (isinstance(self.event_cards[0], ce.PerUnPugnoDiCarte) or isinstance(self.event_cards[0], ceh.MezzogiornoDiFuoco) or isinstance(self.event_cards[0], cew.WildWestShow)): self.event_cards.append(self.event_cards.pop(0)) self.game.notify_event_card() self.game.notify_all() diff --git a/backend/bang/game.py b/backend/bang/game.py index deedb1c..6c1d739 100644 --- a/backend/bang/game.py +++ b/backend/bang/game.py @@ -649,6 +649,9 @@ class Game: if self.waiting_for != 0: return self.dalton_on = False + elif self.check_event(cew.WildWestShow): + for p in self.players: + p.set_role(roles.Renegade()) if self.check_event(ce.PerUnPugnoDiCarte) and len(self.players[self.turn].hand) > 0: self.player_bangs = len(self.players[self.turn].hand) diff --git a/backend/tests/wild_west_show_events_test.py b/backend/tests/wild_west_show_events_test.py index f4f0763..6279d91 100644 --- a/backend/tests/wild_west_show_events_test.py +++ b/backend/tests/wild_west_show_events_test.py @@ -3,6 +3,7 @@ from tests import started_game, set_events, current_player, next_player, current from bang.expansions.wild_west_show.card_events import * from bang.cards import Card, Suit +import bang.roles as roles # test Camposanto @@ -73,4 +74,11 @@ def test_miss_suzanna(): # test Sacagaway -# test WildWestShow \ No newline at end of file +# test WildWestShow +def test_miss_suzanna(): + g = started_game(['wild_west_show'], 8) + set_events(g, [None, WildWestShow()]) + for i in range(len(g.players)): + current_player_with_cards(g, []).end_turn() + for p in g.players: + assert isinstance(p.role, roles.Renegade) \ No newline at end of file