BattleSession

class BattleSession(effectRepository: EffectDefinitionRepository, battleFlowEngine: BattleFlowEngine, battleFlowPhaseProcessor: BattleFlowPhaseProcessor, mutationInterceptorChain: BattleMutationInterceptorChain, mutationApplier: MutationApplier, replacementStrategy: ReplacementStrategy, captureActionResolver: CaptureActionResolver, actionExecutionSupport: BattleSessionActionExecutionSupport, choiceHandlerRegistry: BattleSessionChoiceHandlerRegistry, actionHandlerRegistry: BattleSessionActionHandlerRegistry, turnPipeline: BattleSessionTurnPipeline, turnReadySpecification: BattleSessionTurnReadySpecification, unitChoiceSpecification: BattleSessionUnitChoiceSpecification, runChoiceSpecification: BattleSessionRunChoiceSpecification, targetChoiceSpecification: BattleSessionTargetChoiceSpecification, captureChoiceSpecification: BattleSessionCaptureChoiceSpecification, moveChoiceSpecification: BattleSessionMoveChoiceSpecification, itemChoiceSpecification: BattleSessionItemChoiceSpecification, targetQueryService: BattleSessionTargetQueryService, actionSortingStrategy: BattleSessionActionSortingStrategy, eventPublisher: BattleSessionEventPublisher, commandFactory: BattleSessionCommandFactory, battleId: String, formatId: String)

最小可跑的 battle session。

设计意图:

  • 把 BattleRuntimeSnapshot 和 BattleFlowEngine 包装成可持续推进的最小会话对象。

  • 提供“开始、注册单位、收集动作、执行回合、结束回合、自动替补、最小胜负判定”能力。

当前阶段不负责:

  • 玩家决策收集

  • 完整行动优先级系统

  • 玩家可选替补决策

  • 复杂胜负规则

Constructors

Link copied to clipboard
constructor(effectRepository: EffectDefinitionRepository, battleFlowEngine: BattleFlowEngine, battleFlowPhaseProcessor: BattleFlowPhaseProcessor, mutationInterceptorChain: BattleMutationInterceptorChain, mutationApplier: MutationApplier, replacementStrategy: ReplacementStrategy, captureActionResolver: CaptureActionResolver, actionExecutionSupport: BattleSessionActionExecutionSupport, choiceHandlerRegistry: BattleSessionChoiceHandlerRegistry, actionHandlerRegistry: BattleSessionActionHandlerRegistry, turnPipeline: BattleSessionTurnPipeline, turnReadySpecification: BattleSessionTurnReadySpecification, unitChoiceSpecification: BattleSessionUnitChoiceSpecification, runChoiceSpecification: BattleSessionRunChoiceSpecification, targetChoiceSpecification: BattleSessionTargetChoiceSpecification, captureChoiceSpecification: BattleSessionCaptureChoiceSpecification, moveChoiceSpecification: BattleSessionMoveChoiceSpecification, itemChoiceSpecification: BattleSessionItemChoiceSpecification, targetQueryService: BattleSessionTargetQueryService, actionSortingStrategy: BattleSessionActionSortingStrategy, eventPublisher: BattleSessionEventPublisher, commandFactory: BattleSessionCommandFactory, battleId: String, formatId: String)

Functions

Link copied to clipboard

返回人类可读 battle log 快照。

Link copied to clipboard

当前回合是否允许进入结算。

Link copied to clipboard

返回每个 side 的当前回合输入状态。

Link copied to clipboard
fun configureBattle(battleKind: BattleType, capturableSideId: String? = null): BattleRuntimeSnapshot

配置当前 battle 的业务语义,例如 wild/trainer 和可捕捉 side。

Link copied to clipboard

推进到回合结束并执行 residual。

Link copied to clipboard

返回结构化 event log 快照。

Link copied to clipboard

按当前队列排序规则执行本回合已收集的全部 move action。

Link copied to clipboard

导出当前可持久化状态。

Link copied to clipboard

当前回合是否已经满足最小提交条件。

Link copied to clipboard

标记当前 battle 已完成结算。

Link copied to clipboard

返回当前回合尚未提交行动的 side 标识列表。

Link copied to clipboard

返回当前待执行动作队列快照。

Link copied to clipboard

返回本回合尚未提交行动的 active 单位列表。

Link copied to clipboard

返回当前待处理的替补请求。

Link copied to clipboard

返回当前会话的统一查询结果。

Link copied to clipboard
fun queryTargets(effectId: String, actorUnitId: String): BattleSessionTargetQuery

查询某个 effect 在当前会话下的目标模式和可选目标。

Link copied to clipboard
fun queueMove(moveId: String, attackerId: String, targetId: String, priority: Int = 0, speed: Int = 0, accuracy: Int? = null, evasion: Int? = null, basePower: Int, damage: Int, attributes: Map<String, Any?> = emptyMap()): List<BattleSessionAction>

将一个 move action 加入当前回合待执行队列。

Link copied to clipboard

注册一个 side。

Link copied to clipboard
fun registerUnit(sideId: String, unit: UnitState, active: Boolean = true): BattleRuntimeSnapshot

注册一个单位并挂到指定 side。

Link copied to clipboard

执行当前回合动作队列,然后推进到回合结束。

Link copied to clipboard

返回当前 battle 内部资源账本。

Link copied to clipboard

用已持久化状态恢复当前 session。

Link copied to clipboard

返回当前会话快照。

Link copied to clipboard

启动 battle session。

Link copied to clipboard
fun submitCaptureChoice(playerId: String, ballItemId: String, sourceUnitId: String, targetId: String, priority: Int = 0, speed: Int = 0): List<BattleSessionAction>

提交一个捕捉选择。

Link copied to clipboard

提交一个统一 choice 输入。

Link copied to clipboard

批量提交多个统一 choice 输入。

Link copied to clipboard
fun submitItemChoice(itemId: String, actorUnitId: String, targetId: String, priority: Int = 0, speed: Int = 0, attributes: Map<String, Any?> = emptyMap()): List<BattleSessionAction>

提交一个玩家物品使用选择。

Link copied to clipboard
fun submitMoveChoice(moveId: String, attackerId: String, targetId: String, priority: Int = 0, speed: Int = 0, accuracy: Int? = null, evasion: Int? = null, basePower: Int, damage: Int, attributes: Map<String, Any?> = emptyMap()): List<BattleSessionAction>

提交一个玩家出招选择。

Link copied to clipboard

对一个待处理替补请求提交具体选择。

Link copied to clipboard
fun submitRunChoice(sideId: String, priority: Int = 0, speed: Int = 0): List<BattleSessionAction>

提交一个玩家逃跑选择。

Link copied to clipboard
fun submitSwitchChoice(sideId: String, outgoingUnitId: String, incomingUnitId: String, priority: Int = 0, speed: Int = 0): List<BattleSessionAction>

提交一个玩家替换选择。

Link copied to clipboard
fun submitWaitChoice(unitId: String, priority: Int = 0, speed: Int = 0): List<BattleSessionAction>

提交一个等待动作。

Link copied to clipboard
fun useMove(moveId: String, attackerId: String, targetId: String, accuracy: Int? = null, evasion: Int? = null, basePower: Int, damage: Int, attributes: Map<String, Any?> = emptyMap()): MoveResolutionResult

执行一次出招。