check win when everyone has died

This commit is contained in:
Alberto Xamin 2021-02-10 14:33:36 +01:00
parent 4f78811c32
commit 72cd2295b3
No known key found for this signature in database
GPG Key ID: 4F026F48309500A2
3 changed files with 32 additions and 2 deletions

View File

@ -227,6 +227,34 @@ def chat_message(sid, msg):
eventlet.sleep(0.3)
else:
sio.emit('chat_message', room=sid, data={'color': f'','text':f'{msg} bad format'})
elif '/ddc' in msg and ses.game.started:
cmd = msg.split()
if len(cmd) == 2:
sio.emit('chat_message', room=ses.game.name, data={'color': f'red','text':f'🚨 {ses.name} is in debug mode destroyed {cmd[1]} cards'})
if cmd[1] == "*":
for p in ses.game.players_map:
ses.game.get_player_named(p).hand = []
ses.game.get_player_named(p).equipment = []
ses.game.get_player_named(p).notify_self()
elif cmd[1] in ses.game.players_map:
ses.game.get_player_named(cmd[1]).hand = []
ses.game.get_player_named(cmd[1]).equipment = []
ses.game.get_player_named(cmd[1]).notify_self()
else:
sio.emit('chat_message', room=sid, data={'color': f'','text':f'{msg} bad format'})
elif '/dsh' in msg and ses.game.started:
cmd = msg.split()
if len(cmd) == 3:
sio.emit('chat_message', room=ses.game.name, data={'color': f'red','text':f'🚨 {ses.name} is in debug mode and is changing {cmd[1]} health'})
if cmd[1] == "*":
for p in ses.game.players_map:
ses.game.get_player_named(p).lives = int(cmd[2])
ses.game.get_player_named(p).notify_self()
elif cmd[1] in ses.game.players_map:
ses.game.get_player_named(cmd[1]).lives = int(cmd[2])
ses.game.get_player_named(cmd[1]).notify_self()
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:

View File

@ -455,7 +455,8 @@ class Game:
if player.attacker and player.attacker in self.players:
attacker_role = player.attacker.role
winners = [p for p in self.players if p.role != None and p.role.on_player_death(self.get_alive_players(), initial_players=self.initial_players, dead_role=player.role, attacker_role=attacker_role)]
if len(winners) > 0:
# print('ready:', self.readyCount, ' waiting:', self.waiting_for)
if self.readyCount == self.waiting_for and len(winners) > 0:
print('WE HAVE A WINNER')
for p in self.get_alive_players():
p.win_status = p in winners

View File

@ -4,11 +4,12 @@
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<meta name="keywords" content="bang, bang online, bang game, bang multiplayer, bang card game, bang card game online"/>
<link rel="icon" href="<%= BASE_URL %>favicon.ico">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="default">
<meta name="apple-mobile-web-app-title" content="PewPew!">
<meta name="description" content="Bang multiplayer online.">
<meta name="description" content="Wanna play Bang with your friends but you cannot meet in person? Play Bang! multiplayer online.">
<title>PewPew!</title>
<!-- Twitter Card data -->