show cards in frontend
This commit is contained in:
parent
8b9f095e4b
commit
46456ed433
@ -100,6 +100,7 @@ def get_me(sid, room):
|
|||||||
de_games[0].notify_event_card(sid)
|
de_games[0].notify_event_card(sid)
|
||||||
de_games[0].notify_scrap_pile(sid)
|
de_games[0].notify_scrap_pile(sid)
|
||||||
de_games[0].notify_all()
|
de_games[0].notify_all()
|
||||||
|
de_games[0].notify_gold_rush_shop()
|
||||||
de_games[0].notify_event_card()
|
de_games[0].notify_event_card()
|
||||||
else:
|
else:
|
||||||
create_room(sid, room['name'])
|
create_room(sid, room['name'])
|
||||||
|
@ -36,10 +36,12 @@ 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_deck = gr.get_cards()
|
self.shop_deck = gr.get_cards()
|
||||||
|
random.shuffle(self.shop_deck)
|
||||||
|
self.fill_gold_rush_shop()
|
||||||
self.scrap_pile: List[cs.Card] = []
|
self.scrap_pile: List[cs.Card] = []
|
||||||
print(f'Deck initialized with {len(self.cards)} cards')
|
print(f'Deck initialized with {len(self.cards)} cards')
|
||||||
|
|
||||||
@ -48,6 +50,14 @@ class Deck:
|
|||||||
self.event_cards.append(self.event_cards.pop(0))
|
self.event_cards.append(self.event_cards.pop(0))
|
||||||
self.game.notify_event_card()
|
self.game.notify_event_card()
|
||||||
|
|
||||||
|
def fill_gold_rush_shop(self):
|
||||||
|
if not any([c == None for c in self.shop_cards]):
|
||||||
|
return
|
||||||
|
for i in range(3):
|
||||||
|
if self.shop_cards[i] == None:
|
||||||
|
self.shop_cards[i] = self.shop_deck.pop(0)
|
||||||
|
self.game.notify_gold_rush_shop()
|
||||||
|
|
||||||
def peek(self, n_cards: int) -> list:
|
def peek(self, n_cards: int) -> list:
|
||||||
return self.cards[:n_cards]
|
return self.cards[:n_cards]
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@ class ShopCardKind(IntEnum):
|
|||||||
|
|
||||||
class ShopCard(Card):
|
class ShopCard(Card):
|
||||||
def __init__(self, name:str, cost:int, kind:ShopCardKind):
|
def __init__(self, name:str, cost:int, kind:ShopCardKind):
|
||||||
super().__init__('💵', cost, name=name)
|
super().__init__(suit='💵', number=cost, name=name)
|
||||||
self.kind = kind
|
self.kind = kind
|
||||||
|
|
||||||
def play_card(self, player, against, _with=None):
|
def play_card(self, player, against, _with=None):
|
||||||
|
@ -27,7 +27,7 @@ class Game:
|
|||||||
self.initial_players = 0
|
self.initial_players = 0
|
||||||
self.password = ''
|
self.password = ''
|
||||||
self.expansions = []
|
self.expansions = []
|
||||||
self.available_expansions = ['dodge_city', 'fistful_of_cards', 'high_noon']
|
self.available_expansions = ['dodge_city', 'fistful_of_cards', 'high_noon', 'gold_rush']
|
||||||
self.shutting_down = False
|
self.shutting_down = False
|
||||||
self.is_competitive = False
|
self.is_competitive = False
|
||||||
self.disconnect_bot = True
|
self.disconnect_bot = True
|
||||||
@ -159,6 +159,8 @@ class Game:
|
|||||||
self.initial_players = len(self.players)
|
self.initial_players = len(self.players)
|
||||||
self.distribute_roles()
|
self.distribute_roles()
|
||||||
self.choose_characters()
|
self.choose_characters()
|
||||||
|
if 'gold_rush' in self.expansions:
|
||||||
|
self.notify_gold_rush_shop()
|
||||||
|
|
||||||
def distribute_roles(self):
|
def distribute_roles(self):
|
||||||
available_roles: List[roles.Role] = []
|
available_roles: List[roles.Role] = []
|
||||||
@ -430,6 +432,12 @@ class Game:
|
|||||||
else:
|
else:
|
||||||
self.sio.emit('event_card', room=room, data=None)
|
self.sio.emit('event_card', room=room, data=None)
|
||||||
|
|
||||||
|
def notify_gold_rush_shop(self, sid=None):
|
||||||
|
if 'gold_rush' in self.expansions and self.deck and self.deck.shop_cards and len(self.deck.shop_cards) > 0:
|
||||||
|
room = self.name if sid == None else sid
|
||||||
|
print(f'gold_rush_shop room={room}, data={self.deck.shop_cards}')
|
||||||
|
self.sio.emit('gold_rush_shop', room=room, data=json.dumps(self.deck.shop_cards, default=lambda o: o.__dict__))
|
||||||
|
|
||||||
def notify_scrap_pile(self, sid=None):
|
def notify_scrap_pile(self, sid=None):
|
||||||
print('scrap')
|
print('scrap')
|
||||||
room = self.name if sid == None else sid
|
room = self.name if sid == None else sid
|
||||||
|
@ -27,6 +27,8 @@ export default {
|
|||||||
if (this.card && !isNaN(this.card.suit)) {
|
if (this.card && !isNaN(this.card.suit)) {
|
||||||
let x = ['♦️','♣️','♥️','♠️']
|
let x = ['♦️','♣️','♥️','♠️']
|
||||||
return x[this.card.suit];
|
return x[this.card.suit];
|
||||||
|
} else if (this.card.suit) {
|
||||||
|
return this.card.suit;
|
||||||
}
|
}
|
||||||
return '';
|
return '';
|
||||||
},
|
},
|
||||||
@ -107,6 +109,17 @@ export default {
|
|||||||
);
|
);
|
||||||
border: 2pt solid rgb(50 122 172);
|
border: 2pt solid rgb(50 122 172);
|
||||||
}
|
}
|
||||||
|
.card.brown.gold-rush {
|
||||||
|
box-shadow: 0 0 0pt 4pt var(--bg-color), 0 0 5pt 4pt #aaa;
|
||||||
|
border: 2pt dotted #9C7340;
|
||||||
|
}
|
||||||
|
.card.black.gold-rush {
|
||||||
|
box-shadow: 0 0 0pt 4pt var(--bg-color), 0 0 5pt 4pt #aaa;
|
||||||
|
border: 2pt dotted #000;
|
||||||
|
}
|
||||||
|
.card.back.gold-rush {
|
||||||
|
background: repeating-linear-gradient(347deg, #ffb32f, #987e51 );
|
||||||
|
}
|
||||||
.card h4 {
|
.card h4 {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
|
@ -2,6 +2,14 @@
|
|||||||
<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 > 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}"/>
|
||||||
|
<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;"/>
|
||||||
|
<card :card="goldRushCardBack" :donotlocalize="true" class="gold-rush back last-event" @click.native="goldRushShopOpen = !goldRushShopOpen"/>
|
||||||
|
</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;"/>
|
||||||
<div class="card fistful-of-cards" style="position:absolute; bottom:-1.5pt;right:-1.5pt;"/>
|
<div class="card fistful-of-cards" style="position:absolute; bottom:-1.5pt;right:-1.5pt;"/>
|
||||||
@ -44,12 +52,18 @@ export default {
|
|||||||
name: 'PewPew!',
|
name: 'PewPew!',
|
||||||
icon: '💥',
|
icon: '💥',
|
||||||
},
|
},
|
||||||
|
goldRushCardBack: {
|
||||||
|
name: 'GoldRush!',
|
||||||
|
icon: '🤑️',
|
||||||
|
},
|
||||||
lastScrap: null,
|
lastScrap: null,
|
||||||
eventCard: null,
|
eventCard: null,
|
||||||
previousScrap: null,
|
previousScrap: null,
|
||||||
pending_action: false,
|
pending_action: false,
|
||||||
isPlaying: true,
|
isPlaying: true,
|
||||||
desc: '',
|
desc: '',
|
||||||
|
goldRushShopOpen: true,
|
||||||
|
goldRushCards: [],
|
||||||
}),
|
}),
|
||||||
sockets: {
|
sockets: {
|
||||||
self(self){
|
self(self){
|
||||||
@ -68,6 +82,10 @@ export default {
|
|||||||
expansion: 'fistful-of-cards',
|
expansion: 'fistful-of-cards',
|
||||||
} : card
|
} : card
|
||||||
},
|
},
|
||||||
|
gold_rush_shop(cards) {
|
||||||
|
console.log('GOLD RUSH:'+ cards)
|
||||||
|
this.goldRushCards = JSON.parse(cards)
|
||||||
|
},
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
endTurnCard() {
|
endTurnCard() {
|
||||||
@ -140,6 +158,10 @@ export default {
|
|||||||
opacity: 0.8;
|
opacity: 0.8;
|
||||||
transform: translateY(-10px);
|
transform: translateY(-10px);
|
||||||
}
|
}
|
||||||
|
.gold-rush:not(.back) {
|
||||||
|
animation-duration: 0.8s;
|
||||||
|
animation-name: slidein;
|
||||||
|
}
|
||||||
@keyframes slidein {
|
@keyframes slidein {
|
||||||
from {
|
from {
|
||||||
transform: translate(-100px, 10px) scale(1.3) rotate(-10deg);
|
transform: translate(-100px, 10px) scale(1.3) rotate(-10deg);
|
||||||
|
Loading…
Reference in New Issue
Block a user