show attacker name

This commit is contained in:
Alberto Xamin 2020-11-23 13:20:45 +01:00
parent 0856e2dd27
commit 91ffae84cf
No known key found for this signature in database
GPG Key ID: 4F026F48309500A2
2 changed files with 8 additions and 4 deletions

View File

@ -88,6 +88,8 @@ class Player:
ser.pop('on_failed_response_cb') ser.pop('on_failed_response_cb')
# ser.pop('expected_response') # ser.pop('expected_response')
ser.pop('attacker') ser.pop('attacker')
if self.attacker:
ser['attacker'] = self.attacker.name
ser['sight'] = self.get_sight() ser['sight'] = self.get_sight()
self.sio.emit('self', room=self.sid, data=json.dumps(ser, default=lambda o: o.__dict__)) self.sio.emit('self', room=self.sid, data=json.dumps(ser, default=lambda o: o.__dict__))
self.sio.emit('self_vis', room=self.sid, data=json.dumps(self.game.get_visible_players(self), default=lambda o: o.__dict__)) self.sio.emit('self_vis', room=self.sid, data=json.dumps(self.game.get_visible_players(self), default=lambda o: o.__dict__))
@ -300,11 +302,11 @@ class Player:
self.sio.emit('chat_message', room=self.game.name, data=f'{self.name} ha estratto {picked}.') self.sio.emit('chat_message', room=self.game.name, data=f'{self.name} ha estratto {picked}.')
if picked.suit == cards.Suit.HEARTS: if picked.suit == cards.Suit.HEARTS:
self.notify_self() self.notify_self()
self.game.responders_did_respond() self.game.responders_did_respond_resume_turn()
return return
if len([c for c in self.hand if isinstance(c, cards.Mancato) or (isinstance(self.character, characters.CalamityJanet) and isinstance(c, cards.Bang))]) == 0: if len([c for c in self.hand if isinstance(c, cards.Mancato) or (isinstance(self.character, characters.CalamityJanet) and isinstance(c, cards.Bang))]) == 0:
self.take_damage_response() self.take_damage_response()
self.game.responders_did_respond() self.game.responders_did_respond_resume_turn()
else: else:
self.pending_action = PendingAction.RESPOND self.pending_action = PendingAction.RESPOND
self.expected_response = [cards.Mancato(0,0).name] self.expected_response = [cards.Mancato(0,0).name]

View File

@ -23,13 +23,13 @@
</div> </div>
<p>{{hint}}</p> <p>{{hint}}</p>
<Chooser v-if="card_against" text="Contro chi vuoi giocare la carta" :cards="visiblePlayers" :select="selectAgainst" :cancel="cancelCardAgainst"/> <Chooser v-if="card_against" text="Contro chi vuoi giocare la carta" :cards="visiblePlayers" :select="selectAgainst" :cancel="cancelCardAgainst"/>
<Chooser v-if="pending_action == 3" text="Scegli come rispondere" :cards="respondCards" :select="respond"/> <Chooser v-if="pending_action == 3" :text="`Scegli come rispondere ${attacker?('a '+attacker):''}`" :cards="respondCards" :select="respond"/>
<Chooser v-if="shouldChooseCard" text="Scegli che carta pescare" :cards="available_cards" :select="choose"/> <Chooser v-if="shouldChooseCard" text="Scegli che carta pescare" :cards="available_cards" :select="choose"/>
<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="!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" :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>
</template> </template>
@ -67,6 +67,7 @@ export default {
sight: 1, sight: 1,
can_target_sheriff: true, can_target_sheriff: true,
show_role: false, show_role: false,
attacker: undefined,
}), }),
sockets: { sockets: {
role(role) { role(role) {
@ -89,6 +90,7 @@ export default {
this.available_cards = self.available_cards this.available_cards = self.available_cards
this.win_status = self.win_status this.win_status = self.win_status
this.sight = self.sight this.sight = self.sight
this.attacker = self.attacker
if (this.pending_action == 5 && self.target_p) { if (this.pending_action == 5 && self.target_p) {
this.chooseCardFromPlayer(self.target_p) this.chooseCardFromPlayer(self.target_p)
} else if (this.pending_action == 5) { } else if (this.pending_action == 5) {