Module mk2lib.events

Event dataclasses - purely informational objects for game flow tracking.

Classes

class AlreadyInGame (player: Player)
Expand source code
@dataclass(frozen=True)
class AlreadyInGame(ErrorEvent):
    """
    Emitted when player who's already in room tries to join again.
    """

    player: Player

Emitted when player who's already in room tries to join again.

Ancestors

Instance variables

var player : Player

The type of the None singleton.

class CanBuild (player: Player, build_options: list[Card])
Expand source code
@dataclass(frozen=True)
class CanBuild(Event):
    """
    Player can build something in build phase.
    """

    player: Player
    build_options: list[Card]

Player can build something in build phase.

Ancestors

Instance variables

var build_options : list[Card]

The type of the None singleton.

var player : Player

The type of the None singleton.

class CanExchangeEstablishments (player: Player)
Expand source code
@dataclass(frozen=True)
class CanExchangeEstablishments(Event):
    """
    Player can exchange establishments with another player.
    """

    player: Player

Player can exchange establishments with another player.

Ancestors

Instance variables

var player : Player

The type of the None singleton.

class CannotExchangeWithSelf (player: Player)
Expand source code
@dataclass(frozen=True)
class CannotExchangeWithSelf(Event):
    """
    Player has attempted to exchange establishments with self.
    """

    player: Player

Player has attempted to exchange establishments with self.

Ancestors

Instance variables

var player : Player

The type of the None singleton.

class CardBuilt (buyer: Player, card: Card, price_paid: int)
Expand source code
@dataclass(frozen=True)
class CardBuilt(Event):
    """
    Player has built a new card.
    """

    buyer: Player
    card: Card
    price_paid: int

Player has built a new card.

Ancestors

Instance variables

var buyer : Player

The type of the None singleton.

var card : Card

The type of the None singleton.

var price_paid : int

The type of the None singleton.

class CardUnavailable (buyer: Player, card_name: str, prohibited: bool = False)
Expand source code
@dataclass(frozen=True)
class CardUnavailable(ErrorEvent):
    """
    Emitted on attempt to build a card that's not currently available.

    If card is technically available on market, but rules don't allow purchasing
    it - prohibited would be set to True.
    """

    buyer: Player
    card_name: str
    prohibited: bool = False

Emitted on attempt to build a card that's not currently available.

If card is technically available on market, but rules don't allow purchasing it - prohibited would be set to True.

Ancestors

Instance variables

var buyer : Player

The type of the None singleton.

var card_name : str

The type of the None singleton.

var prohibited : bool

The type of the None singleton.

class DealtCardsToMarket (cards: list[Card] = <factory>, initial: bool = False)
Expand source code
@dataclass(frozen=True)
class DealtCardsToMarket(Event):
    """
    New cards were dealt to market.
    """

    cards: list[Card] = field(default_factory=list)
    initial: bool = False

New cards were dealt to market.

Ancestors

Instance variables

var cards : list[Card]

The type of the None singleton.

var initial : bool

The type of the None singleton.

class DiceRolled (player: Player, dice: Dice)
Expand source code
@dataclass(frozen=True)
class DiceRolled(Event):
    """
    Player rolls dice.
    """

    player: Player
    dice: Dice

Player rolls dice.

Ancestors

Instance variables

var dice : Dice

The type of the None singleton.

var player : Player

The type of the None singleton.

class ErrorEvent
Expand source code
class ErrorEvent(Event):
    """
    Base class for error events.
    """

Base class for error events.

Ancestors

Subclasses

class EstablishmentExchanged (from_user: Player,
to_user: Player,
establishment_given: Establishment,
establishment_taken: Establishment)
Expand source code
@dataclass(frozen=True)
class EstablishmentExchanged(Event):
    """
    Players have exchanged establishments.
    """

    from_user: Player
    to_user: Player
    establishment_given: Establishment
    establishment_taken: Establishment

Players have exchanged establishments.

Ancestors

Instance variables

var establishment_given : Establishment

The type of the None singleton.

var establishment_taken : Establishment

The type of the None singleton.

var from_user : Player

The type of the None singleton.

var to_user : Player

The type of the None singleton.

class EstablishmentGiven (from_user: Player, to_user: Player, establishment: Establishment)
Expand source code
@dataclass(frozen=True)
class EstablishmentGiven(Event):
    """
    Establishment was given to player.
    """

    from_user: Player
    to_user: Player
    establishment: Establishment

Establishment was given to player.

Ancestors

Instance variables

var establishment : Establishment

The type of the None singleton.

var from_user : Player

The type of the None singleton.

var to_user : Player

The type of the None singleton.

class Event
Expand source code
class Event:
    """
    Base class for all Events.
    """

Base class for all Events.

Subclasses

class FinalScores (scores: dict[int, list[Player]], finished: bool = True)
Expand source code
@dataclass(frozen=True)
class FinalScores(Event):
    """
    Scores at the time of game end.
    """

    scores: dict[int, list[Player]]
    finished: bool = True

Scores at the time of game end.

Ancestors

Instance variables

var finished : bool

The type of the None singleton.

var scores : dict[int, list[Player]]

The type of the None singleton.

class GameCreated (owner: Player)
Expand source code
@dataclass(frozen=True)
class GameCreated(Event):
    """
    New game is created.
    """

    owner: Player

New game is created.

Ancestors

Instance variables

var owner : Player

The type of the None singleton.

class GameEnded (player: Player,
finished: bool = False,
launch_pad: bool = False,
cancelled: bool = False,
owner_left: bool = False,
not_enough_players: bool = False)
Expand source code
@dataclass(frozen=True)
class GameEnded(Event):
    """
    Game finished.
    """

    player: Player
    finished: bool = False
    launch_pad: bool = False
    cancelled: bool = False
    owner_left: bool = False
    not_enough_players: bool = False

Game finished.

Ancestors

Instance variables

var cancelled : bool

The type of the None singleton.

var finished : bool

The type of the None singleton.

var launch_pad : bool

The type of the None singleton.

var not_enough_players : bool

The type of the None singleton.

var owner_left : bool

The type of the None singleton.

var player : Player

The type of the None singleton.

class GameInProgress (player_id: int)
Expand source code
@dataclass(frozen=True)
class GameInProgress(ErrorEvent):
    """
    Emitted when action is attempting to join a game in progress.
    """

    player_id: int

Emitted when action is attempting to join a game in progress.

Ancestors

Instance variables

var player_id : int

The type of the None singleton.

class GameStarted (owner: Player, turn_order: list[Player], use_promo: bool, randomize_players: bool)
Expand source code
@dataclass(frozen=True)
class GameStarted(Event):
    """
    New game is created.
    """

    owner: Player
    turn_order: list[Player]
    use_promo: bool
    randomize_players: bool

New game is created.

Ancestors

Instance variables

var owner : Player

The type of the None singleton.

var randomize_players : bool

The type of the None singleton.

var turn_order : list[Player]

The type of the None singleton.

var use_promo : bool

The type of the None singleton.

class GetExtraTurn (player: Player, no_effect: bool)
Expand source code
@dataclass(frozen=True)
class GetExtraTurn(Event):
    """
    Player gets an extra turn.
    """

    player: Player
    no_effect: bool

Player gets an extra turn.

Ancestors

Instance variables

var no_effect : bool

The type of the None singleton.

var player : Player

The type of the None singleton.

class GetOneCoinBecauseHadNoMoney (user: Player)
Expand source code
@dataclass(frozen=True)
class GetOneCoinBecauseHadNoMoney(Event):
    """
    At the start of build phase, player received 1 coin, because he had none.
    """

    user: Player

At the start of build phase, player received 1 coin, because he had none.

Ancestors

Instance variables

var user : Player

The type of the None singleton.

class MoneyDivided (reason: Card, players: int, total_coins: int, from_bank: int, coins: int)
Expand source code
@dataclass(frozen=True)
class MoneyDivided(Event):
    """
    Money was evenly distributed among the players (possibly rounding up from bank).
    """

    reason: Card
    players: int
    total_coins: int
    from_bank: int
    coins: int

Money was evenly distributed among the players (possibly rounding up from bank).

Ancestors

Instance variables

var coins : int

The type of the None singleton.

var from_bank : int

The type of the None singleton.

var players : int

The type of the None singleton.

var reason : Card

The type of the None singleton.

var total_coins : int

The type of the None singleton.

class MoneyEarned (reason: Card, user: Player, earned: int)
Expand source code
@dataclass(frozen=True)
class MoneyEarned(Event):
    """
    Player gets money from bank.
    """

    reason: Card
    user: Player
    earned: int

Player gets money from bank.

Ancestors

Instance variables

var earned : int

The type of the None singleton.

var reason : Card

The type of the None singleton.

var user : Player

The type of the None singleton.

class MoneyTaken (reason: Card, from_user: Player, to_user: Player, owed: int, taken: int)
Expand source code
@dataclass(frozen=True)
class MoneyTaken(Event):
    """
    Player A takes money from player B (possibly not in full amount, if any).
    """

    reason: Card
    from_user: Player
    to_user: Player
    owed: int
    taken: int

Player A takes money from player B (possibly not in full amount, if any).

Ancestors

Instance variables

var from_user : Player

The type of the None singleton.

var owed : int

The type of the None singleton.

var reason : Card

The type of the None singleton.

var taken : int

The type of the None singleton.

var to_user : Player

The type of the None singleton.

class MustGiveEstablishment (from_user: Player, to_user: Player)
Expand source code
@dataclass(frozen=True)
class MustGiveEstablishment(Event):
    """
    Player must give some establishment to previous player.
    """

    from_user: Player
    to_user: Player

Player must give some establishment to previous player.

Ancestors

Instance variables

var from_user : Player

The type of the None singleton.

var to_user : Player

The type of the None singleton.

class NewLandmarkEffectActivated (landmark: Landmark, builder_only: bool = False)
Expand source code
@dataclass(frozen=True)
class NewLandmarkEffectActivated(Event):
    """
    New landmark effect activates.
    """

    landmark: Landmark
    builder_only: bool = False

New landmark effect activates.

Ancestors

Instance variables

var builder_only : bool

The type of the None singleton.

var landmark : Landmark

The type of the None singleton.

class NoGameInProgress (player: Player)
Expand source code
@dataclass(frozen=True)
class NoGameInProgress(ErrorEvent):
    """
    Emitted when action is attempted on already finished game.
    """

    player: Player

Emitted when action is attempted on already finished game.

Ancestors

Instance variables

var player : Player

The type of the None singleton.

class NotEnoughMoney (buyer: Player, card_name: str, card_price: int)
Expand source code
@dataclass(frozen=True)
class NotEnoughMoney(ErrorEvent):
    """
    Emitted on attempt to build a card with insufficient coins.
    """

    buyer: Player
    card_name: str
    card_price: int

Emitted on attempt to build a card with insufficient coins.

Ancestors

Instance variables

var buyer : Player

The type of the None singleton.

var card_name : str

The type of the None singleton.

var card_price : int

The type of the None singleton.

class NotEnoughPlayers (player: Player)
Expand source code
@dataclass(frozen=True)
class NotEnoughPlayers(ErrorEvent):
    """
    Emitted when attempting to start a game with less than 2 players.
    """

    player: Player

Emitted when attempting to start a game with less than 2 players.

Ancestors

Instance variables

var player : Player

The type of the None singleton.

class NotInGame (player_id: int)
Expand source code
@dataclass(frozen=True)
class NotInGame(ErrorEvent):
    """
    Emitted when action is attempted by player who's not in current game.
    """

    player_id: int

Emitted when action is attempted by player who's not in current game.

Ancestors

Instance variables

var player_id : int

The type of the None singleton.

class NotYourTurn (expected_player: Player, moved_player: Player)
Expand source code
@dataclass(frozen=True)
class NotYourTurn(ErrorEvent):
    """
    Emitted when action is attempted during another player's turn.
    """

    expected_player: Player
    moved_player: Player

Emitted when action is attempted during another player's turn.

Ancestors

Instance variables

var expected_player : Player

The type of the None singleton.

var moved_player : Player

The type of the None singleton.

class OnlyOwnerOperation (owner: Player, user: Player, inactivity_remains: float)
Expand source code
@dataclass(frozen=True)
class OnlyOwnerOperation(ErrorEvent):
    """
    Emitted when attempted to do an owner-only operation.

    Also returns inactivity timeout state.
    """

    owner: Player
    user: Player
    inactivity_remains: float

Emitted when attempted to do an owner-only operation.

Also returns inactivity timeout state.

Ancestors

Instance variables

var inactivity_remains : float

The type of the None singleton.

var owner : Player

The type of the None singleton.

var user : Player

The type of the None singleton.

class OwnerChanged (oldowner: Player, newowner: Player)
Expand source code
@dataclass(frozen=True)
class OwnerChanged(Event):
    """
    Old owner left a game in progress.
    """

    oldowner: Player
    newowner: Player

Old owner left a game in progress.

Ancestors

Instance variables

var newowner : Player

The type of the None singleton.

var oldowner : Player

The type of the None singleton.

class PlayerHasNoSuchCard (player: Player, card_name: str, current: bool)
Expand source code
@dataclass(frozen=True)
class PlayerHasNoSuchCard(ErrorEvent):
    """
    Emitted on attempt to give/take a card that's not in player's possession.
    """

    player: Player
    card_name: str
    current: bool

Emitted on attempt to give/take a card that's not in player's possession.

Ancestors

Instance variables

var card_name : str

The type of the None singleton.

var current : bool

The type of the None singleton.

var player : Player

The type of the None singleton.

class PlayerJoined (player: Player)
Expand source code
@dataclass(frozen=True)
class PlayerJoined(Event):
    """
    Player has joined game.
    """

    player: Player

Player has joined game.

Ancestors

Instance variables

var player : Player

The type of the None singleton.

class PlayerLeft (player: Player, initiator: Player, during_game: bool = False)
Expand source code
@dataclass(frozen=True)
class PlayerLeft(Event):
    """
    Player has left game.
    """

    player: Player
    initiator: Player
    during_game: bool = False

Player has left game.

Ancestors

Instance variables

var during_game : bool

The type of the None singleton.

var initiator : Player

The type of the None singleton.

var player : Player

The type of the None singleton.

class RoomIsFull (player_id: int)
Expand source code
@dataclass(frozen=True)
class RoomIsFull(ErrorEvent):
    """
    Emitted when attempting to join a game with 5 joined players.
    """

    player_id: int

Emitted when attempting to join a game with 5 joined players.

Ancestors

Instance variables

var player_id : int

The type of the None singleton.

class SkipBuild (player: Player, cannot_buy: bool = False)
Expand source code
@dataclass(frozen=True)
class SkipBuild(Event):
    """
    Player skips the build phase.
    """

    player: Player
    cannot_buy: bool = False

Player skips the build phase.

Ancestors

Instance variables

var cannot_buy : bool

The type of the None singleton.

var player : Player

The type of the None singleton.

class SkipExchangeEstablishments (player: Player)
Expand source code
@dataclass(frozen=True)
class SkipExchangeEstablishments(Event):
    """
    Player has decided not to exchange establishments.
    """

    player: Player

Player has decided not to exchange establishments.

Ancestors

Instance variables

var player : Player

The type of the None singleton.

class StateSwitch (prev_state: GameState, new_state: GameState)
Expand source code
@dataclass(frozen=True)
class StateSwitch(Event):
    """
    Game state changes from A to B.
    """

    prev_state: GameState
    new_state: GameState

Game state changes from A to B.

Ancestors

Instance variables

var new_state : GameState

The type of the None singleton.

var prev_state : GameState

The type of the None singleton.

class TurnBegins (extra: bool, turn_number: int, round_number: int, initial: int, player: Player)
Expand source code
@dataclass(frozen=True)
class TurnBegins(Event):
    """
    Next turn begins.
    """

    extra: bool
    turn_number: int
    round_number: int
    initial: int
    player: Player

Next turn begins.

Ancestors

Instance variables

var extra : bool

The type of the None singleton.

var initial : int

The type of the None singleton.

var player : Player

The type of the None singleton.

var round_number : int

The type of the None singleton.

var turn_number : int

The type of the None singleton.

class TurnSkipped (player: Player)
Expand source code
@dataclass(frozen=True)
class TurnSkipped(Event):
    """
    Player skips turn.
    """

    player: Player

Player skips turn.

Ancestors

Instance variables

var player : Player

The type of the None singleton.

class WrongState (expected_state: GameState, current_state: GameState)
Expand source code
@dataclass(frozen=True)
class WrongState(ErrorEvent):
    """
    Emitted when action is attempted in wrong state.
    """

    expected_state: GameState
    current_state: GameState

Emitted when action is attempted in wrong state.

Ancestors

Instance variables

var current_state : GameState

The type of the None singleton.

var expected_state : GameState

The type of the None singleton.