|
|
|
|
import { BattleRole, callDmgPercent, callDmgReduc, callReducPercent, replace } from '@/tool';
|
|
|
|
|
import i18n from '../i18n';
|
|
|
|
|
const { t } = i18n;
|
|
|
|
|
|
|
|
|
|
//BUFF
|
|
|
|
|
export abstract class Buff {
|
|
|
|
|
order: number = 1;
|
|
|
|
|
abstract type: string;
|
|
|
|
|
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 AttackBuff extends Buff {
|
|
|
|
|
type: string = 'attackBuff';
|
|
|
|
|
}
|
|
|
|
|
//被攻击时触发的BUFF
|
|
|
|
|
export abstract class AttackedBuff extends Buff {
|
|
|
|
|
type: string = 'attackedBuff';
|
|
|
|
|
}
|
|
|
|
|
///攻击时触发的百分比BUFF
|
|
|
|
|
export abstract class PercentAttackBuff extends AttackBuff {
|
|
|
|
|
percent: number;
|
|
|
|
|
constructor(name: string, percent: number, last: number, maxLayer?: number) {
|
|
|
|
|
super(name, last, maxLayer);
|
|
|
|
|
this.percent = percent;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//被攻击时触发的百分比BUFF
|
|
|
|
|
export abstract class PercentAttackedBuff extends AttackedBuff {
|
|
|
|
|
percent: number;
|
|
|
|
|
constructor(name: string, percent: number, last: number, maxLayer?: number) {
|
|
|
|
|
super(name, last, maxLayer);
|
|
|
|
|
this.percent = percent;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//被攻击时触发的固定数值BUFF
|
|
|
|
|
export abstract class ConstantAttackBuff extends AttackedBuff {
|
|
|
|
|
number: number;
|
|
|
|
|
constructor(name: string, number: number, last: number, maxLayer?: number) {
|
|
|
|
|
super(name, last, maxLayer);
|
|
|
|
|
this.number = number;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//被攻击时触发的固定数值BUFF
|
|
|
|
|
export abstract class ConstantAttackedBuff extends AttackedBuff {
|
|
|
|
|
number: number;
|
|
|
|
|
constructor(name: string, number: number, last: number, maxLayer?: number) {
|
|
|
|
|
super(name, last, maxLayer);
|
|
|
|
|
this.number = number;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//伤害加成增减益BUFF
|
|
|
|
|
export class DmgPercentBuff extends PercentAttackBuff {
|
|
|
|
|
desc(): string {
|
|
|
|
|
return replace(t('skill.atkbuff.3'), [this.percent * this.layer]);
|
|
|
|
|
}
|
|
|
|
|
takeEffect(owner: BattleRole): void {
|
|
|
|
|
owner.extraAttr.dmgPercent = callDmgPercent(owner.extraAttr.dmgPercent, this.percent);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//基础攻击百分比增减益BUFF
|
|
|
|
|
export class BaseAtkPercentBuff extends PercentAttackBuff {
|
|
|
|
|
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 PercentAttackBuff {
|
|
|
|
|
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 PercentAttackBuff {
|
|
|
|
|
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 PercentAttackedBuff {
|
|
|
|
|
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 PercentAttackedBuff {
|
|
|
|
|
desc(): string {
|
|
|
|
|
return replace(t('skill.defbuff.2'), [this.percent * this.layer]);
|
|
|
|
|
}
|
|
|
|
|
takeEffect(owner: BattleRole): void {
|
|
|
|
|
owner.extraAttr.dmgReduc = callDmgReduc(owner.extraAttr.dmgReduc, this.percent);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//格挡百分比增减益BUFF
|
|
|
|
|
export class BlocPercentBuff extends PercentAttackedBuff {
|
|
|
|
|
desc(): string {
|
|
|
|
|
return replace(t('skill.blocbuff.2'), [this.percent * this.layer]);
|
|
|
|
|
}
|
|
|
|
|
takeEffect(owner: BattleRole): void {
|
|
|
|
|
owner.extraAttr.bloc += Math.ceil((owner.attr.bloc * this.percent) / 100);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//承受伤害增加或减少BUFF
|
|
|
|
|
export class MoreBearBuff extends PercentAttackedBuff {
|
|
|
|
|
desc(): string {
|
|
|
|
|
return replace(t('skill.defbuff.2'), [this.percent * this.layer]);
|
|
|
|
|
}
|
|
|
|
|
takeEffect(owner: BattleRole): void {
|
|
|
|
|
owner.moreBear = callDmgPercent(owner.moreBear, this.percent);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//控制异常
|
|
|
|
|
export class ControlBuff extends AttackBuff {
|
|
|
|
|
constructor(name: string, last: number) {
|
|
|
|
|
super(name, last);
|
|
|
|
|
}
|
|
|
|
|
desc(): string {
|
|
|
|
|
return t('skill.' + this.name + '.0');
|
|
|
|
|
}
|
|
|
|
|
takeEffect(owner: BattleRole): void {
|
|
|
|
|
owner.action = null;
|
|
|
|
|
owner.debuffLog(replace(t('skill.control.2'), [t('skill.' + this.name + '.0'), t(owner.type)]));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//溃烂
|
|
|
|
|
export class KuiLan extends PercentAttackedBuff {
|
|
|
|
|
constructor(name: string, last: number) {
|
|
|
|
|
super(name, 10, last, 6);
|
|
|
|
|
}
|
|
|
|
|
desc(): string {
|
|
|
|
|
return replace(t('skill.kongbulingyu.2'), [this.percent]);
|
|
|
|
|
}
|
|
|
|
|
takeEffect(owner: BattleRole): void {
|
|
|
|
|
owner.extraAttr.def += owner.attr.def * ((this.percent * this.layer) / -100);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//恐怖领域
|
|
|
|
|
export class KBLYDebuff extends ConstantAttackedBuff {
|
|
|
|
|
desc(): string {
|
|
|
|
|
return replace(t('skill.kongbulingyu.2'), [this.number]);
|
|
|
|
|
}
|
|
|
|
|
takeEffect(owner: BattleRole): void {
|
|
|
|
|
owner.extraAttr.def -= this.number;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//灵感
|
|
|
|
|
export class LingGanBuff extends PercentAttackBuff {
|
|
|
|
|
desc(): string {
|
|
|
|
|
return replace(t('skill.linggan.1'), [this.percent]);
|
|
|
|
|
}
|
|
|
|
|
takeEffect(owner: BattleRole): void {
|
|
|
|
|
owner.addHp(Math.ceil(owner.attr.hp * (this.percent / 100)));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//流血
|
|
|
|
|
export class LiuXue extends AttackBuff {
|
|
|
|
|
percent: number = 2;
|
|
|
|
|
maxLayer: number = 10;
|
|
|
|
|
constructor(layer: number, last: number) {
|
|
|
|
|
super('liuxue', last);
|
|
|
|
|
this.layer = layer > this.maxLayer ? this.maxLayer : layer;
|
|
|
|
|
}
|
|
|
|
|
desc(): string {
|
|
|
|
|
return replace(t('skill.liuxue.0'), [this.percent]);
|
|
|
|
|
}
|
|
|
|
|
takeEffect(owner: BattleRole): void {
|
|
|
|
|
const reducPercent = callReducPercent(owner.attr.def + owner.extraAttr.def, owner.attr.lv); //目标防御提供的减伤比例
|
|
|
|
|
const dmg = Math.ceil(owner.attr.curHp * (this.percent / 100) * this.layer * (1 - reducPercent) * (1 + owner.moreBear / 100));
|
|
|
|
|
owner.addHp(-1 * dmg);
|
|
|
|
|
owner.debuffLog(replace(t('skill.liuxue.1'), [this.layer, t(owner.type), dmg]));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//感电
|
|
|
|
|
export class GanDian extends MoreBearBuff {
|
|
|
|
|
constructor(last: number) {
|
|
|
|
|
super('gandian', -50, last);
|
|
|
|
|
}
|
|
|
|
|
}
|