WeatherIsConditionInterpreter.kt

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

import io.github.lishangbu.avalon.game.battle.engine.core.dsl.ConditionNode
import io.github.lishangbu.avalon.game.battle.engine.core.dsl.condition.WeatherIsConditionNode
import io.github.lishangbu.avalon.game.battle.engine.core.event.EventContext
import io.github.lishangbu.avalon.game.battle.engine.core.runtime.ConditionInterpreter
import io.github.lishangbu.avalon.game.battle.engine.core.type.ConditionTypeId
import io.github.lishangbu.avalon.game.battle.engine.core.type.StandardConditionTypeIds

/**
 * `weather_is` 条件解释器。
 */
class WeatherIsConditionInterpreter : ConditionInterpreter {
    override val type: ConditionTypeId = StandardConditionTypeIds.WEATHER_IS

    override fun evaluate(
        condition: ConditionNode,
        context: EventContext,
    ): Boolean {
        require(condition is WeatherIsConditionNode) { "Condition must be WeatherIsConditionNode." }
        return context.field?.weatherState?.effectId == condition.value
    }
}