blackjack
This commit is contained in:
parent
e012013587
commit
0fe2af9574
@ -74,6 +74,14 @@ class Player:
|
|||||||
print(f'I {self.name} have to choose between {available}')
|
print(f'I {self.name} have to choose between {available}')
|
||||||
self.sio.emit('characters', room=self.sid, data=json.dumps(available, default=lambda o: o.__dict__))
|
self.sio.emit('characters', room=self.sid, data=json.dumps(available, default=lambda o: o.__dict__))
|
||||||
|
|
||||||
|
def notify_card(self, player, card):
|
||||||
|
mess = {
|
||||||
|
'player': player.name,
|
||||||
|
'card': card.__dict__
|
||||||
|
}
|
||||||
|
print('notifying card')
|
||||||
|
self.sio.emit('notify_card', room=self.sid, data=mess)
|
||||||
|
|
||||||
def notify_self(self):
|
def notify_self(self):
|
||||||
if self.lives <= 0 and self.max_lives > 0:
|
if self.lives <= 0 and self.max_lives > 0:
|
||||||
print('dying, attacker', self.attacker)
|
print('dying, attacker', self.attacker)
|
||||||
@ -115,9 +123,16 @@ class Player:
|
|||||||
def draw(self):
|
def draw(self):
|
||||||
if self.pending_action != PendingAction.DRAW:
|
if self.pending_action != PendingAction.DRAW:
|
||||||
return
|
return
|
||||||
for i in range(2):
|
|
||||||
self.hand.append(self.game.deck.draw())
|
|
||||||
self.pending_action = PendingAction.PLAY
|
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))
|
||||||
self.notify_self()
|
self.notify_self()
|
||||||
|
|
||||||
def pick(self):
|
def pick(self):
|
||||||
|
@ -28,6 +28,7 @@
|
|||||||
<Chooser v-if="lives <= 0 && max_lives > 0" text="SEI MORTO" />
|
<Chooser v-if="lives <= 0 && max_lives > 0" text="SEI MORTO" />
|
||||||
<Chooser v-if="win_status !== undefined" :text="win_status?'HAI VINTO':'HAI PERSO'" />
|
<Chooser v-if="win_status !== undefined" :text="win_status?'HAI VINTO':'HAI PERSO'" />
|
||||||
<Chooser v-if="show_role" text="Tu sei" :cards="[my_role]" :hintText="my_role.goal" :select="() => {show_role=false}" :cancel="() => {show_role=false}" cancelText="OK" />
|
<Chooser v-if="show_role" text="Tu sei" :cards="[my_role]" :hintText="my_role.goal" :select="() => {show_role=false}" :cancel="() => {show_role=false}" cancelText="OK" />
|
||||||
|
<Chooser v-if="notifycard" :text="`${notifycard.player} ha pescato come seconda carta:`" :cards="[notifycard.card]" hintText="Se la carta è cuori o quadri ne pesca un'altra" class="turn-notify-4s"/>
|
||||||
<Chooser v-if="!show_role && is_my_turn" text="GIOCA IL TUO TURNO" :key="is_my_turn" class="turn-notify" />
|
<Chooser v-if="!show_role && is_my_turn" text="GIOCA IL TUO TURNO" :key="is_my_turn" class="turn-notify" />
|
||||||
<Chooser v-if="hasToPickResponse" :text="`ESTRAI UNA CARTA ${attacker?('PER DIFENDERTI DA '+attacker):''}`" :key="hasToPickResponse" class="turn-notify" />
|
<Chooser v-if="hasToPickResponse" :text="`ESTRAI UNA CARTA ${attacker?('PER DIFENDERTI DA '+attacker):''}`" :key="hasToPickResponse" class="turn-notify" />
|
||||||
</div>
|
</div>
|
||||||
@ -68,6 +69,7 @@ export default {
|
|||||||
can_target_sheriff: true,
|
can_target_sheriff: true,
|
||||||
show_role: false,
|
show_role: false,
|
||||||
attacker: undefined,
|
attacker: undefined,
|
||||||
|
notifycard: null,
|
||||||
}),
|
}),
|
||||||
sockets: {
|
sockets: {
|
||||||
role(role) {
|
role(role) {
|
||||||
@ -102,6 +104,9 @@ export default {
|
|||||||
console.log(vis)
|
console.log(vis)
|
||||||
this.playersDistances = JSON.parse(vis)
|
this.playersDistances = JSON.parse(vis)
|
||||||
},
|
},
|
||||||
|
notify_card(mess) {
|
||||||
|
this.notifycard = mess
|
||||||
|
}
|
||||||
},
|
},
|
||||||
computed:{
|
computed:{
|
||||||
visiblePlayers() {
|
visiblePlayers() {
|
||||||
@ -233,6 +238,10 @@ export default {
|
|||||||
pointer-events: none;
|
pointer-events: none;
|
||||||
animation: disappear 2s ease-in forwards;
|
animation: disappear 2s ease-in forwards;
|
||||||
}
|
}
|
||||||
|
.turn-notify-4s {
|
||||||
|
pointer-events: none;
|
||||||
|
animation: disappear 4s ease-in forwards;
|
||||||
|
}
|
||||||
@keyframes disappear {
|
@keyframes disappear {
|
||||||
0% {
|
0% {
|
||||||
opacity: 1;
|
opacity: 1;
|
||||||
|
Loading…
Reference in New Issue
Block a user