From e08c7162a1cdf227944848b1174350ee8908301d Mon Sep 17 00:00:00 2001 From: Alberto Xamin Date: Sun, 2 Jun 2024 16:24:37 +0100 Subject: [PATCH] fix Mira --- backend/bang/players.py | 6 ++++-- backend/tests/valley_of_shadows_test.py | 17 ++++++++++++++++- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/backend/bang/players.py b/backend/bang/players.py index c6a7025..d53bb56 100644 --- a/backend/bang/players.py +++ b/backend/bang/players.py @@ -1195,7 +1195,7 @@ class Player: playable_cards.append(i) return playable_cards - def play_card(self, hand_index: int, against=None, _with=None): + def play_card(self, hand_index: int, against:str=None, _with:int=None): if self.is_bot: data = {"index": hand_index, "against": against, "with": _with} self.game.rpc_log.append(f"{self.name};play_card;{json.dumps(data)}") @@ -2033,10 +2033,12 @@ class Player: ) ) and not self.can_escape(card_name) - ) or card_name == "Mira": + ): print("Cant defend") if not no_dmg: self.take_damage_response() + if card_name == "Mira": + self.take_damage_response() else: self.take_no_damage_response() return False diff --git a/backend/tests/valley_of_shadows_test.py b/backend/tests/valley_of_shadows_test.py index 6ba33ea..63e5251 100644 --- a/backend/tests/valley_of_shadows_test.py +++ b/backend/tests/valley_of_shadows_test.py @@ -6,6 +6,9 @@ from bang.game import Game from bang.players import Player, PendingAction import bang.cards as cs +from tests import started_game, set_events, current_player, next_player, current_player_with_cards + + # test UltimoGiro def test_ultimo_giro(): g = Game('test') @@ -324,4 +327,16 @@ def test_sventagliata(): assert len(p.hand) == 1 p.play_card(0, against=p2.name) assert p.pending_action == PendingAction.PLAY - assert len(p.hand) == 1 \ No newline at end of file + assert len(p.hand) == 1 + + +def test_mira(): + g = started_game(['the_valley_of_shadows']) + p = current_player(g) + p.draw('') + p.hand = [Mira(0, 0), Bang(0, 0)] + target = next_player(g) + target.hand = [] + target_health = target.lives + p.play_card(0, against=target.name, _with=1) + assert target.lives == target_health - 2