EventContextAttributeReader

EventContext.attributes 的轻量类型化读取器。

设计意图:

  • Map<String, Any?> 上常见的字符串、布尔值、数值、Map 读取逻辑集中到一处;

  • 避免条件解释器和动作执行器到处手写 as?toString()、字符串数值解析;

  • 为 battle attribute key 常量化之后的“按类型读取”提供统一入口。

说明:

  • 这里只处理 battle 引擎执行期最常见的几类读取,不做重量级 schema 校验;

  • 对于布尔值,兼容 BooleanString("true"/"false")Number(0/非0) 三类输入;

  • 对于数值,兼容 Number 与可解析的字符串;

  • 读取失败时返回 null,由调用方决定是否提供默认值。

Functions

Link copied to clipboard
fun readBoolean(key: String, context: EventContext): Boolean?
fun readBoolean(key: String, attributes: Map<String, Any?>): Boolean?
Link copied to clipboard
fun readDouble(key: String, context: EventContext): Double?
fun readDouble(key: String, attributes: Map<String, Any?>): Double?
Link copied to clipboard
fun readInt(key: String, context: EventContext): Int?
fun readInt(key: String, attributes: Map<String, Any?>): Int?
Link copied to clipboard
fun readMap(key: String, context: EventContext): Map<*, *>?
fun readMap(key: String, attributes: Map<String, Any?>): Map<*, *>?
Link copied to clipboard
fun readString(key: String, context: EventContext): String?
fun readString(key: String, attributes: Map<String, Any?>): String?