add express car, lumber, mail

This commit is contained in:
Alberto Xamin 2024-06-10 17:02:47 +01:00
parent beff8151c2
commit 399645de27
No known key found for this signature in database
GPG Key ID: 5ABFCD8A22EA6F5D
5 changed files with 67 additions and 8 deletions

View File

@ -11,6 +11,7 @@ from globals import G
if TYPE_CHECKING: if TYPE_CHECKING:
from bang.game import Game from bang.game import Game
from bang.players import Player
class Deck: class Deck:
@ -195,7 +196,7 @@ class Deck:
else: else:
return self.draw() return self.draw()
def scrap(self, card: cs.Card, ignore_event=False, player=None): def scrap(self, card: cs.Card, ignore_event:bool=False, player:'Player'=None):
if card.number == 42: if card.number == 42:
return return
card.reset_card() card.reset_card()

View File

@ -1,6 +1,7 @@
import random import random
from bang.cards import Card, Bang, Panico, CatBalou, Mancato from bang.cards import Card, Bang, Panico, CatBalou, Mancato
from bang.players import Player, PendingAction from bang.players import Player, PendingAction
from globals import G
class TrainCard(Card): class TrainCard(Card):
def __init__(self, name: str, is_locomotive: bool = False): def __init__(self, name: str, is_locomotive: bool = False):
@ -82,7 +83,7 @@ class Ironhorse(TrainCard):
class Leland(TrainCard): class Leland(TrainCard):
""" """
LOCOMOTIVA: svolgi leffetto dellEmporio, cominciando dal giocatore di turno e procedendo in senso orario. LOCOMOTIVA: svolgi l'effetto dell'Emporio, cominciando dal giocatore di turno e procedendo in senso orario.
""" """
def __init__(self): def __init__(self):
@ -178,6 +179,10 @@ class ExpressCar(TrainCard):
self.icon = "🚋⚡" self.icon = "🚋⚡"
def play_card(self, player, against=None, _with=None) -> bool: def play_card(self, player, against=None, _with=None) -> bool:
while len(player.hand) > 0:
player.game.deck.scrap(player.hand.pop(0), player=player)
player.notify_self()
player.play_turn()
return True return True
@ -209,9 +214,10 @@ class LumberFlatcar(TrainCard):
def __init__(self): def __init__(self):
super().__init__("Lumber Flatcar") super().__init__("Lumber Flatcar")
self.icon = "🚋🪵" self.icon = "🚋🪵"
self.sight_mod = -1
def play_card(self, player, against=None, _with=None) -> bool: def play_card(self, player, against=None, _with=None) -> bool:
return True return False
class MailCar(TrainCard): class MailCar(TrainCard):
@ -221,7 +227,34 @@ class MailCar(TrainCard):
super().__init__("Mail Car") super().__init__("Mail Car")
self.icon = "🚋📮" self.icon = "🚋📮"
def choose_card_callback(self, player: Player, card_index):
chosen_card = player.available_cards.pop(card_index)
player.hand.extend(player.available_cards)
player.set_choose_action(
"choose_other_player",
player.game.get_other_players(player),
lambda p, other_player_index: self.choose_player_callback(p, other_player_index, chosen_card)
)
def choose_player_callback(self, player: Player, other_player_index, chosen_card):
pl_name = player.game.get_other_players(player)[other_player_index]["name"]
other_player = player.game.get_player_named(pl_name)
other_player.hand.append(chosen_card)
G.sio.emit(
"card_drawn",
room=player.game.name,
data={"player": pl_name, "pile": player.name},
)
other_player.notify_self()
player.pending_action = PendingAction.PLAY
def play_card(self, player, against=None, _with=None) -> bool: def play_card(self, player, against=None, _with=None) -> bool:
drawn_cards = [player.game.deck.draw(player=player) for _ in range(3)]
player.set_choose_action(
"choose_mail_car",
drawn_cards,
self.choose_card_callback,
)
return True return True
@ -257,7 +290,7 @@ class PrisonerCar(TrainCard):
self.icon = "🚋👮🏻‍♂️" self.icon = "🚋👮🏻‍♂️"
def play_card(self, player, against=None, _with=None) -> bool: def play_card(self, player, against=None, _with=None) -> bool:
return True return False
class PrivateCar(TrainCard): class PrivateCar(TrainCard):
@ -268,7 +301,7 @@ class PrivateCar(TrainCard):
self.icon = "🚋💁🏻" self.icon = "🚋💁🏻"
def play_card(self, player, against=None, _with=None) -> bool: def play_card(self, player, against=None, _with=None) -> bool:
return True return False
class SleeperCar(TrainCard): class SleeperCar(TrainCard):

View File

@ -57,6 +57,7 @@ debug_commands = [
"help": "Remove a card from hand/equip - sample /removecard 0", "help": "Remove a card from hand/equip - sample /removecard 0",
}, },
{"cmd": "/getcard", "help": "Get a brand new card - sample /getcard Birra"}, {"cmd": "/getcard", "help": "Get a brand new card - sample /getcard Birra"},
{"cmd": "/equipcard", "help": "Equip a brand new card - sample /getcard Barile"},
{"cmd": "/meinfo", "help": "Get player data"}, {"cmd": "/meinfo", "help": "Get player data"},
{"cmd": "/gameinfo", "help": "Get game data"}, {"cmd": "/gameinfo", "help": "Get game data"},
{"cmd": "/deckinfo", "help": "Get deck data"}, {"cmd": "/deckinfo", "help": "Get deck data"},
@ -1240,6 +1241,29 @@ class Game:
def get_alive_players(self): def get_alive_players(self):
return [p for p in self.players if not p.is_dead or p.is_ghost] return [p for p in self.players if not p.is_dead or p.is_ghost]
def get_other_players(self, player:pl.Player):
return [{
"name": p.name,
"dist": 0,
"lives": p.lives,
"max_lives": p.max_lives,
"is_sheriff": isinstance(p.role, roles.Sheriff),
"cards": len(p.hand) + len(p.equipment),
"is_ghost": p.is_ghost,
"is_bot": p.is_bot,
"icon": p.role.icon
if (
p.role is not None
and (
self.initial_players == 3
or isinstance(p.role, roles.Sheriff)
)
)
else "🤠",
"avatar": p.avatar,
"role": p.role,
} for p in self.get_alive_players() if p != player]
def get_dead_players(self, include_ghosts=True): def get_dead_players(self, include_ghosts=True):
return [ return [
p for p in self.players if p.is_dead and (include_ghosts or not p.is_ghost) p for p in self.players if p.is_dead and (include_ghosts or not p.is_ghost)

View File

@ -1038,7 +1038,9 @@ def chat_message(sid, msg, pl=None):
cmd = msg.split() cmd = msg.split()
if len(cmd) >= 2: if len(cmd) >= 2:
import bang.expansions.train_robbery.trains as trt
cards = cs.get_starting_deck(ses.game.expansions) cards = cs.get_starting_deck(ses.game.expansions)
cards.extend(trt.get_all_cards())
card_names = " ".join(cmd[1:]).split(",") card_names = " ".join(cmd[1:]).split(",")
for cn in card_names: for cn in card_names:
ses.equipment.append( ses.equipment.append(

View File

@ -28,14 +28,13 @@ export const expansionsMap = {
icon: '👻', icon: '👻',
back: true, back: true,
expansion: 'the-valley-of-shadows', expansion: 'the-valley-of-shadows',
status: 'beta',
}, },
'wild_west_show': { 'wild_west_show': {
name: 'Wild West Show', name: 'Wild West Show',
icon: '🎪', icon: '🎪',
back: true, back: true,
expansion: 'wild-west-show', expansion: 'wild-west-show',
status: 'alpha', status: 'beta',
}, },
'train_robbery': { 'train_robbery': {
name: 'The Great Train Robbery', name: 'The Great Train Robbery',