diff --git a/backend/__init__.py b/backend/__init__.py index 1ee5666..6edded9 100644 --- a/backend/__init__.py +++ b/backend/__init__.py @@ -194,7 +194,9 @@ def chat_message(sid, msg): # ses.game.add_player(Player(f'AI_{random.randint(0,1000)}', 'bot', sio, bot=True)) sio.emit('chat_message', room=ses.game.name, data={'color': f'red','text':f'Only 1 bot at the time'}) else: - bot = Player(f'AI_{random.randint(0,1000)}', 'bot', sio, bot=True) + bot = Player(f'AI_{random.randint(0,10)}', 'bot', sio, bot=True) + while any([p for p in ses.game.players if p.name == bot.name]): + bot = Player(f'AI_{random.randint(0,10)}', 'bot', sio, bot=True) ses.game.add_player(bot) bot.bot_spin() elif '/removebot' in msg and not ses.game.started: diff --git a/backend/bang/game.py b/backend/bang/game.py index 65a1739..1aae79d 100644 --- a/backend/bang/game.py +++ b/backend/bang/game.py @@ -39,6 +39,7 @@ class Game: self.did_resuscitate_deadman = False self.is_handling_death = False self.pending_winners = [] + self.noStar = False # no Sheriff, because there are only three players def notify_room(self, sid=None): @@ -124,6 +125,8 @@ class Game: print('GAME IS STARING') if self.started: return + if len(self.players) == 3: + self.noStar = True self.players_map = {c.name: i for i, c in enumerate(self.players)} self.sio.emit('chat_message', room=self.name, data=f'_starting') self.sio.emit('start', room=self.name) @@ -318,7 +321,7 @@ class Game: 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): + if isinstance(self.players[self.turn].role, roles.Sheriff) or (self.noStar and isinstance(self.players[self.turn].role, roles.Vice)): self.deck.flip_event() if len(self.deck.event_cards) > 0 and self.deck.event_cards[0] != None: print(f'flip new event {self.deck.event_cards[0].name}') @@ -534,6 +537,7 @@ class Game: self.players = [p for p in self.players if not p.is_bot] print(self.players) self.started = False + self.noStar = False self.is_handling_death = False self.waiting_for = 0 self.incremental_turn = 0 diff --git a/frontend/src/components/Lobby.vue b/frontend/src/components/Lobby.vue index af8e71c..29b3d1e 100644 --- a/frontend/src/components/Lobby.vue +++ b/frontend/src/components/Lobby.vue @@ -172,7 +172,7 @@ export default { }, computed: { inviteLink() { - return `${window.location.origin}/game?code=${this.lobbyName}${this.password?`&pwd=${this.password}`:''}` + return `${window.location.origin}/game?code=${encodeURIComponent(this.lobbyName)}${this.password?`&pwd=${this.password}`:''}` }, isThereAnyBot() { return this.players.filter(x => x.is_bot).length > 0;