Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions docs/en/plugin-development.md
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,46 @@ The normal path no longer triggers a check from keywords in a player's message.

**Multi-language extension**: vocabularies are data-driven. Adding a language only requires adding keys (such as `ja`) to `aliases` / `skill_candidates` and registering the language suffix in `engine/language.py`. New languages do not pollute other languages.

#### 7.2.2 Special-stat initial values and the skill bonus table

Two numeric fields in a rule template fail silently when omitted. Check both before publishing:

**`special_stats[].initial`**

Every `special_stats` entry should declare `initial` explicitly. Without it, the engine initializes the stat to its maximum (`max`):

- Resource pools (mana, qi, stamina) legitimately start full - write `"initial": <max>` to pin that intent.
- Progress bars (KPI, mystery progress, danger meters, countdown starts) **must** declare `initial`. If omitted, the character starts with the progress already full - endings meant to trigger at 100 (promotion, collapse, truth reveal) should fire on round one, and GMs typically won't, leaving the game running from a corrupted initial state.

```json
"special_stats": [
{"key": "mana", "name": "Mana", "max": 100, "initial": 100, "description": "Spent on spells, restored by meditation"},
{"key": "kpi", "name": "KPI", "max": 100, "initial": 42, "description": "Work progress; reaching 100 triggers the ending"}
]
```

`sanity` and `luck` receive dedicated CoC-style initialization from the engine and may omit `initial`.

**`skill_value_to_bonus`**

In d20 rules, skill values only affect checks (`d20 + attribute modifier + skill bonus vs DC`) through this table. Without it the skill bonus is always zero: skill values never change any check result and only inform narration. If skills are a numeric mechanism in your rule, provide the table explicitly or `"extends": "base_d20"` to inherit the built-in default:

```json
"skill_value_to_bonus": {"20": 1, "40": 2, "60": 3, "80": 4}
```

- d100 rules (CoC-style): the skill value itself is the success chance; this table is not used.
- `dice_system: "none"` narrative-only rules have no checks and do not need it.
- Keeping skills purely narrative is a valid design; in that case omit the table on purpose.

**Self-check**: the DiceFrame main repository ships an audit script. Run it over your rule files before publishing:

```bash
python scripts/audit_rules.py --strict
```

Missing `initial` or a missing skill bonus table surface as warnings (advisory by default, failures under `--strict`).

### 7.3 Themes

Themes register JSON through `contributes.theme` or `contributes.themes`. Only theme contract v2 is supported; themes without `"schema_version": 2` are ignored and legacy variables are not mapped.
Expand Down
40 changes: 40 additions & 0 deletions docs/zh/plugin-development.md
Original file line number Diff line number Diff line change
Expand Up @@ -471,6 +471,46 @@ content/

**多语言扩展**:词表是数据驱动的,加语言只需给 `aliases` / `skill_candidates` 增加对应语言键(如 `ja`),并保证 `engine/language.py` 登记了该语言后缀。新增语言不会污染其他语言场景。

#### 7.2.2 特殊属性起点与技能加值表

规则模板里有两个数值字段缺省时不会报错,但会让数值机制静默失效。发布前请逐项确认:

**`special_stats[].initial`(特殊属性初始值)**

`special_stats` 的每个条目都建议显式写 `initial`。不写时引擎会把该属性初始化为满值(`max`):

- 资源池型属性(魔力、内力、体力)开局满值是合理的,写 `"initial": <max>` 把意图固化即可。
- 进度条型属性(KPI、谜团进度、危险度、倒计时起点)**必须**显式写 `initial`。漏写会让角色开局就处于"进度已满"状态--本应到 100 才触发的结局(转正、猝死、真相揭示)在第一轮就该发生,而 GM 往往不会执行,游戏从此带着损坏的初始状态运行。

```json
"special_stats": [
{"key": "mana", "name": "魔力", "max": 100, "initial": 100, "description": "施法消耗,冥想恢复"},
{"key": "kpi", "name": "KPI", "max": 100, "initial": 42, "description": "业绩进度,满 100 触发转正结局"}
]
```

理智(`sanity`)与幸运(`luck`)由引擎按 CoC 规则专门初始化,可不写 `initial`。

**`skill_value_to_bonus`(技能加值表)**

d20 规则中,技能值只有通过这张表才参与检定(`d20 + 属性修正 + 技能加值 vs DC`)。不提供此表时技能加值恒为 0:玩家分配的技能值高低不影响任何检定结果,只影响叙事。如果技能在你的规则里是数值机制的一部分,请显式提供加值表,或 `"extends": "base_d20"` 继承内置默认表:

```json
"skill_value_to_bonus": {"20": 1, "40": 2, "60": 3, "80": 4}
```

- d100 规则(CoC 系)技能值本身就是成功率,不需要此表。
- `dice_system: "none"` 的纯叙事规则没有检定,不需要此表。
- 刻意让技能保持纯叙事也是合法设计,此时无需配置。

**自检**:DiceFrame 主仓库提供规则审计脚本,发布内容包前可对规则文件跑一遍:

```bash
python scripts/audit_rules.py --strict
```

缺少 `initial` 或技能加值表会以警告形式列出(默认不拦截,`--strict` 时视为失败),用于发布前自查。

### 7.3 主题插件

主题插件是声明型插件,适用于色板、字体、圆角和阴影。当前只支持主题契约 v2;未声明 `"schema_version": 2` 的旧主题不会被加载,也不会进行旧变量映射。
Expand Down
Loading