working on usable black cards

This commit is contained in:
Alberto 2021-06-16 16:47:06 +02:00
parent b5ded346fb
commit a4a5c61eba
No known key found for this signature in database
GPG Key ID: 4F026F48309500A2
4 changed files with 31 additions and 7 deletions

View File

@ -42,7 +42,10 @@ class Card(ABC):
self.must_be_used = False
def __str__(self):
if str(self.suit).isnumeric():
char = ['♦️', '♣️', '♥️', '♠️'][int(self.suit)]
else:
char = self.suit
return f'{self.name} {char}{self.number}'
return super().__str__()

View File

@ -17,11 +17,16 @@ class ShopCard(Card):
self.reset_card()
if not self.is_duplicate_card(player):
self.reset_card()
self.can_be_used_now = True
player.equipment.append(self)
return True
else:
return False
def reset_card(self):
if self.kind == ShopCardKind.BLACK:
self.can_be_used_now = False
class Bicchierino(ShopCard):
def __init__(self):
super().__init__('Bicchierino', 1, ShopCardKind.BROWN)
@ -130,6 +135,7 @@ class Ricercato(ShopCard):
def play_card(self, player, against=None, _with=None):
pass
# TODO
# la giochi su un altro giocatore, ricompensa di 2 carte e 1 pepita a chi lo uccide
class Setaccio(ShopCard):
@ -138,7 +144,12 @@ class Setaccio(ShopCard):
self.icon = '🥘️'
def play_card(self, player, against=None, _with=None):
if not self.can_be_used_now:
super().play_card(player, against, _with)
else:
if player.gold_nuggets > 1:
player.gold_nuggets -= 1
player.hand.append(player.game.deck.draw())
# paghi 1 pepita per pescare 1 carta durante il tuo turno (max 2 volte per turno)
class Stivali(ShopCard):
@ -166,6 +177,12 @@ class Zaino(ShopCard):
def play_card(self, player, against=None, _with=None):
super().play_card(player, against, _with)
if not self.can_be_used_now:
super().play_card(player, against, _with)
else:
if player.gold_nuggets > 2:
player.gold_nuggets -= 2
player.lives = min(player.lives + 1, player.max_lives)
# paga 2 pepite per recuperare 1 vita
def get_cards() -> List[Card]:

View File

@ -541,9 +541,12 @@ class Player:
return playable_cards
def play_card(self, hand_index: int, against=None, _with=None):
print(self.name, 'wants to play card ', hand_index, ' against:', against, ' with:', _with)
if not self.is_my_turn or self.pending_action != PendingAction.PLAY or self.game.is_handling_death:
print('but cannot')
return
if not (0 <= hand_index < len(self.hand) + len(self.equipment)):
print('but the card index is out of range')
return
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
@ -552,19 +555,19 @@ class Player:
print(self.name, 'is playing ', card, ' against:', against, ' with:', _with)
did_play_card = False
event_blocks_card = (self.game.check_event(ce.IlGiudice) and (card.is_equipment or (card.usable_next_turn and not card.can_be_used_now))) or (self.game.check_event(ce.Lazo) and card.usable_next_turn and card.can_be_used_now) or (self.game.check_event(ceh.Manette) and card.suit != self.committed_suit_manette and not (card.usable_next_turn and card.can_be_used_now))
if not(against != None and (isinstance(self.game.get_player_named(against).character, chd.ApacheKid) or len([c for c in self.game.get_player_named(against).equipment if isinstance(c, grc.Calumet)]) > 0) and card.check_suit(self.game, [cs.Suit.DIAMONDS])) and not event_blocks_card:
if not(against != None and (isinstance(self.game.get_player_named(against).character, chd.ApacheKid) or len([c for c in self.game.get_player_named(against).equipment if isinstance(c, grc.Calumet)]) > 0) and card.check_suit(self.game, [cs.Suit.DIAMONDS])) or (isinstance(card, grc.ShopCard) and card.kind == grc.ShopCardKind.BLACK) and not event_blocks_card:
if against == self.name and not isinstance(card, csd.Tequila):
did_play_card = False
else:
did_play_card = card.play_card(self, against, withCard)
if not card.is_equipment and not card.usable_next_turn or event_blocks_card:
if not card.is_equipment and not card.usable_next_turn and not (isinstance(card, grc.ShopCard) and card.kind == grc.ShopCardKind.BLACK) or event_blocks_card:
if did_play_card:
self.game.deck.scrap(card, True)
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:
elif (card.usable_next_turn and card.can_be_used_now) or (isinstance(card, grc.ShopCard) and card.kind == grc.ShopCardKind.BLACK):
if did_play_card:
self.game.deck.scrap(card, True)
else:

View File

@ -29,7 +29,7 @@
<div v-if="lives > 0 || is_ghost" style="position:relative">
<span id="hand_text">{{$t('hand')}}</span>
<transition-group name="list" tag="div" :class="{hand:true, 'play-cards':pending_action===2}">
<Card v-for="card in handComputed" v-bind:key="card.name+card.number" :card="card"
<Card v-for="card in handComputed" v-bind:key="card.name+card.number+card.suit" :card="card"
@click.native="play_card(card, false)"
@pointerenter.native="setHint(card)" @pointerleave.native="hint=''"
:class="{'cant-play':card.cantBePlayed}"/>
@ -328,7 +328,8 @@ export default {
this.$socket.emit('scrap', this.hand.indexOf(c))
},
play_card(card, from_equipment) {
if (from_equipment && (!card.usable_next_turn || !card.can_be_used_now || (this.eventCard && this.eventCard.name == "Lazo"))) return;
console.log('play' + card.name)
if (from_equipment && (!card.can_be_used_now || (this.eventCard && this.eventCard.name == "Lazo"))) 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)