ricompense
This commit is contained in:
parent
5674b9f541
commit
ed52dcffe1
@ -87,7 +87,7 @@ class Game:
|
|||||||
self.readyCount = 0
|
self.readyCount = 0
|
||||||
for p in self.players:
|
for p in self.players:
|
||||||
if p != attacker:
|
if p != attacker:
|
||||||
if p.get_banged():
|
if p.get_banged(attacker=attacker):
|
||||||
self.waiting_for += 1
|
self.waiting_for += 1
|
||||||
if self.waiting_for == 0:
|
if self.waiting_for == 0:
|
||||||
attacker.pending_action = players.PendingAction.PLAY
|
attacker.pending_action = players.PendingAction.PLAY
|
||||||
@ -100,14 +100,14 @@ class Game:
|
|||||||
self.readyCount = 0
|
self.readyCount = 0
|
||||||
for p in self.players:
|
for p in self.players:
|
||||||
if p != attacker:
|
if p != attacker:
|
||||||
if p.get_indians():
|
if p.get_indians(attacker=attacker):
|
||||||
self.waiting_for += 1
|
self.waiting_for += 1
|
||||||
if self.waiting_for == 0:
|
if self.waiting_for == 0:
|
||||||
attacker.pending_action = players.PendingAction.PLAY
|
attacker.pending_action = players.PendingAction.PLAY
|
||||||
attacker.notify_self()
|
attacker.notify_self()
|
||||||
|
|
||||||
def attack(self, attacker:Player, target_username:str):
|
def attack(self, attacker:Player, target_username:str):
|
||||||
if self.players[self.players_map[target_username]].get_banged():
|
if self.players[self.players_map[target_username]].get_banged(attacker=attacker):
|
||||||
self.readyCount = 0
|
self.readyCount = 0
|
||||||
self.waiting_for = 1
|
self.waiting_for = 1
|
||||||
attacker.pending_action = players.PendingAction.WAIT
|
attacker.pending_action = players.PendingAction.WAIT
|
||||||
@ -174,6 +174,17 @@ class Game:
|
|||||||
else: return False
|
else: return False
|
||||||
|
|
||||||
def player_death(self, player: players.Player):
|
def player_death(self, player: players.Player):
|
||||||
|
print(player.attacker)
|
||||||
|
if player.attacker and isinstance(player.attacker, roles.Sheriff) and isinstance(player.role, roles.Vice):
|
||||||
|
for i in range(len(player.attacker.hand)):
|
||||||
|
self.deck.scrap(player.attacker.hand.pop())
|
||||||
|
for i in range(len(player.attacker.equipment)):
|
||||||
|
self.deck.scrap(player.attacker.hand.pop())
|
||||||
|
player.attacker.notify_self()
|
||||||
|
elif player.attacker and isinstance(player.role, roles.Outlaw):
|
||||||
|
for i in range(3):
|
||||||
|
player.attacker.hand.append(self.deck.draw())
|
||||||
|
player.attacker.notify_self()
|
||||||
print(f'player {player.name} died')
|
print(f'player {player.name} died')
|
||||||
if (self.waiting_for > 0):
|
if (self.waiting_for > 0):
|
||||||
self.responders_did_respond_resume_turn()
|
self.responders_did_respond_resume_turn()
|
||||||
|
@ -75,6 +75,7 @@ class Player:
|
|||||||
|
|
||||||
def notify_self(self):
|
def notify_self(self):
|
||||||
if self.lives <= 0 and self.max_lives > 0:
|
if self.lives <= 0 and self.max_lives > 0:
|
||||||
|
print('dying, attacker', self.attacker)
|
||||||
self.game.player_death(self)
|
self.game.player_death(self)
|
||||||
ser = self.__dict__.copy()
|
ser = self.__dict__.copy()
|
||||||
ser.pop('game')
|
ser.pop('game')
|
||||||
@ -292,7 +293,6 @@ class Player:
|
|||||||
if picked.suit == cards.Suit.HEARTS:
|
if picked.suit == cards.Suit.HEARTS:
|
||||||
self.notify_self()
|
self.notify_self()
|
||||||
self.game.responders_did_respond()
|
self.game.responders_did_respond()
|
||||||
self.attacker = None
|
|
||||||
return
|
return
|
||||||
if len([c for c in self.hand if isinstance(c, cards.Mancato)]) == 0:
|
if len([c for c in self.hand if isinstance(c, cards.Mancato)]) == 0:
|
||||||
self.take_damage_response()
|
self.take_damage_response()
|
||||||
@ -303,7 +303,8 @@ class Player:
|
|||||||
self.on_failed_response_cb = self.take_damage_response
|
self.on_failed_response_cb = self.take_damage_response
|
||||||
self.notify_self()
|
self.notify_self()
|
||||||
|
|
||||||
def get_banged(self, attacker = None):
|
def get_banged(self, attacker):
|
||||||
|
self.attacker = attacker
|
||||||
if len([c for c in self.hand if isinstance(c, cards.Mancato)]) == 0 and len([c for c in self.equipment if isinstance(c, cards.Barile)]) == 0:
|
if len([c for c in self.hand if isinstance(c, cards.Mancato)]) == 0 and len([c for c in self.equipment if isinstance(c, cards.Barile)]) == 0:
|
||||||
print('Cant defend')
|
print('Cant defend')
|
||||||
self.take_damage_response()
|
self.take_damage_response()
|
||||||
@ -321,7 +322,8 @@ class Player:
|
|||||||
self.notify_self()
|
self.notify_self()
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def get_indians(self, attacker = None):
|
def get_indians(self, attacker):
|
||||||
|
self.attacker = attacker
|
||||||
if len([c for c in self.hand if isinstance(c, cards.Bang)]) == 0:
|
if len([c for c in self.hand if isinstance(c, cards.Bang)]) == 0:
|
||||||
print('Cant defend')
|
print('Cant defend')
|
||||||
self.take_damage_response()
|
self.take_damage_response()
|
||||||
@ -336,13 +338,13 @@ class Player:
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
def get_dueled(self, attacker):
|
def get_dueled(self, attacker):
|
||||||
|
self.attacker = attacker
|
||||||
if len([c for c in self.hand if isinstance(c, cards.Bang)]) == 0:
|
if len([c for c in self.hand if isinstance(c, cards.Bang)]) == 0:
|
||||||
print('Cant defend')
|
print('Cant defend')
|
||||||
self.take_damage_response()
|
self.take_damage_response()
|
||||||
self.game.responders_did_respond_resume_turn()
|
self.game.responders_did_respond_resume_turn()
|
||||||
return False
|
return False
|
||||||
else:
|
else:
|
||||||
self.attacker = attacker
|
|
||||||
self.pending_action = PendingAction.RESPOND
|
self.pending_action = PendingAction.RESPOND
|
||||||
self.expected_response = cards.Bang(0,0).name
|
self.expected_response = cards.Bang(0,0).name
|
||||||
self.event_type = 'duel'
|
self.event_type = 'duel'
|
||||||
@ -352,8 +354,8 @@ class Player:
|
|||||||
|
|
||||||
def take_damage_response(self):
|
def take_damage_response(self):
|
||||||
self.lives -= 1
|
self.lives -= 1
|
||||||
self.attacker = None
|
|
||||||
self.notify_self()
|
self.notify_self()
|
||||||
|
self.attacker = None
|
||||||
|
|
||||||
def respond(self, hand_index):
|
def respond(self, hand_index):
|
||||||
self.pending_action = PendingAction.WAIT
|
self.pending_action = PendingAction.WAIT
|
||||||
|
Loading…
Reference in New Issue
Block a user