skill msg add errorcode

This commit is contained in:
y.x 2020-12-07 11:46:51 +08:00
parent 37b8c37918
commit 0d245751ed
4 changed files with 70 additions and 31 deletions

View File

@ -78,7 +78,7 @@ export class BattleHandler {
switch(skill._data.targetid){ switch(skill._data.targetid){
case GameUnitType.PLAYER: case GameUnitType.PLAYER:
players.forEach((item:PlayerHandler)=>{ 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; break;
case GameUnitType.BATTLEUNIT: case GameUnitType.BATTLEUNIT:
@ -86,7 +86,7 @@ export class BattleHandler {
case GameUnitType.PET: case GameUnitType.PET:
if(skill.isSingleTarget()){ if(skill.isSingleTarget()){
if(param.dstpet && this.petIsValid(param.dstpet, players, skill._data.targetid)){ 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)); param.dstpet, param.dstpet._isHero? GameUnitType.HERO: GameUnitType.PET));
} }
}else{ }else{

View File

@ -92,18 +92,18 @@ export class PlayerHandler {
let lst = this._pets.reverse(); let lst = this._pets.reverse();
lst.forEach(element => { lst.forEach(element => {
if(expet != 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; break;
case GameUnitType.HERO: 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; break;
case GameUnitType.PET: case GameUnitType.PET:
lst.forEach(element => { lst.forEach(element => {
if(expet != 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; 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 cfg = CfgMan.findSkillCfg(skillid);
let lst:SkillTarget[] = [];
if(cfg.skill_typeid == SkillType.MAGIC){ if(cfg.skill_typeid == SkillType.MAGIC){
for(let i = 0; i < count; i++){ for(let i = 0; i < count; i++){
let sk = this.newSkill(skillid); 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 //todo: build json -> client
} }
return 1;
}else { }else {
for(let i = 0; i < count; i++){ for(let i = 0; i < count; i++){
this._self.addSkill(skillid, this.onHaloChanged); this._self.addSkill(skillid, this.onHaloChanged);
} }
return 1;
} }
return lst;
}; };
public newSkill(skillid: number): Skill{ public newSkill(skillid: number): Skill{
@ -232,8 +239,15 @@ export class PlayerHandler {
// 战吼 // 战吼
let reslst: SkillTarget[] = []; let reslst: SkillTarget[] = [];
apet._bornSkills.forEach((item: Skill)=>{ apet._bornSkills.forEach((item: Skill)=>{
let lst = item.checkTrigger(TriggerType.NO_COND, 0, param); item.checkTrigger(TriggerType.NO_COND, 0, param, (skill: Skill, ap: SkillParam, res: SkillTarget[])=>{
reslst = reslst.concat(lst); if(res){
reslst = reslst.concat(res);
}else{
let st = new SkillTarget(skill);
st.LoadParam(param);
reslst.push(st);
}
});
}); });
this._owner.onSkillResult(reslst); this._owner.onSkillResult(reslst);
@ -246,8 +260,15 @@ export class PlayerHandler {
let ps = new SkillParam(0, 0, 0, this, apet, null, null); let ps = new SkillParam(0, 0, 0, this, apet, null, null);
let reslst: SkillTarget[] = []; let reslst: SkillTarget[] = [];
apet._dieSkills.forEach((item: Skill)=>{ apet._dieSkills.forEach((item: Skill)=>{
let lst = item.checkTrigger(TriggerType.NO_COND, 0, ps); item.checkTrigger(TriggerType.NO_COND, 0, ps, (skill: Skill, ap: SkillParam, res: SkillTarget[])=>{
reslst = reslst.concat(lst); if(res){
reslst = reslst.concat(res);
}else{
let st = new SkillTarget(skill);
st.LoadParam(ps);
reslst.push(st);
}
});
}); });
this._owner.onSkillResult(reslst); this._owner.onSkillResult(reslst);

View File

@ -162,7 +162,7 @@ export class Skill {
this._data.num_signid, this._data.eff_num, ap? ap: this._data.eff_num); this._data.num_signid, this._data.eff_num, ap? ap: this._data.eff_num);
}; };
trigger(param: SkillParam) { trigger(param: SkillParam, cb?: any) {
//触发buff效果 //触发buff效果
let res = TriggerManager.onTrigger(this, param); let res = TriggerManager.onTrigger(this, param);
@ -172,6 +172,8 @@ export class Skill {
this._start = true; this._start = true;
} }
cb && cb(this, param, res);
this._cb && this._cb(this, param, res); this._cb && this._cb(this, param, res);
this._man && this._man.onSkillTrigger(this, param, res); this._man && this._man.onSkillTrigger(this, param, res);
@ -186,11 +188,11 @@ export class Skill {
this._startround++; this._startround++;
} }
} }
cb && (this._cb = cb);
if(this._tgctrl.checkTrigger(tg_type, tg_value, this._owner)){ if(this._tgctrl.checkTrigger(tg_type, tg_value, this._owner)){
return this.trigger(tg_target); this.trigger(tg_target, cb);
return 1;
}else{ }else{
return null; return 0;
} }
}; };
@ -280,9 +282,9 @@ export class Skill {
} }
break; break;
case SkillEffectType.SUMMON_SKILL: case SkillEffectType.SUMMON_SKILL:
tgt.srcplayer.useSkill(this._data.quoteskillid, ncount, exparam); let res = tgt.srcplayer.useSkill(this._data.quoteskillid, ncount, exparam);
if(n >= 0){ if(res){
tgt.success(efftype, n); tgt.success(efftype, res.length);
} }
break; break;
default: default:

View File

@ -51,12 +51,24 @@ export class SkillTarget{
res: SkillResult[]; 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.srcplayer = splayer;
this.srcpet = spet; this.srcpet = spet;
this.srcskill = skill; this.srcskill = skill;
this.dst = ds; this.dst = dstobj;
this.dsttype = dstp; 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(){ public checkRes(){
@ -82,13 +94,17 @@ export class SkillTarget{
obj.player = this.srcplayer.getId(), obj.player = this.srcplayer.getId(),
obj.pos = this.srcpet? this.srcpet._idx: 0; obj.pos = this.srcpet? this.srcpet._idx: 0;
obj.datas = []; obj.datas = [];
this.res.forEach((item: SkillResult) => { if(!this.res){
let ed = new SKillEffectData(); msg.errcode = -1;
ed.effect_id = item.effect_type; }else{
ed.val = item.bsuccess? item.effect_res: item.err; this.res.forEach((item: SkillResult) => {
ed.result = item.bsuccess? 0: -1; let ed = new SKillEffectData();
obj.datas.push(ed); ed.effect_id = item.effect_type;
}); ed.val = item.bsuccess? item.effect_res: item.err;
ed.result = item.bsuccess? 0: -1;
obj.datas.push(ed);
});
}
return msg; return msg;
} }
}; };