diff --git a/backend/bang/expansions/fistful_of_cards/card_events.py b/backend/bang/expansions/fistful_of_cards/card_events.py index 5d414fc..782fa18 100644 --- a/backend/bang/expansions/fistful_of_cards/card_events.py +++ b/backend/bang/expansions/fistful_of_cards/card_events.py @@ -24,7 +24,7 @@ class DeadMan(CardEvent): self.desc_eng = "The first player that died return back to life with 2 hp and 2 cards" class FratelliDiSangue(CardEvent): - def __init__(self):#TODO + def __init__(self): super().__init__("Fratelli Di Sangue", "๐Ÿ’‰") self.desc = "All'inizio del proprio turno i giocatori possono perdere 1 vita per darla a un altro giocatore" self.desc_eng = "At the begin of their turn, payers can lose 1 hp to give it to another player" @@ -100,7 +100,7 @@ def get_all_events(): Agguato(), # Cecchino(), DeadMan(), - # FratelliDiSangue(), + FratelliDiSangue(), IlGiudice(), Lazo(), LeggeDelWest(), diff --git a/backend/bang/players.py b/backend/bang/players.py index 84405e4..6c45107 100644 --- a/backend/bang/players.py +++ b/backend/bang/players.py @@ -48,6 +48,7 @@ class Player: self.attacker: Player = None self.target_p: str = None self.is_drawing = False + self.is_giving_life = False self.mancato_needed = 0 self.molly_discarded_cards = 0 self.is_bot = bot @@ -304,9 +305,19 @@ class Player: self.is_waiting_for_action = True self.has_played_bang = False self.special_use_count = 0 - if not self.game.check_event(ce.Lazo) and any([isinstance(c, cs.Dinamite) or isinstance(c, cs.Prigione) for c in self.equipment]): + if self.game.check_event(ce.FratelliDiSangue) and self.lives > 1 and not self.is_giving_life and len([p for p in self.game.players if p != self and p.lives < p.max_lives]): + self.available_cards = [{ + 'name': p.name, + 'icon': isinstance(p.role, r.Sheriff), + } for p in self.game.players if p != self and p.lives < p.max_lives] + self.available_cards.append({'icon': 'โŒ'}) + self.pending_action = PendingAction.CHOOSE + self.is_giving_life = True + elif not self.game.check_event(ce.Lazo) and any([isinstance(c, cs.Dinamite) or isinstance(c, cs.Prigione) for c in self.equipment]): + self.is_giving_life = False self.pending_action = PendingAction.PICK else: + self.is_giving_life = False if isinstance(self.real_character, chd.VeraCuster): self.set_available_character([p.character for p in self.game.players if p != self]) else: @@ -494,6 +505,15 @@ class Player: while self.target_p == self.name or len(self.game.players[self.game.players_map[self.target_p]].hand) + len(self.game.players[self.game.players_map[self.target_p]].equipment) == 0: self.target_p = self.game.players[self.game.players_map[self.target_p]+1].name self.notify_self() + elif self.is_giving_life and self.game.check_event(ce.FratelliDiSangue): + try: + player = self.game.get_player_named(self.available_cards[card_index]['name']) + player.lives += 1 + self.lives -= 1 + player.notify_self() + self.sio.emit('chat_message', room=self.game.name, data=f'_fratelli_sangue|{self.name}|{player.name}') + except: pass + self.play_turn() elif self.is_drawing and self.game.check_event(ce.Peyote): self.is_drawing = False card = self.game.deck.draw() diff --git a/frontend/src/i18n/en.json b/frontend/src/i18n/en.json index 5b780f3..69c916f 100644 --- a/frontend/src/i18n/en.json +++ b/frontend/src/i18n/en.json @@ -83,7 +83,8 @@ "allroles": "In the game there are: {0}.", "guess": "{0} guesses {1}.", "guess_right": "{0} was right.", - "guess_wrong": "{0} was wrong." + "guess_wrong": "{0} was wrong.", + "fratelli_sangue": "{0} gave one of his lives to {1}." }, "foc": { "leggedelwest": "He must play this card on this turn if possible." diff --git a/frontend/src/i18n/it.json b/frontend/src/i18n/it.json index 9eaa065..773bb29 100644 --- a/frontend/src/i18n/it.json +++ b/frontend/src/i18n/it.json @@ -83,7 +83,8 @@ "allroles": "Nella partita ci sono: {0}.", "guess": "{0} pensa sia {1}.", "guess_right": "{0} ha indovinato.", - "guess_wrong": "{0} ha sbagliato." + "guess_wrong": "{0} ha sbagliato.", + "fratelli_sangue": "{0} ha donato una delle sue vite a {1}." }, "foc": { "leggedelwest": "Ed รจ obbligato a usarla nel suo turno, se possibile"