SetRelayActionExecutor.kt

package io.github.lishangbu.avalon.game.battle.engine.core.runtime.action

import io.github.lishangbu.avalon.game.battle.engine.core.dsl.ActionNode
import io.github.lishangbu.avalon.game.battle.engine.core.dsl.action.SetRelayActionNode
import io.github.lishangbu.avalon.game.battle.engine.core.event.EventContext
import io.github.lishangbu.avalon.game.battle.engine.core.runtime.ActionExecutor
import io.github.lishangbu.avalon.game.battle.engine.core.runtime.ActionResult
import io.github.lishangbu.avalon.game.battle.engine.core.type.ActionTypeId
import io.github.lishangbu.avalon.game.battle.engine.core.type.StandardActionTypeIds

/**
 * `set_relay` 动作执行器。
 *
 * 它不关心当前 relay 的旧类型,只负责直接替换为新值。
 */
class SetRelayActionExecutor : ActionExecutor {
    override val type: ActionTypeId = StandardActionTypeIds.SET_RELAY

    override fun execute(
        action: ActionNode,
        context: EventContext,
    ): ActionResult {
        require(action is SetRelayActionNode) { "Action must be SetRelayActionNode." }
        return ActionResult(relay = action.value)
    }
}