fun and debug stuff

This commit is contained in:
Alberto Xamin 2020-12-14 18:43:24 +01:00
parent 2b3928cffa
commit 88f452df8f
No known key found for this signature in database
GPG Key ID: 4F026F48309500A2
3 changed files with 34 additions and 4 deletions

View File

@ -171,18 +171,42 @@ def chat_message(sid, msg):
elif '/suicide' in msg and ses.game.started and ses.lives > 0:
ses.lives = 0
ses.notify_self()
elif '/notify' in msg and ses.game.started:
cmd = msg.split()
if len(cmd) == 3:
if cmd[1] in ses.game.players_map:
ses.game.get_player_named(cmd[1]).notify_card(ses, {
'name': cmd[2],
'icon': '🚨',
'suit': 4,
'number': cmd[2]
})
else:
sio.emit('chat_message', room=sid, data={'color': f'','text':f'{msg} bad format'})
elif '/debug_show_cards' in msg and ses.game.started:
cmd = msg.split()
if len(cmd) == 2:
if cmd[1] in ses.game.players_map:
sio.emit('chat_message', room=ses.game.name, data={'color': f'red','text':f'🚨 {ses.name} is in debug mode and is looking at {cmd[1]} hand'})
for c in ses.game.get_player_named(cmd[1]).hand:
ses.notify_card(ses, c)
eventlet.sleep(0.3)
else:
sio.emit('chat_message', room=sid, data={'color': f'','text':f'{msg} bad format'})
elif '/togglecomp' in msg and ses.game:
ses.game.toggle_competitive()
elif '/togglebot' in msg and ses.game:
ses.game.toggle_disconnect_bot()
elif '/cancelgame' in msg and ses.game.started:
ses.game.reset()
elif '/startgame' in msg and not ses.game.started:
ses.game.start_game()
elif '/gameinfo' in msg:
sio.emit('chat_message', room=sid, data={'color': f'#black','text':f'info: {ses.game.__dict__}'})
sio.emit('chat_message', room=sid, data={'color': f'','text':f'info: {ses.game.__dict__}'})
elif '/meinfo' in msg:
sio.emit('chat_message', room=sid, data={'color': f'#black','text':f'info: {ses.__dict__}'})
sio.emit('chat_message', room=sid, data={'color': f'','text':f'info: {ses.__dict__}'})
else:
sio.emit('chat_message', room=sid, data={'color': f'#black','text':f'{msg} COMMAND NOT FOUND'})
sio.emit('chat_message', room=sid, data={'color': f'','text':f'{msg} COMMAND NOT FOUND'})
else:
color = sid.encode('utf-8').hex()[-3:]
sio.emit('chat_message', room=ses.game.name, data={'color': f'#{color}','text':f'[{ses.name}]: {msg}'})

View File

@ -121,6 +121,8 @@ class Game:
elif len(self.players) >= 4:
available_roles = [roles.Sheriff(), roles.Renegade(), roles.Outlaw(), roles.Outlaw(), roles.Vice(), roles.Outlaw(), roles.Vice(), roles.Renegade(), roles.Outlaw(), roles.Vice(), roles.Outlaw()]
available_roles = available_roles[:len(self.players)]
else:
available_roles = [roles.Renegade(), roles.Renegade()]
random.shuffle(available_roles)
for i in range(len(self.players)):
self.players[i].set_role(available_roles[i])

View File

@ -117,9 +117,13 @@ class Player:
self.set_character(available[randrange(0, len(available))].name)
def notify_card(self, player, card):
try:
card = card.__dict__
except:
pass
mess = {
'player': player.name,
'card': card.__dict__
'card': card
}
print('notifying card')
self.sio.emit('notify_card', room=self.sid, data=mess)