From 3c4357eaac96ea4084f42afccd9f0b1f134927f6 Mon Sep 17 00:00:00 2001 From: Alberto Xamin Date: Sat, 21 Jan 2023 16:13:03 +0000 Subject: [PATCH 1/5] fix error if no player is alive --- frontend/src/components/Lobby.vue | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/frontend/src/components/Lobby.vue b/frontend/src/components/Lobby.vue index f8a6d25..569ec1d 100644 --- a/frontend/src/components/Lobby.vue +++ b/frontend/src/components/Lobby.vue @@ -244,7 +244,11 @@ export default { return '' }, isRoomOwner() { - return this.players.length > 0 && this.players.filter(x => !x.is_bot)[0].name == this.username + if (this.players.length > 0){ + let pls = this.players.filter(x => !x.is_bot) + return pls.length > 0 && pls[0].name == this.username + } + return false }, startGameCard() { if (!this.started && this.players.length > 2 && this.isRoomOwner) { @@ -319,12 +323,13 @@ export default { }, getPlayerCard(player) { let icon = '' - let owner = this.players.filter(x => !x.is_bot)[0]; + let nonBots = this.players.filter(x => !x.is_bot) + let isOwner = nonBots.length > 0 && nonBots[0].name == player.name; if (!this.started) icon = '🤠' else icon = player.ready !== undefined ? ((player.ready)?'👍': '🤔') : (player.is_sheriff ? '⭐' : player.icon) return { name: player.name, - number: ((this.username == player.name) ? this.$t('you') : (owner.name == player.name) ? this.$t('owner') :'') + (player.dist ? `${player.dist}⛰` : ''), + number: ((this.username == player.name) ? this.$t('you') : isOwner ? this.$t('owner') :'') + (player.dist ? `${player.dist}⛰` : ''), icon: icon, is_character: true, avatar: player.avatar, From fc16756805f43c750902c34e80129a25ab53986a Mon Sep 17 00:00:00 2001 From: GM Date: Sat, 21 Jan 2023 17:07:48 +0000 Subject: [PATCH 2/5] fix bot logic with The Judge and green cards --- backend/bang/players.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/bang/players.py b/backend/bang/players.py index da300d1..5a10b9b 100644 --- a/backend/bang/players.py +++ b/backend/bang/players.py @@ -319,7 +319,7 @@ class Player: self.game.rpc_log.append(f'{self.name};draw;') self.draw('') elif self.pending_action == PendingAction.PLAY: - non_blocked_cards = [card for card in self.hand if (not self.game.check_event(ceh.Manette) or card.suit == self.committed_suit_manette)] + non_blocked_cards = [card for card in self.hand if (not self.game.check_event(ceh.Manette) or card.suit == self.committed_suit_manette) and (not self.game.check_event(ce.IlGiudice) or not card.usable_next_turn) ] equippables = [c for c in non_blocked_cards if (c.is_equipment or c.usable_next_turn) and not isinstance(c, cs.Prigione) and not c.need_target and not any((type(c) == type(x) and not (c.is_weapon and c.must_be_used) for x in self.equipment))] misc = [c for c in non_blocked_cards if not c.need_target and (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 or c.must_be_used) and not self.game.check_event(ceh.IlReverendo)) or (c.need_with and len(self.hand) > 1 and not (isinstance(c, csd.Whisky) and self.lives == self.max_lives))) and not (not c.can_be_used_now and self.game.check_event(ce.IlGiudice)) and not c.is_equipment] From 292fbe4dde0e0768e6cc5b755c196c8a4e80bbf6 Mon Sep 17 00:00:00 2001 From: GM Date: Sun, 22 Jan 2023 20:51:44 +0000 Subject: [PATCH 3/5] volume save --- Dockerfile | 1 + backend/server.py | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index 34a6cc6..1080c65 100644 --- a/Dockerfile +++ b/Dockerfile @@ -23,5 +23,6 @@ WORKDIR /dist EXPOSE 5001 ENV PATH=/root/.local/bin:${PATH} +VOLUME /code/save ENTRYPOINT ["python", "/dist/server.py"] diff --git a/backend/server.py b/backend/server.py index 2c5a2b6..d726ab2 100644 --- a/backend/server.py +++ b/backend/server.py @@ -813,13 +813,13 @@ def save_games(): while True: sio.sleep(2) if not save_lock: - with open('games.pickle', 'wb') as f: + with open('./save/games.pickle', 'wb') as f: pickle.dump([g for g in games if g.started and not g.is_replay and not g.is_hidden], f) if __name__ == '__main__': - if os.path.exists('games.pickle'): + if os.path.exists('./save/games.pickle'): try: - with open('games.pickle', 'rb') as file: + with open('./save/games.pickle', 'rb') as file: games = pickle.load(file) for g in games: for p in g.players: From a7ec4935e0042317294ed6b5ee034e1e11ff0adf Mon Sep 17 00:00:00 2001 From: GM Date: Sun, 22 Jan 2023 21:17:18 +0000 Subject: [PATCH 4/5] fix folder --- Dockerfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 1080c65..3a96222 100644 --- a/Dockerfile +++ b/Dockerfile @@ -20,9 +20,10 @@ COPY --from=pybuilder /code /dist # copy the frontend static files from the builder COPY --from=builder ./dist /dist/ WORKDIR /dist +RUN mkdir save EXPOSE 5001 ENV PATH=/root/.local/bin:${PATH} -VOLUME /code/save +VOLUME /dist/save ENTRYPOINT ["python", "/dist/server.py"] From 953a024ff1fc308a6d71cee7acd4a6afb4e07d90 Mon Sep 17 00:00:00 2001 From: GM Date: Sun, 22 Jan 2023 21:44:34 +0000 Subject: [PATCH 5/5] just for commit --- Dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Dockerfile b/Dockerfile index 3a96222..c1ce59e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -20,6 +20,7 @@ COPY --from=pybuilder /code /dist # copy the frontend static files from the builder COPY --from=builder ./dist /dist/ WORKDIR /dist +# create dir for save RUN mkdir save EXPOSE 5001