fix bot wait and add commands
This commit is contained in:
parent
6abd3bfffe
commit
c356917ec2
@ -119,7 +119,8 @@ def join_room(sid, room):
|
||||
@sio.event
|
||||
def chat_message(sid, msg):
|
||||
ses: Player = sio.get_session(sid)
|
||||
sio.emit('chat_message', room=ses.game.name, data=f'[{ses.name}]: {msg}')
|
||||
if len(msg) > 0:
|
||||
if msg[0] == '/':
|
||||
if '/addbot' in msg and not ses.game.started:
|
||||
if len(msg.split()) > 1:
|
||||
for _ in range(int(msg.split()[1])):
|
||||
@ -132,6 +133,16 @@ def chat_message(sid, msg):
|
||||
elif '/suicide' in msg and ses.game.started:
|
||||
ses.lives = 0
|
||||
ses.notify_self()
|
||||
elif '/cancelgame' in msg and ses.game.started:
|
||||
ses.game.reset()
|
||||
elif '/gameinfo' in msg:
|
||||
sio.emit('chat_message', room=sid, data=f'info: {ses.game.__dict__}')
|
||||
elif '/meinfo' in msg:
|
||||
sio.emit('chat_message', room=sid, data=f'info: {ses.__dict__}')
|
||||
else:
|
||||
sio.emit('chat_message', room=sid, data=f'{msg} COMMAND NOT FOUND')
|
||||
else:
|
||||
sio.emit('chat_message', room=ses.game.name, data=f'[{ses.name}]: {msg}')
|
||||
|
||||
@sio.event
|
||||
def start_game(sid):
|
||||
|
@ -45,6 +45,8 @@ class Game:
|
||||
self.notify_room()
|
||||
|
||||
def add_player(self, player: players.Player):
|
||||
if player.is_bot and len(self.players) >= 8:
|
||||
return
|
||||
if player in self.players or len(self.players) >= 10:
|
||||
return
|
||||
if len(self.players) > 7:
|
||||
|
@ -174,7 +174,7 @@ class Player:
|
||||
|
||||
def bot_logic(self):
|
||||
if self.game.shutting_down: return
|
||||
if self.pending_action != PendingAction.WAIT:
|
||||
if self.pending_action != None and self.pending_action != PendingAction.WAIT:
|
||||
eventlet.sleep(uniform(0.6, 1.5))
|
||||
else:
|
||||
return
|
||||
|
Loading…
Reference in New Issue
Block a user