You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
113 lines
2.9 KiB
113 lines
2.9 KiB
2 weeks ago
|
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;
|
||
|
}
|
||
|
abstract desc(): string;
|
||
|
abstract takeEffect(owner: BattleRole): void;
|
||
|
}
|
||
|
//攻击增益BUFF
|
||
|
export class AtkPercentBuff 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 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;
|
||
|
}
|
||
|
}
|