healing on boom

This commit is contained in:
Alberto Xamin 2020-12-22 15:37:08 +01:00
parent ea5be9b535
commit 363293a76b
No known key found for this signature in database
GPG Key ID: 4F026F48309500A2

View File

@ -171,6 +171,15 @@ class Player:
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 isinstance(self.character, 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:
print('dying, attacker', self.attacker)
if isinstance(self.character, chars.SidKetchum) and len(self.hand) > 1:
self.lives += 1
#TODO Sid dovrebbe poter decidere cosa scartare
self.game.deck.scrap(self.hand.pop(
randrange(0, len(self.hand))), True)
self.game.deck.scrap(self.hand.pop(
randrange(0, len(self.hand))), True)
ser = self.__dict__.copy() ser = self.__dict__.copy()
ser.pop('game') ser.pop('game')
ser.pop('sio') ser.pop('sio')
@ -184,15 +193,6 @@ class Player:
ser['sight'] = self.get_sight() ser['sight'] = self.get_sight()
ser['lives'] = max(ser['lives'], 0) ser['lives'] = max(ser['lives'], 0)
if self.lives <= 0 and self.max_lives > 0:
print('dying, attacker', self.attacker)
if isinstance(self.character, chars.SidKetchum) and len(self.hand) > 1:
self.lives += 1
#TODO Sid dovrebbe poter decidere cosa scartare
self.game.deck.scrap(self.hand.pop(
randrange(0, len(self.hand))), True)
self.game.deck.scrap(self.hand.pop(
randrange(0, len(self.hand))), True)
if self.lives <= 0 and self.max_lives > 0: if self.lives <= 0 and self.max_lives > 0:
self.pending_action = PendingAction.WAIT self.pending_action = PendingAction.WAIT
ser['hand'] = [] ser['hand'] = []
@ -408,13 +408,12 @@ class Player:
if picked.suit == cs.Suit.SPADES and 2 <= picked.number <= 9 and pickable_cards == 0: if picked.suit == cs.Suit.SPADES and 2 <= picked.number <= 9 and pickable_cards == 0:
self.lives -= 3 self.lives -= 3
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, self.sio.emit('chat_message', room=self.game.name, data=f'_explode|{self.name}')
data=f'_explode|{self.name}') self.heal_if_needed()
if isinstance(self.character, chars.BartCassidy) and self.lives > 0: if isinstance(self.character, 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, self.sio.emit('chat_message', room=self.game.name, data=f'_special_bart_cassidy|{self.name}')
data=f'_special_bart_cassidy|{self.name}')
print(f'{self.name} Boom, -3 hp') print(f'{self.name} Boom, -3 hp')
break break
else: else:
@ -693,6 +692,18 @@ class Player:
self.on_failed_response_cb = self.take_damage_response self.on_failed_response_cb = self.take_damage_response
return True return True
def heal_if_needed(self):
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)):
if isinstance(self.hand[i], cs.Birra):
if isinstance(self.character, chd.MollyStark) and not self.is_my_turn:
self.hand.append(self.game.deck.draw(True))
self.lives += 1 if not isinstance(self.character, chd.TequilaJoe) else 2
self.game.deck.scrap(self.hand.pop(i), True)
self.sio.emit('chat_message', room=self.game.name,
data=f'_beer_save|{self.name}')
break
def take_damage_response(self): def take_damage_response(self):
self.lives -= 1 self.lives -= 1
if self.lives > 0: if self.lives > 0:
@ -706,16 +717,7 @@ class Player:
self.sio.emit('chat_message', room=self.game.name, self.sio.emit('chat_message', room=self.game.name,
data=f'_special_el_gringo|{self.name}|{self.attacker.name}') data=f'_special_el_gringo|{self.name}|{self.attacker.name}')
self.attacker.notify_self() self.attacker.notify_self()
while self.lives <= 0 and len(self.game.players) > 2 and len([c for c in self.hand if isinstance(c, cs.Birra)]) > 0: self.heal_if_needed()
for i in range(len(self.hand)):
if isinstance(self.hand[i], cs.Birra):
if isinstance(self.character, chd.MollyStark) and not self.is_my_turn:
self.hand.append(self.game.deck.draw(True))
self.lives += 1
self.game.deck.scrap(self.hand.pop(i), True)
self.sio.emit('chat_message', room=self.game.name,
data=f'_beer_save|{self.name}')
break
self.mancato_needed = 0 self.mancato_needed = 0
self.expected_response = [] self.expected_response = []
self.event_type = '' self.event_type = ''