open and close shop

This commit is contained in:
Alberto Xamin 2021-06-16 17:38:11 +02:00
parent 849aaabb79
commit 3e9e1d5d35
No known key found for this signature in database
GPG Key ID: 4F026F48309500A2
4 changed files with 31 additions and 27 deletions

View File

@ -36,6 +36,7 @@ class Deck:
self.event_cards.append(random.choice(endgame_cards)) self.event_cards.append(random.choice(endgame_cards))
random.shuffle(self.cards) random.shuffle(self.cards)
self.shop_deck = [] self.shop_deck = []
self.shop_cards = []
if 'gold_rush' in game.expansions: if 'gold_rush' in game.expansions:
import bang.expansions.gold_rush.shop_cards as gr import bang.expansions.gold_rush.shop_cards as gr
self.shop_cards = [None, None, None] self.shop_cards = [None, None, None]

View File

@ -18,7 +18,7 @@ class ShopCard(Card):
if not self.is_duplicate_card(player): if not self.is_duplicate_card(player):
self.reset_card() self.reset_card()
self.can_be_used_now = True self.can_be_used_now = True
player.equipment.append(self) player.gold_rush_equipment.append(self)
return True return True
else: else:
return False return False

View File

@ -76,6 +76,7 @@ class Player:
self.using_rimbalzo = 0 # 0 no, 1 scegli giocatore, 2 scegli carta self.using_rimbalzo = 0 # 0 no, 1 scegli giocatore, 2 scegli carta
self.bang_used = 0 self.bang_used = 0
self.gold_nuggets = 0 self.gold_nuggets = 0
self.gold_rush_equipment = []
def join_game(self, game): def join_game(self, game):
self.game = game self.game = game
@ -272,7 +273,7 @@ class Player:
return return
break break
maxcards = self.lives if not self.character.check(self.game, chd.SeanMallory) else 10 maxcards = self.lives if not self.character.check(self.game, chd.SeanMallory) else 10
if maxcards == self.lives and len([c for c in self.equipment if isinstance(c, grc.Cinturone)]) > 0: if maxcards == self.lives and len([c for c in self.gold_rush_equipment if isinstance(c, grc.Cinturone)]) > 0:
maxcards = 8 maxcards = 8
if len(self.hand) > maxcards: if len(self.hand) > maxcards:
self.scrap(0) self.scrap(0)
@ -323,9 +324,9 @@ class Player:
if self.game.check_event(ceh.MezzogiornoDiFuoco): if self.game.check_event(ceh.MezzogiornoDiFuoco):
self.attacker = None self.attacker = None
self.lives -= 1 self.lives -= 1
if len([c for c in self.equipment if isinstance(c, grc.Talismano)]) > 0: if len([c for c in self.gold_rush_equipment if isinstance(c, grc.Talismano)]) > 0:
self.gold_nuggets += 1 self.gold_nuggets += 1
if len([c for c in self.equipment if isinstance(c, grc.Stivali)]) > 0: if len([c for c in self.gold_rush_equipment if isinstance(c, grc.Stivali)]) > 0:
self.hand.append(self.game.deck.draw()) self.hand.append(self.game.deck.draw())
if self.character.check(self.game, chars.BartCassidy) and self.lives > 0: if self.character.check(self.game, chars.BartCassidy) and self.lives > 0:
self.hand.append(self.game.deck.draw(True)) self.hand.append(self.game.deck.draw(True))
@ -443,7 +444,7 @@ class Player:
return self.notify_self() return self.notify_self()
if self.game.check_event(ceh.IlTreno) or (self.is_ghost and self.game.check_event(ceh.CittaFantasma)): if self.game.check_event(ceh.IlTreno) or (self.is_ghost and self.game.check_event(ceh.CittaFantasma)):
self.hand.append(self.game.deck.draw()) self.hand.append(self.game.deck.draw())
if len([c for c in self.equipment if isinstance(c, grc.Piccone)]) > 0: if len([c for c in self.gold_rush_equipment if isinstance(c, grc.Piccone)]) > 0:
self.hand.append(self.game.deck.draw()) self.hand.append(self.game.deck.draw())
self.manette() self.manette()
self.notify_self() self.notify_self()
@ -463,7 +464,7 @@ class Player:
if self.pending_action != PendingAction.PICK: if self.pending_action != PendingAction.PICK:
return return
pickable_cards = 1 + self.character.pick_mod pickable_cards = 1 + self.character.pick_mod
if len([c for c in self.equipment if isinstance(c, grc.FerroDiCavallo)]) > 0: if len([c for c in self.gold_rush_equipment if isinstance(c, grc.FerroDiCavallo)]) > 0:
pickable_cards += 1 pickable_cards += 1
if self.is_my_turn: if self.is_my_turn:
for i in range(len(self.equipment)): for i in range(len(self.equipment)):
@ -476,9 +477,9 @@ class Player:
data=f'_flipped|{self.name}|{picked.name}|{picked.num_suit()}') data=f'_flipped|{self.name}|{picked.name}|{picked.num_suit()}')
if picked.check_suit(self.game, [cs.Suit.SPADES]) and 2 <= picked.number <= 9 and pickable_cards == 0: if picked.check_suit(self.game, [cs.Suit.SPADES]) and 2 <= picked.number <= 9 and pickable_cards == 0:
self.lives -= 3 self.lives -= 3
if len([c for c in self.equipment if isinstance(c, grc.Talismano)]) > 0: if len([c for c in self.gold_rush_equipment if isinstance(c, grc.Talismano)]) > 0:
self.gold_nuggets += 3 self.gold_nuggets += 3
if len([c for c in self.equipment if isinstance(c, grc.Stivali)]) > 0: if len([c for c in self.gold_rush_equipment if isinstance(c, grc.Stivali)]) > 0:
self.hand.append(self.game.deck.draw()) self.hand.append(self.game.deck.draw())
self.hand.append(self.game.deck.draw()) self.hand.append(self.game.deck.draw())
self.hand.append(self.game.deck.draw()) self.hand.append(self.game.deck.draw())
@ -556,7 +557,7 @@ class Player:
print(self.name, 'is playing ', card, ' against:', against, ' with:', _with) print(self.name, 'is playing ', card, ' against:', against, ' with:', _with)
did_play_card = False did_play_card = False
event_blocks_card = (self.game.check_event(ce.IlGiudice) and (card.is_equipment or (card.usable_next_turn and not card.can_be_used_now))) or (self.game.check_event(ce.Lazo) and card.usable_next_turn and card.can_be_used_now) or (self.game.check_event(ceh.Manette) and card.suit != self.committed_suit_manette and not (card.usable_next_turn and card.can_be_used_now)) event_blocks_card = (self.game.check_event(ce.IlGiudice) and (card.is_equipment or (card.usable_next_turn and not card.can_be_used_now))) or (self.game.check_event(ce.Lazo) and card.usable_next_turn and card.can_be_used_now) or (self.game.check_event(ceh.Manette) and card.suit != self.committed_suit_manette and not (card.usable_next_turn and card.can_be_used_now))
if not(against != None and (isinstance(self.game.get_player_named(against).character, chd.ApacheKid) or len([c for c in self.game.get_player_named(against).equipment if isinstance(c, grc.Calumet)]) > 0) and card.check_suit(self.game, [cs.Suit.DIAMONDS])) or (isinstance(card, grc.ShopCard) and card.kind == grc.ShopCardKind.BLACK) and not event_blocks_card: if not(against != None and (isinstance(self.game.get_player_named(against).character, chd.ApacheKid) or len([c for c in self.game.get_player_named(against).gold_rush_equipment if isinstance(c, grc.Calumet)]) > 0) and card.check_suit(self.game, [cs.Suit.DIAMONDS])) or (isinstance(card, grc.ShopCard) and card.kind == grc.ShopCardKind.BLACK) and not event_blocks_card:
if against == self.name and not isinstance(card, csd.Tequila): if against == self.name and not isinstance(card, csd.Tequila):
did_play_card = False did_play_card = False
else: else:
@ -627,9 +628,9 @@ class Player:
player = self.game.get_player_named(self.available_cards[card_index]['name']) player = self.game.get_player_named(self.available_cards[card_index]['name'])
player.lives += 1 player.lives += 1
self.lives -= 1 self.lives -= 1
if len([c for c in self.equipment if isinstance(c, grc.Talismano)]) > 0: if len([c for c in self.gold_rush_equipment if isinstance(c, grc.Talismano)]) > 0:
self.gold_nuggets += 1 self.gold_nuggets += 1
if len([c for c in self.equipment if isinstance(c, grc.Stivali)]) > 0: if len([c for c in self.gold_rush_equipment if isinstance(c, grc.Stivali)]) > 0:
self.hand.append(self.game.deck.draw()) self.hand.append(self.game.deck.draw())
player.notify_self() player.notify_self()
self.sio.emit('chat_message', room=self.game.name, data=f'_fratelli_sangue|{self.name}|{player.name}') self.sio.emit('chat_message', room=self.game.name, data=f'_fratelli_sangue|{self.name}|{player.name}')
@ -705,7 +706,7 @@ class Player:
self.hand.append(self.available_cards.pop(card_index)) self.hand.append(self.available_cards.pop(card_index))
pickable_stop = 1 pickable_stop = 1
if self.game.check_event(ceh.Sete): pickable_stop = 2 if self.game.check_event(ceh.Sete): pickable_stop = 2
if self.game.check_event(ceh.IlTreno) or len([c for c in self.equipment if isinstance(c, grc.Piccone)]) > 0: if self.game.check_event(ceh.IlTreno) or len([c for c in self.gold_rush_equipment if isinstance(c, grc.Piccone)]) > 0:
pickable_stop = 0 pickable_stop = 0
if len(self.available_cards) == pickable_stop: if len(self.available_cards) == pickable_stop:
if len(self.available_cards) > 0: if len(self.available_cards) > 0:
@ -729,7 +730,7 @@ class Player:
def barrel_pick(self): def barrel_pick(self):
pickable_cards = 1 + self.character.pick_mod pickable_cards = 1 + self.character.pick_mod
if len([c for c in self.equipment if isinstance(c, grc.FerroDiCavallo)]) > 0: if len([c for c in self.gold_rush_equipment if isinstance(c, grc.FerroDiCavallo)]) > 0:
pickable_cards += 1 pickable_cards += 1
if len([c for c in self.equipment if isinstance(c, cs.Barile)]) > 0 and self.character.check(self.game, chars.Jourdonnais): if len([c for c in self.equipment if isinstance(c, cs.Barile)]) > 0 and self.character.check(self.game, chars.Jourdonnais):
pickable_cards = 2 pickable_cards = 2
@ -761,7 +762,7 @@ class Player:
pickable_cards = 1 + self.character.pick_mod pickable_cards = 1 + self.character.pick_mod
if len([c for c in self.equipment if isinstance(c, cs.Barile)]) > 0 and self.character.check(self.game, chars.Jourdonnais): if len([c for c in self.equipment if isinstance(c, cs.Barile)]) > 0 and self.character.check(self.game, chars.Jourdonnais):
pickable_cards = 2 pickable_cards = 2
if len([c for c in self.equipment if isinstance(c, grc.FerroDiCavallo)]) > 0: if len([c for c in self.gold_rush_equipment if isinstance(c, grc.FerroDiCavallo)]) > 0:
pickable_cards += 1 pickable_cards += 1
while pickable_cards > 0: while pickable_cards > 0:
pickable_cards -= 1 pickable_cards -= 1
@ -841,7 +842,7 @@ class Player:
def get_indians(self, attacker): def get_indians(self, attacker):
self.attacker = attacker self.attacker = attacker
if self.character.check(self.game, chd.ApacheKid) or len([c for c in self.equipment if isinstance(c, grc.Calumet)]) > 0: return False if self.character.check(self.game, chd.ApacheKid) or len([c for c in self.gold_rush_equipment if isinstance(c, grc.Calumet)]) > 0: return False
if not self.game.is_competitive and len([c for c in self.hand if isinstance(c, cs.Bang) or (self.character.check(self.game, chars.CalamityJanet) and isinstance(c, cs.Mancato))]) == 0: if not self.game.is_competitive and len([c for c in self.hand if isinstance(c, cs.Bang) or (self.character.check(self.game, chars.CalamityJanet) and isinstance(c, cs.Mancato))]) == 0:
print('Cant defend') print('Cant defend')
self.take_damage_response() self.take_damage_response()
@ -900,9 +901,9 @@ class Player:
if self.attacker and 'gold_rush' in self.game.expansions: if self.attacker and 'gold_rush' in self.game.expansions:
self.attacker.gold_nuggets += 1 self.attacker.gold_nuggets += 1
self.attacker.notify_self() self.attacker.notify_self()
if len([c for c in self.equipment if isinstance(c, grc.Talismano)]) > 0: if len([c for c in self.gold_rush_equipment if isinstance(c, grc.Talismano)]) > 0:
self.gold_nuggets += 1 self.gold_nuggets += 1
if len([c for c in self.equipment if isinstance(c, grc.Stivali)]) > 0: if len([c for c in self.gold_rush_equipment if isinstance(c, grc.Stivali)]) > 0:
self.hand.append(self.game.deck.draw()) self.hand.append(self.game.deck.draw())
self.heal_if_needed() self.heal_if_needed()
self.mancato_needed = 0 self.mancato_needed = 0
@ -1021,9 +1022,9 @@ class Player:
def chuck_lose_hp_draw(self): def chuck_lose_hp_draw(self):
if self.character.check(self.game, chd.ChuckWengam) and self.lives > 1 and self.is_my_turn: if self.character.check(self.game, chd.ChuckWengam) and self.lives > 1 and self.is_my_turn:
self.lives -= 1 self.lives -= 1
if len([c for c in self.equipment if isinstance(c, grc.Talismano)]) > 0: if len([c for c in self.gold_rush_equipment if isinstance(c, grc.Talismano)]) > 0:
self.gold_nuggets += 1 self.gold_nuggets += 1
if len([c for c in self.equipment if isinstance(c, grc.Stivali)]) > 0: if len([c for c in self.gold_rush_equipment if isinstance(c, grc.Stivali)]) > 0:
self.hand.append(self.game.deck.draw()) self.hand.append(self.game.deck.draw())
self.hand.append(self.game.deck.draw(True)) self.hand.append(self.game.deck.draw(True))
self.hand.append(self.game.deck.draw(True)) self.hand.append(self.game.deck.draw(True))

View File

@ -1,14 +1,16 @@
<template> <template>
<div> <div >
<div class="deck"> <div class="deck">
<card v-if="endTurnAction && isPlaying" :donotlocalize="true" v-show="pending_action == 2" :card="endTurnCard" class="end-turn" @click.native="endTurnAction"/> <card v-if="endTurnAction && isPlaying" :donotlocalize="true" v-show="pending_action == 2" :card="endTurnCard" class="end-turn" @click.native="endTurnAction"/>
<card v-if="goldRushShopOpen && goldRushCards.length > 0" :key="goldRushCards[0].name" :card="goldRushCards[0]" :class="{'cant-play': pending_action !==2 || gold_nuggets < goldRushCards[0].number}" @click.native="() => {buy_gold_rush_card(0)}"/> <div class="deck" style="position:relative" v-if="goldRushCards.length > 0" >
<card v-if="goldRushShopOpen && goldRushCards.length > 1" :key="goldRushCards[1].name" :card="goldRushCards[1]" :class="{'cant-play': pending_action !==2 || gold_nuggets < goldRushCards[1].number}" @click.native="() => {buy_gold_rush_card(1)}"/> <card :style="goldRushShopOpen?``:`position:absolute; top:0; right:0; transform: rotate(-15deg) translate(0, -50px) scale(0.6)`" v-if="goldRushCards.length > 0" :key="goldRushCards[0].name" :card="goldRushCards[0]" :class="{'shop-open':goldRushShopOpen, 'cant-play': pending_action !==2 || gold_nuggets < goldRushCards[0].number}" @click.native="() => {buy_gold_rush_card(0)}"/>
<card v-if="goldRushShopOpen && goldRushCards.length > 2" :key="goldRushCards[2].name" :card="goldRushCards[2]" :class="{'cant-play': pending_action !==2 || gold_nuggets < goldRushCards[2].number}" @click.native="() => {buy_gold_rush_card(2)}"/> <card :style="goldRushShopOpen?``:`position:absolute; top:0; right:0; transform: rotate(+0deg) translate(0, -50px) scale(0.6)`" v-if="goldRushCards.length > 1" :key="goldRushCards[1].name" :card="goldRushCards[1]" :class="{'shop-open':goldRushShopOpen, 'cant-play': pending_action !==2 || gold_nuggets < goldRushCards[1].number}" @click.native="() => {buy_gold_rush_card(1)}"/>
<div style="position:relative"> <card :style="goldRushShopOpen?``:`position:absolute; top:0; right:0; transform: rotate(+15deg) translate(0, -50px) scale(0.6)`" v-if="goldRushCards.length > 2" :key="goldRushCards[2].name" :card="goldRushCards[2]" :class="{'shop-open':goldRushShopOpen, 'cant-play': pending_action !==2 || gold_nuggets < goldRushCards[2].number}" @click.native="() => {buy_gold_rush_card(2)}"/>
<div class="card gold-rush back" style="position:relative; bottom:-3pt;right:-3pt;"/> <div style="position:relative">
<div class="card gold-rush back" style="position:absolute; bottom:-1.5pt;right:-1.5pt;"/> <div class="card gold-rush back" style="position:relative; bottom:-3pt;right:-3pt;"/>
<card :card="goldRushCardBack" :donotlocalize="true" class="gold-rush back last-event" @click.native="goldRushShopOpen = !goldRushShopOpen"/> <div class="card gold-rush back" style="position:absolute; bottom:-1.5pt;right:-1.5pt;"/>
<card :card="goldRushCardBack" :donotlocalize="true" class="gold-rush back last-event" @click.native="goldRushShopOpen = !goldRushShopOpen"/>
</div>
</div> </div>
<div v-if="eventCard" style="position:relative"> <div v-if="eventCard" style="position:relative">
<div class="card fistful-of-cards" style="position:relative; bottom:-3pt;right:-3pt;"/> <div class="card fistful-of-cards" style="position:relative; bottom:-3pt;right:-3pt;"/>