syncronize scrap pile
This commit is contained in:
parent
a119ce6852
commit
79f363a5a0
@ -9,6 +9,8 @@ class Character(ABC):
|
||||
self.visibility_mod = 0
|
||||
self.pick_mod = 0
|
||||
self.desc = desc
|
||||
self.icon = '🤷♂️'
|
||||
self.number = ''.join(['❤️']*self.max_lives)
|
||||
|
||||
# @abstractmethod
|
||||
# def on_hurt(self, dmg: int):
|
||||
@ -40,6 +42,7 @@ class BlackJack(Character):
|
||||
class CalamityJanet(Character):
|
||||
def __init__(self):
|
||||
super().__init__("Calamity Janet", max_lives=4)
|
||||
self.icon = '🤷♀️'
|
||||
|
||||
class ElGringo(Character):
|
||||
def __init__(self):
|
||||
@ -72,6 +75,7 @@ class PedroRamirez(Character):
|
||||
class RoseDoolan(Character):
|
||||
def __init__(self):
|
||||
super().__init__("Rose Doolan", max_lives=4)
|
||||
self.icon = '🤷♀️'
|
||||
|
||||
class SidKetchum(Character):
|
||||
def __init__(self):
|
||||
|
@ -3,9 +3,10 @@ import random
|
||||
from cards import Card, get_starting_deck
|
||||
|
||||
class Deck:
|
||||
def __init__(self, sio):
|
||||
def __init__(self, game):
|
||||
super().__init__()
|
||||
self.cards: List[Card] = get_starting_deck()
|
||||
self.game = game
|
||||
random.shuffle(self.cards)
|
||||
self.scrap_pile: List[Card] = []
|
||||
print(f'Deck initialized with {len(self.cards)} cards')
|
||||
@ -13,7 +14,7 @@ class Deck:
|
||||
def peek(self, n_cards: int) -> list:
|
||||
return self.cards[:n_cards]
|
||||
|
||||
def peek_scrap_pile(self,) -> Card:
|
||||
def peek_scrap_pile(self) -> Card:
|
||||
if len(self.scrap_pile) > 0:
|
||||
return self.scrap_pile[-1]
|
||||
else:
|
||||
@ -35,8 +36,10 @@ class Deck:
|
||||
def draw_from_scrap_pile(self) -> Card:
|
||||
if len(self.scrap_pile) > 0:
|
||||
return self.scrap_pile.pop(0)
|
||||
self.game.notify_scrap_pile()
|
||||
else:
|
||||
return self.draw()
|
||||
|
||||
def scrap(self, card: Card):
|
||||
self.scrap_pile.append(card)
|
||||
self.game.notify_scrap_pile()
|
||||
|
@ -53,7 +53,7 @@ class Game:
|
||||
self.sio.emit('chat_message', room=self.name, data=f'La partita sta iniziando...')
|
||||
self.sio.emit('start', room=self.name)
|
||||
self.started = True
|
||||
self.deck = Deck(self.sio)
|
||||
self.deck = Deck(self)
|
||||
self.choose_characters()
|
||||
|
||||
def distribute_roles(self):
|
||||
@ -86,6 +86,10 @@ class Game:
|
||||
self.turn = (self.turn + 1) % len(self.players)
|
||||
self.play_turn()
|
||||
|
||||
def notify_scrap_pile(self):
|
||||
print('scrap')
|
||||
self.sio.emit('scrap', room=self.name, data=self.deck.peek_scrap_pile().__dict__)
|
||||
|
||||
|
||||
# game = Game()
|
||||
# p1 = players.Player('p1')
|
||||
|
@ -1,10 +1,6 @@
|
||||
<template>
|
||||
<div class="deck">
|
||||
<!-- <div v-if="lastScrap != null" :class="{ card:true, equipment: lastScrap.is_equipment }">
|
||||
<h3>{{lastScrap.name}}</h3>
|
||||
<emoji>{{lastScrap.icon}}</emoji>
|
||||
<span>{{lastScrap.number}}{{lastScrap.suit}}</span>
|
||||
</div> -->
|
||||
<card v-if="lastScrap" :card="lastScrap" />
|
||||
<div style="position:relative">
|
||||
<div class="card back" style="position:absolute; bottom:-3pt;right:-2pt;"/>
|
||||
<div class="card back" style="position:absolute; bottom:-1pt;right:-1pt;"/>
|
||||
@ -26,12 +22,16 @@ export default {
|
||||
name: 'PewPew!',
|
||||
icon: '💥',
|
||||
},
|
||||
lastScrap: null,
|
||||
pending_action: false,
|
||||
}),
|
||||
sockets: {
|
||||
self(self){
|
||||
self = JSON.parse(self)
|
||||
this.pending_action = self.pending_action
|
||||
},
|
||||
scrap(card) {
|
||||
this.lastScrap = card
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
|
Loading…
Reference in New Issue
Block a user