user rng instead of random
This commit is contained in:
parent
06069462ae
commit
2ddf18b8c0
@ -1,3 +1,4 @@
|
|||||||
|
from typing import TYPE_CHECKING
|
||||||
from abc import ABC, abstractmethod
|
from abc import ABC, abstractmethod
|
||||||
import random
|
import random
|
||||||
import bang.players as players
|
import bang.players as players
|
||||||
@ -6,6 +7,9 @@ import bang.cards as cs
|
|||||||
|
|
||||||
from globals import G
|
from globals import G
|
||||||
|
|
||||||
|
if TYPE_CHECKING:
|
||||||
|
from bang.game import Game
|
||||||
|
|
||||||
|
|
||||||
class CardEvent(ABC):
|
class CardEvent(ABC):
|
||||||
"""Base class for all event cards"""
|
"""Base class for all event cards"""
|
||||||
@ -14,7 +18,7 @@ class CardEvent(ABC):
|
|||||||
self.name = name
|
self.name = name
|
||||||
self.icon = icon
|
self.icon = icon
|
||||||
|
|
||||||
def on_flipped(self, game):
|
def on_flipped(self, game: "Game"):
|
||||||
"""Default on flipped event
|
"""Default on flipped event
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
|
@ -7,6 +7,16 @@ from globals import G
|
|||||||
from bang.expansions.fistful_of_cards.card_events import CardEvent
|
from bang.expansions.fistful_of_cards.card_events import CardEvent
|
||||||
|
|
||||||
|
|
||||||
|
class WildWestShowCardEvent(CardEvent):
|
||||||
|
"""
|
||||||
|
Base class for all card events in the Wild West Show expansion
|
||||||
|
"""
|
||||||
|
|
||||||
|
def __init__(self, name, icon):
|
||||||
|
super().__init__(name, icon)
|
||||||
|
self.expansion = "wild-west-show"
|
||||||
|
|
||||||
|
|
||||||
# class Bavaglio(CardEvent):
|
# class Bavaglio(CardEvent):
|
||||||
# def __init__(self):
|
# def __init__(self):
|
||||||
# super().__init__("Bavaglio", "🤐")
|
# super().__init__("Bavaglio", "🤐")
|
||||||
@ -14,7 +24,7 @@ from bang.expansions.fistful_of_cards.card_events import CardEvent
|
|||||||
# # NOT IMPLEMENTED
|
# # NOT IMPLEMENTED
|
||||||
|
|
||||||
|
|
||||||
class Camposanto(CardEvent):
|
class Camposanto(WildWestShowCardEvent):
|
||||||
"""
|
"""
|
||||||
All'inizio del proprio turno, ogni giocatore eliminato torna in gioco con 1 punto vita. Pesca il ruolo a caso fra quelli dei giocatori eliminati.
|
All'inizio del proprio turno, ogni giocatore eliminato torna in gioco con 1 punto vita. Pesca il ruolo a caso fra quelli dei giocatori eliminati.
|
||||||
"""
|
"""
|
||||||
@ -23,7 +33,7 @@ class Camposanto(CardEvent):
|
|||||||
super().__init__("Camposanto", "⚰")
|
super().__init__("Camposanto", "⚰")
|
||||||
|
|
||||||
|
|
||||||
class DarlingValentine(CardEvent):
|
class DarlingValentine(WildWestShowCardEvent):
|
||||||
"""
|
"""
|
||||||
All'inizio del proprio turno, ogni giocatore scarta le carte in mano e ne pesca dal mazzo altrettante.
|
All'inizio del proprio turno, ogni giocatore scarta le carte in mano e ne pesca dal mazzo altrettante.
|
||||||
"""
|
"""
|
||||||
@ -32,7 +42,7 @@ class DarlingValentine(CardEvent):
|
|||||||
super().__init__("Darling Valentine", "💋")
|
super().__init__("Darling Valentine", "💋")
|
||||||
|
|
||||||
|
|
||||||
class DorothyRage(CardEvent):
|
class DorothyRage(WildWestShowCardEvent):
|
||||||
"""
|
"""
|
||||||
Nel proprio turno, ogni giocatore può obbligarne un altro a giocare una carta.
|
Nel proprio turno, ogni giocatore può obbligarne un altro a giocare una carta.
|
||||||
"""
|
"""
|
||||||
@ -41,7 +51,7 @@ class DorothyRage(CardEvent):
|
|||||||
super().__init__("Dorothy Rage", "👩⚖️")
|
super().__init__("Dorothy Rage", "👩⚖️")
|
||||||
|
|
||||||
|
|
||||||
class HelenaZontero(CardEvent):
|
class HelenaZontero(WildWestShowCardEvent):
|
||||||
"""
|
"""
|
||||||
Quando Helena entra in gioco, "estrai!": se esce Cuori o Quadri, rimescola i ruoli attivi tranne lo Sceriffo, e ridistribuiscili a caso.
|
Quando Helena entra in gioco, "estrai!": se esce Cuori o Quadri, rimescola i ruoli attivi tranne lo Sceriffo, e ridistribuiscili a caso.
|
||||||
"""
|
"""
|
||||||
@ -64,14 +74,14 @@ class HelenaZontero(CardEvent):
|
|||||||
)
|
)
|
||||||
pls = [p for p in game.players if not isinstance(p.role, roles.Sheriff)]
|
pls = [p for p in game.players if not isinstance(p.role, roles.Sheriff)]
|
||||||
newroles = [p.role for p in pls]
|
newroles = [p.role for p in pls]
|
||||||
random.shuffle(newroles)
|
game.rng.shuffle(newroles)
|
||||||
for p in pls:
|
for p in pls:
|
||||||
p.set_role(newroles.pop(random.randint(0, len(newroles) - 1)))
|
p.set_role(newroles.pop(game.rng.randint(0, len(newroles) - 1)))
|
||||||
|
|
||||||
return super().on_flipped(game)
|
return super().on_flipped(game)
|
||||||
|
|
||||||
|
|
||||||
class LadyRosaDelTexas(CardEvent):
|
class LadyRosaDelTexas(WildWestShowCardEvent):
|
||||||
"""
|
"""
|
||||||
Nel proprio turno, ogni giocatore può scambiarsi di posto con quello alla sua destra, il quale salta il prossimo turno.
|
Nel proprio turno, ogni giocatore può scambiarsi di posto con quello alla sua destra, il quale salta il prossimo turno.
|
||||||
"""
|
"""
|
||||||
@ -89,7 +99,7 @@ class LadyRosaDelTexas(CardEvent):
|
|||||||
game.notify_all()
|
game.notify_all()
|
||||||
|
|
||||||
|
|
||||||
class MissSusanna(CardEvent):
|
class MissSusanna(WildWestShowCardEvent):
|
||||||
"""
|
"""
|
||||||
Nel proprio turno ogni giocatore deve giocare almeno 3 carte. Se non lo fa, perde 1 punto vita.
|
Nel proprio turno ogni giocatore deve giocare almeno 3 carte. Se non lo fa, perde 1 punto vita.
|
||||||
"""
|
"""
|
||||||
@ -98,7 +108,7 @@ class MissSusanna(CardEvent):
|
|||||||
super().__init__("Miss Susanna", "👩🎤")
|
super().__init__("Miss Susanna", "👩🎤")
|
||||||
|
|
||||||
|
|
||||||
class RegolamentoDiConti(CardEvent):
|
class RegolamentoDiConti(WildWestShowCardEvent):
|
||||||
"""
|
"""
|
||||||
Tutte le carte possono essere giocate come se fossero BANG!. Le carte BANG! come se fossero Mancato!
|
Tutte le carte possono essere giocate come se fossero BANG!. Le carte BANG! come se fossero Mancato!
|
||||||
"""
|
"""
|
||||||
@ -124,7 +134,7 @@ class RegolamentoDiConti(CardEvent):
|
|||||||
player.notify_self()
|
player.notify_self()
|
||||||
|
|
||||||
|
|
||||||
class Sacagaway(CardEvent):
|
class Sacagaway(WildWestShowCardEvent):
|
||||||
"""
|
"""
|
||||||
Tutti i giocatori giocano a carte scoperte (tranne il ruolo!).
|
Tutti i giocatori giocano a carte scoperte (tranne il ruolo!).
|
||||||
"""
|
"""
|
||||||
@ -133,7 +143,7 @@ class Sacagaway(CardEvent):
|
|||||||
super().__init__("Sacagaway", "🌄")
|
super().__init__("Sacagaway", "🌄")
|
||||||
|
|
||||||
|
|
||||||
class WildWestShow(CardEvent):
|
class WildWestShow(WildWestShowCardEvent):
|
||||||
"""
|
"""
|
||||||
L'obiettivo di ogni giocatore diventa: "Rimani l'ultimo in gioco!"
|
L'obiettivo di ogni giocatore diventa: "Rimani l'ultimo in gioco!"
|
||||||
"""
|
"""
|
||||||
@ -148,12 +158,12 @@ class WildWestShow(CardEvent):
|
|||||||
|
|
||||||
|
|
||||||
def get_endgame_card():
|
def get_endgame_card():
|
||||||
end_game = WildWestShow()
|
"""Return the endgame card for this expansion"""
|
||||||
end_game.expansion = "wild-west-show"
|
return WildWestShow()
|
||||||
return end_game
|
|
||||||
|
|
||||||
|
|
||||||
def get_all_events(rng=random):
|
def get_all_events(rng=random):
|
||||||
|
"""Return all the events for this expansion shuffled, excluding the endgame card"""
|
||||||
cards = [
|
cards = [
|
||||||
Camposanto(),
|
Camposanto(),
|
||||||
DarlingValentine(),
|
DarlingValentine(),
|
||||||
@ -165,6 +175,4 @@ def get_all_events(rng=random):
|
|||||||
Sacagaway(),
|
Sacagaway(),
|
||||||
]
|
]
|
||||||
rng.shuffle(cards)
|
rng.shuffle(cards)
|
||||||
for c in cards:
|
|
||||||
c.expansion = "wild-west-show"
|
|
||||||
return cards
|
return cards
|
||||||
|
@ -804,7 +804,7 @@ class Game:
|
|||||||
elif self.check_event(cew.Camposanto):
|
elif self.check_event(cew.Camposanto):
|
||||||
pl.lives = 1
|
pl.lives = 1
|
||||||
pl.set_role = self.dead_roles.pop(
|
pl.set_role = self.dead_roles.pop(
|
||||||
random.randint(0, len(self.dead_roles) - 1)
|
self.rng.randint(0, len(self.dead_roles) - 1)
|
||||||
)
|
)
|
||||||
pl.is_dead = False
|
pl.is_dead = False
|
||||||
pl.is_ghost = False
|
pl.is_ghost = False
|
||||||
|
Loading…
Reference in New Issue
Block a user