This commit is contained in:
Alberto Xamin 2020-12-23 14:25:23 +01:00
parent a7fe148ff9
commit 0ac0a66c06
No known key found for this signature in database
GPG Key ID: 4F026F48309500A2
5 changed files with 65 additions and 69 deletions

View File

@ -196,7 +196,7 @@ class Bang(Card):
super().play_card(player, against=against) super().play_card(player, against=against)
player.has_played_bang = not isinstance( player.has_played_bang = not isinstance(
player.character, chars.WillyTheKid) player.character, chars.WillyTheKid)
player.game.attack(player, against, double=isinstance(player.character, chars.SlabTheKiller)) player.game.attack(player, against, double=player.character.check(player.game, chars.SlabTheKiller))
return True return True
return False return False
@ -213,7 +213,7 @@ class Birra(Card):
super().play_card(player, against=against) super().play_card(player, against=against)
player.lives = min(player.lives+1, player.max_lives) player.lives = min(player.lives+1, player.max_lives)
import bang.expansions.dodge_city.characters as chd import bang.expansions.dodge_city.characters as chd
if isinstance(player.character, chd.TequilaJoe): if player.character.check(player.game, chd.TequilaJoe):
player.lives = min(player.lives+1, player.max_lives) player.lives = min(player.lives+1, player.max_lives)
return True return True
elif len(player.game.players) == 2: elif len(player.game.players) == 2:
@ -323,7 +323,7 @@ class Mancato(Card):
def play_card(self, player, against, _with=None): def play_card(self, player, against, _with=None):
import bang.characters as chars import bang.characters as chars
if (not player.has_played_bang and against != None and isinstance(player.character, chars.CalamityJanet)): if (not player.has_played_bang and against != None and player.character.check(player.game, chars.CalamityJanet)):
player.sio.emit('chat_message', room=player.game.name, player.sio.emit('chat_message', room=player.game.name,
data=f'_special_calamity|{player.name}|{self.name}|{against}') data=f'_special_calamity|{player.name}|{self.name}|{against}')
player.has_played_bang = True player.has_played_bang = True

View File

@ -13,21 +13,11 @@ class Character(ABC):
self.icon = '🤷‍♂️' self.icon = '🤷‍♂️'
self.number = ''.join(['❤️']*self.max_lives) self.number = ''.join(['❤️']*self.max_lives)
# @abstractmethod def check(self, game, character):
# def on_hurt(self, dmg: int): import bang.expansions.high_noon.card_events as ceh
# pass if game.check_event(ceh.Sbornia):
return False
# @abstractmethod return isinstance(self, character)
# def on_pick(self, card): # tipo dinamite e prigione
# pass
# @abstractmethod
# def on_empty_hand(self):
# pass
# @abstractmethod
# def on_empty_hand(self):
# pass
class BartCassidy(Character): class BartCassidy(Character):
def __init__(self): def __init__(self):

View File

@ -13,6 +13,12 @@ class Maledizione(CardEvent):
self.desc = "Tutte le carte sono considerate di picche ♠" self.desc = "Tutte le carte sono considerate di picche ♠"
self.desc_eng = "" self.desc_eng = ""
class Sbornia(CardEvent):
def __init__(self):
super().__init__("Sbornia", "🥴")
self.desc = "I personaggi perdono la loro abilità speciale"
self.desc_eng = ""
class MezzogiornoDiFuoco(CardEvent): class MezzogiornoDiFuoco(CardEvent):
def __init__(self): def __init__(self):
super().__init__("Mezzogiorno di Fuoco", "🔥") super().__init__("Mezzogiorno di Fuoco", "🔥")
@ -29,13 +35,13 @@ def get_all_events():
# IlDottore(), # IlDottore(),
# IlReverendo(), # IlReverendo(),
# IlTreno(), # IlTreno(),
# Sbornia(), Sbornia(),
# Seromone(), # Seromone(),
# Sete(), # Sete(),
# Sparatoria(), # Sparatoria(),
] ]
random.shuffle(cards) random.shuffle(cards)
cards.append(MezzogiornoDiFuoco()) # cards.append(MezzogiornoDiFuoco())
for c in cards: for c in cards:
c.expansion = 'high-noon' c.expansion = 'high-noon'
return cards return cards

View File

@ -376,7 +376,7 @@ class Game:
eventlet.sleep(5.0) eventlet.sleep(5.0)
return self.reset() return self.reset()
vulture = [p for p in self.players if isinstance(p.character, characters.VultureSam)] vulture = [p for p in self.players if p.character.check(self, characters.VultureSam)]
if len(vulture) == 0: if len(vulture) == 0:
for i in range(len(player.hand)): for i in range(len(player.hand)):
self.deck.scrap(player.hand.pop(), True) self.deck.scrap(player.hand.pop(), True)
@ -402,10 +402,10 @@ class Game:
self.deck.scrap(player.attacker.hand.pop(), True) self.deck.scrap(player.attacker.hand.pop(), True)
player.attacker.notify_self() player.attacker.notify_self()
greg = [p for p in self.players if isinstance(p.character, chd.GregDigger)] greg = [p for p in self.players if p.character.check(self, chd.GregDigger)]
if len(greg) > 0: if len(greg) > 0:
greg[0].lives = min(greg[0].lives+2, greg[0].max_lives) greg[0].lives = min(greg[0].lives+2, greg[0].max_lives)
herb = [p for p in self.players if isinstance(p.character, chd.HerbHunter)] herb = [p for p in self.players if p.character.check(self, chd.HerbHunter)]
if len(herb) > 0: if len(herb) > 0:
herb[0].hand.append(self.deck.draw(True)) herb[0].hand.append(self.deck.draw(True))
herb[0].hand.append(self.deck.draw(True)) herb[0].hand.append(self.deck.draw(True))

View File

@ -174,11 +174,11 @@ class Player:
self.is_playing_ranch = True self.is_playing_ranch = True
self.choose_text = 'choose_ranch' self.choose_text = 'choose_ranch'
self.pending_action = PendingAction.CHOOSE self.pending_action = PendingAction.CHOOSE
elif isinstance(self.character, chars.SuzyLafayette) and len(self.hand) == 0 and ( not self.is_my_turn or self.pending_action == PendingAction.PLAY): elif self.character and self.character.check(self.game, chars.SuzyLafayette) and len(self.hand) == 0 and ( not self.is_my_turn or self.pending_action == PendingAction.PLAY):
self.hand.append(self.game.deck.draw(True)) self.hand.append(self.game.deck.draw(True))
if self.lives <= 0 and self.max_lives > 0: if self.lives <= 0 and self.max_lives > 0:
print('dying, attacker', self.attacker) print('dying, attacker', self.attacker)
if isinstance(self.character, chars.SidKetchum) and len(self.hand) > 1: if self.character.check(self.game, chars.SidKetchum) and len(self.hand) > 1:
self.lives += 1 self.lives += 1
#TODO Sid dovrebbe poter decidere cosa scartare #TODO Sid dovrebbe poter decidere cosa scartare
self.game.deck.scrap(self.hand.pop( self.game.deck.scrap(self.hand.pop(
@ -272,7 +272,7 @@ class Player:
if self.play_card(len(self.hand)+self.equipment.index(c), against=target['name']): if self.play_card(len(self.hand)+self.equipment.index(c), against=target['name']):
return return
break break
maxcards = self.lives if not isinstance(self.character, chd.SeanMallory) else 10 maxcards = self.lives if not self.character.check(self.game, chd.SeanMallory) else 10
if len(self.hand) > maxcards: if len(self.hand) > maxcards:
self.scrap(0) self.scrap(0)
else: else:
@ -366,13 +366,13 @@ class Player:
self.lives += 1 self.lives += 1
self.pending_action = PendingAction.PLAY self.pending_action = PendingAction.PLAY
self.notify_self() self.notify_self()
elif isinstance(self.character, chars.KitCarlson): elif self.character.check(self.game, chars.KitCarlson):
self.is_drawing = True self.is_drawing = True
self.available_cards = [self.game.deck.draw() for i in range(3)] self.available_cards = [self.game.deck.draw() for i in range(3)]
self.choose_text = 'choose_card_to_get' self.choose_text = 'choose_card_to_get'
self.pending_action = PendingAction.CHOOSE self.pending_action = PendingAction.CHOOSE
self.notify_self() self.notify_self()
elif isinstance(self.character, chd.PatBrennan) and type(pile) == str and pile != self.name and pile in self.game.players_map and len(self.game.get_player_named(pile).equipment) > 0: elif self.character.check(self.game, chd.PatBrennan) and type(pile) == str and pile != self.name and pile in self.game.players_map and len(self.game.get_player_named(pile).equipment) > 0:
self.is_drawing = True self.is_drawing = True
self.available_cards = self.game.get_player_named(pile).equipment self.available_cards = self.game.get_player_named(pile).equipment
self.choose_text = 'choose_card_to_get' self.choose_text = 'choose_card_to_get'
@ -380,19 +380,19 @@ class Player:
self.notify_self() self.notify_self()
else: else:
self.pending_action = PendingAction.PLAY self.pending_action = PendingAction.PLAY
if pile == 'scrap' and isinstance(self.character, chars.PedroRamirez): if pile == 'scrap' and self.character.check(self.game, chars.PedroRamirez):
self.hand.append(self.game.deck.draw_from_scrap_pile()) self.hand.append(self.game.deck.draw_from_scrap_pile())
self.hand.append(self.game.deck.draw()) self.hand.append(self.game.deck.draw())
self.sio.emit('chat_message', room=self.game.name, self.sio.emit('chat_message', room=self.game.name,
data=f'_draw_from_scrap|{self.name}') data=f'_draw_from_scrap|{self.name}')
elif type(pile) == str and pile != self.name and pile in self.game.players_map and isinstance(self.character, chars.JesseJones) and len(self.game.get_player_named(pile).hand) > 0: elif type(pile) == str and pile != self.name and pile in self.game.players_map and self.character.check(self.game, chars.JesseJones) and len(self.game.get_player_named(pile).hand) > 0:
self.hand.append(self.game.get_player_named(pile).hand.pop( self.hand.append(self.game.get_player_named(pile).hand.pop(
randrange(0, len(self.game.get_player_named(pile).hand)))) randrange(0, len(self.game.get_player_named(pile).hand))))
self.game.get_player_named(pile).notify_self() self.game.get_player_named(pile).notify_self()
self.sio.emit('chat_message', room=self.game.name, self.sio.emit('chat_message', room=self.game.name,
data=f'_draw_from_player|{self.name}|{pile}') data=f'_draw_from_player|{self.name}|{pile}')
self.hand.append(self.game.deck.draw()) self.hand.append(self.game.deck.draw())
elif isinstance(self.character, chd.BillNoface): elif self.character.check(self.game, chd.BillNoface):
self.hand.append(self.game.deck.draw()) self.hand.append(self.game.deck.draw())
for i in range(self.max_lives-self.lives): for i in range(self.max_lives-self.lives):
self.hand.append(self.game.deck.draw()) self.hand.append(self.game.deck.draw())
@ -400,13 +400,13 @@ class Player:
for i in range(2): for i in range(2):
card: cs.Card = self.game.deck.draw() card: cs.Card = self.game.deck.draw()
self.hand.append(card) self.hand.append(card)
if i == 1 and isinstance(self.character, chars.BlackJack) or self.game.check_event(ce.LeggeDelWest): if i == 1 and self.character.check(self.game, chars.BlackJack) or self.game.check_event(ce.LeggeDelWest):
for p in self.game.players: for p in self.game.players:
if p != self: if p != self:
p.notify_card(self, card, 'blackjack_special' if isinstance(self.character, chars.BlackJack) else 'foc.leggedelwest') p.notify_card(self, card, 'blackjack_special' if self.character.check(self.game, chars.BlackJack) else 'foc.leggedelwest')
if card.check_suit(self.game, [cs.Suit.HEARTS, cs.Suit.DIAMONDS]) and isinstance(self.character, chars.BlackJack): if card.check_suit(self.game, [cs.Suit.HEARTS, cs.Suit.DIAMONDS]) and self.character.check(self.game, chars.BlackJack):
self.hand.append(self.game.deck.draw()) self.hand.append(self.game.deck.draw())
if isinstance(self.character, chd.PixiePete): if self.character.check(self.game, chd.PixiePete):
self.hand.append(self.game.deck.draw()) self.hand.append(self.game.deck.draw())
self.notify_self() self.notify_self()
@ -428,7 +428,7 @@ class Player:
self.game.deck.scrap(self.equipment.pop(i), True) self.game.deck.scrap(self.equipment.pop(i), True)
self.sio.emit('chat_message', room=self.game.name, data=f'_explode|{self.name}') self.sio.emit('chat_message', room=self.game.name, data=f'_explode|{self.name}')
self.heal_if_needed() self.heal_if_needed()
if isinstance(self.character, chars.BartCassidy) and self.lives > 0: if self.character.check(self.game, chars.BartCassidy) and self.lives > 0:
for i in range(3): for i in range(3):
self.hand.append(self.game.deck.draw(True)) self.hand.append(self.game.deck.draw(True))
self.sio.emit('chat_message', room=self.game.name, data=f'_special_bart_cassidy|{self.name}') self.sio.emit('chat_message', room=self.game.name, data=f'_special_bart_cassidy|{self.name}')
@ -620,14 +620,14 @@ class Player:
self.pending_action = PendingAction.PLAY self.pending_action = PendingAction.PLAY
self.notify_self() self.notify_self()
# specifico per personaggio # specifico per personaggio
elif self.is_drawing and isinstance(self.character, chars.KitCarlson): elif self.is_drawing and self.character.check(self.game, chars.KitCarlson):
self.hand.append(self.available_cards.pop(card_index)) self.hand.append(self.available_cards.pop(card_index))
if len(self.available_cards) == 1: if len(self.available_cards) == 1:
self.game.deck.put_on_top(self.available_cards.pop()) self.game.deck.put_on_top(self.available_cards.pop())
self.is_drawing = False self.is_drawing = False
self.pending_action = PendingAction.PLAY self.pending_action = PendingAction.PLAY
self.notify_self() self.notify_self()
elif self.is_drawing and isinstance(self.character, chd.PatBrennan): elif self.is_drawing and self.character.check(self.game, chd.PatBrennan):
card = self.available_cards.pop(card_index) card = self.available_cards.pop(card_index)
if card.usable_next_turn: if card.usable_next_turn:
card.can_be_used_now = False card.can_be_used_now = False
@ -640,7 +640,7 @@ class Player:
def barrel_pick(self): def barrel_pick(self):
pickable_cards = 1 + self.character.pick_mod pickable_cards = 1 + self.character.pick_mod
if len([c for c in self.equipment if isinstance(c, cs.Barile)]) > 0 and isinstance(self.character, chars.Jourdonnais): if len([c for c in self.equipment if isinstance(c, cs.Barile)]) > 0 and self.character.check(self.game, chars.Jourdonnais):
pickable_cards = 2 pickable_cards = 2
while pickable_cards > 0: while pickable_cards > 0:
pickable_cards -= 1 pickable_cards -= 1
@ -654,23 +654,23 @@ class Player:
if self.mancato_needed <= 0: if self.mancato_needed <= 0:
self.game.responders_did_respond_resume_turn(did_lose=False) self.game.responders_did_respond_resume_turn(did_lose=False)
return return
if not self.game.is_competitive and len([c for c in self.hand if isinstance(c, cs.Mancato) or (isinstance(self.character, chars.CalamityJanet) and isinstance(c, cs.Bang)) or isinstance(self.character, chd.ElenaFuente)]) == 0\ if not self.game.is_competitive and len([c for c in self.hand if isinstance(c, cs.Mancato) or (self.character.check(self.game, chars.CalamityJanet) and isinstance(c, cs.Bang)) or self.character.check(self.game, chd.ElenaFuente)]) == 0\
and len([c for c in self.equipment if c.can_be_used_now and isinstance(c, cs.Mancato)]) == 0: and len([c for c in self.equipment if c.can_be_used_now and isinstance(c, cs.Mancato)]) == 0:
self.take_damage_response() self.take_damage_response()
self.game.responders_did_respond_resume_turn(did_lose=True) self.game.responders_did_respond_resume_turn(did_lose=True)
else: else:
self.pending_action = PendingAction.RESPOND self.pending_action = PendingAction.RESPOND
self.expected_response = self.game.deck.mancato_cards.copy() self.expected_response = self.game.deck.mancato_cards.copy()
if isinstance(self.character, chars.CalamityJanet) and cs.Bang(0, 0).name not in self.expected_response: if self.character.check(self.game, chars.CalamityJanet) and cs.Bang(0, 0).name not in self.expected_response:
self.expected_response.append(cs.Bang(0, 0).name) self.expected_response.append(cs.Bang(0, 0).name)
elif isinstance(self.character, chd.ElenaFuente): elif self.character.check(self.game, chd.ElenaFuente):
self.expected_response = self.game.deck.all_cards_str self.expected_response = self.game.deck.all_cards_str
self.on_failed_response_cb = self.take_damage_response self.on_failed_response_cb = self.take_damage_response
self.notify_self() self.notify_self()
def barrel_pick_no_dmg(self): def barrel_pick_no_dmg(self):
pickable_cards = 1 + self.character.pick_mod pickable_cards = 1 + self.character.pick_mod
if len([c for c in self.equipment if isinstance(c, cs.Barile)]) > 0 and isinstance(self.character, chars.Jourdonnais): if len([c for c in self.equipment if isinstance(c, cs.Barile)]) > 0 and self.character.check(self.game, chars.Jourdonnais):
pickable_cards = 2 pickable_cards = 2
while pickable_cards > 0: while pickable_cards > 0:
pickable_cards -= 1 pickable_cards -= 1
@ -684,16 +684,16 @@ class Player:
if self.mancato_needed <= 0: if self.mancato_needed <= 0:
self.game.responders_did_respond_resume_turn(did_lose=False) self.game.responders_did_respond_resume_turn(did_lose=False)
return return
if not self.game.is_competitive and len([c for c in self.hand if isinstance(c, cs.Mancato) or (isinstance(self.character, chars.CalamityJanet) and isinstance(c, cs.Bang)) or isinstance(self.character, chd.ElenaFuente)]) == 0\ if not self.game.is_competitive and len([c for c in self.hand if isinstance(c, cs.Mancato) or (self.character.check(self.game, chars.CalamityJanet) and isinstance(c, cs.Bang)) or self.character.check(self.game, chd.ElenaFuente)]) == 0\
and len([c for c in self.equipment if c.can_be_used_now and isinstance(c, cs.Mancato)]) == 0: and len([c for c in self.equipment if c.can_be_used_now and isinstance(c, cs.Mancato)]) == 0:
self.take_no_damage_response() self.take_no_damage_response()
self.game.responders_did_respond_resume_turn(did_lose=True) self.game.responders_did_respond_resume_turn(did_lose=True)
else: else:
self.pending_action = PendingAction.RESPOND self.pending_action = PendingAction.RESPOND
self.expected_response = self.game.deck.mancato_cards.copy() self.expected_response = self.game.deck.mancato_cards.copy()
if isinstance(self.character, chars.CalamityJanet) and cs.Bang(0, 0).name not in self.expected_response: if self.character.check(self.game, chars.CalamityJanet) and cs.Bang(0, 0).name not in self.expected_response:
self.expected_response.append(cs.Bang(0, 0).name) self.expected_response.append(cs.Bang(0, 0).name)
elif isinstance(self.character, chd.ElenaFuente): elif self.character.check(self.game, chd.ElenaFuente):
self.expected_response = self.game.deck.all_cards_str self.expected_response = self.game.deck.all_cards_str
self.on_failed_response_cb = self.take_no_damage_response self.on_failed_response_cb = self.take_no_damage_response
self.notify_self() self.notify_self()
@ -708,8 +708,8 @@ class Player:
for i in range(len(self.equipment)): for i in range(len(self.equipment)):
if self.equipment[i].can_be_used_now: if self.equipment[i].can_be_used_now:
print('usable', self.equipment[i]) print('usable', self.equipment[i])
if not self.game.is_competitive and len([c for c in self.equipment if isinstance(c, cs.Barile)]) == 0 and not isinstance(self.character, chars.Jourdonnais)\ if not self.game.is_competitive and len([c for c in self.equipment if isinstance(c, cs.Barile)]) == 0 and not self.character.check(self.game, chars.Jourdonnais)\
and len([c for c in self.hand if isinstance(c, cs.Mancato) or (isinstance(self.character, chars.CalamityJanet) and isinstance(c, cs.Bang)) or isinstance(self.character, chd.ElenaFuente)]) == 0\ and len([c for c in self.hand if isinstance(c, cs.Mancato) or (self.character.check(self.game, chars.CalamityJanet) and isinstance(c, cs.Bang)) or self.character.check(self.game, chd.ElenaFuente)]) == 0\
and len([c for c in self.equipment if c.can_be_used_now and isinstance(c, cs.Mancato)]) == 0: and len([c for c in self.equipment if c.can_be_used_now and isinstance(c, cs.Mancato)]) == 0:
print('Cant defend') print('Cant defend')
if not no_dmg: if not no_dmg:
@ -718,7 +718,7 @@ class Player:
self.take_no_damage_response() self.take_no_damage_response()
return False return False
else: else:
if (not self.game.check_event(ce.Lazo) and len([c for c in self.equipment if isinstance(c, cs.Barile)]) > 0) or isinstance(self.character, chars.Jourdonnais): if (not self.game.check_event(ce.Lazo) and len([c for c in self.equipment if isinstance(c, cs.Barile)]) > 0) or self.character.check(self.game, chars.Jourdonnais):
print('has barrel') print('has barrel')
self.pending_action = PendingAction.PICK self.pending_action = PendingAction.PICK
if not no_dmg: if not no_dmg:
@ -731,9 +731,9 @@ class Player:
self.expected_response = self.game.deck.mancato_cards.copy() self.expected_response = self.game.deck.mancato_cards.copy()
if self.attacker and self.attacker in self.game.players and isinstance(self.attacker.character, chd.BelleStar) or self.game.check_event(ce.Lazo): if self.attacker and self.attacker in self.game.players and isinstance(self.attacker.character, chd.BelleStar) or self.game.check_event(ce.Lazo):
self.expected_response = self.game.deck.mancato_cards_not_green self.expected_response = self.game.deck.mancato_cards_not_green
elif isinstance(self.character, chars.CalamityJanet) and cs.Bang(0, 0).name not in self.expected_response: elif self.character.check(self.game, chars.CalamityJanet) and cs.Bang(0, 0).name not in self.expected_response:
self.expected_response.append(cs.Bang(0, 0).name) self.expected_response.append(cs.Bang(0, 0).name)
elif isinstance(self.character, chd.ElenaFuente): elif self.character.check(self.game, chd.ElenaFuente):
self.expected_response = self.game.deck.all_cards_str self.expected_response = self.game.deck.all_cards_str
if not no_dmg: if not no_dmg:
self.on_failed_response_cb = self.take_damage_response self.on_failed_response_cb = self.take_damage_response
@ -743,8 +743,8 @@ class Player:
def get_indians(self, attacker): def get_indians(self, attacker):
self.attacker = attacker self.attacker = attacker
if isinstance(self.character, chd.ApacheKid): return False if self.character.check(self.game, chd.ApacheKid): return False
if not self.game.is_competitive and len([c for c in self.hand if isinstance(c, cs.Bang) or (isinstance(self.character, chars.CalamityJanet) and isinstance(c, cs.Mancato))]) == 0: if not self.game.is_competitive and len([c for c in self.hand if isinstance(c, cs.Bang) or (self.character.check(self.game, chars.CalamityJanet) and isinstance(c, cs.Mancato))]) == 0:
print('Cant defend') print('Cant defend')
self.take_damage_response() self.take_damage_response()
return False return False
@ -752,7 +752,7 @@ class Player:
print('has bang') print('has bang')
self.pending_action = PendingAction.RESPOND self.pending_action = PendingAction.RESPOND
self.expected_response = [cs.Bang(0, 0).name] self.expected_response = [cs.Bang(0, 0).name]
if isinstance(self.character, chars.CalamityJanet) and cs.Mancato(0, 0).name not in self.expected_response: if self.character.check(self.game, chars.CalamityJanet) and cs.Mancato(0, 0).name not in self.expected_response:
self.expected_response.append(cs.Mancato(0, 0).name) self.expected_response.append(cs.Mancato(0, 0).name)
self.event_type = 'indians' self.event_type = 'indians'
self.on_failed_response_cb = self.take_damage_response self.on_failed_response_cb = self.take_damage_response
@ -760,7 +760,7 @@ class Player:
def get_dueled(self, attacker): def get_dueled(self, attacker):
self.attacker = attacker self.attacker = attacker
if not self.game.is_competitive and len([c for c in self.hand if isinstance(c, cs.Bang) or (isinstance(self.character, chars.CalamityJanet) and isinstance(c, cs.Mancato))]) == 0: if not self.game.is_competitive and len([c for c in self.hand if isinstance(c, cs.Bang) or (self.character.check(self.game, chars.CalamityJanet) and isinstance(c, cs.Mancato))]) == 0:
print('Cant defend') print('Cant defend')
self.take_damage_response() self.take_damage_response()
self.game.responders_did_respond_resume_turn(did_lose=True) self.game.responders_did_respond_resume_turn(did_lose=True)
@ -768,7 +768,7 @@ class Player:
else: else:
self.pending_action = PendingAction.RESPOND self.pending_action = PendingAction.RESPOND
self.expected_response = [cs.Bang(0, 0).name] self.expected_response = [cs.Bang(0, 0).name]
if isinstance(self.character, chars.CalamityJanet) and cs.Mancato(0, 0).name not in self.expected_response: if self.character.check(self.game, chars.CalamityJanet) and cs.Mancato(0, 0).name not in self.expected_response:
self.expected_response.append(cs.Mancato(0, 0).name) self.expected_response.append(cs.Mancato(0, 0).name)
self.event_type = 'duel' self.event_type = 'duel'
self.on_failed_response_cb = self.take_damage_response self.on_failed_response_cb = self.take_damage_response
@ -778,9 +778,9 @@ class Player:
while self.lives <= 0 and len(self.game.players) > 2 and len([c for c in self.hand if isinstance(c, cs.Birra)]) > 0: while self.lives <= 0 and len(self.game.players) > 2 and len([c for c in self.hand if isinstance(c, cs.Birra)]) > 0:
for i in range(len(self.hand)): for i in range(len(self.hand)):
if isinstance(self.hand[i], cs.Birra): if isinstance(self.hand[i], cs.Birra):
if isinstance(self.character, chd.MollyStark) and not self.is_my_turn: if self.character.check(self.game, chd.MollyStark) and not self.is_my_turn:
self.hand.append(self.game.deck.draw(True)) self.hand.append(self.game.deck.draw(True))
self.lives += 1 if not isinstance(self.character, chd.TequilaJoe) else 2 self.lives += 1 if not self.character.check(self.game, chd.TequilaJoe) else 2
self.game.deck.scrap(self.hand.pop(i), True) self.game.deck.scrap(self.hand.pop(i), True)
self.sio.emit('chat_message', room=self.game.name, self.sio.emit('chat_message', room=self.game.name,
data=f'_beer_save|{self.name}') data=f'_beer_save|{self.name}')
@ -789,11 +789,11 @@ class Player:
def take_damage_response(self): def take_damage_response(self):
self.lives -= 1 self.lives -= 1
if self.lives > 0: if self.lives > 0:
if isinstance(self.character, chars.BartCassidy): if self.character.check(self.game, chars.BartCassidy):
self.sio.emit('chat_message', room=self.game.name, self.sio.emit('chat_message', room=self.game.name,
data=f'_special_bart_cassidy|{self.name}') data=f'_special_bart_cassidy|{self.name}')
self.hand.append(self.game.deck.draw(True)) self.hand.append(self.game.deck.draw(True))
elif isinstance(self.character, chars.ElGringo) and self.attacker and self.attacker in self.game.players and len(self.attacker.hand) > 0: elif self.character.check(self.game, chars.ElGringo) and self.attacker and self.attacker in self.game.players and len(self.attacker.hand) > 0:
self.hand.append(self.attacker.hand.pop( self.hand.append(self.attacker.hand.pop(
randrange(0, len(self.attacker.hand)))) randrange(0, len(self.attacker.hand))))
self.sio.emit('chat_message', room=self.game.name, self.sio.emit('chat_message', room=self.game.name,
@ -823,7 +823,7 @@ class Player:
((hand_index < len(self.hand) and self.hand[hand_index].name in self.expected_response)) or ((hand_index < len(self.hand) and self.hand[hand_index].name in self.expected_response)) or
(hand_index-len(self.hand) < len(self.equipment) and self.equipment[hand_index-len(self.hand)].name in self.expected_response)): (hand_index-len(self.hand) < len(self.equipment) and self.equipment[hand_index-len(self.hand)].name in self.expected_response)):
card = self.hand.pop(hand_index) if hand_index < len(self.hand) else self.equipment.pop(hand_index-len(self.hand)) card = self.hand.pop(hand_index) if hand_index < len(self.hand) else self.equipment.pop(hand_index-len(self.hand))
if isinstance(self.character, chd.MollyStark) and hand_index < len(self.hand)+1 and not self.is_my_turn and self.event_type != 'duel': if self.character.check(self.game, chd.MollyStark) and hand_index < len(self.hand)+1 and not self.is_my_turn and self.event_type != 'duel':
self.hand.append(self.game.deck.draw(True)) self.hand.append(self.game.deck.draw(True))
card.use_card(self) card.use_card(self)
self.game.deck.scrap(card, True) self.game.deck.scrap(card, True)
@ -832,7 +832,7 @@ class Player:
if self.mancato_needed <= 0: if self.mancato_needed <= 0:
if self.event_type == 'duel': if self.event_type == 'duel':
self.game.duel(self, self.attacker.name) self.game.duel(self, self.attacker.name)
if isinstance(self.character, chd.MollyStark) and hand_index < len(self.hand)+1 and not self.is_my_turn: if self.character.check(self.game, chd.MollyStark) and hand_index < len(self.hand)+1 and not self.is_my_turn:
self.molly_discarded_cards += 1 self.molly_discarded_cards += 1
else: else:
self.game.responders_did_respond_resume_turn(did_lose=False) self.game.responders_did_respond_resume_turn(did_lose=False)
@ -842,7 +842,7 @@ class Player:
self.pending_action = PendingAction.RESPOND self.pending_action = PendingAction.RESPOND
self.notify_self() self.notify_self()
else: else:
if isinstance(self.character, chd.MollyStark) and not self.is_my_turn: if self.character.check(self.game, chd.MollyStark) and not self.is_my_turn:
for i in range(self.molly_discarded_cards): for i in range(self.molly_discarded_cards):
self.hand.append(self.game.deck.draw(True)) self.hand.append(self.game.deck.draw(True))
self.molly_discarded_cards = 0 self.molly_discarded_cards = 0
@ -882,13 +882,13 @@ class Player:
return self.character.visibility_mod + covers return self.character.visibility_mod + covers
def scrap(self, card_index): def scrap(self, card_index):
if self.is_my_turn or isinstance(self.character, chars.SidKetchum): if self.is_my_turn or self.character.check(self.game, chars.SidKetchum):
self.scrapped_cards += 1 self.scrapped_cards += 1
card = self.hand.pop(card_index) card = self.hand.pop(card_index)
if isinstance(self.character, chars.SidKetchum) and self.scrapped_cards == 2: if self.character.check(self.game, chars.SidKetchum) and self.scrapped_cards == 2:
self.scrapped_cards = 0 self.scrapped_cards = 0
self.lives = min(self.lives+1, self.max_lives) self.lives = min(self.lives+1, self.max_lives)
elif isinstance(self.character, chd.JoseDelgrado) and card.is_equipment and self.special_use_count < 2: elif self.character.check(self.game, chd.JoseDelgrado) and card.is_equipment and self.special_use_count < 2:
self.hand.append(self.game.deck.draw(True)) self.hand.append(self.game.deck.draw(True))
self.hand.append(self.game.deck.draw(True)) self.hand.append(self.game.deck.draw(True))
self.special_use_count += 1 self.special_use_count += 1
@ -896,7 +896,7 @@ class Player:
self.notify_self() self.notify_self()
def holyday_special(self, data): def holyday_special(self, data):
if isinstance(self.character, chd.DocHolyday) and self.special_use_count < 1: if self.character.check(self.game, chd.DocHolyday) and self.special_use_count < 1:
self.special_use_count += 1 self.special_use_count += 1
cards = sorted(data['cards'], reverse=True) cards = sorted(data['cards'], reverse=True)
for c in cards: for c in cards:
@ -905,7 +905,7 @@ class Player:
self.game.attack(self, data['against']) self.game.attack(self, data['against'])
def chuck_lose_hp_draw(self): def chuck_lose_hp_draw(self):
if isinstance(self.character, chd.ChuckWengam) and self.lives > 1 and self.is_my_turn: if self.character.check(self.game, chd.ChuckWengam) and self.lives > 1 and self.is_my_turn:
self.lives -= 1 self.lives -= 1
self.hand.append(self.game.deck.draw(True)) self.hand.append(self.game.deck.draw(True))
self.hand.append(self.game.deck.draw(True)) self.hand.append(self.game.deck.draw(True))
@ -914,7 +914,7 @@ class Player:
def end_turn(self, forced=False): def end_turn(self, forced=False):
if not self.is_my_turn: if not self.is_my_turn:
return return
maxcards = self.lives if not isinstance(self.character, chd.SeanMallory) else 10 maxcards = self.lives if not self.character.check(self.game, chd.SeanMallory) else 10
if len(self.hand) > maxcards and not forced: if len(self.hand) > maxcards and not forced:
print( print(
f"I {self.name} have to many cards in my hand and I can't end the turn") f"I {self.name} have to many cards in my hand and I can't end the turn")