all black cards working
This commit is contained in:
parent
f65ffbd5d5
commit
7e644cd456
@ -3,6 +3,7 @@ import random
|
||||
import bang.cards as cs
|
||||
import bang.expansions.fistful_of_cards.card_events as ce
|
||||
import bang.expansions.high_noon.card_events as ceh
|
||||
import bang.expansions.gold_rush.shop_cards as grc
|
||||
|
||||
class Deck:
|
||||
def __init__(self, game):
|
||||
@ -21,7 +22,7 @@ class Deck:
|
||||
self.all_cards_str.append(c.name)
|
||||
self.game = game
|
||||
self.event_cards: List[ce.CardEvent] = []
|
||||
endgame_cards = []
|
||||
endgame_cards: List[ce.CardEvent] = []
|
||||
if 'fistful_of_cards' in game.expansions:
|
||||
self.event_cards.extend(ce.get_all_events())
|
||||
endgame_cards.append(ce.get_endgame_card())
|
||||
@ -35,12 +36,11 @@ class Deck:
|
||||
self.event_cards.insert(0, None) # 2 perchè iniziale, e primo flip dallo sceriffo
|
||||
self.event_cards.append(random.choice(endgame_cards))
|
||||
random.shuffle(self.cards)
|
||||
self.shop_deck = []
|
||||
self.shop_cards = []
|
||||
self.shop_deck: List[grc.ShopCard] = []
|
||||
self.shop_cards: List[grc.ShopCard] = []
|
||||
if 'gold_rush' in game.expansions:
|
||||
import bang.expansions.gold_rush.shop_cards as gr
|
||||
self.shop_cards = [None, None, None]
|
||||
self.shop_deck = gr.get_cards()
|
||||
self.shop_deck = grc.get_cards()
|
||||
random.shuffle(self.shop_deck)
|
||||
self.fill_gold_rush_shop()
|
||||
self.scrap_pile: List[cs.Card] = []
|
||||
@ -58,6 +58,7 @@ class Deck:
|
||||
if self.shop_cards[i] == None:
|
||||
print(f'replacing gr-card {i}')
|
||||
self.shop_cards[i] = self.shop_deck.pop(0)
|
||||
self.shop_cards[i].reset_card()
|
||||
self.game.notify_gold_rush_shop()
|
||||
|
||||
def peek(self, n_cards: int) -> list:
|
||||
|
@ -8,6 +8,8 @@ class ShopCard(Card):
|
||||
def __init__(self, name:str, cost:int, kind:ShopCardKind):
|
||||
super().__init__(suit='💵', number=cost, name=name)
|
||||
self.kind = kind
|
||||
self.expansion_icon = '🤑️'
|
||||
self.expansion = 'gold_rush'
|
||||
|
||||
def play_card(self, player, against, _with=None):
|
||||
if self.kind == ShopCardKind.BROWN:
|
||||
@ -19,6 +21,7 @@ class ShopCard(Card):
|
||||
self.reset_card()
|
||||
self.can_be_used_now = True
|
||||
player.gold_rush_equipment.append(self)
|
||||
player.sio.emit('chat_message', room=player.game.name, data=f'_purchase_card|{player.name}|{self.name}')
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
@ -134,8 +137,16 @@ class Ricercato(ShopCard):
|
||||
self.icon = '🤠️'
|
||||
|
||||
def play_card(self, player, against=None, _with=None):
|
||||
pass
|
||||
# TODO
|
||||
import bang.players as pl
|
||||
player.available_cards = [{
|
||||
'name': p.name,
|
||||
'icon': p.role.icon if(player.game.initial_players == 3) else '⭐️' if p['is_sheriff'] else '🤠',
|
||||
'alt_text': ''.join(['❤️']*p.lives)+''.join(['💀']*(p.max_lives-p.lives)),
|
||||
'noDesc': True
|
||||
} for p in player.game.get_alive_players() if p != player]
|
||||
player.choose_text = 'choose_ricercato'
|
||||
player.pending_action = pl.PendingAction.CHOOSE
|
||||
player.notify_self()
|
||||
# la giochi su un altro giocatore, ricompensa di 2 carte e 1 pepita a chi lo uccide
|
||||
|
||||
class Setaccio(ShopCard):
|
||||
@ -147,9 +158,11 @@ class Setaccio(ShopCard):
|
||||
if not self.can_be_used_now:
|
||||
super().play_card(player, against, _with)
|
||||
else:
|
||||
if player.gold_nuggets > 1:
|
||||
if player.gold_nuggets >= 1:
|
||||
player.sio.emit('chat_message', room=player.game.name, data=f'_play_card|{player.name}|{self.name}')
|
||||
player.gold_nuggets -= 1
|
||||
player.hand.append(player.game.deck.draw())
|
||||
player.notify_self()
|
||||
# paghi 1 pepita per pescare 1 carta durante il tuo turno (max 2 volte per turno)
|
||||
|
||||
class Stivali(ShopCard):
|
||||
@ -176,18 +189,19 @@ class Zaino(ShopCard):
|
||||
self.icon = '🎒️'
|
||||
|
||||
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:
|
||||
if player.gold_nuggets >= 2:
|
||||
player.sio.emit('chat_message', room=player.game.name, data=f'_play_card|{player.name}|{self.name}')
|
||||
player.gold_nuggets -= 2
|
||||
player.lives = min(player.lives + 1, player.max_lives)
|
||||
player.notify_self()
|
||||
# paga 2 pepite per recuperare 1 vita
|
||||
|
||||
def get_cards() -> List[Card]:
|
||||
cards = [
|
||||
# Bicchierino(),
|
||||
Bicchierino(),
|
||||
# Bottiglia(),
|
||||
# Complice(),
|
||||
CorsaAllOro(),
|
||||
@ -203,7 +217,4 @@ def get_cards() -> List[Card]:
|
||||
Talismano(),
|
||||
Zaino(),
|
||||
]
|
||||
for c in cards:
|
||||
c.expansion_icon = '🤑️'
|
||||
c.expansion = 'gold_rush'
|
||||
return cards
|
||||
|
@ -541,7 +541,11 @@ class Game:
|
||||
return self.announces_winners(winners)
|
||||
elif len(winners) > 0 and not self.someone_won: # non tutti hanno risposto, ma ci sono vincitori.
|
||||
self.pending_winners = winners
|
||||
|
||||
if len([c for c in player.equipment if isinstance(c, grc.Ricercato)]) > 0 and player.attacker:
|
||||
player.attacker.gold_nuggets += 1
|
||||
player.attacker.hand.append(self.deck.draw(True))
|
||||
player.attacker.hand.append(self.deck.draw(True))
|
||||
player.attacker.notify_self()
|
||||
vulture = [p for p in self.get_alive_players() if p.character.check(self, characters.VultureSam)]
|
||||
if len(vulture) == 0:
|
||||
for i in range(len(player.hand)):
|
||||
@ -620,6 +624,7 @@ class Game:
|
||||
'name': p.name,
|
||||
'ncards': len(p.hand),
|
||||
'equipment': [e.__dict__ for e in p.equipment],
|
||||
'gold_rush_equipment': [e.__dict__ for e in p.gold_rush_equipment],
|
||||
'lives': p.lives,
|
||||
'max_lives': p.max_lives,
|
||||
'gold_nuggets': p.gold_nuggets,
|
||||
|
@ -547,9 +547,13 @@ class Player:
|
||||
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)):
|
||||
if not (0 <= hand_index < len(self.hand) + len(self.equipment) + len(self.gold_rush_equipment)):
|
||||
print('but the card index is out of range')
|
||||
return
|
||||
elif len(self.hand) + len(self.equipment) <= hand_index < len(self.hand) + len(self.equipment) + len(self.gold_rush_equipment) and len(self.gold_rush_equipment):
|
||||
print('which is a gold rush black card')
|
||||
card: grc.ShopCard = self.gold_rush_equipment[hand_index - len(self.hand) + len(self.equipment)]
|
||||
return card.play_card(self)
|
||||
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:
|
||||
@ -610,6 +614,12 @@ class Player:
|
||||
while self.target_p == self.name or len(self.game.players[self.game.players_map[self.target_p]].hand) + len(self.game.players[self.game.players_map[self.target_p]].equipment) == 0:
|
||||
self.target_p = self.game.players[(self.game.players_map[self.target_p]+1)%len(self.game.players)].name
|
||||
self.notify_self()
|
||||
elif self.choose_text == 'choose_ricercato':
|
||||
player = self.game.get_player_named(self.available_cards[card_index]['name'])
|
||||
player.gold_rush_equipment.append(grc.Ricercato())
|
||||
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
|
||||
|
@ -57,7 +57,10 @@
|
||||
<div class="tiny-equipment">
|
||||
<Card v-for="(card, i) in p.equipment" v-bind:key="card.name+card.number"
|
||||
:card="card" @click.native="selectedInfo = p.equipment"
|
||||
:style="`margin-top: ${i<1?10:-(Math.min((p.equipment.length+1)*12,80))}pt`"/>
|
||||
:style="`margin-top: ${i<1?10:-(Math.min((p.equipment.length+p.gold_rush_equipment+1)*12,80))}pt`"/>
|
||||
<Card v-for="(card, i) in p.gold_rush_equipment" v-bind:key="card.name+card.number"
|
||||
:card="card" @click.native="selectedInfo = p.gold_rush_equipment"
|
||||
:style="`margin-top: ${i+p.equipment.length<1?10:-(Math.min((p.equipment.length+p.gold_rush_equipment.length+1)*12,80))}pt`"/>
|
||||
</div>
|
||||
<div v-if="p.is_bot" style="position:absolute;bottom:57%;" class="center-stuff">
|
||||
<span>🤖</span>
|
||||
|
@ -393,7 +393,7 @@ export default {
|
||||
really_play_card(card, against) {
|
||||
let res = this.handComputed.indexOf(card)
|
||||
if (res === -1) {
|
||||
res = this.equipment.indexOf(card)
|
||||
res = this.equipmentComputed.indexOf(card)
|
||||
if (res !== -1) res += this.hand.length
|
||||
}
|
||||
let card_data = {
|
||||
|
Loading…
Reference in New Issue
Block a user