-
-
Notifications
You must be signed in to change notification settings - Fork 0
Game class reference
iqnite edited this page Jun 29, 2025
·
1 revision
Caution
This article is still under construction and incomplete.
eggsplode/core.py contains the main classes and methods that are responsible the game's flow control. It automates a lot of complex flow control actions, allowing you to focus on your card mechanics!
The Game class represents an Eggsplode game. It is initialized automatically at game start.
-
app (EggsplodeApp): The Discord app the game runs on. -
config (dict): The configuration generated from the game settings. -
players (list[int]): Contains the user IDs of the players that are still alive. -
hands (dict[int, list[str]]): Contains the cards of the players that are still alive, matched to their user IDs. -
deck (list[str]): The deck players draw from. -
current_player (int): The list index of the player who has to draw or play next. Not to be confused withcurrent_player_id. -
current_player_id (get/set int): The Discord user ID of the current player. -
current_player_hand (list[str]): The cards of the current player. -
next_player (int): The list index of the player who will have to play after the current player, regardless of Atteggs. Not to be confused withnext_player_id. -
next_player_id (get int): The Discord user ID of the next player. -
next_turn_player_id (get int): The Discord user ID of the player that will have to play after the current turn finishes. This considers Atteggs. -
action_id (int): A number that is increased after every action, to ensure no "stale" actions are performed. -
remaining_turns (int): The number of turns the current player has to perform before it is the next player's turn. Especially useful to handle Atteggs. -
events (EventSet): A fixed set of events the game can notify and listen to. -
last_activity (datetime): The time of the last user activity. -
running (bool): Whether the game is still running or has ended. -
paused (bool): Whether the turn timer is paused or should count down. No cards can be played (except for special ones such as Nope) while this isTrue. Useful when there is an active view with its ownon_timeoutfunction. -
inactivity_count (int): The number of turns that have passed since the last activity. -
anchor_interaction (discord.Interaction | None): The last valid public interaction, used to send follow-up messages on timeout. -
play_actions (dict[str, Callable[[Game, discord.Interaction], Coroutine]]): The play actions from the expansions that have been loaded into the game. -
draw_actions (dict[str, Callable[[Game, discord.Interaction, bool | None], Coroutine]]): The draw actions from the expansions that have been loaded into the game. -
turn_warnings (list[Callable[[Game], str]]): The turn warnings from the expansions that have been loaded into the game. -
setup_actions (list[Callable[[Game], None]]): The setup actions from the expansions that have been loaded into the game. -
turn_prompt (get str): The message displayed above the Play a card and Draw buttons, telling who's turn it is. -
warnings (get str): The message displayed below the Play a card and Draw buttons, set in the turn warnings list.
-
setup: Prepares the deck and player hands, and calls the setup actions. -
start (async): Calls thesetupmethod and begins the first turn.- Arguments:
interaction (Interaction)
- Arguments:
-
trim_deck: Removes a random number (frommin_parttomax_part) of cards from the deck. Unused sincev1.4.- Arguments:
min_part (int),max_part (int)
- Arguments:
-
shuffle_deck: Shuffles the deck. -
expand_deck: Increases the number of cards for every 5 players. -
load_cards: Loads expansions from the configuration. -
next_turn (async): Starts the next turn, considering remaining turns from Atteggs. -
group_hand: Returns the cards of a certain player.- Arguments:
-
user_id (int): The Discord user ID of the player. -
usable_only (bool): Whether only cards that can be played normally from the card selection should be included. Defaults toFalse.
-
- Returns
dict:-
str: The name of the card. -
int: How many of that card the player has.
-
- Arguments:
-
play (async): Calls the play action for the specified card.- Arguments:
interaction (Interaction),card (str)
- Arguments:
-
draw (async): If present, calls the draw action for the specified card, else adds the card to the current player's hand.- Arguments:
-
interaction (Interaction): The Discord interaction that should be used to handle the action. -
card (str): The drawn card. -
timed_out (bool): Whether the card was drawn after turn timeout. Defaults toFalse.
-
- Returns
tuple:-
str: The drawn card. -
bool:Falseif the card had a draw action,Trueif it did not.
-
- Arguments:
-
action_check (async): Checks if an interaction is legitimate, and shows an error message if it is not.- Arguments:
Interaction - Returns
bool: Whether the action is valid and should be continued.
- Arguments:
