From beeabac3428d22953e772c61c14f46c7ee884e00 Mon Sep 17 00:00:00 2001 From: Alberto Xamin Date: Sat, 30 Jan 2021 22:22:19 +0100 Subject: [PATCH] should fix death disconnect and also bots not playing some cards --- backend/__init__.py | 2 +- backend/bang/game.py | 1 + backend/bang/players.py | 3 ++- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/backend/__init__.py b/backend/__init__.py index 91a323e..2b5e9c7 100644 --- a/backend/__init__.py +++ b/backend/__init__.py @@ -291,7 +291,7 @@ def chat_message(sid, msg): elif '/arcadekick' in msg and ses.game.started: if len([p for p in ses.game.players if p.pending_action != PendingAction.WAIT]) == 0: sio.emit('chat_message', room=ses.game.name, data={'color': f'','text':f'KICKING THE ARCADE CABINET'}) - ses.game.play_turn() + ses.game.next_turn() else: sio.emit('chat_message', room=sid, data={'color': f'','text':f'{msg} COMMAND NOT FOUND'}) else: diff --git a/backend/bang/game.py b/backend/bang/game.py index 96cc24b..bd3e98f 100644 --- a/backend/bang/game.py +++ b/backend/bang/game.py @@ -425,6 +425,7 @@ class Game: print(f'player {player.name} died') if self.waiting_for > 0 and player.pending_action == pl.PendingAction.RESPOND: self.responders_did_respond_resume_turn() + player.pending_action = pl.PendingAction.WAIT if player.is_dead: return if not self.started: diff --git a/backend/bang/players.py b/backend/bang/players.py index c411d86..5578ee8 100644 --- a/backend/bang/players.py +++ b/backend/bang/players.py @@ -237,7 +237,8 @@ class Player: self.draw('') elif self.pending_action == PendingAction.PLAY: equippables = [c for c in self.hand if (c.is_equipment or c.usable_next_turn) and not isinstance(c, cs.Prigione) and not any([type(c) == type(x) for x in self.equipment])] - misc = [c for c in self.hand if (isinstance(c, cs.WellsFargo) and not c.usable_next_turn) or isinstance(c, cs.Diligenza) or isinstance(c, cs.Emporio) or (isinstance(c, cs.Birra) and self.lives < self.max_lives and not self.game.check_event(ceh.IlReverendo))] + misc = [c for c in self.hand if (isinstance(c, cs.WellsFargo) or isinstance(c, cs.Indiani) or isinstance(c, cs.Gatling) or isinstance(c, cs.Diligenza) or isinstance(c, cs.Emporio) or (isinstance(c, cs.Birra) and self.lives < self.max_lives and not self.game.check_event(ceh.IlReverendo))) + and not (not c.can_be_used_now and self.game.check_event(ce.IlGiudice))] need_target = [c for c in self.hand if c.need_target and c.can_be_used_now and not (c.need_with and len(self.hand) < 2) and not ( (self.game.check_event(ceh.Sermone) or self.has_played_bang and not (any([isinstance(c, cs.Volcanic) for c in self.equipment]) and type(c) == type(cs.Bang) ) and not self.game.check_event(ce.Lazo))) and not ( isinstance(c, cs.Prigione) and self.game.check_event(ce.IlGiudice))]