feat: add stat-modifiers role for automatic stat generation
Introduces a new `stat-modifiers` CSV role that simplifies the creation of template stats and their associated modifier stats. A single CSV block now automatically generates: - A template stat definition. - Multiple modifier stat definitions (prefixed with the template ID). - The corresponding template table. This reduces the need for manual YAML definitions for every modifier associated with a template.
This commit is contained in:
@@ -239,42 +239,71 @@ CSV 列说明:
|
||||
|
||||
模板属性用于查表掷骰(年龄表、职业表等)。
|
||||
|
||||
**第一步:定义模板表**
|
||||
### 方式一:stat-modifiers(推荐)
|
||||
|
||||
```csv id=年龄 role=stat-template
|
||||
1d10,label,heart,mind,strength,speed
|
||||
1-3,青少年,+20,-10,,
|
||||
一个代码块同时生成模板 stat 和修饰符 stat defs:
|
||||
|
||||
```csv id=年龄 role=stat-modifiers
|
||||
1d10,label,mind,heart,strength,speed
|
||||
1-3,青少年,-10,+20,,
|
||||
4-7,成年,,-10,,+20
|
||||
8-9,老年,,+20,-10,
|
||||
10,换躯者,,,+30,-10
|
||||
```
|
||||
|
||||
- **第一列(header)**:骰子表达式,如 `1d10`
|
||||
- **第一列(rows)**:匹配范围,`1-3`(区间)、`4`(精确)、`1-3,5`(多个)
|
||||
- **`label`**:显示名称
|
||||
- **其余列**:修饰符键名,值为变化量(`+`加、`-`减、空不修改)
|
||||
这会自动生成:
|
||||
- `age`(type: template, template: 年龄)
|
||||
- `age_mind`(type: modifier, target: mind)
|
||||
- `age_heart`(type: modifier, target: heart)
|
||||
- `age_strength`(type: modifier, target: strength)
|
||||
- `age_speed`(type: modifier, target: speed)
|
||||
|
||||
**第二步:引用模板**
|
||||
修饰符键名规则:`{id}_{列名}`,目标为列名本身。
|
||||
|
||||
### 方式二:手动定义
|
||||
|
||||
分别定义模板表和修饰符 stat:
|
||||
|
||||
```csv id=年龄 role=stat-template
|
||||
1d10,label,age_mind,age_heart,age_strength,age_speed
|
||||
1-3,青少年,-10,+20,,
|
||||
4-7,成年,,-10,,+20
|
||||
8-9,老年,,+20,-10,
|
||||
10,换躯者,,,+30,-10
|
||||
```
|
||||
|
||||
```yaml role=stat
|
||||
- key: age_mind
|
||||
type: modifier
|
||||
target: mind
|
||||
- key: age_heart
|
||||
type: modifier
|
||||
target: heart
|
||||
- key: age
|
||||
scope: player
|
||||
label: 年龄
|
||||
type: template
|
||||
template: 年龄
|
||||
```
|
||||
|
||||
**第三步:掷骰或直接设置**
|
||||
### 使用
|
||||
|
||||
### 使用
|
||||
|
||||
- `/stat roll age` — 掷 `1d10`,匹配范围,应用修饰符
|
||||
- `/stat set age=换躯者` — 直接设置,同样应用修饰符
|
||||
|
||||
`/stat roll age` 或 `/stat set age=青少年` 时:
|
||||
1. 发布 `set age=青少年`
|
||||
2. 同时发布 `set alice:heart=52`(原始值 +20)、`set alice:mind=22`(-10)
|
||||
2. 同时发布 `set alice:age_mind=-10`、`set alice:age_heart=+20` 等
|
||||
|
||||
修饰符值中的 `+`/`-` 前缀表示相对调整,基于当前值计算。
|
||||
|
||||
### 模板表语法
|
||||
|
||||
- **第一列(header)**:骰子表达式,如 `1d10`
|
||||
- **第一列(rows)**:匹配范围,`1-3`(区间)、`4`(精确)、`1-3,5`(多个)
|
||||
- **`label`**:显示名称
|
||||
- **其余列**:修饰符键名,值为变化量(`+`加、`-`减、空不修改)
|
||||
|
||||
## 掷骰公式中的属性引用
|
||||
|
||||
`roll` 字段中的标识符自动替换为当前属性值:
|
||||
|
||||
Reference in New Issue
Block a user