skill msg add errorcode
This commit is contained in:
parent
37b8c37918
commit
0d245751ed
@ -78,7 +78,7 @@ export class BattleHandler {
|
||||
switch(skill._data.targetid){
|
||||
case GameUnitType.PLAYER:
|
||||
players.forEach((item:PlayerHandler)=>{
|
||||
lst.push(new SkillTarget(param.srcplayer, param.srcpet, skill, item, GameUnitType.PLAYER));
|
||||
lst.push(new SkillTarget(skill, param.srcplayer, param.srcpet, item, GameUnitType.PLAYER));
|
||||
});
|
||||
break;
|
||||
case GameUnitType.BATTLEUNIT:
|
||||
@ -86,7 +86,7 @@ export class BattleHandler {
|
||||
case GameUnitType.PET:
|
||||
if(skill.isSingleTarget()){
|
||||
if(param.dstpet && this.petIsValid(param.dstpet, players, skill._data.targetid)){
|
||||
lst.push(new SkillTarget(param.srcplayer, param.srcpet, skill,
|
||||
lst.push(new SkillTarget(skill, param.srcplayer, param.srcpet,
|
||||
param.dstpet, param.dstpet._isHero? GameUnitType.HERO: GameUnitType.PET));
|
||||
}
|
||||
}else{
|
||||
|
@ -92,18 +92,18 @@ export class PlayerHandler {
|
||||
let lst = this._pets.reverse();
|
||||
lst.forEach(element => {
|
||||
if(expet != element){
|
||||
dst.push(new SkillTarget(param.srcplayer, param.srcpet, param.skill, element, GameUnitType.PET));
|
||||
dst.push(new SkillTarget(param.skill, param.srcplayer, param.srcpet, element, GameUnitType.PET));
|
||||
}
|
||||
});
|
||||
(expet != this._self) && dst.push(new SkillTarget(param.srcplayer, param.srcpet, param.skill, this._self, GameUnitType.PET));
|
||||
(expet != this._self) && dst.push(new SkillTarget(param.skill, param.srcplayer, param.srcpet, this._self, GameUnitType.PET));
|
||||
break;
|
||||
case GameUnitType.HERO:
|
||||
(expet != this._self) && dst.push(new SkillTarget(param.srcplayer, param.srcpet, param.skill, this._self, GameUnitType.PET));
|
||||
(expet != this._self) && dst.push(new SkillTarget(param.skill, param.srcplayer, param.srcpet, this._self, GameUnitType.PET));
|
||||
break;
|
||||
case GameUnitType.PET:
|
||||
lst.forEach(element => {
|
||||
if(expet != element){
|
||||
dst.push(new SkillTarget(param.srcplayer, param.srcpet, param.skill, element, GameUnitType.PET));
|
||||
dst.push(new SkillTarget(param.skill, param.srcplayer, param.srcpet, element, GameUnitType.PET));
|
||||
}
|
||||
});
|
||||
break;
|
||||
@ -144,21 +144,28 @@ export class PlayerHandler {
|
||||
});
|
||||
};
|
||||
|
||||
public useSkill(skillid: number, count: number, obj: SkillParam){
|
||||
public useSkill(skillid: number, count: number, obj: SkillParam): SkillTarget[]{
|
||||
let cfg = CfgMan.findSkillCfg(skillid);
|
||||
let lst:SkillTarget[] = [];
|
||||
if(cfg.skill_typeid == SkillType.MAGIC){
|
||||
for(let i = 0; i < count; i++){
|
||||
let sk = this.newSkill(skillid);
|
||||
let lst = sk.checkTrigger(TriggerType.NO_COND, 0, obj);
|
||||
sk.checkTrigger(TriggerType.NO_COND, 0, obj,
|
||||
(sk: Skill, sp: SkillParam, res: SkillTarget[])=>{
|
||||
if(res){
|
||||
lst.concat(res);
|
||||
}else{
|
||||
lst.push()
|
||||
}
|
||||
});
|
||||
//todo: build json -> client
|
||||
}
|
||||
return 1;
|
||||
}else {
|
||||
for(let i = 0; i < count; i++){
|
||||
this._self.addSkill(skillid, this.onHaloChanged);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
return lst;
|
||||
};
|
||||
|
||||
public newSkill(skillid: number): Skill{
|
||||
@ -232,8 +239,15 @@ export class PlayerHandler {
|
||||
// 战吼
|
||||
let reslst: SkillTarget[] = [];
|
||||
apet._bornSkills.forEach((item: Skill)=>{
|
||||
let lst = item.checkTrigger(TriggerType.NO_COND, 0, param);
|
||||
reslst = reslst.concat(lst);
|
||||
item.checkTrigger(TriggerType.NO_COND, 0, param, (skill: Skill, ap: SkillParam, res: SkillTarget[])=>{
|
||||
if(res){
|
||||
reslst = reslst.concat(res);
|
||||
}else{
|
||||
let st = new SkillTarget(skill);
|
||||
st.LoadParam(param);
|
||||
reslst.push(st);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
this._owner.onSkillResult(reslst);
|
||||
@ -246,8 +260,15 @@ export class PlayerHandler {
|
||||
let ps = new SkillParam(0, 0, 0, this, apet, null, null);
|
||||
let reslst: SkillTarget[] = [];
|
||||
apet._dieSkills.forEach((item: Skill)=>{
|
||||
let lst = item.checkTrigger(TriggerType.NO_COND, 0, ps);
|
||||
reslst = reslst.concat(lst);
|
||||
item.checkTrigger(TriggerType.NO_COND, 0, ps, (skill: Skill, ap: SkillParam, res: SkillTarget[])=>{
|
||||
if(res){
|
||||
reslst = reslst.concat(res);
|
||||
}else{
|
||||
let st = new SkillTarget(skill);
|
||||
st.LoadParam(ps);
|
||||
reslst.push(st);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
this._owner.onSkillResult(reslst);
|
||||
|
@ -162,7 +162,7 @@ export class Skill {
|
||||
this._data.num_signid, this._data.eff_num, ap? ap: this._data.eff_num);
|
||||
};
|
||||
|
||||
trigger(param: SkillParam) {
|
||||
trigger(param: SkillParam, cb?: any) {
|
||||
//触发buff效果
|
||||
let res = TriggerManager.onTrigger(this, param);
|
||||
|
||||
@ -172,6 +172,8 @@ export class Skill {
|
||||
this._start = true;
|
||||
}
|
||||
|
||||
cb && cb(this, param, res);
|
||||
|
||||
this._cb && this._cb(this, param, res);
|
||||
|
||||
this._man && this._man.onSkillTrigger(this, param, res);
|
||||
@ -186,11 +188,11 @@ export class Skill {
|
||||
this._startround++;
|
||||
}
|
||||
}
|
||||
cb && (this._cb = cb);
|
||||
if(this._tgctrl.checkTrigger(tg_type, tg_value, this._owner)){
|
||||
return this.trigger(tg_target);
|
||||
this.trigger(tg_target, cb);
|
||||
return 1;
|
||||
}else{
|
||||
return null;
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
|
||||
@ -280,9 +282,9 @@ export class Skill {
|
||||
}
|
||||
break;
|
||||
case SkillEffectType.SUMMON_SKILL:
|
||||
tgt.srcplayer.useSkill(this._data.quoteskillid, ncount, exparam);
|
||||
if(n >= 0){
|
||||
tgt.success(efftype, n);
|
||||
let res = tgt.srcplayer.useSkill(this._data.quoteskillid, ncount, exparam);
|
||||
if(res){
|
||||
tgt.success(efftype, res.length);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
|
@ -51,12 +51,24 @@ export class SkillTarget{
|
||||
|
||||
res: SkillResult[];
|
||||
|
||||
constructor(splayer: PlayerHandler, spet: PetHandler, skill: Skill, ds: any, dstp: GameUnitType) {
|
||||
constructor(skill: Skill, splayer?: PlayerHandler, spet?: PetHandler, dstobj?: any, dsttype?: GameUnitType) {
|
||||
this.srcplayer = splayer;
|
||||
this.srcpet = spet;
|
||||
this.srcskill = skill;
|
||||
this.dst = ds;
|
||||
this.dsttype = dstp;
|
||||
this.dst = dstobj;
|
||||
this.dsttype = dsttype;
|
||||
};
|
||||
|
||||
public LoadParam(sp: SkillParam){
|
||||
this.srcplayer = sp.srcplayer;
|
||||
this.srcpet = sp.srcpet;
|
||||
if(sp.dstpet){
|
||||
this.dsttype = sp.dstpet._isHero? GameUnitType.HERO: GameUnitType.PET;
|
||||
this.dst = sp.dstpet;
|
||||
}else if(sp.dstplayer){
|
||||
this.dsttype = GameUnitType.PLAYER;
|
||||
this.dst = sp.dstplayer;
|
||||
}
|
||||
};
|
||||
|
||||
public checkRes(){
|
||||
@ -82,6 +94,9 @@ export class SkillTarget{
|
||||
obj.player = this.srcplayer.getId(),
|
||||
obj.pos = this.srcpet? this.srcpet._idx: 0;
|
||||
obj.datas = [];
|
||||
if(!this.res){
|
||||
msg.errcode = -1;
|
||||
}else{
|
||||
this.res.forEach((item: SkillResult) => {
|
||||
let ed = new SKillEffectData();
|
||||
ed.effect_id = item.effect_type;
|
||||
@ -89,6 +104,7 @@ export class SkillTarget{
|
||||
ed.result = item.bsuccess? 0: -1;
|
||||
obj.datas.push(ed);
|
||||
});
|
||||
}
|
||||
return msg;
|
||||
}
|
||||
};
|
Loading…
x
Reference in New Issue
Block a user