diff --git a/backend/bang/game.py b/backend/bang/game.py index e8c70fa..46722fb 100644 --- a/backend/bang/game.py +++ b/backend/bang/game.py @@ -272,6 +272,7 @@ class Game: if self.players[self.turn].lives <= 0 or self.players[self.turn].is_dead: pl = sorted(self.get_dead_players(), key=lambda x:x.death_turn)[0] if self.check_event(ce.DeadMan) and not self.did_resuscitate_deadman and pl != self.players[self.turn]: + print(f'{self.players[self.turn]} is dead, revive') self.did_resuscitate_deadman = True pl.is_dead = False pl.is_ghost = False @@ -280,13 +281,16 @@ class Game: pl.hand.append(self.deck.draw()) pl.notify_self() elif self.check_event(ceh.CittaFantasma): - pl.is_ghost = True - pl.notify_self() + print(f'{self.players[self.turn]} is dead, event ghost') + self.players[self.turn].is_ghost = True else: + print(f'{self.players[self.turn]} is dead, next turn') return self.next_turn() self.player_bangs = 0 if isinstance(self.players[self.turn].role, roles.Sheriff): self.deck.flip_event() + if len(self.deck.event_cards) > 0: + print(f'flip new event {self.deck.event_cards[0].name}') if self.check_event(ce.DeadMan): self.did_resuscitate_deadman = False elif self.check_event(ce.RouletteRussa): @@ -323,17 +327,12 @@ class Game: else: self.responders_did_respond_resume_turn() else: + print(f'notifying {self.players[self.turn].name} about his turn') self.players[self.turn].play_turn() def next_turn(self): if self.shutting_down: return - if self.players[self.turn].is_dead and self.players[self.turn].is_ghost and self.check_event(ceh.CittaFantasma): - self.players[self.turn].is_ghost = False - for i in range(len(self.players[self.turn].attacker.hand)): - self.deck.scrap(self.players[self.turn].attacker.hand.pop(), True) - for i in range(len(self.players[self.turn].attacker.equipment)): - self.deck.scrap(self.players[self.turn].attacker.equipment.pop(), True) - self.players[self.turn].notify_self() + print(f'{self.players[self.turn].name} invoked next turn') pls = self.get_alive_players() if len(pls) > 0: if self.check_event(ceh.CorsaAllOro): diff --git a/backend/bang/players.py b/backend/bang/players.py index c41d6ea..8885cc7 100644 --- a/backend/bang/players.py +++ b/backend/bang/players.py @@ -164,6 +164,7 @@ class Player: self.sio.emit('notify_card', room=self.sid, data=mess) def notify_self(self): + if self.is_ghost: self.lives = 0 if self.pending_action == PendingAction.DRAW and self.game.check_event(ce.Peyote): self.available_cards = [{ 'icon': '🔴' @@ -181,9 +182,9 @@ class Player: self.is_playing_ranch = True self.choose_text = 'choose_ranch' self.pending_action = PendingAction.CHOOSE - 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): + elif self.character and self.character.check(self.game, chars.SuzyLafayette) and self.lives > 0 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)) - if self.lives <= 0 and self.max_lives > 0 and not self.is_ghost: + if self.lives <= 0 and self.max_lives > 0 and not self.is_dead: print('dying, attacker', self.attacker) if self.character.check(self.game, chars.SidKetchum) and len(self.hand) > 1: self.lives += 1 @@ -205,7 +206,7 @@ class Player: ser['sight'] = self.get_sight() ser['lives'] = max(ser['lives'], 0) - if self.lives <= 0 and self.max_lives > 0 and not self.is_ghost: + if self.lives <= 0 and self.max_lives > 0 and not self.is_dead: self.pending_action = PendingAction.WAIT ser['hand'] = [] ser['equipment'] = [] @@ -959,6 +960,7 @@ class Player: self.notify_self() def end_turn(self, forced=False): + print(f"{self.name} wants to end his turn") if not self.is_my_turn: return maxcards = self.lives if not self.character.check(self.game, chd.SeanMallory) else 10 @@ -976,6 +978,12 @@ class Player: for i in range(len(self.equipment)): if self.equipment[i].usable_next_turn and not self.equipment[i].can_be_used_now: self.equipment[i].can_be_used_now = True + if self.is_dead and self.is_ghost and self.game.check_event(ceh.CittaFantasma): + self.is_ghost = False + for i in range(len(self.hand)): + self.deck.scrap(self.hand.pop(), True) + for i in range(len(self.equipment)): + self.deck.scrap(self.equipment.pop(), True) self.pending_action = PendingAction.WAIT self.notify_self() self.game.next_turn()