kards-env/kards_battle/core/enums.py

109 lines
2.8 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

"""
核心枚举类定义
"""
from enum import Enum, auto
class UnitType(Enum):
"""单位类型枚举"""
INFANTRY = auto() # 步兵
TANK = auto() # 坦克
ARTILLERY = auto() # 火炮
FIGHTER = auto() # 战斗机
BOMBER = auto() # 轰炸机
def __str__(self):
return self.name
class LineType(Enum):
"""战线类型枚举"""
PLAYER1_SUPPORT = auto() # 玩家1支援线
FRONT = auto() # 共用前线
PLAYER2_SUPPORT = auto() # 玩家2支援线
def __str__(self):
return self.name
class GamePhase(Enum):
"""游戏阶段枚举(简化版)"""
PLAYER_TURN = auto() # 玩家回合(可执行任何动作)
OPERATION = auto() # 操作阶段(用于向后兼容)
GAME_END = auto() # 游戏结束
class Nation(Enum):
"""国家枚举"""
# 主要国家 (Major)
GERMANY = "Germany"
USA = "USA"
UK = "UK"
JAPAN = "Japan"
SOVIET = "Soviet"
# 小国 (Minor)
FINLAND = "Finland"
POLAND = "Poland"
FRANCE = "France"
ITALY = "Italy"
def __str__(self):
return self.value
@classmethod
def get_majors(cls):
"""获取所有主要国家"""
return [cls.GERMANY, cls.USA, cls.UK, cls.JAPAN, cls.SOVIET]
@classmethod
def get_minors(cls):
"""获取所有小国"""
return [cls.FINLAND, cls.POLAND, cls.FRANCE, cls.ITALY]
@classmethod
def get_all(cls):
"""获取所有国家"""
return cls.get_majors() + cls.get_minors()
class Rarity(Enum):
"""卡牌稀有度枚举"""
SPECIAL = 0 # 0级 - 特殊卡牌,不可带入初始卡组
ELITE = 1 # 1级 - 精英整个卡组只能带1张
RARE = 2 # 2级 - 稀有整个卡组最多带2张
UNCOMMON = 3 # 3级 - 罕见整个卡组最多带3张
COMMON = 4 # 4级 - 普通整个卡组最多带4张
def __str__(self):
return f"{self.value}"
def max_copies_in_deck(self) -> int:
"""返回该稀有度在卡组中允许的最大数量"""
if self == Rarity.SPECIAL:
return 0 # 不能带入初始卡组
return self.value
class CardType(Enum):
"""卡牌类型枚举"""
UNIT_INFANTRY = "Infantry"
UNIT_TANK = "Tank"
UNIT_ARTILLERY = "Artillery"
UNIT_FIGHTER = "Fighter"
UNIT_BOMBER = "Bomber"
ORDER = "Order"
COUNTER = "Counter"
def __str__(self):
return self.value
def is_unit_card(self) -> bool:
"""判断是否为单位卡"""
return self in [
CardType.UNIT_INFANTRY,
CardType.UNIT_TANK,
CardType.UNIT_ARTILLERY,
CardType.UNIT_FIGHTER,
CardType.UNIT_BOMBER
]