diff --git a/backend/bang/deck.py b/backend/bang/deck.py index d73a869..2112620 100644 --- a/backend/bang/deck.py +++ b/backend/bang/deck.py @@ -103,6 +103,7 @@ class Deck: return self.draw() def scrap(self, card: cs.Card, ignore_event = False): + if card.number == 42: return card.reset_card() if self.game.check_event(ce.MinieraAbbandonata) and not ignore_event: self.put_on_top(card) diff --git a/backend/bang/expansions/gold_rush/shop_cards.py b/backend/bang/expansions/gold_rush/shop_cards.py index 7604deb..4e84743 100644 --- a/backend/bang/expansions/gold_rush/shop_cards.py +++ b/backend/bang/expansions/gold_rush/shop_cards.py @@ -1,4 +1,5 @@ from bang.cards import * +import bang.players as pl class ShopCardKind(IntEnum): BROWN = 0 # Se l’equipaggiamento ha il bordo marrone, applicane subito l’effetto e poi scartalo. @@ -36,7 +37,6 @@ class Bicchierino(ShopCard): self.icon = '🍸️' def play_card(self, player, against=None, _with=None): - import bang.players as pl player.available_cards = [{ 'name': p.name, 'icon': p.role.icon if(player.game.initial_players == 3) else '⭐️' if p['is_sheriff'] else '🤠', @@ -54,9 +54,14 @@ class Bottiglia(ShopCard): self.icon = '🍾️' def play_card(self, player, against=None, _with=None): - if against != None: - pass # bang, birra, panico - return False + # bang, birra, panico + player.available_cards = [Bang(1,42), Birra(1,42), Panico(1,42)] + for i in range(len(player.available_cards)): + player.available_cards[i].must_be_used = True + player.choose_text = 'choose_bottiglia' + player.pending_action = pl.PendingAction.CHOOSE + player.notify_self() + return True class Complice(ShopCard): def __init__(self): @@ -64,9 +69,14 @@ class Complice(ShopCard): self.icon = '😉️' def play_card(self, player, against=None, _with=None): - if against != None: - pass # emporio, duello, Cat balou - return False + # emporio, duello, Cat balou + player.available_cards = [Emporio(1,42), Duello(1,42), CatBalou(1,42)] + for i in range(len(player.available_cards)): + player.available_cards[i].must_be_used = True + player.choose_text = 'choose_complice' + player.pending_action = pl.PendingAction.CHOOSE + player.notify_self() + return True class CorsaAllOro(ShopCard): def __init__(self): @@ -141,7 +151,6 @@ class Ricercato(ShopCard): self.icon = '🤠️' def play_card(self, player, against=None, _with=None): - import bang.players as pl player.available_cards = [{ 'name': p.name, 'icon': p.role.icon if(player.game.initial_players == 3) else '⭐️' if p['is_sheriff'] else '🤠', @@ -206,20 +215,8 @@ class Zaino(ShopCard): def get_cards() -> List[Card]: cards = [ Bicchierino(), - Bicchierino(), - Bicchierino(), - Bicchierino(), - Bicchierino(), - Bicchierino(), - Bicchierino(), - Bicchierino(), - Bicchierino(), - Bicchierino(), - Bicchierino(), - Bicchierino(), - Bicchierino(), - # Bottiglia(), - # Complice(), + Bottiglia(), + Complice(), CorsaAllOro(), Rum(), UnionPacific(), diff --git a/backend/bang/players.py b/backend/bang/players.py index 1acfa38..158037d 100644 --- a/backend/bang/players.py +++ b/backend/bang/players.py @@ -626,6 +626,19 @@ class Player: player.lives = min(player.lives+1, player.max_lives) self.pending_action = PendingAction.PLAY self.notify_self() + elif self.choose_text == 'choose_bottiglia': + self.sio.emit('chat_message', room=self.game.name, data=f'_play_card|{self.name}|{"Bottiglia"}') + if isinstance(self.available_cards[card_index], cs.Birra): + self.lives = min(self.lives+1, self.max_lives) + else: + self.hand.append(self.available_cards[card_index]) + self.pending_action = PendingAction.PLAY + self.notify_self() + elif self.choose_text == 'choose_complice': + self.sio.emit('chat_message', room=self.game.name, data=f'_play_card|{self.name}|{"Bottiglia"}') + self.hand.append(self.available_cards[card_index]) + self.pending_action = PendingAction.PLAY + self.notify_self() elif self.game.check_event(ceh.NuovaIdentita) and self.choose_text == 'choose_nuova_identita': if card_index == 1: # the other character self.character = self.not_chosen_character diff --git a/frontend/src/components/Player.vue b/frontend/src/components/Player.vue index ba97a06..d67a86d 100644 --- a/frontend/src/components/Player.vue +++ b/frontend/src/components/Player.vue @@ -169,6 +169,10 @@ export default { this.shouldChooseCard = false } this.noStar = self.noStar + let mustplay = this.handComputed.filter(x => x.number == 42); + if (mustplay.length > 0) { + this.play_card(mustplay[0], false) + } }, self_vis(vis) { // console.log('received visibility update')