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