Fix multi death
Co-authored-by: GM <giulio.migani@studenti.unitn.it>
This commit is contained in:
parent
87f37dbf90
commit
b77c56763d
@ -234,7 +234,7 @@ class Game:
|
|||||||
if self.waiting_for == 0:
|
if self.waiting_for == 0:
|
||||||
attacker.pending_action = pl.PendingAction.PLAY
|
attacker.pending_action = pl.PendingAction.PLAY
|
||||||
attacker.notify_self()
|
attacker.notify_self()
|
||||||
self.attack_in_progress = False
|
self.attack_in_progress = False
|
||||||
if self.pending_winners and not self.someone_won:
|
if self.pending_winners and not self.someone_won:
|
||||||
return self.announces_winners()
|
return self.announces_winners()
|
||||||
|
|
||||||
@ -252,7 +252,7 @@ class Game:
|
|||||||
if self.waiting_for == 0:
|
if self.waiting_for == 0:
|
||||||
attacker.pending_action = pl.PendingAction.PLAY
|
attacker.pending_action = pl.PendingAction.PLAY
|
||||||
attacker.notify_self()
|
attacker.notify_self()
|
||||||
self.attack_in_progress = False
|
self.attack_in_progress = False
|
||||||
if self.pending_winners and not self.someone_won:
|
if self.pending_winners and not self.someone_won:
|
||||||
return self.announces_winners()
|
return self.announces_winners()
|
||||||
|
|
||||||
@ -360,6 +360,7 @@ class Game:
|
|||||||
if self.ready_count == self.waiting_for:
|
if self.ready_count == self.waiting_for:
|
||||||
self.waiting_for = 0
|
self.waiting_for = 0
|
||||||
self.ready_count = 0
|
self.ready_count = 0
|
||||||
|
self.attack_in_progress = False
|
||||||
if self.pending_winners and not self.someone_won:
|
if self.pending_winners and not self.someone_won:
|
||||||
return self.announces_winners()
|
return self.announces_winners()
|
||||||
if self.dalton_on:
|
if self.dalton_on:
|
||||||
|
@ -62,7 +62,7 @@ class Outlaw(Role):
|
|||||||
return True
|
return True
|
||||||
elif initial_players == 3 and attacker_role != None:
|
elif initial_players == 3 and attacker_role != None:
|
||||||
return isinstance(dead_role, Vice) and isinstance(attacker_role, Outlaw)
|
return isinstance(dead_role, Vice) and isinstance(attacker_role, Outlaw)
|
||||||
elif initial_players != 3 and not any([isinstance(p.role, Sheriff) for p in alive_players]):
|
elif initial_players != 3 and (not any([isinstance(p.role, Sheriff) for p in alive_players])) and any([isinstance(p.role, Outlaw) for p in alive_players]):
|
||||||
print("The Outlaw won!")
|
print("The Outlaw won!")
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
@ -82,7 +82,7 @@ class Renegade(Role):
|
|||||||
return True
|
return True
|
||||||
elif initial_players == 3 and attacker_role != None:
|
elif initial_players == 3 and attacker_role != None:
|
||||||
return isinstance(dead_role, Outlaw) and isinstance(attacker_role, Renegade)
|
return isinstance(dead_role, Outlaw) and isinstance(attacker_role, Renegade)
|
||||||
elif initial_players != 3 and len(alive_players) == 1 and alive_players[0].role == self:
|
elif initial_players != 3 and len(alive_players) == 1 and isinstance(alive_players[0].role, Renegade):
|
||||||
print("The Renegade won!")
|
print("The Renegade won!")
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
@ -129,6 +129,7 @@ def test_5p_renegade_gatling_win():
|
|||||||
print(roles)
|
print(roles)
|
||||||
assert len(roles) == 4
|
assert len(roles) == 4
|
||||||
assert isinstance(g.players[g.turn].role, Sheriff)
|
assert isinstance(g.players[g.turn].role, Sheriff)
|
||||||
|
g.players[g.turn].is_my_turn = False
|
||||||
for i in range(len(g.players)):
|
for i in range(len(g.players)):
|
||||||
g.players[i].lives = 1
|
g.players[i].lives = 1
|
||||||
g.players[i].hand = []
|
g.players[i].hand = []
|
||||||
@ -137,6 +138,38 @@ def test_5p_renegade_gatling_win():
|
|||||||
g.players[g.turn].draw('')
|
g.players[g.turn].draw('')
|
||||||
g.players[g.turn].hand = [Gatling(0,0)]
|
g.players[g.turn].hand = [Gatling(0,0)]
|
||||||
g.players[g.turn].play_card(0)
|
g.players[g.turn].play_card(0)
|
||||||
|
for i in range(len(g.players)):
|
||||||
|
if isinstance(g.players[i].role, Renegade):
|
||||||
|
print (g.players[i].role.name, 'win_status:', hasattr(g.players[i], 'win_status') and g.players[i].win_status)
|
||||||
|
assert (hasattr(g.players[i], 'win_status') and g.players[i].win_status)
|
||||||
|
else:
|
||||||
|
print(g.players[i].role.name, 'win_status:', (hasattr(g.players[i], 'win_status') and g.players[i].win_status))
|
||||||
|
assert not (hasattr(g.players[i], 'win_status') and g.players[i].win_status)
|
||||||
|
|
||||||
|
# test that a game with 5 player the renegade kills all the other players and wins
|
||||||
|
def test_5p_renegade_indiani_win():
|
||||||
|
sio = DummySocket()
|
||||||
|
g = Game('test', sio)
|
||||||
|
for i in range(5):
|
||||||
|
p = Player(f'p{i}', f'p{i}', sio)
|
||||||
|
g.add_player(p)
|
||||||
|
g.start_game()
|
||||||
|
for p in g.players:
|
||||||
|
p.available_characters = [Character('test_char', 4)]
|
||||||
|
p.set_character(p.available_characters[0].name)
|
||||||
|
roles = {g.players[i].role.name:i for i in range(len(g.players))}
|
||||||
|
print(roles)
|
||||||
|
assert len(roles) == 4
|
||||||
|
assert isinstance(g.players[g.turn].role, Sheriff)
|
||||||
|
g.players[g.turn].is_my_turn = False
|
||||||
|
for i in range(len(g.players)):
|
||||||
|
g.players[i].lives = 1
|
||||||
|
g.players[i].hand = []
|
||||||
|
g.turn = roles['Rinnegato']
|
||||||
|
g.play_turn()
|
||||||
|
g.players[g.turn].draw('')
|
||||||
|
g.players[g.turn].hand = [Indiani(0,0)]
|
||||||
|
g.players[g.turn].play_card(0)
|
||||||
for i in range(len(g.players)):
|
for i in range(len(g.players)):
|
||||||
if isinstance(g.players[i].role, Renegade):
|
if isinstance(g.players[i].role, Renegade):
|
||||||
print (g.players[i].role.name, 'win_status:', hasattr(g.players[i], 'win_status') and g.players[i].win_status)
|
print (g.players[i].role.name, 'win_status:', hasattr(g.players[i], 'win_status') and g.players[i].win_status)
|
||||||
|
Loading…
Reference in New Issue
Block a user