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:
from bang.game import Game
from bang.players import Player
class Deck:
@ -195,7 +196,7 @@ class Deck:
else:
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:
return
card.reset_card()

View File

@ -1,6 +1,7 @@
import random
from bang.cards import Card, Bang, Panico, CatBalou, Mancato
from bang.players import Player, PendingAction
from globals import G
class TrainCard(Card):
def __init__(self, name: str, is_locomotive: bool = False):
@ -82,7 +83,7 @@ class Ironhorse(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):
@ -96,7 +97,7 @@ class Leland(TrainCard):
class BaggageCar(TrainCard):
"""Scartalo: ottieni l'effetto di un Mancato!, Panico!, Cat Balou o di un BANG! extra.
Discard this for a Missed!Panic!, Cat Balou, or an extra BANG!"""
Discard this for a Missed! Panic!, Cat Balou, or an extra BANG!"""
def __init__(self):
super().__init__("Baggage Car")
@ -178,6 +179,10 @@ class ExpressCar(TrainCard):
self.icon = "🚋⚡"
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
@ -209,9 +214,10 @@ class LumberFlatcar(TrainCard):
def __init__(self):
super().__init__("Lumber Flatcar")
self.icon = "🚋🪵"
self.sight_mod = -1
def play_card(self, player, against=None, _with=None) -> bool:
return True
return False
class MailCar(TrainCard):
@ -221,7 +227,34 @@ class MailCar(TrainCard):
super().__init__("Mail Car")
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:
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
@ -257,7 +290,7 @@ class PrisonerCar(TrainCard):
self.icon = "🚋👮🏻‍♂️"
def play_card(self, player, against=None, _with=None) -> bool:
return True
return False
class PrivateCar(TrainCard):
@ -268,7 +301,7 @@ class PrivateCar(TrainCard):
self.icon = "🚋💁🏻"
def play_card(self, player, against=None, _with=None) -> bool:
return True
return False
class SleeperCar(TrainCard):

View File

@ -57,6 +57,7 @@ debug_commands = [
"help": "Remove a card from hand/equip - sample /removecard 0",
},
{"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": "/gameinfo", "help": "Get game data"},
{"cmd": "/deckinfo", "help": "Get deck data"},
@ -1240,6 +1241,29 @@ class Game:
def get_alive_players(self):
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):
return [
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()
if len(cmd) >= 2:
import bang.expansions.train_robbery.trains as trt
cards = cs.get_starting_deck(ses.game.expansions)
cards.extend(trt.get_all_cards())
card_names = " ".join(cmd[1:]).split(",")
for cn in card_names:
ses.equipment.append(

View File

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