discard others cards

This commit is contained in:
Alberto Xamin 2021-06-20 17:44:29 +02:00
parent 09298f8d10
commit 9b057bb468
No known key found for this signature in database
GPG Key ID: 4F026F48309500A2
6 changed files with 45 additions and 1 deletions

View File

@ -460,6 +460,11 @@ def special(sid, data):
ses: Player = sio.get_session(sid)
ses.special(data)
@sio.event
def gold_rush_discard(sid):
ses: Player = sio.get_session(sid)
ses.gold_rush_discard()
@sio.event
def buy_gold_rush_card(sid, data:int):
ses: Player = sio.get_session(sid)

View File

@ -659,6 +659,26 @@ class Player:
self.hand.append(self.available_cards[card_index])
self.pending_action = PendingAction.PLAY
self.notify_self()
elif self.choose_text == 'gold_rush_discard':
if card_index == len(self.available_cards) - 1:
self.pending_action = PendingAction.PLAY
else:
player = self.game.get_player_named(self.available_cards[card_index]['name'])
self.available_cards = [c for c in player.gold_rush_equipment if c.number+1 <= self.gold_nuggets]
self.available_cards.append({'icon': '', 'noDesc': True})
self.choose_text = 'gold_rush_discard_2|' + player.name
self.notify_self()
elif 'gold_rush_discard_2' in self.choose_text:
if card_index == len(self.available_cards) - 1:
self.pending_action = PendingAction.PLAY
else:
self.gold_nuggets -= self.available_cards[card_index].number + 1
player = self.game.get_player_named(self.choose_text.split('|')[1])
player.gold_rush_equipment.remove(self.available_cards[card_index])
self.game.deck.shop_deck.append(self.available_cards[card_index])
player.notify_self()
self.pending_action = PendingAction.PLAY
self.notify_self()
elif self.game.check_event(ceh.NuovaIdentita) and self.choose_text == 'choose_nuova_identita':
if card_index == 1: # the other character
self.character = self.not_chosen_character
@ -1077,6 +1097,18 @@ class Player:
def special(self, data):
self.character.special(self, data)
def gold_rush_discard(self):
self.available_cards = [{
'name': p.name,
'icon': p.role.icon if(self.game.initial_players == 3) else '⭐️' if p['is_sheriff'] else '🤠',
'alt_text': ''.join(['🎴️'] * len(p.gold_rush_equipment)),
'noDesc': True
} for p in self.game.get_alive_players() if p != self and len(p.gold_rush_equipment) > 0]
self.available_cards.append({'icon': '', 'noDesc': True})
self.choose_text = 'gold_rush_discard'
self.pending_action = PendingAction.CHOOSE
self.notify_self()
def buy_gold_rush_card(self, index):
print(f'{self.name} wants to buy gr-card index {index} in room {self.game.name}')
card: cs.Card = self.game.deck.shop_cards[index]

View File

@ -35,6 +35,9 @@
<transition name="list">
<p v-if="goldRushDesc" class="center-stuff">🤑 <i>{{goldRushDesc}}</i> 🤑</p>
</transition>
<div style="margin-bottom:6pt;margin-bottom: 6pt;display: flex;flex-direction: column;">
<button class="btn" v-if="pending_action == 2 && gold_nuggets > 2" @click="$socket.emit('gold_rush_discard')">{{$t('gold_rush_discard')}}</button>
</div>
<transition name="list">
<p v-if="desc" class="center-stuff"><i>{{desc}}</i></p>
</transition>

View File

@ -155,7 +155,7 @@ export default {
this.max_lives = self.max_lives
this.has_played_bang = self.has_played_bang
this.special_use_count = self.special_use_count
this.choose_text = self.choose_text
this.choose_text = self.choose_text.split('|')[0]
this.is_my_turn = self.is_my_turn
this.committed_suit_manette = self.committed_suit_manette
if (this.is_my_turn) document.title = this.$t('your_turn')+' | PewPew!'

View File

@ -58,6 +58,8 @@
"you_win": "YOU WON",
"you_lose": "YOU LOST",
"special_ability": "SPECIAL ABILITY",
"gold_rush_discard": "Discard another player's gold rush equipment (paying the price + 1)",
"gold_rush_discard_2": "Discard another player's gold rush equipment (paying the price + 1)",
"discard": "DISCARD",
"to_regain_1_hp": "TO REGAIN 1 HP",
"play_your_turn": "PLAY YOUR TURN",

View File

@ -58,6 +58,8 @@
"you_win": "HAI VINTO",
"you_lose": "HAI PERSO",
"special_ability": "ABILITÀ SPECIALE",
"gold_rush_discard": "Fai scartare equipaggiamento gold rush (pagando pepite + 1)",
"gold_rush_discard_2": "Fai scartare equipaggiamento gold rush (pagando pepite + 1)",
"discard": "SCARTA",
"to_regain_1_hp": "PER RECUPERARE 1 VITA",
"play_your_turn": "GIOCA IL TUO TURNO",