|
|
|
import { BattleRole, callDmgReduc, replace } from '@/tool';
|
|
|
|
import i18n from '../i18n';
|
|
|
|
const { t } = i18n;
|
|
|
|
|
|
|
|
//增益BUFF
|
|
|
|
export abstract class Buff {
|
|
|
|
order: number = 1;
|
|
|
|
type: string = 'buff';
|
|
|
|
name: string;
|
|
|
|
layer: number = 1;
|
|
|
|
maxLayer: number = 1;
|
|
|
|
last: number;
|
|
|
|
|
|
|
|
constructor(name: string, last: number, maxLayer?: number) {
|
|
|
|
this.name = name;
|
|
|
|
this.last = last;
|
|
|
|
this.maxLayer = maxLayer || 1;
|
|
|
|
}
|
|
|
|
abstract desc(): string;
|
|
|
|
check(): boolean {
|
|
|
|
if (this.layer <= 0) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if (this.last > 0) {
|
|
|
|
this.last--;
|
|
|
|
}
|
|
|
|
return this.last > 0;
|
|
|
|
}
|
|
|
|
addLayer(add: number) {
|
|
|
|
const n = this.layer + add;
|
|
|
|
if (n > this.maxLayer) {
|
|
|
|
this.layer = this.maxLayer;
|
|
|
|
} else if (n < 0) {
|
|
|
|
this.layer = 0;
|
|
|
|
} else {
|
|
|
|
this.layer = n;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
abstract takeEffect(owner: BattleRole): void;
|
|
|
|
}
|
|
|
|
//减益BUFF
|
|
|
|
export abstract class Debuff extends Buff {
|
|
|
|
type: string = 'debuff';
|
|
|
|
}
|
|
|
|
//异常
|
|
|
|
export abstract class Abnormal extends Buff {
|
|
|
|
type: string = 'abnormal';
|
|
|
|
}
|
|
|
|
//百分比增益BUFF
|
|
|
|
export abstract class PercentBuff extends Buff {
|
|
|
|
percent: number;
|
|
|
|
constructor(name: string, percent: number, last: number, maxLayer?: number) {
|
|
|
|
super(name, last, maxLayer);
|
|
|
|
this.percent = percent;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//百分比减益DEBUFF
|
|
|
|
export abstract class PercentDebuff extends Debuff {
|
|
|
|
percent: number;
|
|
|
|
constructor(name: string, percent: number, last: number, maxLayer?: number) {
|
|
|
|
super(name, last, maxLayer);
|
|
|
|
this.percent = percent;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//固定数值减益DEBUFF
|
|
|
|
export abstract class ConstantDebuff extends Debuff {
|
|
|
|
number: number;
|
|
|
|
constructor(name: string, number: number, last: number, maxLayer?: number) {
|
|
|
|
super(name, last, maxLayer);
|
|
|
|
this.number = number;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//基础攻击百分比增益BUFF
|
|
|
|
export class BaseAtkPercentBuff extends PercentBuff {
|
|
|
|
desc(): string {
|
|
|
|
return replace(t('skill.atkbuff.1'), [this.percent * this.layer]);
|
|
|
|
}
|
|
|
|
takeEffect(owner: BattleRole): void {
|
|
|
|
owner.extraAttr.baseAtk += (this.percent / 100) * this.layer * owner.attr.baseAtk;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//攻击加成增益BUFF
|
|
|
|
export class AtkPercentBuff extends PercentBuff {
|
|
|
|
desc(): string {
|
|
|
|
return replace(t('skill.atkbuff.2'), [this.percent * this.layer]);
|
|
|
|
}
|
|
|
|
takeEffect(owner: BattleRole): void {
|
|
|
|
owner.extraAttr.atkPercent += this.percent;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//爆伤增益BUFF
|
|
|
|
export class CritDmgBuff extends PercentBuff {
|
|
|
|
desc(): string {
|
|
|
|
return replace(t('skill.critbuff.1'), [this.percent * this.layer]);
|
|
|
|
}
|
|
|
|
takeEffect(owner: BattleRole): void {
|
|
|
|
owner.extraAttr.critDmg += this.percent * this.layer;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//爆伤减免增益BUFF
|
|
|
|
export class CritDmgReducBuff extends PercentBuff {
|
|
|
|
desc(): string {
|
|
|
|
return replace(t('skill.critbuff.3'), [this.percent * this.layer]);
|
|
|
|
}
|
|
|
|
takeEffect(owner: BattleRole): void {
|
|
|
|
owner.extraAttr.critDmgReduc += this.percent * this.layer;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//伤害减免增益BUFF
|
|
|
|
export class DmgReducBuff extends Buff {
|
|
|
|
dmgReduc: number;
|
|
|
|
constructor(name: string, dmgReduc: number, last: number, maxLayer?: number) {
|
|
|
|
super(name, last, maxLayer);
|
|
|
|
this.dmgReduc = dmgReduc;
|
|
|
|
}
|
|
|
|
desc(): string {
|
|
|
|
return replace(t('skill.defbuff.2'), [this.dmgReduc * this.layer]);
|
|
|
|
}
|
|
|
|
takeEffect(owner: BattleRole): void {
|
|
|
|
owner.extraAttr.dmgReduc = callDmgReduc(owner.extraAttr.dmgReduc, this.dmgReduc);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//控制异常
|
|
|
|
export class ControlAbnormal extends Abnormal {
|
|
|
|
constructor(name: string, last: number) {
|
|
|
|
super(name, last);
|
|
|
|
}
|
|
|
|
desc(): string {
|
|
|
|
return t('skill.' + this.name + '.0');
|
|
|
|
}
|
|
|
|
takeEffect(owner: BattleRole): void {
|
|
|
|
owner.action = null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//溃烂
|
|
|
|
export class KuiLan extends PercentDebuff {
|
|
|
|
desc(): string {
|
|
|
|
return replace(t('skill.kongbulingyu.2'), [this.percent]);
|
|
|
|
}
|
|
|
|
takeEffect(owner: BattleRole): void {
|
|
|
|
owner.extraAttr.def += owner.attr.def * (this.percent / -100);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//恐怖领域
|
|
|
|
export class KBLYDebuff extends ConstantDebuff {
|
|
|
|
desc(): string {
|
|
|
|
return replace(t('skill.kongbulingyu.2'), [this.number]);
|
|
|
|
}
|
|
|
|
takeEffect(owner: BattleRole): void {
|
|
|
|
owner.extraAttr.def -= this.number;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//灵感
|
|
|
|
export class LingGanBuff extends PercentBuff {
|
|
|
|
desc(): string {
|
|
|
|
return replace(t('skill.linggan.1'), [this.percent]);
|
|
|
|
}
|
|
|
|
takeEffect(owner: BattleRole): void {
|
|
|
|
owner.addHp(Math.ceil(owner.attr.hp * (this.percent / 100)));
|
|
|
|
}
|
|
|
|
}
|