diff --git a/backend/bang/expansions/dodge_city/cards.py b/backend/bang/expansions/dodge_city/cards.py
index f5d61d5..eef122b 100644
--- a/backend/bang/expansions/dodge_city/cards.py
+++ b/backend/bang/expansions/dodge_city/cards.py
@@ -178,6 +178,21 @@ class Sombrero(Cappello):
self.name = 'Sombrero'
self.icon = '👒'
+class Pugnale(Pugno):
+ def __init__(self, suit, number):
+ super().__init__(suit, number)
+ self.name = 'Pugnale'
+ self.icon = '🗡'
+ self.usable_next_turn = True
+ self.can_be_used_now = False
+
+ def play_card(self, player, against, _with=None):
+ if self.can_be_used_now:
+ return super().play_card(player, against=against)
+ else:
+ player.equipment.append(self)
+ return True
+
def get_starting_deck() -> List[Card]:
return [
#TODO: aggiungere anche le carte normalmente presenti https://bang.dvgiochi.com/cardslist.php?id=3
@@ -212,5 +227,5 @@ def get_starting_deck() -> List[Card]:
PlaccaDiFerro(Suit.DIAMONDS, 'A'),
PlaccaDiFerro(Suit.SPADES, 'Q'),
Sombrero(Suit.CLUBS, 7),
-
+ Pugnale(Suit.HEARTS, 8),
]
diff --git a/backend/bang/players.py b/backend/bang/players.py
index 2bb94ed..d0f2920 100644
--- a/backend/bang/players.py
+++ b/backend/bang/players.py
@@ -249,22 +249,27 @@ class Player:
return s
def play_card(self, hand_index: int, against=None, _with=None):
- if not (0 <= hand_index < len(self.hand)):
+ if not (0 <= hand_index < len(self.hand) + len(self.equipment)):
print('illegal')
return
- card: cs.Card = self.hand.pop(hand_index)
+ card: cs.Card = self.hand.pop(hand_index) if hand_index < len(self.hand) else self.equipment.pop(hand_index-len(self.hand))
withCard: cs.Card = None
if _with != None:
withCard = self.hand.pop(_with) if hand_index > _with else self.hand.pop(_with - 1)
print(self.name, 'is playing ', card, ' against:', against, ' with:', _with)
did_play_card = card.play_card(self, against, withCard)
- if not card.is_equipment:
+ if not card.is_equipment and not card.usable_next_turn:
if did_play_card:
self.game.deck.scrap(card)
else:
self.hand.insert(hand_index, card)
if withCard:
self.hand.insert(_with, withCard)
+ elif card.usable_next_turn and card.can_be_used_now:
+ if did_play_card:
+ self.game.deck.scrap(card)
+ else:
+ self.equipment.insert(hand_index-len(self.hand), card)
self.notify_self()
def choose(self, card_index):
diff --git a/frontend/src/components/Player.vue b/frontend/src/components/Player.vue
index c88bdda..0cf25b1 100644
--- a/frontend/src/components/Player.vue
+++ b/frontend/src/components/Player.vue
@@ -12,7 +12,9 @@
💀
-
+
@@ -22,7 +24,7 @@
{{$t('hand')}}
@@ -223,7 +225,9 @@ export default {
scrap(c) {
this.$socket.emit('scrap', this.hand.indexOf(c))
},
- play_card(card) {
+ play_card(card, from_equipment) {
+ if (from_equipment && (!card.usable_next_turn || !card.can_be_used_now)) return;
+ else if (card.usable_next_turn && !card.can_be_used_now) return this.really_play_card(card, null);
let calamity_special = (card.name === 'Mancato!' && this.character.name === 'Calamity Janet')
let cant_play_bang = (this.has_played_bang && this.equipment.filter(x => x.name == 'Volcanic').length == 0)
if (this.pending_action == 2) {
@@ -276,8 +280,13 @@ export default {
this.card_with = null
},
really_play_card(card, against) {
+ let res = this.hand.indexOf(card)
+ if (res === -1) {
+ res = this.equipment.indexOf(card)
+ if (res !== -1) res += this.hand.length
+ }
let card_data = {
- index: this.hand.indexOf(card),
+ index: res,
against: against,
with: this.hand.indexOf(this.card_with) > -1 ? this.hand.indexOf(this.card_with):null,
}