From 7692c7818ff7d62adefa40eaad5391d0d7cc5ab5 Mon Sep 17 00:00:00 2001 From: Alberto Xamin Date: Sun, 2 Apr 2023 17:05:49 +0100 Subject: [PATCH] add henry block --- .../the_valley_of_shadows/characters.py | 95 +++++++++++++------ backend/bang/game.py | 2 +- backend/bang/players.py | 2 + 3 files changed, 69 insertions(+), 30 deletions(-) diff --git a/backend/bang/expansions/the_valley_of_shadows/characters.py b/backend/bang/expansions/the_valley_of_shadows/characters.py index 21a0607..cdea867 100644 --- a/backend/bang/expansions/the_valley_of_shadows/characters.py +++ b/backend/bang/expansions/the_valley_of_shadows/characters.py @@ -2,75 +2,110 @@ from typing import List from bang.characters import Character import bang.cards as cs + class BlackFlower(Character): + """Una volta nel tuo turno, puoi usare una carta di fiori per sparare un BANG! extra.""" + def __init__(self): super().__init__("Black Flower", max_lives=4) - # Una volta nel tuo turno, puoi usare una carta di fiori per sparare un BANG! extra. - self.icon = '🥀' + self.icon = "🥀" - def special(self, player, data): #fiori = suit.Clubs - if player.special_use_count > 0 or not any((c.suit == cs.Suit.CLUBS for c in player.hand)): + def special(self, player, data): # fiori = suit.Clubs + if player.special_use_count > 0 or not any( + (c.suit == cs.Suit.CLUBS for c in player.hand) + ): return False - if any((player.get_sight() >= p['dist'] for p in player.game.get_visible_players(player))) and super().special(player, data): + if any( + ( + player.get_sight() >= p["dist"] + for p in player.game.get_visible_players(player) + ) + ) and super().special(player, data): from bang.players import PendingAction + player.available_cards = [c for c in player.hand if c.suit == cs.Suit.CLUBS] player.special_use_count += 1 player.pending_action = PendingAction.CHOOSE - player.choose_text = 'choose_play_as_bang' + player.choose_text = "choose_play_as_bang" player.notify_self() + class ColoradoBill(Character): + """Ogni volta che giochi una carta BANG!, "estrai!": se è Picche, il colpo non può essere evitato. + + Whenever you play a BANG! card, "draw!": if it's a Spade, the shot can't be avoided. + """ + def __init__(self): super().__init__("Colorado Bill", max_lives=4) - # Ogni volta che giochi una carta BANG!, "estrai!": se è Picche, il colpo non può essere evitato. - self.icon = '♠️' + self.icon = "♠️" + class DerSpotBurstRinger(Character): + """Una volta nel tuo turno, puoi usare una carta BANG! come Gatling. + + Once per turn, you can use a BANG! card as a Gatling.""" + def __init__(self): super().__init__("Der Spot Burst Ringer", max_lives=4) - # Una volta nel tuo turno, puoi usare una carta BANG! come Gatling. - self.icon = '🫧' + self.icon = "🫧" def special(self, player, data): - if player.special_use_count == 0 and \ - any((c.name == 'Bang!' for c in player.hand)) and super().special(player, data): + if ( + player.special_use_count == 0 + and any((c.name == "Bang!" for c in player.hand)) + and super().special(player, data) + ): player.special_use_count += 1 - #get cards from hand of type Bang and sort them by suit - cards = sorted([c for c in player.hand if c.name == 'Bang!'], key=lambda c: c.suit) + # get cards from hand of type Bang and sort them by suit + cards = sorted( + [c for c in player.hand if c.name == "Bang!"], key=lambda c: c.suit + ) player.hand.remove(cards[0]) player.game.deck.scrap(cards[0], True, player=player) player.notify_self() - player.game.attack_others(player, cs.Gatling(0,0).name) + player.game.attack_others(player, cs.Gatling(0, 0).name) + class EvelynShebang(Character): + """Puoi rinunciare a pescare carte nella tua fase di pesca. Per ogni carta non pescata, spari un BANG! a distanza raggiungibile, a un diverso bersaglio.""" + def __init__(self): super().__init__("Evelyn Shebang", max_lives=4) - # Puoi rinunciare a pescare carte nella tua fase di pesca. Per ogni carta non pescata, spari un BANG! a distanza raggiungibile, a un diverso bersaglio. - self.icon = '📵' + self.icon = "📵" + class HenryBlock(Character): + """Chiunque peschi o scarti una tua cartain gioco o in mano) è bersaglio di un BANG!""" + def __init__(self): super().__init__("Henry Block", max_lives=4) - # Chiunque peschi o scarti una tua cartain gioco o in mano) è bersaglio di un BANG!. - self.icon = '🚯' + self.icon = "🚯" + class LemonadeJim(Character): + """Ogni volta che un altro giocatore gioca una Birra, puoi scartare una carta dalla mano per riguadagnare anche tu 1 punto vita.""" + def __init__(self): super().__init__("Lemonade Jim", max_lives=4) - # Ogni volta che un altro giocatore gioca una Birra, puoi scartare una carta dalla mano per riguadagnare anche tu 1 punto vita. - self.icon = '🍋' + self.icon = "🍋" + class MickDefender(Character): + """Se sei bersaglio di una carta marrone (non BANG!), puoi usare una carta Mancato! evitarne 1 gli effetti.""" + def __init__(self): super().__init__("Mick Defender", max_lives=4) - # Se sei bersaglio di una carta marrone (non BANG!), puoi usare una carta Mancato! evitarne 1 gli effetti. - self.icon = '⛔' + self.icon = "⛔" + class TucoFranziskaner(Character): + """Durante la tua fase di pesca, se non hai carte blu in gioco, pesca 2 carte extra.""" + def __init__(self): super().__init__("Tuco Franziskaner", max_lives=4) - # Durante la tua fase di pesca, se non hai carte blu in gioco, pesca 2 carte extra. - self.icon = '🥬' + self.icon = "🥬" + def all_characters() -> List[Character]: cards = [ @@ -78,12 +113,14 @@ def all_characters() -> List[Character]: ColoradoBill(), DerSpotBurstRinger(), # EvelynShebang(), - # HenryBlock(), + HenryBlock(), # LemonadeJim(), MickDefender(), TucoFranziskaner(), ] - for c in cards: - c.expansion_icon = '👻️' - c.expansion = 'the_valley_of_shadows' + for card in cards: + card.expansion_icon = "👻️" # pylint: disable=attribute-defined-outside-init + card.expansion = ( # pylint: disable=attribute-defined-outside-init + "the_valley_of_shadows" + ) return cards diff --git a/backend/bang/game.py b/backend/bang/game.py index dfd68ca..e9a075a 100644 --- a/backend/bang/game.py +++ b/backend/bang/game.py @@ -530,7 +530,7 @@ class Game: attacker.pending_action = pl.PendingAction.WAIT attacker.notify_self() self.get_player_named(target_username).notify_self() - elif not attacker.is_my_turn: + elif not attacker.is_my_turn or len(self.attack_queue) == 0: self.players[self.turn].pending_action = pl.PendingAction.PLAY def steal_discard(self, attacker: pl.Player, target_username: str, card: cs.Card): diff --git a/backend/bang/players.py b/backend/bang/players.py index 4be9d22..cb15539 100644 --- a/backend/bang/players.py +++ b/backend/bang/players.py @@ -1385,6 +1385,8 @@ class Player: self.target_p = "" self.choose_action = "" self.pending_action = PendingAction.PLAY + if target.character.check(self.game, tvosch.HenryBlock): + self.game.attack(target, self.name, card_name="Henry Block") else: self.target_p = self.rissa_targets.pop(0).name print(f"rissa targets: {self.rissa_targets}")