buy cards and earn nuggets on other player damage

This commit is contained in:
Alberto Xamin 2021-06-15 18:52:30 +02:00
parent 46456ed433
commit 445399d7b3
No known key found for this signature in database
GPG Key ID: 4F026F48309500A2
8 changed files with 36 additions and 5 deletions

View File

@ -419,6 +419,11 @@ def holyday_special(sid, data):
ses: Player = sio.get_session(sid)
ses.holyday_special(data)
@sio.event
def buy_gold_rush_card(sid, data:int):
ses: Player = sio.get_session(sid)
ses.buy_gold_rush_card(data)
@sio.event
def get_cards(sid):
import bang.cards as c

View File

@ -55,6 +55,7 @@ class Deck:
return
for i in range(3):
if self.shop_cards[i] == None:
print(f'replacing gr-card {i}')
self.shop_cards[i] = self.shop_deck.pop(0)
self.game.notify_gold_rush_shop()

View File

@ -125,7 +125,7 @@ class Piccone(ShopCard):
class Ricercato(ShopCard):
def __init__(self):
super().__init__("Ricercato", 2, ShopCardKind.BLACK)
self.icon = ''
self.icon = '🤠'
def play_card(self, player, against, _with=None):
pass

View File

@ -614,6 +614,7 @@ class Game:
'equipment': [e.__dict__ for e in p.equipment],
'lives': p.lives,
'max_lives': p.max_lives,
'gold_nuggets': p.gold_nuggets,
'is_sheriff': isinstance(p.role, roles.Sheriff),
'is_my_turn': p.is_my_turn,
'pending_action': p.pending_action,

View File

@ -74,6 +74,7 @@ class Player:
self.choose_text = 'choose_card_to_get'
self.using_rimbalzo = 0 # 0 no, 1 scegli giocatore, 2 scegli carta
self.bang_used = 0
self.gold_nuggets = 0
def join_game(self, game):
self.game = game
@ -866,6 +867,9 @@ class Player:
self.sio.emit('chat_message', room=self.game.name,
data=f'_special_el_gringo|{self.name}|{self.attacker.name}')
self.attacker.notify_self()
if self.attacker and 'gold_rush' in self.game.expansions:
self.attacker.gold_nuggets += 1
self.attacker.notify_self()
self.heal_if_needed()
self.mancato_needed = 0
self.expected_response = []
@ -987,6 +991,16 @@ class Player:
self.hand.append(self.game.deck.draw(True))
self.notify_self()
def buy_gold_rush_card(self, index):
print(f'{self.name} wants to buy gr-card index {index} in room {self.game.name}')
card = self.game.deck.shop_cards[index]
if self.pending_action == PendingAction.PLAY and self.gold_nuggets >= card.number:
self.gold_nuggets -= card.number
self.game.deck.shop_deck.append(card)
self.game.deck.shop_cards[index] = None
self.game.deck.fill_gold_rush_shop()
self.notify_self()
def end_turn(self, forced=False):
print(f"{self.name} wants to end his turn")
if not self.is_my_turn and not forced:

View File

@ -33,6 +33,8 @@ export default {
return '';
},
number() {
if (isNaN(this.card.suit))
return this.card.number
if (this.card.number === 1) return 'A'
else if (this.card.number === 11) return 'J'
else if (this.card.number === 12) return 'Q'

View File

@ -2,9 +2,9 @@
<div>
<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="goldRushShopOpen && goldRushCards.length > 0" :key="goldRushCards[0].name" :card="goldRushCards[0]" :class="{'gold-rush':true, 'brown':goldRushCards[0].kind === 0, 'black':goldRushCards[0].kind === 1}"/>
<card v-if="goldRushShopOpen && goldRushCards.length > 1" :key="goldRushCards[1].name" :card="goldRushCards[1]" :class="{'gold-rush':true, 'brown':goldRushCards[1].kind === 0, 'black':goldRushCards[1].kind === 1}"/>
<card v-if="goldRushShopOpen && goldRushCards.length > 2" :key="goldRushCards[2].name" :card="goldRushCards[2]" :class="{'gold-rush':true, 'brown':goldRushCards[2].kind === 0, 'black':goldRushCards[2].kind === 1}"/>
<card v-if="goldRushShopOpen && goldRushCards.length > 0" :key="goldRushCards[0].name" :card="goldRushCards[0]" :class="{'gold-rush':true, 'brown':goldRushCards[0].kind === 0, 'black':goldRushCards[0].kind === 1, 'cant-play': pending_action !==2 || gold_nuggets < goldRushCards[0].number}" @click.native="() => {buy_gold_rush_card(0)}"/>
<card v-if="goldRushShopOpen && goldRushCards.length > 1" :key="goldRushCards[1].name" :card="goldRushCards[1]" :class="{'gold-rush':true, 'brown':goldRushCards[1].kind === 0, 'black':goldRushCards[1].kind === 1, 'cant-play': pending_action !==2 || gold_nuggets < goldRushCards[1].number}" @click.native="() => {buy_gold_rush_card(1)}"/>
<card v-if="goldRushShopOpen && goldRushCards.length > 2" :key="goldRushCards[2].name" :card="goldRushCards[2]" :class="{'gold-rush':true, 'brown':goldRushCards[2].kind === 0, 'black':goldRushCards[2].kind === 1, 'cant-play': pending_action !==2 || gold_nuggets < goldRushCards[2].number}" @click.native="() => {buy_gold_rush_card(2)}"/>
<div style="position:relative">
<div class="card gold-rush back" style="position:relative; bottom:-3pt;right:-3pt;"/>
<div class="card gold-rush back" style="position:absolute; bottom:-1.5pt;right:-1.5pt;"/>
@ -64,12 +64,14 @@ export default {
desc: '',
goldRushShopOpen: true,
goldRushCards: [],
gold_nuggets: 0,
}),
sockets: {
self(self){
self = JSON.parse(self)
this.isPlaying = self.lives > 0 || self.is_ghost
this.pending_action = self.pending_action
this.gold_nuggets = self.gold_nuggets
},
scrap(card) {
this.lastScrap = card
@ -120,6 +122,9 @@ export default {
this.$socket.emit('draw', pile)
}
},
buy_gold_rush_card(index) {
this.$socket.emit('buy_gold_rush_card', index)
},
event() {
if (this.pending_action !== false) {
this.$socket.emit('draw', 'event')

View File

@ -20,6 +20,9 @@
<transition-group name="list" tag="div" class="players-table">
<Card v-if="startGameCard" key="_start_game_" :donotlocalize="true" :card="startGameCard" @click.native="startGame"/>
<div v-for="p in playersTable" v-bind:key="p.card.name" style="position:relative;">
<transition-group v-if="p.gold_nuggets && p.gold_nuggets > 0" name="list" tag="div" style="position: absolute;top: -10pt;">
<span v-for="(n, i) in p.gold_nuggets" v-bind:key="i" :alt="i">💵</span>
</transition-group>
<transition-group v-if="p.max_lives && !p.is_ghost" name="list" tag="div" class="tiny-health">
<span v-for="(n, i) in p.lives" v-bind:key="i" :alt="i"></span>
<span v-for="(n, i) in (p.max_lives-p.lives)" v-bind:key="`${i}-sk`" :alt="i">💀</span>