mirror of
https://github.com/motajs/template.git
synced 2026-11-18 18:24:30 +08:00
docs(10-04): write query, final, and calculator docs
- document query effects as new, not built into the engine - add final effect comparison and attack-copy example - explain damage formula, critical conventions, and arithmetic example
This commit is contained in:
1 parent
5528edc70d
commit
e13ebf71ed
3 files changed
+368
No files matched your search
@@ -0,0 +1,79 @@
|
||||
# 最终属性效果
|
||||
|
||||
最终效果(final effect)是构建计算后怪物的最后一个阶段:它只对怪物自身的基础属性做收尾调整,不查询怪物上下文,也不影响其他怪物。它适合实现「只看自己(和勇士)就能决定」的转换,例如坚固、模仿。整体流程见[战斗总览](./combat-overview.md)。
|
||||
|
||||
## 接口
|
||||
|
||||
`IEnemyFinalEffect` 只有两个成员:
|
||||
|
||||
- `priority`:优先级,越高越先执行;
|
||||
- `apply(handler)`:读取 `handler.enemy` 与 `handler.hero`,修改 `handler.enemy` 的基础属性。
|
||||
|
||||
注册方式:
|
||||
|
||||
```ts
|
||||
state.enemyContext.registerFinalEffect(effect);
|
||||
```
|
||||
|
||||
`initializeEnemy` 已经注册了内置的 `MainEnemyFinalEffect`(`src/data/enemy/final.ts`)。它处理两个属性:
|
||||
|
||||
- **坚固(code 3)**:把怪物防御提升到不低于「勇士攻击 - 1」;
|
||||
- **模仿(code 8)**:把怪物攻击与防御设置为勇士的最终攻击与最终防御。
|
||||
|
||||
## 三方对比
|
||||
|
||||
光环、查询、最终效果都在构建计算后怪物时执行,但读取与影响的范围不同:
|
||||
|
||||
| 效果 | 读取其他怪物/上下文 | 影响其他怪物 | 典型用途 |
|
||||
|------|---------------------|--------------|----------|
|
||||
| 光环 | 否(只按范围命中) | 是 | 给周围怪物加属性或特殊属性 |
|
||||
| 查询 | 是 | 否(只改自身) | 抱团、同化、号角 |
|
||||
| 最终 | 否 | 否 | 坚固、模仿、仿攻 |
|
||||
|
||||
最终效果可以读取勇士属性(模仿与仿攻都需要),但不会扫描周围怪物,也不会改变其他怪物。
|
||||
|
||||
## 示例:仿攻
|
||||
|
||||
「仿攻」让怪物的攻击力等于勇士的最终攻击力。仿攻与内置的模仿类似,区别是只改攻击、不改防御:
|
||||
|
||||
```ts
|
||||
// special.ts:32 - 仿攻
|
||||
map.set(
|
||||
32,
|
||||
defineNonePropertySpecial(32, {
|
||||
name: '仿攻',
|
||||
desc: '怪物攻击等于勇士攻击。',
|
||||
color: '#B0C0DD'
|
||||
})
|
||||
);
|
||||
```
|
||||
|
||||
```ts
|
||||
import { IEnemyAttr, IHeroAttr } from '@user/data-common';
|
||||
import { IEnemyFinalEffect, IEnemyHandler } from '@user/data-system';
|
||||
|
||||
export class AttackCopyFinal implements IEnemyFinalEffect<
|
||||
IEnemyAttr,
|
||||
IHeroAttr
|
||||
> {
|
||||
readonly priority = 0;
|
||||
|
||||
apply(handler: IEnemyHandler<IEnemyAttr, IHeroAttr>): void {
|
||||
if (!handler.enemy.hasSpecial(32)) return;
|
||||
handler.enemy.setAttribute(
|
||||
'atk',
|
||||
handler.hero.getFinalAttribute('atk')
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
state.enemyContext.registerFinalEffect(new AttackCopyFinal());
|
||||
```
|
||||
|
||||
`apply` 里直接 `setAttribute`,因为最终阶段拿到的 `handler.enemy` 就是可修改的怪物对象。最终阶段之后不再有别的属性修正,所以这里写进去的值会直接进入伤害计算。
|
||||
|
||||
`priority` 只需要记住一句:数值越大越先执行;内置最终效果的 `priority` 是 `0`。
|
||||
|
||||
## 与伤害计算的分工
|
||||
|
||||
最终效果改的是怪物的基础属性,伤害计算器负责决定「这些属性如何变成伤害与回合数」。如果某个效果只是让怪物攻击更高,优先考虑写成光环、查询或最终效果;只有需要改变公式本身时,才去改[伤害计算](./enemy-calculator.md)。
|
||||
Reference in new issue
Block a user