522 lines
12 KiB
TypeScript
522 lines
12 KiB
TypeScript
import { PetHandler } from "../Handler/PetHandler";
|
|
import TriggerManager from "./TriggerMan";
|
|
|
|
let con = require('constant');
|
|
|
|
let SK_TYPE = con.SKILL_TYPE;
|
|
let TG_TYPE = con.TRIGGER_TYPE;
|
|
|
|
export class Skill {
|
|
_currCount: number;
|
|
_roundCount: number;
|
|
_startround: number;
|
|
_delayround: number;
|
|
_movegrid: number;
|
|
_visiongrid: number;
|
|
_id: number;
|
|
_data: any;
|
|
_type: any;
|
|
_show_effect: any[];
|
|
_params: any;
|
|
_tgctrl: any;
|
|
_condv: any;
|
|
_condv2: any;
|
|
_maxvalue: any;
|
|
_man: any;
|
|
_splashinfo: {};
|
|
_owner: PetHandler;
|
|
attr_value: any;
|
|
groupattr_value: any;
|
|
_aclst: any;
|
|
_skill1pr: any;
|
|
_skill2pr: any;
|
|
start: any;
|
|
_start: boolean;
|
|
_cb: any;
|
|
atk_attr: any;
|
|
_tmp: any;
|
|
atk_type: any;
|
|
atk_value: any;
|
|
atk_count: any;
|
|
_attrmap: any;
|
|
wudi: any;
|
|
_need_disappear: boolean;
|
|
_atkfirst: any;
|
|
_no_move: any;
|
|
_no_atk: any;
|
|
_no_atkback: any;
|
|
_hide: any;
|
|
_imm_ph: any;
|
|
_imm_magic: any;
|
|
_immeffid: number;
|
|
_immlst: any;
|
|
_acrp: any;
|
|
attr: any;
|
|
groupattr: any;
|
|
// LIFE-CYCLE CALLBACKS:
|
|
|
|
// onLoad () {};
|
|
|
|
// start () {};
|
|
|
|
// update (dt) {};
|
|
|
|
init(skillid: number, skilldata: any, manager: any) {
|
|
this._currCount = 0; // 当前计数
|
|
this._roundCount = 0; // 回合数
|
|
this._startround = 0; // 触发后回合数
|
|
this._delayround = 0; // 延迟回合数
|
|
this._movegrid = 0;
|
|
this._visiongrid = 0;
|
|
this._id = skillid;
|
|
this._data = skilldata;
|
|
this._type = skilldata.effec_id;
|
|
this._show_effect = this.initSkillShowEffectData();
|
|
// todo: 根据bufftype处理paramlst
|
|
this._params = TriggerManager.handleEffectParam(this._type, skilldata.effec_valu);
|
|
this._tgctrl = TriggerManager.addSkillTrigger(this._id, skilldata.triggerType, skilldata.condType, skilldata.condition_valu);
|
|
|
|
if (this._params.length > 4) {
|
|
this._maxvalue = this._params[4];
|
|
}
|
|
this._man = manager;
|
|
};
|
|
|
|
initSkillShowEffectData() {
|
|
//0: "3,0,1,1,1,1"
|
|
let _show_effect = [];
|
|
for (let i = 0; i < this._data.show_effect.length; i++) {
|
|
let effect = this._data.show_effect[i].split(',');
|
|
if (effect == '') {
|
|
continue;
|
|
}
|
|
let tmp = {
|
|
'times': Number(effect[0]),
|
|
'fight_type': Number(effect[1]),
|
|
'delay': Number(effect[2]),
|
|
'trigger': Number(effect[3]),
|
|
'effect': Number(effect[4]),
|
|
'loop': Number(effect[5]),
|
|
'speed': Number(effect[6]),
|
|
'data': this._data,
|
|
'sound': effect.length > 7? ''+effect[7]: ''
|
|
}
|
|
_show_effect.push(tmp);
|
|
}
|
|
return _show_effect;
|
|
};
|
|
|
|
triggerType() {
|
|
return this._data.trigger_id;
|
|
};
|
|
|
|
skillname() {
|
|
return this._data.name;
|
|
};
|
|
|
|
icon() {
|
|
return this._data.icon ? this._data.icon : '';
|
|
};
|
|
|
|
clear() {
|
|
this._id = 0;
|
|
this._data = null;
|
|
};
|
|
|
|
removeSelf() {
|
|
|
|
};
|
|
|
|
isSkill() {
|
|
return true;
|
|
};
|
|
|
|
// 是否是稀有技能
|
|
isRareSkill() {
|
|
return this._data && (this._data.is_sp == 1);
|
|
};
|
|
|
|
// 是否是位移技能
|
|
isMapSkill() {
|
|
return false; //this._type == SK_TYPE.DASH_ATK || this._type == SK_TYPE.BACK_ATK;
|
|
};
|
|
|
|
// 是否是获得即起效技能
|
|
isIMMSkill() {
|
|
return this._data && (this._data.trigger_id == TG_TYPE.IMM);
|
|
};
|
|
|
|
// 是否是抢先攻击技能
|
|
isDefFirstSkill() {
|
|
return this._data && (this._type == SK_TYPE.ATK_FIRST);
|
|
};
|
|
|
|
canComposition() {
|
|
return this._data.is_composition == 1;
|
|
};
|
|
|
|
// 割草技能溅射相关
|
|
splashInfo() {
|
|
return this._splashinfo;
|
|
};
|
|
|
|
trigger(param: any) {
|
|
//触发buff效果
|
|
let bok = TriggerManager.onTrigger(this, param);
|
|
|
|
this._currCount++;
|
|
|
|
if (!this.start) {
|
|
this._start = true;
|
|
}
|
|
|
|
this._cb && this._cb(this, param, bok);
|
|
|
|
this._man && this._man.onSkillTrigger(this, param, bok);
|
|
};
|
|
|
|
checkTrigger(tg_type: any, tg_value: any, tg_target: any, cb: any) {
|
|
if (tg_type == TG_TYPE.MYGROUPROUND_START) {
|
|
this._roundCount++;
|
|
if (this._start) {
|
|
this._startround++;
|
|
}
|
|
}
|
|
this._tgctrl.checkTrigger(tg_type, tg_value, this._condv, this._owner, () => {
|
|
cb && cb(this);
|
|
this.trigger(tg_target);
|
|
});
|
|
};
|
|
|
|
setOwner(owner: PetHandler) {
|
|
this._owner = owner;
|
|
};
|
|
|
|
setTriggerCallback(cb: any) {
|
|
this._cb = cb;
|
|
};
|
|
|
|
isOver() {
|
|
return false;
|
|
};
|
|
|
|
isSame(id: number) {
|
|
return this._id == id;
|
|
};
|
|
|
|
// 获取攻击属性
|
|
getAtkAttr() {
|
|
let n = this.atk_attr ? this.atk_attr : 0;
|
|
if (this._tmp) {
|
|
this.atk_attr = 0;
|
|
}
|
|
return n;
|
|
};
|
|
|
|
// 获取攻击类型
|
|
getAtkType() {
|
|
return this.atk_type ? this.atk_type : 0;
|
|
};
|
|
|
|
// 获取攻击力加值
|
|
getAtkValue() {
|
|
return this.atk_value ? this.atk_value : 0;
|
|
};
|
|
|
|
// 获取连续攻击次数
|
|
getAtkCount() {
|
|
let res = this.atk_count ? this.atk_count : 0;
|
|
this.atk_count = 0;
|
|
return res;
|
|
};
|
|
|
|
// 获取属性加值
|
|
getAttrValue(typestr: string) {
|
|
if (!this._attrmap) {
|
|
this._attrmap = {};
|
|
}
|
|
let v = this._attrmap[typestr];
|
|
if (v && (this._startround >= this._delayround)) {
|
|
if (this._tmp) {
|
|
this._attrmap[typestr] = 0;
|
|
}
|
|
return v;
|
|
}
|
|
return 0;
|
|
};
|
|
|
|
// 获取是否无敌
|
|
getInvincible() {
|
|
let bwudi = this.wudi;
|
|
if (this._tmp) {
|
|
this.wudi = false;
|
|
}
|
|
return bwudi;
|
|
};
|
|
|
|
// 获取是否需要消失
|
|
getDisappear() {
|
|
return this._need_disappear && (this._startround >= this._delayround);
|
|
};
|
|
|
|
// 获取是否先出手
|
|
getAtkFirst() {
|
|
let bok = this._atkfirst;
|
|
if (this._tmp) {
|
|
this._atkfirst = false;
|
|
}
|
|
return bok;
|
|
};
|
|
|
|
canMove() {
|
|
return !this._no_move;
|
|
};
|
|
|
|
canAtk() {
|
|
return !this._no_atk;
|
|
};
|
|
|
|
canAtkBack() {
|
|
return !this._no_atkback;
|
|
};
|
|
|
|
isHide() {
|
|
return this._hide;
|
|
};
|
|
|
|
// 物理免疫
|
|
isImmPH() {
|
|
return this._imm_ph;
|
|
};
|
|
|
|
// 魔法免疫
|
|
isImmMagic() {
|
|
return this._imm_magic;
|
|
};
|
|
|
|
// 技能免疫
|
|
isImmSkill(effectid: number) {
|
|
return this._immeffid && (this._immeffid == effectid);
|
|
};
|
|
|
|
// buff免疫
|
|
isImmBuff(buffid: number) {
|
|
if (!this._immlst) {
|
|
return false;
|
|
}
|
|
return this._immlst.includes(buffid);
|
|
};
|
|
|
|
// 获取增加的移动力
|
|
getMoveGrid() {
|
|
return this._movegrid;
|
|
};
|
|
|
|
// 获取增加的视野
|
|
getVisionGrid() {
|
|
return this._visiongrid;
|
|
};
|
|
|
|
// 设置攻击属性
|
|
setAtkAttr(attr_type: any) {
|
|
this.atk_attr = attr_type;
|
|
};
|
|
|
|
setTempAtkAttr(attr_type: any) {
|
|
this.atk_attr = attr_type;
|
|
this._tmp = true;
|
|
};
|
|
|
|
// 设置攻击类型
|
|
setAtkType(atk_type: any) {
|
|
this.atk_type = atk_type;
|
|
};
|
|
|
|
// 设置连续攻击次数
|
|
setAtkCount(value: number) {
|
|
if (this.canComposition()) {
|
|
this.atk_count ? (this.atk_count += value) : (this.atk_count = value);
|
|
if (typeof (this._maxvalue) == 'number') {
|
|
if ((value > 0 && this.atk_count > this._maxvalue) || (value < 0 && this.atk_count < this._maxvalue)) {
|
|
this.atk_count = this._maxvalue;
|
|
}
|
|
}
|
|
} else {
|
|
this.atk_count = value;
|
|
}
|
|
};
|
|
|
|
addGroupAttr(attrstr: string, value: number) {
|
|
this._owner.addGroupAttr(attrstr, value);
|
|
this.groupattr_value = value;
|
|
};
|
|
|
|
// 是否是团队加属性技能
|
|
isGroupAttrSkill() {
|
|
if (this.groupattr) {
|
|
return true;
|
|
}
|
|
return false;
|
|
};
|
|
|
|
// 增加属性
|
|
addAttr(attrstr: string, value: number) {
|
|
// if(!this._attrmap){
|
|
// this._attrmap = {};
|
|
// }
|
|
// this._tmp = btemp;
|
|
// let n = this._attrmap[attrstr];
|
|
// if(n){
|
|
// this._attrmap[attrstr] = n + value;
|
|
// }else{
|
|
// this._attrmap[attrstr] = value;
|
|
// }
|
|
|
|
// this._delayround = delaycount? delaycount: 0;
|
|
this._owner.addAttr(attrstr, value, this);
|
|
};
|
|
|
|
// 是否是加属性技能
|
|
isAttrSkill() {
|
|
if (this.attr) {
|
|
return true;
|
|
}
|
|
return false;
|
|
};
|
|
|
|
isDelAttr() {
|
|
return this.attr_value < 0;
|
|
};
|
|
|
|
isAddAttr() {
|
|
return this.attr_value > 0;
|
|
};
|
|
|
|
getLastAttr() {
|
|
return this.attr;
|
|
};
|
|
|
|
getLastAttrValue() {
|
|
return 0;
|
|
};
|
|
|
|
// 设置是否无敌
|
|
setInvincible(bInv: boolean) {
|
|
this.wudi = bInv;
|
|
this._tmp = true;
|
|
};
|
|
|
|
// 设置存在回合数(到达次数后消失)
|
|
setExistRound(count: number) {
|
|
this._delayround = count;
|
|
this._need_disappear = true;
|
|
};
|
|
|
|
// 设置不能移动
|
|
setNoMove() {
|
|
this._no_move = true;
|
|
};
|
|
|
|
getNoMove() {
|
|
return this._no_move;
|
|
};
|
|
|
|
// 设置不能攻击
|
|
setNoAtk() {
|
|
this._no_atk = true;
|
|
};
|
|
|
|
getNoAtk() {
|
|
return this._no_atk;
|
|
};
|
|
|
|
// 设置不能还击
|
|
setNoAtkBack() {
|
|
this._no_atkback = true;
|
|
};
|
|
|
|
getNoAtkBack() {
|
|
return this._no_atkback;
|
|
};
|
|
|
|
// 设置隐身属性
|
|
setHide() {
|
|
this._hide = true;
|
|
};
|
|
|
|
// 设置是否先出手
|
|
setTempAtkFirst() {
|
|
this._atkfirst = true;
|
|
this._tmp = true;
|
|
};
|
|
|
|
// 物理免疫
|
|
setPhImm() {
|
|
this._imm_ph = true;
|
|
};
|
|
|
|
// 魔法免疫
|
|
setMagicImm() {
|
|
this._imm_magic = true;
|
|
};
|
|
|
|
setSkillImm(effectid: number) {
|
|
this._immeffid = effectid;
|
|
};
|
|
|
|
setBuffImm(bufflst: any[]) {
|
|
if (!this._immlst) {
|
|
this._immlst = [];
|
|
}
|
|
if (!this.canComposition()) {
|
|
this._immlst.length = 0;
|
|
}
|
|
let nmax = bufflst.length;
|
|
// if(typeof(this._maxvalue) == 'number'){
|
|
// if(nmax + this._immlst.length > this._maxvalue){
|
|
// nmax = this._maxvalue - this._immlst.length;
|
|
// }
|
|
// }
|
|
// 【2020.09.08】策划要求不限制
|
|
for (let i = 0; i < nmax; i++) {
|
|
if (!Number(bufflst[i])) {
|
|
break;
|
|
}
|
|
this._immlst.push(Number(bufflst[i]));
|
|
}
|
|
};
|
|
|
|
getMPReduce() {
|
|
return this._acrp ? this._acrp : 0;
|
|
};
|
|
|
|
setMPReduce(rper: number) {
|
|
this._acrp = rper;
|
|
};
|
|
|
|
clone() {
|
|
let obj = new Skill();
|
|
obj._currCount = 0; // 当前计数
|
|
obj._roundCount = 0; // 回合数
|
|
obj._startround = 0; // 触发后回合数
|
|
obj._delayround = 0; // 延迟回合数
|
|
obj._movegrid = 0;
|
|
obj._visiongrid = 0;
|
|
obj._id = this._id;
|
|
obj._data = this._data;
|
|
obj._type = this._type;
|
|
this._params.forEach((element: any) => {
|
|
if (!obj._params) {
|
|
obj._params = [];
|
|
}
|
|
obj._params.push(element);
|
|
});
|
|
// obj._params = this._params;
|
|
obj._tgctrl = this._tgctrl;
|
|
obj._condv = this._condv;
|
|
obj._man = this._man;
|
|
obj._show_effect = this._show_effect;
|
|
obj._maxvalue = this._maxvalue;
|
|
return obj;
|
|
};
|
|
}; |