feat: 内置最终效果

This commit is contained in:
AncTe committed 2026-04-15 18:48:59 +08:00
1 parent 0517da5000
commit 63e1a01fab
6 files changed
+55 -15

No files matched your search

+2
View File
@@ -13,6 +13,7 @@ import { IEnemyAttributes } from './enemy/types';
import {
CommonAuraConverter,
GuardAuraConverter,
MainEnemyFinalEffect,
MainMapDamageConverter,
MainMapDamageReducer
} from './enemy';
@@ -44,6 +45,7 @@ export class CoreState implements ICoreState {
enemyContext.attachMapDamage(mapDamage);
enemyContext.registerAuraConverter(new CommonAuraConverter());
enemyContext.registerAuraConverter(new GuardAuraConverter());
enemyContext.registerFinalEffect(new MainEnemyFinalEffect());
enemyContext.resize(core._WIDTH_, core._HEIGHT_);
this.enemyContext = enemyContext;
}
+6 -15
View File
@@ -95,27 +95,18 @@ export class CommonAura implements IEnemyAuraView<
const { hpBuff, atkBuff, defBuff } = this.special.value;
if (hpBuff !== 0) {
enemy.setAttribute(
'hp',
enemy.getAttribute('hp') +
Math.floor((baseEnemy.getAttribute('hp') * hpBuff) / 100)
);
const hpValue = (baseEnemy.getAttribute('hp') * hpBuff) / 100;
enemy.addAttribute('hp', Math.floor(hpValue));
}
if (atkBuff !== 0) {
enemy.setAttribute(
'atk',
enemy.getAttribute('atk') +
Math.floor((baseEnemy.getAttribute('atk') * atkBuff) / 100)
);
const atkValue = (baseEnemy.getAttribute('atk') * atkBuff) / 100;
enemy.addAttribute('atk', Math.floor(atkValue));
}
if (defBuff !== 0) {
enemy.setAttribute(
'def',
enemy.getAttribute('def') +
Math.floor((baseEnemy.getAttribute('def') * defBuff) / 100)
);
const defValue = (baseEnemy.getAttribute('def') * defBuff) / 100;
enemy.addAttribute('def', Math.floor(defValue));
}
}
@@ -0,0 +1,29 @@
import { IEnemy, IEnemyFinalEffect } from '@user/data-base';
import { IEnemyAttributes } from './types';
import { ITileLocator } from '@user/types';
const HERO_STATUS_PLACEHOLDER = {
atk: 0,
def: 0
} as const;
export class MainEnemyFinalEffect implements IEnemyFinalEffect<IEnemyAttributes> {
readonly priority: number = 0;
apply(enemy: IEnemy<IEnemyAttributes>, _locator: ITileLocator): void {
if (enemy.hasSpecial(3)) {
enemy.setAttribute(
'def',
Math.max(
enemy.getAttribute('def'),
HERO_STATUS_PLACEHOLDER.atk - 1
)
);
}
if (enemy.hasSpecial(10)) {
enemy.setAttribute('atk', HERO_STATUS_PLACEHOLDER.atk);
enemy.setAttribute('def', HERO_STATUS_PLACEHOLDER.def);
}
}
}
@@ -1,4 +1,5 @@
export * from './aura';
export * from './damage';
export * from './final';
export * from './mapDamage';
export * from './special';