This commit is contained in:
Alberto Xamin 2024-06-02 16:24:37 +01:00
parent 72dc942901
commit e08c7162a1
No known key found for this signature in database
GPG Key ID: 5ABFCD8A22EA6F5D
2 changed files with 20 additions and 3 deletions

View File

@ -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

View File

@ -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')
@ -325,3 +328,15 @@ def test_sventagliata():
p.play_card(0, against=p2.name)
assert p.pending_action == PendingAction.PLAY
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