BattleSessionChoiceFactory.kt
package io.github.lishangbu.avalon.game.battle.engine.core.session
/**
* battle session choice 构造器。
*
* 设计意图:
* - 把 `DefaultBattleSessionCommandFactory` 中 choice 族的数据对象创建逻辑拆出来;
* - 让 choice 与 action 两组命令创建职责分离,避免单个工厂继续膨胀;
* - 保持纯数据构造,不夹带校验或补全逻辑。
*/
internal class BattleSessionChoiceFactory {
fun createMoveChoice(
moveId: String,
attackerId: String,
targetId: String,
priority: Int,
speed: Int,
accuracy: Int?,
evasion: Int?,
basePower: Int,
damage: Int,
attributes: Map<String, Any?>,
): MoveChoice =
MoveChoice(
moveId = moveId,
attackerId = attackerId,
targetId = targetId,
priority = priority,
speed = speed,
accuracy = accuracy,
evasion = evasion,
basePower = basePower,
damage = damage,
attributes = attributes,
)
fun createItemChoice(
itemId: String,
actorUnitId: String,
targetId: String,
priority: Int,
speed: Int,
attributes: Map<String, Any?>,
): ItemChoice =
ItemChoice(
itemId = itemId,
actorUnitId = actorUnitId,
targetId = targetId,
priority = priority,
speed = speed,
attributes = attributes,
)
fun createCaptureChoice(
playerId: String,
ballItemId: String,
sourceUnitId: String,
targetId: String,
priority: Int,
speed: Int,
): CaptureChoice =
CaptureChoice(
playerId = playerId,
ballItemId = ballItemId,
sourceUnitId = sourceUnitId,
targetId = targetId,
priority = priority,
speed = speed,
)
fun createSwitchChoice(
sideId: String,
outgoingUnitId: String,
incomingUnitId: String,
priority: Int,
speed: Int,
): SwitchChoice =
SwitchChoice(
sideId = sideId,
outgoingUnitId = outgoingUnitId,
incomingUnitId = incomingUnitId,
priority = priority,
speed = speed,
)
fun createRunChoice(
sideId: String,
priority: Int,
speed: Int,
): RunChoice =
RunChoice(
sideId = sideId,
priority = priority,
speed = speed,
)
fun createWaitChoice(
unitId: String,
priority: Int,
speed: Int,
): WaitChoice =
WaitChoice(
unitId = unitId,
priority = priority,
speed = speed,
)
}