pugnale
This commit is contained in:
parent
0a50379447
commit
c69e599554
@ -178,6 +178,21 @@ class Sombrero(Cappello):
|
|||||||
self.name = 'Sombrero'
|
self.name = 'Sombrero'
|
||||||
self.icon = '👒'
|
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]:
|
def get_starting_deck() -> List[Card]:
|
||||||
return [
|
return [
|
||||||
#TODO: aggiungere anche le carte normalmente presenti https://bang.dvgiochi.com/cardslist.php?id=3
|
#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.DIAMONDS, 'A'),
|
||||||
PlaccaDiFerro(Suit.SPADES, 'Q'),
|
PlaccaDiFerro(Suit.SPADES, 'Q'),
|
||||||
Sombrero(Suit.CLUBS, 7),
|
Sombrero(Suit.CLUBS, 7),
|
||||||
|
Pugnale(Suit.HEARTS, 8),
|
||||||
]
|
]
|
||||||
|
@ -249,22 +249,27 @@ class Player:
|
|||||||
return s
|
return s
|
||||||
|
|
||||||
def play_card(self, hand_index: int, against=None, _with=None):
|
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')
|
print('illegal')
|
||||||
return
|
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
|
withCard: cs.Card = None
|
||||||
if _with != None:
|
if _with != None:
|
||||||
withCard = self.hand.pop(_with) if hand_index > _with else self.hand.pop(_with - 1)
|
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)
|
print(self.name, 'is playing ', card, ' against:', against, ' with:', _with)
|
||||||
did_play_card = card.play_card(self, against, withCard)
|
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:
|
if did_play_card:
|
||||||
self.game.deck.scrap(card)
|
self.game.deck.scrap(card)
|
||||||
else:
|
else:
|
||||||
self.hand.insert(hand_index, card)
|
self.hand.insert(hand_index, card)
|
||||||
if withCard:
|
if withCard:
|
||||||
self.hand.insert(_with, 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()
|
self.notify_self()
|
||||||
|
|
||||||
def choose(self, card_index):
|
def choose(self, card_index):
|
||||||
|
@ -12,7 +12,9 @@
|
|||||||
<span v-for="(n, i) in (max_lives-lives)" v-bind:key="n" :alt="i">💀</span>
|
<span v-for="(n, i) in (max_lives-lives)" v-bind:key="n" :alt="i">💀</span>
|
||||||
</transition-group>
|
</transition-group>
|
||||||
<transition-group v-if="lives > 0" name="list" tag="div" style="margin: 0 0 0 10pt; display:flex;">
|
<transition-group v-if="lives > 0" name="list" tag="div" style="margin: 0 0 0 10pt; display:flex;">
|
||||||
<Card v-for="card in equipment" v-bind:key="card.name+card.number" :card="card" @pointerenter.native="desc=card.desc" @pointerleave.native="desc=''" />
|
<Card v-for="card in equipment" v-bind:key="card.name+card.number" :card="card"
|
||||||
|
@pointerenter.native="desc=card.desc" @pointerleave.native="desc=''"
|
||||||
|
@click.native="play_card(card, true)" />
|
||||||
</transition-group>
|
</transition-group>
|
||||||
</div>
|
</div>
|
||||||
<transition name="list">
|
<transition name="list">
|
||||||
@ -22,7 +24,7 @@
|
|||||||
<span>{{$t('hand')}}</span>
|
<span>{{$t('hand')}}</span>
|
||||||
<transition-group name="list" tag="div" class="hand">
|
<transition-group name="list" tag="div" class="hand">
|
||||||
<Card v-for="card in hand" v-bind:key="card.name+card.number" :card="card"
|
<Card v-for="card in hand" v-bind:key="card.name+card.number" :card="card"
|
||||||
@click.native="play_card(card)"
|
@click.native="play_card(card, false)"
|
||||||
@pointerenter.native="hint=card.desc" @pointerleave.native="hint=''"/>
|
@pointerenter.native="hint=card.desc" @pointerleave.native="hint=''"/>
|
||||||
</transition-group>
|
</transition-group>
|
||||||
</div>
|
</div>
|
||||||
@ -223,7 +225,9 @@ export default {
|
|||||||
scrap(c) {
|
scrap(c) {
|
||||||
this.$socket.emit('scrap', this.hand.indexOf(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 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)
|
let cant_play_bang = (this.has_played_bang && this.equipment.filter(x => x.name == 'Volcanic').length == 0)
|
||||||
if (this.pending_action == 2) {
|
if (this.pending_action == 2) {
|
||||||
@ -276,8 +280,13 @@ export default {
|
|||||||
this.card_with = null
|
this.card_with = null
|
||||||
},
|
},
|
||||||
really_play_card(card, against) {
|
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 = {
|
let card_data = {
|
||||||
index: this.hand.indexOf(card),
|
index: res,
|
||||||
against: against,
|
against: against,
|
||||||
with: this.hand.indexOf(this.card_with) > -1 ? this.hand.indexOf(this.card_with):null,
|
with: this.hand.indexOf(this.card_with) > -1 ? this.hand.indexOf(this.card_with):null,
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user