ChanceRollReader.kt

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

import io.github.lishangbu.avalon.game.battle.engine.core.constant.BattleAttributeKeys
import io.github.lishangbu.avalon.game.battle.engine.core.event.EventContext

/**
 * 概率判定辅助组件。
 *
 * 当前实现从 EventContext.attributes 中读取 `chanceRoll`。
 */
object ChanceRollReader {
    fun read(context: EventContext): Int =
        EventContextAttributeReader.readInt(BattleAttributeKeys.CHANCE_ROLL, context)
            ?: error("EventContext.attributes['${BattleAttributeKeys.CHANCE_ROLL}'] is required for chance evaluation.")
}