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