buy cards and earn nuggets on other player damage
This commit is contained in:
parent
46456ed433
commit
445399d7b3
@ -419,6 +419,11 @@ def holyday_special(sid, data):
|
|||||||
ses: Player = sio.get_session(sid)
|
ses: Player = sio.get_session(sid)
|
||||||
ses.holyday_special(data)
|
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
|
@sio.event
|
||||||
def get_cards(sid):
|
def get_cards(sid):
|
||||||
import bang.cards as c
|
import bang.cards as c
|
||||||
|
@ -55,6 +55,7 @@ class Deck:
|
|||||||
return
|
return
|
||||||
for i in range(3):
|
for i in range(3):
|
||||||
if self.shop_cards[i] == None:
|
if self.shop_cards[i] == None:
|
||||||
|
print(f'replacing gr-card {i}')
|
||||||
self.shop_cards[i] = self.shop_deck.pop(0)
|
self.shop_cards[i] = self.shop_deck.pop(0)
|
||||||
self.game.notify_gold_rush_shop()
|
self.game.notify_gold_rush_shop()
|
||||||
|
|
||||||
|
@ -125,7 +125,7 @@ class Piccone(ShopCard):
|
|||||||
class Ricercato(ShopCard):
|
class Ricercato(ShopCard):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super().__init__("Ricercato", 2, ShopCardKind.BLACK)
|
super().__init__("Ricercato", 2, ShopCardKind.BLACK)
|
||||||
self.icon = '⛏️'
|
self.icon = '🤠️'
|
||||||
|
|
||||||
def play_card(self, player, against, _with=None):
|
def play_card(self, player, against, _with=None):
|
||||||
pass
|
pass
|
||||||
|
@ -614,6 +614,7 @@ class Game:
|
|||||||
'equipment': [e.__dict__ for e in p.equipment],
|
'equipment': [e.__dict__ for e in p.equipment],
|
||||||
'lives': p.lives,
|
'lives': p.lives,
|
||||||
'max_lives': p.max_lives,
|
'max_lives': p.max_lives,
|
||||||
|
'gold_nuggets': p.gold_nuggets,
|
||||||
'is_sheriff': isinstance(p.role, roles.Sheriff),
|
'is_sheriff': isinstance(p.role, roles.Sheriff),
|
||||||
'is_my_turn': p.is_my_turn,
|
'is_my_turn': p.is_my_turn,
|
||||||
'pending_action': p.pending_action,
|
'pending_action': p.pending_action,
|
||||||
|
@ -74,6 +74,7 @@ class Player:
|
|||||||
self.choose_text = 'choose_card_to_get'
|
self.choose_text = 'choose_card_to_get'
|
||||||
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
|
||||||
|
|
||||||
def join_game(self, game):
|
def join_game(self, game):
|
||||||
self.game = game
|
self.game = game
|
||||||
@ -866,6 +867,9 @@ class Player:
|
|||||||
self.sio.emit('chat_message', room=self.game.name,
|
self.sio.emit('chat_message', room=self.game.name,
|
||||||
data=f'_special_el_gringo|{self.name}|{self.attacker.name}')
|
data=f'_special_el_gringo|{self.name}|{self.attacker.name}')
|
||||||
self.attacker.notify_self()
|
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.heal_if_needed()
|
||||||
self.mancato_needed = 0
|
self.mancato_needed = 0
|
||||||
self.expected_response = []
|
self.expected_response = []
|
||||||
@ -987,6 +991,16 @@ class Player:
|
|||||||
self.hand.append(self.game.deck.draw(True))
|
self.hand.append(self.game.deck.draw(True))
|
||||||
self.notify_self()
|
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):
|
def end_turn(self, forced=False):
|
||||||
print(f"{self.name} wants to end his turn")
|
print(f"{self.name} wants to end his turn")
|
||||||
if not self.is_my_turn and not forced:
|
if not self.is_my_turn and not forced:
|
||||||
|
@ -33,6 +33,8 @@ export default {
|
|||||||
return '';
|
return '';
|
||||||
},
|
},
|
||||||
number() {
|
number() {
|
||||||
|
if (isNaN(this.card.suit))
|
||||||
|
return this.card.number
|
||||||
if (this.card.number === 1) return 'A'
|
if (this.card.number === 1) return 'A'
|
||||||
else if (this.card.number === 11) return 'J'
|
else if (this.card.number === 11) return 'J'
|
||||||
else if (this.card.number === 12) return 'Q'
|
else if (this.card.number === 12) return 'Q'
|
||||||
|
@ -2,9 +2,9 @@
|
|||||||
<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="{'gold-rush':true, 'brown':goldRushCards[0].kind === 0, 'black':goldRushCards[0].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}"/>
|
<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}"/>
|
<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 style="position:relative">
|
||||||
<div class="card gold-rush back" style="position:relative; bottom:-3pt;right:-3pt;"/>
|
<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;"/>
|
<div class="card gold-rush back" style="position:absolute; bottom:-1.5pt;right:-1.5pt;"/>
|
||||||
@ -64,12 +64,14 @@ export default {
|
|||||||
desc: '',
|
desc: '',
|
||||||
goldRushShopOpen: true,
|
goldRushShopOpen: true,
|
||||||
goldRushCards: [],
|
goldRushCards: [],
|
||||||
|
gold_nuggets: 0,
|
||||||
}),
|
}),
|
||||||
sockets: {
|
sockets: {
|
||||||
self(self){
|
self(self){
|
||||||
self = JSON.parse(self)
|
self = JSON.parse(self)
|
||||||
this.isPlaying = self.lives > 0 || self.is_ghost
|
this.isPlaying = self.lives > 0 || self.is_ghost
|
||||||
this.pending_action = self.pending_action
|
this.pending_action = self.pending_action
|
||||||
|
this.gold_nuggets = self.gold_nuggets
|
||||||
},
|
},
|
||||||
scrap(card) {
|
scrap(card) {
|
||||||
this.lastScrap = card
|
this.lastScrap = card
|
||||||
@ -120,6 +122,9 @@ export default {
|
|||||||
this.$socket.emit('draw', pile)
|
this.$socket.emit('draw', pile)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
buy_gold_rush_card(index) {
|
||||||
|
this.$socket.emit('buy_gold_rush_card', index)
|
||||||
|
},
|
||||||
event() {
|
event() {
|
||||||
if (this.pending_action !== false) {
|
if (this.pending_action !== false) {
|
||||||
this.$socket.emit('draw', 'event')
|
this.$socket.emit('draw', 'event')
|
||||||
|
@ -20,6 +20,9 @@
|
|||||||
<transition-group name="list" tag="div" class="players-table">
|
<transition-group name="list" tag="div" class="players-table">
|
||||||
<Card v-if="startGameCard" key="_start_game_" :donotlocalize="true" :card="startGameCard" @click.native="startGame"/>
|
<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;">
|
<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">
|
<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.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>
|
<span v-for="(n, i) in (p.max_lives-p.lives)" v-bind:key="`${i}-sk`" :alt="i">💀</span>
|
||||||
@ -221,7 +224,7 @@ export default {
|
|||||||
playersTable() {
|
playersTable() {
|
||||||
if (Vue.config.devtools)
|
if (Vue.config.devtools)
|
||||||
console.log('update players')
|
console.log('update players')
|
||||||
return this.players.map((x,i) => {
|
return this.players.map((x, i) => {
|
||||||
let offsetAngle = 360.0 / this.players.length
|
let offsetAngle = 360.0 / this.players.length
|
||||||
let rotateAngle = (i) * offsetAngle
|
let rotateAngle = (i) * offsetAngle
|
||||||
let size = 130
|
let size = 130
|
||||||
|
Loading…
Reference in New Issue
Block a user