slab the killer

This commit is contained in:
Alberto Xamin 2020-11-23 17:35:39 +01:00
parent e9529b0b19
commit 08ff9abad6
No known key found for this signature in database
GPG Key ID: 4F026F48309500A2
2 changed files with 23 additions and 10 deletions

View File

@ -101,7 +101,7 @@ class Game:
attacker.notify_self() attacker.notify_self()
def attack(self, attacker:Player, target_username:str): def attack(self, attacker:Player, target_username:str):
if self.players[self.players_map[target_username]].get_banged(attacker=attacker): if self.players[self.players_map[target_username]].get_banged(attacker=attacker, double=isinstance(attacker.character, characters.SlabTheKiller)):
self.readyCount = 0 self.readyCount = 0
self.waiting_for = 1 self.waiting_for = 1
attacker.pending_action = players.PendingAction.WAIT attacker.pending_action = players.PendingAction.WAIT

View File

@ -41,6 +41,7 @@ class Player:
self.expected_response = None self.expected_response = None
self.attacker = None self.attacker = None
self.target_p: str = None self.target_p: str = None
self.mancato_needed = 0
def join_game(self, game): def join_game(self, game):
self.game = game self.game = game
@ -267,8 +268,11 @@ class Player:
self.sio.emit('chat_message', room=self.game.name, data=f'{self.name} ha giocato {card.name}.') self.sio.emit('chat_message', room=self.game.name, data=f'{self.name} ha giocato {card.name}.')
self.game.indian_others(self) self.game.indian_others(self)
did_play_card = True did_play_card = True
elif isinstance(card, cards.Mancato): elif isinstance(card, cards.Mancato) and (not self.has_played_bang and againts != None and isinstance(self.character, characters.CalamityJanet)):
pass self.sio.emit('chat_message', room=self.game.name, data=f'{self.name} ha giocato {card.name} come un BANG! contro {againts}.')
self.has_played_bang = True
self.game.attack(self, againts)
did_play_card = True
elif isinstance(card, cards.Panico): elif isinstance(card, cards.Panico):
self.sio.emit('chat_message', room=self.game.name, data=f'{self.name} ha giocato {card.name} contro {againts}.') self.sio.emit('chat_message', room=self.game.name, data=f'{self.name} ha giocato {card.name} contro {againts}.')
self.pending_action = PendingAction.CHOOSE self.pending_action = PendingAction.CHOOSE
@ -325,9 +329,11 @@ class Player:
print(f'Did pick {picked}') print(f'Did pick {picked}')
self.sio.emit('chat_message', room=self.game.name, data=f'{self.name} ha estratto {picked}.') self.sio.emit('chat_message', room=self.game.name, data=f'{self.name} ha estratto {picked}.')
if picked.suit == cards.Suit.HEARTS: if picked.suit == cards.Suit.HEARTS:
self.mancato_needed -= 1
self.notify_self() self.notify_self()
self.game.responders_did_respond_resume_turn() if self.mancato_needed <= 0:
return self.game.responders_did_respond_resume_turn()
return
if len([c for c in self.hand if isinstance(c, cards.Mancato) or (isinstance(self.character, characters.CalamityJanet) and isinstance(c, cards.Bang))]) == 0: if len([c for c in self.hand if isinstance(c, cards.Mancato) or (isinstance(self.character, characters.CalamityJanet) and isinstance(c, cards.Bang))]) == 0:
self.take_damage_response() self.take_damage_response()
self.game.responders_did_respond_resume_turn() self.game.responders_did_respond_resume_turn()
@ -337,8 +343,9 @@ class Player:
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 get_banged(self, attacker): def get_banged(self, attacker, double=False):
self.attacker = attacker self.attacker = attacker
self.mancato_needed = 1 if not double else 2
if len([c for c in self.hand if isinstance(c, cards.Mancato)]) == 0 and len([c for c in self.equipment if isinstance(c, cards.Barile)]) == 0 and not isinstance(self.character, characters.Jourdonnais): if len([c for c in self.hand if isinstance(c, cards.Mancato)]) == 0 and len([c for c in self.equipment if isinstance(c, cards.Barile)]) == 0 and not isinstance(self.character, characters.Jourdonnais):
print('Cant defend') print('Cant defend')
self.take_damage_response() self.take_damage_response()
@ -400,6 +407,7 @@ class Player:
self.lives += 1 self.lives += 1
self.game.deck.scrap(self.hand.pop(i)) self.game.deck.scrap(self.hand.pop(i))
break break
self.mancato_needed = 0
self.notify_self() self.notify_self()
self.attacker = None self.attacker = None
@ -408,11 +416,16 @@ class Player:
if hand_index != -1 and self.hand[hand_index].name in self.expected_response: if hand_index != -1 and self.hand[hand_index].name in self.expected_response:
self.game.deck.scrap(self.hand.pop(hand_index)) self.game.deck.scrap(self.hand.pop(hand_index))
self.notify_self() self.notify_self()
if self.event_type == 'duel': self.mancato_needed -= 1
self.game.duel(self, self.attacker.name) if self.mancato_needed <= 0:
if self.event_type == 'duel':
self.game.duel(self, self.attacker.name)
else:
self.game.responders_did_respond_resume_turn()
self.event_type = ''
else: else:
self.game.responders_did_respond_resume_turn() self.pending_action = PendingAction.RESPOND
self.event_type = '' self.notify_self()
else: else:
self.on_failed_response_cb() self.on_failed_response_cb()
self.game.responders_did_respond_resume_turn() self.game.responders_did_respond_resume_turn()