Add CardRarityTier enum for pull rate calculations (common through crown_rare). Add CardSubtype enum for Pokemon classifications (basic, stage1, stage2, ex, etc.). Update CardDefinition model with new fields for subtypes and rarity display.
242 lines
7.3 KiB
Python
242 lines
7.3 KiB
Python
"""Enumeration types for the Mantimon TCG game engine.
|
|
|
|
This module defines all enum types used throughout the game engine. We use StrEnum
|
|
for JSON serialization compatibility - enum values serialize as strings directly.
|
|
|
|
This is the foundational module with zero internal dependencies, allowing other
|
|
core modules to import from it without circular import concerns.
|
|
|
|
Note on extensibility: While these enums define the standard types, the game engine
|
|
is designed to be configurable. Custom energy types or card types could be added
|
|
via configuration for free play mode.
|
|
"""
|
|
|
|
from enum import StrEnum
|
|
|
|
|
|
class CardType(StrEnum):
|
|
"""The primary type of a card.
|
|
|
|
Every card in the game belongs to exactly one of these types, which determines
|
|
how it can be played and what rules apply to it.
|
|
"""
|
|
|
|
POKEMON = "pokemon"
|
|
TRAINER = "trainer"
|
|
ENERGY = "energy"
|
|
|
|
|
|
class PokemonStage(StrEnum):
|
|
"""The evolution stage of a Pokemon card.
|
|
|
|
Determines how the Pokemon can be played:
|
|
- BASIC: Can be played directly from hand to bench
|
|
- STAGE_1: Must evolve from a Basic Pokemon
|
|
- STAGE_2: Must evolve from a Stage 1 Pokemon
|
|
|
|
Note: This is separate from PokemonVariant (EX, V, GX, etc.) which affects
|
|
knockout points but not evolution mechanics.
|
|
"""
|
|
|
|
BASIC = "basic"
|
|
STAGE_1 = "stage_1"
|
|
STAGE_2 = "stage_2"
|
|
|
|
|
|
class PokemonVariant(StrEnum):
|
|
"""Special variant classification for Pokemon cards.
|
|
|
|
Variants affect knockout points and may have special rules, but are
|
|
orthogonal to evolution stage. A card can be a "Basic EX" or "Stage 2 GX".
|
|
|
|
- NORMAL: Standard Pokemon, worth 1 knockout point
|
|
- EX: Worth 2 knockout points
|
|
- GX: Worth 2 knockout points, has GX attack (once per game)
|
|
- V: Worth 2 knockout points
|
|
- VMAX: Evolves from V variant, worth 3 knockout points
|
|
- VSTAR: Evolves from V variant, worth 3 knockout points, has VSTAR power
|
|
- RADIANT: Worth 2 knockout points, only 1 Radiant Pokemon allowed per deck
|
|
- PRISM_STAR: Worth 2 knockout points, only 1 per deck, goes to Lost Zone when KO'd
|
|
"""
|
|
|
|
NORMAL = "normal"
|
|
EX = "ex"
|
|
GX = "gx"
|
|
V = "v"
|
|
VMAX = "vmax"
|
|
VSTAR = "vstar"
|
|
RADIANT = "radiant"
|
|
PRISM_STAR = "prism_star"
|
|
|
|
|
|
class PokemonPowerType(StrEnum):
|
|
"""Type of Pokemon Power or Ability (era-specific).
|
|
|
|
Different eras of the Pokemon TCG used different terminology and rules
|
|
for special abilities:
|
|
|
|
- POKEMON_POWER: Original Base-Fossil era. Can be "turned off" by certain effects.
|
|
- POKE_POWER: Neo era activated abilities. Require explicit activation.
|
|
- POKE_BODY: Neo era passive abilities. Always active, cannot be "turned off".
|
|
- ABILITY: Modern era (BW onwards). Unified term for all special abilities.
|
|
"""
|
|
|
|
POKEMON_POWER = "pokemon_power"
|
|
POKE_POWER = "poke_power"
|
|
POKE_BODY = "poke_body"
|
|
ABILITY = "ability"
|
|
|
|
|
|
class EnergyType(StrEnum):
|
|
"""Energy types available in the game.
|
|
|
|
Based on modern Pokemon TCG with 10 types. Colorless is special - any energy
|
|
can satisfy colorless requirements.
|
|
|
|
Note: The engine supports all types, but specific games can restrict which
|
|
types are enabled via RulesConfig.
|
|
"""
|
|
|
|
COLORLESS = "colorless"
|
|
DARKNESS = "darkness"
|
|
DRAGON = "dragon"
|
|
FIGHTING = "fighting"
|
|
FIRE = "fire"
|
|
GRASS = "grass"
|
|
LIGHTNING = "lightning"
|
|
METAL = "metal"
|
|
PSYCHIC = "psychic"
|
|
WATER = "water"
|
|
|
|
|
|
class TrainerType(StrEnum):
|
|
"""Subtypes of Trainer cards.
|
|
|
|
Each subtype has different rules for how many can be played per turn:
|
|
- ITEM: Unlimited per turn
|
|
- SUPPORTER: One per turn
|
|
- STADIUM: One per turn, stays in play
|
|
- TOOL: Attached to Pokemon, unlimited per turn
|
|
"""
|
|
|
|
ITEM = "item"
|
|
SUPPORTER = "supporter"
|
|
STADIUM = "stadium"
|
|
TOOL = "tool"
|
|
|
|
|
|
class TurnPhase(StrEnum):
|
|
"""Phases within a player's turn.
|
|
|
|
Turn structure:
|
|
1. SETUP: Initial game setup (draw starting hand, place basics, set prizes)
|
|
2. DRAW: Draw a card from deck
|
|
3. MAIN: Play cards, attach energy, evolve, use abilities, retreat
|
|
4. ATTACK: Declare and resolve an attack (optional)
|
|
5. END: Apply end-of-turn effects, check knockouts, score points
|
|
|
|
Valid transitions:
|
|
- SETUP -> DRAW (game start, first player's turn)
|
|
- DRAW -> MAIN
|
|
- MAIN -> ATTACK or END (can skip attack)
|
|
- ATTACK -> END
|
|
- END -> DRAW (next player's turn)
|
|
"""
|
|
|
|
SETUP = "setup"
|
|
DRAW = "draw"
|
|
MAIN = "main"
|
|
ATTACK = "attack"
|
|
END = "end"
|
|
|
|
|
|
class StatusCondition(StrEnum):
|
|
"""Status conditions that can affect Pokemon in play.
|
|
|
|
Status conditions have specific effects and removal conditions:
|
|
- POISONED: 10 damage between turns; removed by evolution, retreat, or card effect
|
|
- BURNED: 20 damage between turns + flip to remove; removed on heads
|
|
- ASLEEP: Cannot attack or retreat; removed on heads flip; overrides PARALYZED/CONFUSED
|
|
- PARALYZED: Cannot attack or retreat for 1 turn; removed at end of next turn;
|
|
overrides ASLEEP/CONFUSED
|
|
- CONFUSED: Flip to attack, 30 self-damage on tails; removed by evolution/retreat;
|
|
overrides ASLEEP/PARALYZED
|
|
|
|
Note: POISONED and BURNED stack with other conditions. ASLEEP, PARALYZED, and
|
|
CONFUSED override each other (only one can be active at a time).
|
|
"""
|
|
|
|
POISONED = "poisoned"
|
|
BURNED = "burned"
|
|
ASLEEP = "asleep"
|
|
PARALYZED = "paralyzed"
|
|
CONFUSED = "confused"
|
|
|
|
|
|
class ActionType(StrEnum):
|
|
"""Types of actions a player can take during their turn.
|
|
|
|
Each action type has specific validation rules and can only be performed
|
|
during certain phases. See rules_validator.py for details.
|
|
"""
|
|
|
|
PLAY_POKEMON = "play_pokemon"
|
|
EVOLVE = "evolve"
|
|
ATTACH_ENERGY = "attach_energy"
|
|
PLAY_TRAINER = "play_trainer"
|
|
USE_ABILITY = "use_ability"
|
|
ATTACK = "attack"
|
|
RETREAT = "retreat"
|
|
PASS = "pass"
|
|
|
|
|
|
class GameEndReason(StrEnum):
|
|
"""Reasons why a game ended.
|
|
|
|
Used in GameState.end_reason to indicate how the game concluded:
|
|
- PRIZES_TAKEN: A player took all required prize points
|
|
- NO_POKEMON: A player has no Pokemon in play (active or bench)
|
|
- DECK_EMPTY: A player cannot draw a card at the start of their turn
|
|
- RESIGNATION: A player resigned from the match
|
|
- TIMEOUT: A player ran out of time (multiplayer only)
|
|
- TURN_LIMIT: The turn limit was reached (winner determined by score)
|
|
- DRAW: The game ended in a draw (tie on points at timer expiration)
|
|
"""
|
|
|
|
PRIZES_TAKEN = "prizes_taken"
|
|
NO_POKEMON = "no_pokemon"
|
|
DECK_EMPTY = "deck_empty"
|
|
RESIGNATION = "resignation"
|
|
TIMEOUT = "timeout"
|
|
TURN_LIMIT = "turn_limit"
|
|
DRAW = "draw"
|
|
|
|
|
|
class ModifierMode(StrEnum):
|
|
"""How damage modifiers (weakness/resistance) are calculated.
|
|
|
|
- MULTIPLICATIVE: Multiply damage by modifier (e.g., x2 for weakness)
|
|
- ADDITIVE: Add modifier to damage (e.g., +20 for weakness, -30 for resistance)
|
|
|
|
Standard Pokemon TCG uses multiplicative weakness (x2) and additive resistance (-30).
|
|
Some game variants or house rules may prefer different calculations.
|
|
"""
|
|
|
|
MULTIPLICATIVE = "multiplicative"
|
|
ADDITIVE = "additive"
|
|
|
|
|
|
__all__ = [
|
|
"ActionType",
|
|
"CardType",
|
|
"EnergyType",
|
|
"GameEndReason",
|
|
"ModifierMode",
|
|
"PokemonPowerType",
|
|
"PokemonStage",
|
|
"PokemonVariant",
|
|
"StatusCondition",
|
|
"TrainerType",
|
|
"TurnPhase",
|
|
]
|