In a Game
, we have 5 different phase in total. 在 Game
类中,我们共有5个不同的阶段:
- SET_CARD :The phase of choosing hand cards, 选择手牌阶段
- At the start of a game. 游戏开始时。Choose initial hand cards. 选择初始手牌。
- EventCard
Nature and Wisdom
. 事件牌“草与智慧”。Insert a special phase of SET_CARD, 插入一个特殊的选择手牌阶段。
- SET_CHARACTER: The phase of choosing active character,选择出战角色阶段。
- After choosing initial hand cards. 选择初始手牌后。Choose initial active character. 选择初始出战角色。
- When an active character dies. 在某个出战角色死亡时。Choose the new active character. 选择一个新的出战角色。
- ROLL_PHASE: 投掷阶段
- Begin of each round. 每个回合开始时。
Toss-up
,Knights of Favonius Library
are played. "一掷乾坤", "骑士团图书馆" 打出之时。Insert a special phase. 插入一个特殊阶段。
- ACTION_PHASE: 行动阶段
- In each ACTION_PHASE , two player act alternately. 在每一个行动阶段,双方轮流行动。
- END_PHASE: 回合结束阶段
first_player
: which player acts first in this round,当前轮次内先手。 (Index only, 只记录了序号)active_player
: which player is active. 当前行动角色。 (Instance ofGeniusPlayer
)active_player_index
: the index of active player. 当前行动角色编号。player0
,player1
: two player instance. 2个玩家实例。players=[player0, player1]
: list of players,玩家列表。game_phase
Game Phase, 游戏阶段。special_phase
: The insert special phase to deal, default asNone
. 需要处理的插入阶段,默认为None
.round
: round of the game, 游戏轮次。current_dice
: current 当前计算行动的骰子current_action
: current action you choose当前执行的行动current_damage
: damage in current settlement 当前结算中的伤害current_skill
: current skills used 当前使用的技能current_card
: the hand currently played 当前打出的手牌damage_list
: the damage that is still pending settlement, such as the other two points of damage generated by swirl 当前仍待结算的伤害,如扩散时产生的其他两点伤害is_changed_player
: does the current action result in the need to switch players 当前行动是否导致需要切换玩家is_end
: is the game over 是否游戏结束manager
: event settlement manager事件结算管理器
In a game, we have 2 players, which are instances of class GeniusPlayer
. 一局游戏里,每个玩家时一个GeniusPlayer
类的实例。
We maintain some global team state in this class: 我们在这个类中维护了一些全队的状态:
is_pass
The player has finished its action in this round. 玩家已结束该回合行动。play_arcane_legend
: The player has played one ofarcane legend
cards. 玩家已打出一张秘传牌。is_after_change
: The player just finishs an action of change character. 玩家刚进行了切人操作。 Used to checkplunging attack
, 用于判断下落攻击。is_quick_change
: The action of changing character is an quick action. 切人操作为快速行动。change_num
: The number of change character in a round. 该回合内切人数量。 Used to checkRed Feather Fan
. 用于确认 “红羽团扇”的触发。- Maybe more to come. 可能未来会新增内容。
The other states are divided in to the following zones: 剩余的状态被划分到一下几个区域内:
- Card_Zone:牌库, Number of remaining cards. 牌库剩余牌数。
- Hand_Zone: 手牌区。
- Team_Combat_Status_Zone: 队伍状态区: We may call it Active_Zone for convience, which contains
Combat_Status
. 我们简称其为出战状态区,其中包含出战状态
。 Dice_Zone
: 骰子区。Support_Zone
: 支援区。Summon_Zone
: 召唤物区。
A player has a character list, instances of Character
are in it. 每一个玩家有一个角色列表,每一个均为一个Character
实例。
All of Status
, Shield
, Combat_Status
, Combat_Shield
, Summon
, Support
, Weapon
, Artifact
and Character
are entities (subclass of Entity
). 包括状态、护盾、出战状态、出战护盾,召唤物,支援物,武器,圣遗物,角色在内的对象均为实例,是Entity
类的子类。
Class of character status, maintain in Character_Zone
of each Character
. 角色状态类,在每个角色的角色区内维护。
Same as Status
. Design for shield on single character. 和角色状态一致,用于附着在单个角色的盾。
Class of Combat_Status
, maintain in Team_Combat_Status_Zone
. 出战状态类,在出战状态区内。
Same as Combat_Status
for shields. 与出战状态一致,用于盾。
Class of Summon
, lying in Summon_Zone
. 召唤物类,置于召唤物区。
Class of Support
, lying in Support_Zone
。 支援,于支援区。
Class of weapon, stored the card information of the weapon. 武器类,存有武器牌信息。
Similar with weapon
. 与武器类似。 Not Implement Yet. 还未实现。
Each character should has the following attributes: 每个角色需要维护以下属性:
id
: Indentity Document. 角色卡牌编号name
: name, 姓名element
: element type, 元素类别。weapon_type
: weapon type, 武器类别。country
: country, 所属国家。health_point
: current health point,当前血量。init_health_point
: init health point. 初始血量。max_health_point
: max health point. 血量上限。skill_list
: list of skills, containing severalCharacterSkill
class. 技能列表,包含若干个“角色技能”类。skills
: list of instances of skill, the instance can be called by game. 技能实例列表,每个实例均可以被游戏调用。power
: current power, 角色当前充能数。max_power
:max power, 角色充能上限。element_application
: list, element applications on the character. 列表,当前角色的附着元素。index
: index of the character in the player's character list. 该角色在玩家在角色列表中的编号。talent
: whether equips talent. 是否装有天赋。is_active
: whether the active character. 是否出战。is_alive
: whether alive. 是否存活。is_frozen
: whether frozen. 是否冻结。is_satisfied
: whether satisfies. 是否饱腹。character_zone
: Character Zone, 角色区域。
In this base class, several basic operations have been defined. 在该基类中,定义了许多基本操作。
More detail could be viewed in 更多信息可以在以下文件中查看: genius_invocation/entity/character.py
。
This zone contains Weapon
, Artifact
, Status
List. 该区域包含装备的武器牌,圣遗物牌,角色状态列表。
Event System provides the simulator with the event listening (listen
), event triggering (invoke
) functions. When an event occurs, the listener
can be notified to perform a predefined action
. 事件系统为模拟环境提供了事件监听 (listen
) 和触发 (invoke
) 功能。在事件 (event
) 发生时,可以通知监听者 (listener
) 执行预定义的动作 (action
)。
The event system provides unified management and triggering mechanism for tasks with uncertain source, quantity, frequency, and timing. 事件系统提供了不确定来源、数量、次数、时机的任务的统一管理、触发机制。
Event represents some abstract timing. 事件代表某种抽象时刻。
We can treat any gaps during execution as events. 我们可以把代码执行的任何间隔时刻当作事件。
Here are the Event
used in the project: 一下为我们使用到的事件: Enum: EventType
BEGIN_ROLL_PHASE
开始投掷阶段BEGIN_ACTION_PHASE
开始行动阶段CALCULATE_DICE
计算骰子需求ON_PLAY_CARD
打出手牌AFTER_PLAY_CARD
打出手牌后ON_USE_SKILL
执行技能AFTER_USE_SKILL
执行技能后ON_CHANGE_CHARACTER
切换角色AFTER_CHANGE_CHARACTER
切换角色后END_PHASE
结束阶段AFTER_TAKES_DMG
受到伤害后INFUSION
: 伤害元素附着DAMAGE_ADD
计算伤害增加量DAMAGE_ADD_AFTER_REACTION
: 计算由于触发反应引起的加伤。 e.g.Elemental Resonance: Fervent Flames
例如:元素共鸣:热诚之火
。DEALING_DAMAGE
: Multiplicative damage dealing. 结算伤害时,for Mona only right now, 现仅对莫娜起作用。DIVIDE_DAMAGE
: Dividing damage. 伤害除算。For Noelle only right now. 现仅对诺艾尔起作用。EXECUTE_DAMAGE
: 执行伤害时,Calculate the damage discount from shield and status, 计算由盾、状态产生的伤害减免。CHARACTER_DIE
角色死亡时BEFORE_ANY_ACTION
任意行动之前AFTER_ANY_ACTION
任意行动之后ON_SUMMON_REMOVE
召唤物移除时ELEMENTAL_APPLICATION_REACTION
: The timing that a reaction is triggered by an elemental application (no damage). 附着元素造成反应之时(无伤害)。
The execution order is defined by the priority of zones. 执行顺序由各区域的优先级确定。
As far as we known, the priority is as bellow: 具我们所知,优先级按下列排列:
-
CHARACTER_ZONE
$0$ -
ACTIVE_ZONE_SHIELD
$1$ -
ACTIVE_ZONE
$2$ -
SUMMON_ZONE
:$3$ -
SUPPORT_ZONE
:$4$
In the same priority, the event registered earlier will be triggered earlier, too. 在同一优先级内,先注册的事件会优先执行。
-
Each entity may need to be listened at some specific event timing. 每个实例都有可能需要在某些时刻被监听。
-
Please maintain the listener list of each
Entity
:listeners
in its functionupdate_listener_list
. 请对每个需要监听的Entity
对象维护 listener 列表: 在所属函数update_listener_list
中维护listeners
。 -
The list consists tuples: (
EventType
,ZoneType
,ACTION
),theACTION
is the called function when the event is invoked. 这个列表由一个或多个三元组构成,(EventType
,ZoneType
,ACTION
), 其中,ACTION
为触发时调用的函数。 -
·
ACTION
always has the only input param:game
.ACTION
的输入总是只有game
一项。
You only need to give the event
to the event manager, the ACTION
s will automatically invoked. 仅需将需要触发的事件发送给事件管理器,对应的函数将自动触发。
To tackle the difficult calculation of damage, we create the class of Damage
, 为了解决复杂的伤害计算,我们创建了伤害类。
damage_type
: Which type of skill causes the damage. 造成伤害的技能类型。main_damage_element
: Which element the main damage is. 伤害的元素类型。main_damage
: The mount of damage. 伤害量。piercing_damage
: The mount of piercing damage. 穿透伤害量。damage_from
: WhichEntity
the damage from. 伤害来源实例
。damage_to
: WhichCharacter
the damage to. 伤害目标角色
。reaction
: The reaction type this damage triggered. 该伤害触发的元素反应。swirl_crystallize_type
: The swirl or crystallize's element type. 扩散、结晶对应的元素类型。is_plunging_attack
: Whether the damage from a plugging attack. 是否来自下落攻击。is_charged_attack
: Whether the damage from a charged attack. 是否来自重击。
-
We can call
game.add_damage(DMG)
to add aDamage
instance into the damage list. 我们通过调用game.add_damage(DMG)
将带计算的伤害加入伤害列表中。 -
Then we call
game.resolve_damage()
to resolve all the damages in the list. 然后通过调用game.resolve_damage()
来计算这个伤害的影响。 -
In
game.resolve_damage()
, we repeatedly pop the first damage in damage list, and setgame.current_damage
, dealing the damages one by one. 在game.resolve_damage()
中,我们一个个处理列表中的伤害,设置game.current_damage
,依次处理。 -
For a single damage, we need to follow the sequential steps: 对于一个伤害,我们需要根据如下的顺序结算。 During the process, it will invoke the corresponding event. 在此过程中,将不断触发对应的事件。
- Infusion : infuse current damage to certain element. 将当前伤害染色。
- Damage Add: Call
Status
, etc. to enhance the main damage. 结算各种状态,使得加算增伤得到计算。 - Elemental Reaction: Check and trigger elemental reaction. 检查并触发元素反应。Swirl will trigger additonal damage. 扩散会触发额外伤害。
- Damage Add After Reactoin: Calculate additonal damage add because of triggering reaction. 计算由于触发反应引起的增伤。
- Damage Dealing: Calculate the final multiplicative damage increase. 计算最终乘算增伤。
- Damage Dividing: Calculate the division damage reduction. 计算最终除算减伤。
- Damage Execute: Calculate the status, shield etc's effect on damage reduction. 计算状态、盾提供的减伤。
- Suffer Damage: The characters suffer the final damage. 承受最终伤害。
- If triggered overload on active character, switch the active character to the next. 若在出战角色触发超载,则切换出战角色。
- TO BE UPDATED.
- We have a total of 7 basic dice and universal dice. Dice are transferred and calculated in the game as int. 我们共有7种基础元素骰和万能骰。骰子以int的形式在游戏中传输和计算。
- We use a two-dimensional np.array to maintain our dice area. We sort the dice in the dice area according to four rules: universal dice priority, character element type dice priority, large number of dice priority, and dice type order. 我们使用一个二维的np.array来维护我们的骰子区,我们按照万能骰优先、出战角色元素类型骰子优先、数量多骰子优先和骰子类型顺序四种规则对骰子区的骰子进行排序。
- Our dice area supports five basic operations: add, use remove, remove_all, show, and num return quantity, which are used to maintain the number of your dice. 我们的骰子区支持 add添加、remove使用、remove_all清空、show展示和num返回数量五个基本操作,用于维护您骰子的数量。
- We also support check_dice, which is used to determine whether the dice you choose is legal, and calculate_dice, which is used to calculate whether there is currently a dice type that supports you to perform a certain operation. 我们还支持了 check_dice 用于判断您某次选择的骰子是否合法,以及calculate_dice 用于计算当前是否有支持您进行某个操作的骰子类型。
- Before we can perform any action, we will calculate for you the mask that you can perform the action on. Go through your action list: 1. Does the action goal exist? 2. Are the action requirements met? 2. Are there enough dice required for the action? , at this time we will trigger the CALCULATE_DICE moment for calculation, but it will not affect your status. When we actually perform an action, we will generate current_dice again. At this time, the Entity will autonomously call its own on_calculate event and change its own state. 当我们可以执行任意行动前,我们会为您计算你能够执行行动的mask。遍历您的行动列表:1. 行动目标是否存在?2. 行动要求是否满足?2. 行动所需骰子是否足够?,此时我们会触发CALCULATE_DICE时刻进行计算,但不会影响到您的状态。当我们真正执行某一行动时,我们会再次生成current_dice,此时在Entity内部会自主的调用自己的on_calculate事件,并改变自身的状态。
CharacterSkill
has NoramalAttack
, ElementalSkill
, ElementalBurst
3 subclass. 技能有普通攻击、元素战技、元素爆发三个子类。It is the base class for each character's each skill. 是每个角色的每个技能的基类。 It contains the following attributes, 包含如下属性
name
type
Skill type 技能类别.damage_type
,main_damage_element
,main_damage
,piercing_damage
cost
: cost of the dice. 骰子消耗。energy_cost
,energy_gain
能量消耗与获得。is_prepared_skill
是否是(被)准备的技能。
In CharacterSkill
class, several atom operations have been implemented. 在该类中已经写好许多原子操作。Some other operation need to implement dependently in the specific character. 更多的操作需要在特定的角色中实现。
- All our action cards belong to the ActionCard category, they will only exist in your hand area and library area. One of them consists of three basic operations: on_played (performs the effect of the card you played), find_target (finds the card's executable target), and on_tuning (uses the card for elemental attunement). 我们所有的行动牌均属于 ActionCard类,他们将仅存在于您的手牌区和牌库区中。他们一个包含三个基本操作:on_played(执行您打出该牌的效果)、find_target(寻找卡牌可执行目标) 和 on_tuning(将该牌用于元素调和)。
- 对于打出后会持续存在在场上或者产生特定效果状态的卡牌,我们会维护一个同名的 Status 用于执行该牌在场时的效果。例如:我打出支援牌 Paimon时,会在我方支援区产生一个名为 Paimon 的Status,其拥有一个在回合行动阶段开始时触发的事件:为我方增加两个万能骰。
- For cards that will continue to exist on the field or produce a specific effect status after being played, we will maintain a Status with the same name to perform the effect of the card while it is on the field. For example: When I play the support card Paimon, a Status named Paimon will be generated in our support area, which has an event triggered at the beginning of the action phase of the round: adding two omni dice to our dicezone. 我们的牌库区会在游戏开始时排好顺序,将牌依次返回给玩家。当我们将牌放回牌库时,会随机插入牌库区。牌库区支持以下操作:find_card(检索并获取特定类型的牌)、 get_card(随机获取牌)、return_car(将牌放回牌堆)和num(返回剩余数量)
- Our hand area will get five cards from the card library at the beginning of the game (must include arcane legend cards), and the number will not exceed 10. When the number exceeds 10, the newly obtained cards will be burned randomly. Our hand area supports the following operations: remove (batch removal), use (remove a single card by serial number), add (batch acquisition), has_card (determine whether you have a card with a certain name), remove_name (remove by name) and num (returns the current number) 我们的手牌区会在游戏开始时从牌库获取五张牌(一定包含秘传牌),数量不超过10张。当数量将超过10张时,会随机烧毁改次获得的牌。我们的手牌区支持以下操作:remove(批量移除)、use(按序号移除单张)、add(批量获取)、has_card(判断是否拥有某个名字的牌)、remove_name(按名字移除)和num(返回当前数量)