mirror of
https://github.com/motajs/template.git
synced 2026-09-30 07:20:18 +08:00
fix(07-04): #06-05-1 refresh final attributes without modifiers
- recalculateAttribute writes the base value into finalAttribute when no modifier is attached - un-skip the base-only-change case; catchCalculateProgress is intentionally left untouched
This commit is contained in:
parent
02786047d2
commit
04943416a5
@ -111,8 +111,8 @@ describe('HeroAttribute base and final values', () => {
|
||||
expect(attribute.getFinalAttribute('atk')).toBe(15);
|
||||
});
|
||||
|
||||
// 疑似 bug:无修饰器时 recalculateAttribute 提前返回,基础属性变化不反映到最终属性,详见 06-TEST-FINDINGS.md #06-05-1
|
||||
it.skip('reflects base-only changes without any modifier', () => {
|
||||
// 验证无修饰器时基础属性变化同步反映到最终属性(#06-05-1)
|
||||
it('reflects base-only changes without any modifier', () => {
|
||||
const attribute = createAttribute();
|
||||
attribute.set('hp', 40);
|
||||
attribute.add('hp', 5);
|
||||
|
||||
@ -79,7 +79,11 @@ export class HeroAttribute<THero> implements IHeroAttribute<THero> {
|
||||
*/
|
||||
private recalculateAttribute<K extends keyof THero>(name: K): void {
|
||||
const modifierList = this.modifier.get(name);
|
||||
if (!modifierList) return;
|
||||
if (!modifierList) {
|
||||
// 无修饰器时 final 与 base 保持同值
|
||||
this.finalAttribute[name] = this.attribute[name];
|
||||
return;
|
||||
}
|
||||
|
||||
const baseValue = this.attribute[name];
|
||||
let value = baseValue;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user