From 89dfb533b57d4c8ad0719b800f734ce67f3e10e4 Mon Sep 17 00:00:00 2001 From: GM Date: Fri, 20 Jan 2023 11:03:43 +0000 Subject: [PATCH] fix game freeze when a ghost kill himself --- backend/bang/players.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/backend/bang/players.py b/backend/bang/players.py index 35d71a4..a65aa2d 100644 --- a/backend/bang/players.py +++ b/backend/bang/players.py @@ -222,8 +222,18 @@ class Player: def notify_self(self): if any((True for c in self.equipment if isinstance(c, tvosc.Fantasma))): self.is_ghost = True - elif self.is_ghost: - self.is_ghost = self.game.check_event(ceh.CittaFantasma) and self.is_my_turn + elif self.is_ghost and self.is_my_turn and not self.game.check_event(ceh.CittaFantasma): + self.end_turn(forced=True) + elif self.is_ghost and not self.game.check_event(ceh.CittaFantasma): + self.is_ghost = False + #mi assicuro che non i morti non abbiano carte + if self.is_dead and not self.is_ghost: + if len(self.hand): + for i in range(len(self.hand)): + self.game.deck.scrap(self.hand.pop(), True) + if len(self.equipment): + for i in range(len(self.equipment)): + self.game.deck.scrap(self.equipment.pop(), True) if self.is_ghost: self.lives = 0 if self.pending_action == PendingAction.DRAW and self.game.check_event(ce.Peyote): self.available_cards = [{ @@ -1454,7 +1464,7 @@ class Player: self.play_turn(can_play_vendetta=False) return ##Ghost## - if self.is_dead and self.is_ghost and self.game.check_event(ceh.CittaFantasma) and not any((True for c in self.equipment if isinstance(c, tvosc.Fantasma))): + if (self.is_dead and self.is_ghost and self.game.check_event(ceh.CittaFantasma) and not any((True for c in self.equipment if isinstance(c, tvosc.Fantasma)))) or (self.is_dead and forced and self.is_ghost and not any((True for c in self.equipment if isinstance(c, tvosc.Fantasma)))): self.is_ghost = False for i in range(len(self.hand)): self.game.deck.scrap(self.hand.pop(), True)