pedro ramirez
This commit is contained in:
parent
0b7a05c3b6
commit
d4149f46bf
@ -77,9 +77,9 @@ def refresh(sid):
|
||||
ses.notify_self()
|
||||
|
||||
@sio.event
|
||||
def draw(sid):
|
||||
def draw(sid, pile):
|
||||
ses = sio.get_session(sid)
|
||||
ses.draw()
|
||||
ses.draw(pile)
|
||||
|
||||
@sio.event
|
||||
def pick(sid):
|
||||
|
@ -36,8 +36,9 @@ class Deck:
|
||||
|
||||
def draw_from_scrap_pile(self) -> Card:
|
||||
if len(self.scrap_pile) > 0:
|
||||
return self.scrap_pile.pop(0)
|
||||
card = self.scrap_pile.pop(0)
|
||||
self.game.notify_scrap_pile()
|
||||
return card
|
||||
else:
|
||||
return self.draw()
|
||||
|
||||
|
@ -62,8 +62,11 @@ class Game:
|
||||
available_roles = available_roles[:len(self.players)]
|
||||
random.shuffle(available_roles)
|
||||
for i in range(len(self.players)):
|
||||
self.sio.emit('chat_message', room=self.name, data=f'{self.players[i].name} ha come personaggio {self.players[i].character.name}')
|
||||
self.players[i].set_role(available_roles[i])
|
||||
if isinstance(available_roles[i], roles.Sheriff) or (len(available_roles) == 3 and isinstance(available_roles[i], roles.Vice)):
|
||||
if isinstance(available_roles[i], roles.Sheriff):
|
||||
self.sio.emit('chat_message', room=self.name, data=f'{self.players[i].name} È lo sceriffo')
|
||||
self.turn = i
|
||||
self.players[i].prepare()
|
||||
for k in range(self.players[i].max_lives):
|
||||
|
@ -120,19 +120,23 @@ class Player:
|
||||
self.pending_action = PendingAction.DRAW
|
||||
self.notify_self()
|
||||
|
||||
def draw(self):
|
||||
def draw(self, pile):
|
||||
if self.pending_action != PendingAction.DRAW:
|
||||
return
|
||||
self.pending_action = PendingAction.PLAY
|
||||
for i in range(2):
|
||||
card: cards.Card = self.game.deck.draw()
|
||||
self.hand.append(card)
|
||||
if i == 1 and isinstance(self.character, characters.BlackJack):
|
||||
for p in self.game.players:
|
||||
if p != self:
|
||||
p.notify_card(self, card)
|
||||
if card.suit == cards.Suit.HEARTS or card.suit == cards.Suit.DIAMONDS:
|
||||
self.game.deck.draw(self.hand.append(card))
|
||||
if pile == 'scrap' and isinstance(self.character, characters.PedroRamirez):
|
||||
self.hand.append(self.game.deck.draw_from_scrap_pile())
|
||||
self.hand.append(self.game.deck.draw())
|
||||
else:
|
||||
for i in range(2):
|
||||
card: cards.Card = self.game.deck.draw()
|
||||
self.hand.append(card)
|
||||
if i == 1 and isinstance(self.character, characters.BlackJack):
|
||||
for p in self.game.players:
|
||||
if p != self:
|
||||
p.notify_card(self, card)
|
||||
if card.suit == cards.Suit.HEARTS or card.suit == cards.Suit.DIAMONDS:
|
||||
self.hand.append(self.game.deck.draw())
|
||||
self.notify_self()
|
||||
|
||||
def pick(self):
|
||||
|
@ -8,7 +8,7 @@
|
||||
<div style="position:relative;">
|
||||
<card v-if="previousScrap" :card="previousScrap"/>
|
||||
<card v-else :card="card" class="back" style="opacity:0"/>
|
||||
<card v-if="lastScrap" :card="lastScrap" :key="lastScrap" class="last-scrap"/>
|
||||
<card v-if="lastScrap" :card="lastScrap" :key="lastScrap" class="last-scrap" @click.native="action('scrap')"/>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@ -40,13 +40,13 @@ export default {
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
action() {
|
||||
action(pile) {
|
||||
if (this.pending_action !== false && this.pending_action < 2) {
|
||||
console.log('action')
|
||||
if (this.pending_action == 0)
|
||||
this.$socket.emit('pick')
|
||||
else if (this.pending_action == 1)
|
||||
this.$socket.emit('draw')
|
||||
this.$socket.emit('draw', pile)
|
||||
}
|
||||
}
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user