handle skill logic (not test)
This commit is contained in:
parent
24b62f39dd
commit
8bf6e4ecca
3
package-lock.json
generated
3
package-lock.json
generated
@ -224,7 +224,8 @@
|
|||||||
"@types/debug": {
|
"@types/debug": {
|
||||||
"version": "4.1.5",
|
"version": "4.1.5",
|
||||||
"resolved": "https://registry.npmjs.org/@types/debug/-/debug-4.1.5.tgz",
|
"resolved": "https://registry.npmjs.org/@types/debug/-/debug-4.1.5.tgz",
|
||||||
"integrity": "sha512-Q1y515GcOdTHgagaVFhHnIFQ38ygs/kmxdNpvpou+raI9UO3YZcHDngBSYKQklcKlvA7iuQlmIKbzvmxcOE9CQ=="
|
"integrity": "sha512-Q1y515GcOdTHgagaVFhHnIFQ38ygs/kmxdNpvpou+raI9UO3YZcHDngBSYKQklcKlvA7iuQlmIKbzvmxcOE9CQ==",
|
||||||
|
"dev": true
|
||||||
},
|
},
|
||||||
"@types/express": {
|
"@types/express": {
|
||||||
"version": "4.17.9",
|
"version": "4.17.9",
|
||||||
|
@ -9,6 +9,7 @@ import {SkillParam, SkillTarget} from "../skill/SkillParam";
|
|||||||
import { Room } from "colyseus";
|
import { Room } from "colyseus";
|
||||||
import { Skill } from "../skill/Skill";
|
import { Skill } from "../skill/Skill";
|
||||||
import { PetHandler } from "./PetHandler";
|
import { PetHandler } from "./PetHandler";
|
||||||
|
import { SkillInfoMsg } from "message/SkillInfo";
|
||||||
|
|
||||||
|
|
||||||
export class BattleHandler {
|
export class BattleHandler {
|
||||||
@ -184,7 +185,7 @@ export class BattleHandler {
|
|||||||
pt *= obj.dbpt_cnt;
|
pt *= obj.dbpt_cnt;
|
||||||
}
|
}
|
||||||
|
|
||||||
let ps = new SkillParam(obj.card, pt, obj.eff_cnt, ph, dstph, dstpt);
|
let ps = new SkillParam(obj.card, pt, obj.eff_cnt, ph, null, dstph, dstpt);
|
||||||
|
|
||||||
ph.useCard(ps);
|
ph.useCard(ps);
|
||||||
};
|
};
|
||||||
@ -287,4 +288,9 @@ export class BattleHandler {
|
|||||||
public onPlayerStealCard(srcplayer: PlayerHandler, dstplayer: PlayerHandler, count: number){
|
public onPlayerStealCard(srcplayer: PlayerHandler, dstplayer: PlayerHandler, count: number){
|
||||||
return this._room.drawCardFromPlayer(srcplayer.getId(), dstplayer.getId(), count);
|
return this._room.drawCardFromPlayer(srcplayer.getId(), dstplayer.getId(), count);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
public onSkillResult(skillres: SkillTarget[]){
|
||||||
|
//todo: build skillrest json -> client
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,6 +8,7 @@ import SkillMan from "../skill/SkillMan";
|
|||||||
import { EnhanceEffectType, PowerValueType } from "../skill/SkillConst";
|
import { EnhanceEffectType, PowerValueType } from "../skill/SkillConst";
|
||||||
import { PlayerHandler } from "./PlayerHandler";
|
import { PlayerHandler } from "./PlayerHandler";
|
||||||
import { PetInfoMsg } from "../../../message/PetInfo";
|
import { PetInfoMsg } from "../../../message/PetInfo";
|
||||||
|
import { SkillParam } from "../skill/SkillParam";
|
||||||
|
|
||||||
export class PetHandler {
|
export class PetHandler {
|
||||||
_pet: Pet;
|
_pet: Pet;
|
||||||
@ -20,7 +21,7 @@ export class PetHandler {
|
|||||||
_dieSkills: Skill[] = [];
|
_dieSkills: Skill[] = [];
|
||||||
_halos: Skill[] = [];
|
_halos: Skill[] = [];
|
||||||
|
|
||||||
_otherhalos: Skill[] = [];
|
_effhalos: Skill[] = [];
|
||||||
|
|
||||||
_baseap: number; // 基础
|
_baseap: number; // 基础
|
||||||
|
|
||||||
@ -42,22 +43,20 @@ export class PetHandler {
|
|||||||
this._idx = index;
|
this._idx = index;
|
||||||
};
|
};
|
||||||
|
|
||||||
public setParam(obj:{
|
public setParam(id: number, param?: SkillParam, exskillid?: number[]){
|
||||||
id: number, ap?: number, effcnt?: number, exskillid: number[]}
|
this._id = id || 0;
|
||||||
){
|
|
||||||
this._id = obj.id || 0;
|
|
||||||
this._cfg = CfgMan.findUnitCfg(this._id);
|
this._cfg = CfgMan.findUnitCfg(this._id);
|
||||||
if(!obj.ap){
|
if(!param || !param.cardpoint){
|
||||||
this._baseap = this._cfg.powernum;
|
this._baseap = this._cfg.powernum;
|
||||||
}else{
|
}else{
|
||||||
this._baseap = obj.ap;
|
this._baseap = param.cardpoint;
|
||||||
if(this._cfg.powernum_typeid == PowerValueType.RATIO){
|
if(this._cfg.powernum_typeid == PowerValueType.RATIO){
|
||||||
this._baseap *= this._cfg.powernum;
|
this._baseap *= this._cfg.powernum;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(obj.effcnt && this._isEnhancePower(this._cfg.edd_effid)){
|
if(param && param.edd_cnt && this._isEnhancePower(this._cfg.edd_effid)){
|
||||||
this._baseap += CfgMan.calcEnhanceValue(this._cfg.edd_effid, this._cfg.edd_effnum,
|
this._baseap += CfgMan.calcEnhanceValue(this._cfg.edd_effid, this._cfg.edd_effnum,
|
||||||
obj.effcnt, obj.ap);
|
param.edd_cnt, this._baseap);
|
||||||
}
|
}
|
||||||
this._skills.clear();
|
this._skills.clear();
|
||||||
|
|
||||||
@ -65,9 +64,15 @@ export class PetHandler {
|
|||||||
this.addSkill(this._cfg.base_skill2id);
|
this.addSkill(this._cfg.base_skill2id);
|
||||||
this.addSkill(this._cfg.base_skill3id);
|
this.addSkill(this._cfg.base_skill3id);
|
||||||
|
|
||||||
obj.exskillid && obj.exskillid.forEach((skillid: number)=>{
|
exskillid && exskillid.forEach((skillid: number)=>{
|
||||||
this.addSkill(skillid);
|
this.addSkill(skillid);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if(this._halos.length > 0){
|
||||||
|
this._owner.onHaloChanged(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.born(param);
|
||||||
};
|
};
|
||||||
|
|
||||||
private _isEnhancePower(enid: number){
|
private _isEnhancePower(enid: number){
|
||||||
@ -78,7 +83,16 @@ export class PetHandler {
|
|||||||
this._halos.push(halo);
|
this._halos.push(halo);
|
||||||
};
|
};
|
||||||
|
|
||||||
public addSkill(skillid: number){
|
public clearEffHalos(){
|
||||||
|
// this._effhalos.length = 0;
|
||||||
|
this._exap = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
public addEffHalo(skill: Skill, ap: number){
|
||||||
|
this._exap += ap;
|
||||||
|
};
|
||||||
|
|
||||||
|
public addSkill(skillid: number, halocb?: any){
|
||||||
if(skillid > 0){
|
if(skillid > 0){
|
||||||
let obj = this._skills.get(skillid);
|
let obj = this._skills.get(skillid);
|
||||||
if(!obj){
|
if(!obj){
|
||||||
@ -93,17 +107,18 @@ export class PetHandler {
|
|||||||
this._dieSkills.push(obj);
|
this._dieSkills.push(obj);
|
||||||
}else if(obj.isHaloSkill()){
|
}else if(obj.isHaloSkill()){
|
||||||
this._halos.push(obj);
|
this._halos.push(obj);
|
||||||
|
halocb && halocb(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return obj;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return null;
|
||||||
};
|
};
|
||||||
|
|
||||||
public delSkill(skillid:number){
|
public delSkill(skillid:number, halocb?: any){
|
||||||
if(skillid > 0){
|
if(skillid > 0){
|
||||||
let obj = this._skills.get(skillid);
|
let obj = this._skills.get(skillid);
|
||||||
if(obj){
|
if(obj){
|
||||||
@ -118,6 +133,7 @@ export class PetHandler {
|
|||||||
idx = this._halos.indexOf(obj);
|
idx = this._halos.indexOf(obj);
|
||||||
if(idx >= 0){
|
if(idx >= 0){
|
||||||
this._halos.splice(idx, 1);
|
this._halos.splice(idx, 1);
|
||||||
|
halocb && halocb(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this._skills.delete(skillid);
|
this._skills.delete(skillid);
|
||||||
@ -162,25 +178,29 @@ export class PetHandler {
|
|||||||
return value;
|
return value;
|
||||||
};
|
};
|
||||||
|
|
||||||
public born(param: any){
|
public born(param: SkillParam){
|
||||||
this._owner && this._owner.onPetBorned(this, param);
|
this._owner && this._owner.onPetBorned(this, param);
|
||||||
};
|
};
|
||||||
|
|
||||||
public die(){
|
public die(){
|
||||||
this._dieSkills.forEach((item: Skill)=>{
|
this.clear();
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
this._owner && this._owner.onPetDied(this);
|
this._owner && this._owner.onPetDied(this);
|
||||||
};
|
};
|
||||||
|
|
||||||
public useSkill(skillid: number){
|
public clear(){
|
||||||
|
this._halos.length = 0;
|
||||||
|
this._owner.onHaloChanged(this);
|
||||||
|
};
|
||||||
|
|
||||||
|
public hasHalo(): boolean{
|
||||||
|
return this._halos.length > 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
public checkHalo(apet: PetHandler){
|
public checkHalo(apet: PetHandler){
|
||||||
this._halos.forEach((item: Skill)=>{
|
this._halos.forEach((item: Skill)=>{
|
||||||
|
if(item.isEffSelfPet(this, apet)){
|
||||||
|
this.addEffHalo(item, item.getEffValue()); // 暂时都加战力
|
||||||
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@ import { HeroCfg } from "../../../cfg/parsers/HeroCfg";
|
|||||||
import { BattleHandler } from "./BattleHandler";
|
import { BattleHandler } from "./BattleHandler";
|
||||||
import CfgMan from "../CfgMan";
|
import CfgMan from "../CfgMan";
|
||||||
import { Pet } from "rooms/schema/Pet";
|
import { Pet } from "rooms/schema/Pet";
|
||||||
import { EffectCardType, GameUnitType, TriggerType } from "../skill/SkillConst";
|
import { EffectCardType, GameUnitType, SkillType, TriggerType } from "../skill/SkillConst";
|
||||||
import { UnitCfg } from "cfg/parsers/UnitCfg";
|
import { UnitCfg } from "cfg/parsers/UnitCfg";
|
||||||
import { Skill } from "../skill/Skill";
|
import { Skill } from "../skill/Skill";
|
||||||
import { SkillParam, SkillTarget } from "../skill/SkillParam";
|
import { SkillParam, SkillTarget } from "../skill/SkillParam";
|
||||||
@ -37,7 +37,8 @@ export class PlayerHandler {
|
|||||||
this._self.init(null, this, 0);
|
this._self.init(null, this, 0);
|
||||||
this._self._isHero = true;
|
this._self._isHero = true;
|
||||||
let lst = this._playercfg.ex_skill? [this._playercfg.ex_skill]: null;
|
let lst = this._playercfg.ex_skill? [this._playercfg.ex_skill]: null;
|
||||||
this._self.setParam({id: this._playercfg.herounit_id, exskillid: lst});
|
let ps = new SkillParam(0, 0, 0, this, this._self, null, null);
|
||||||
|
this._self.setParam(this._playercfg.herounit_id, ps, lst);
|
||||||
this._unitcfg = this._playercfg && CfgMan.findUnitCfg(this._playercfg.herounit_id);
|
this._unitcfg = this._playercfg && CfgMan.findUnitCfg(this._playercfg.herounit_id);
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -124,31 +125,42 @@ export class PlayerHandler {
|
|||||||
if(!pet){
|
if(!pet){
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
pet.setParam({id: cfg.stageunit_id, ap:obj.cardpoint, effcnt: obj.edd_cnt, exskillid:
|
|
||||||
[cfg.quoteskill1id, cfg.quoteskill2id, cfg.quoteskill3id, cfg.quoteskill4id]});
|
|
||||||
|
|
||||||
obj.srcpet = pet;
|
obj.srcpet = pet;
|
||||||
|
pet.setParam(cfg.stageunit_id, obj,
|
||||||
pet.born(obj);
|
[cfg.quoteskill1id, cfg.quoteskill2id, cfg.quoteskill3id, cfg.quoteskill4id]);
|
||||||
}else if(cfg.type_id == EffectCardType.MAGIC){
|
}else if(cfg.type_id == EffectCardType.MAGIC){
|
||||||
this.useSkill([cfg.quoteskill1id, cfg.quoteskill2id, cfg.quoteskill3id, cfg.quoteskill4id], obj);
|
this.useSkills([cfg.quoteskill1id, cfg.quoteskill2id, cfg.quoteskill3id, cfg.quoteskill4id], obj);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
public useSkill(skills: number[], obj: SkillParam)
|
public useSkills(skills: number[], obj: SkillParam)
|
||||||
{
|
{
|
||||||
if(!skills){
|
if(!skills){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
let res : SkillTarget[] = [];
|
|
||||||
skills.forEach((item: number)=>{
|
skills.forEach((item: number)=>{
|
||||||
let sk = this.newSkill(item);
|
this.useSkill(item, 1, obj);
|
||||||
let lst = sk.checkTrigger(TriggerType.NO_COND, 0, obj);
|
|
||||||
res = res.concat(lst);
|
|
||||||
});
|
});
|
||||||
//todo: build json -> client
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
public useSkill(skillid: number, count: number, obj: SkillParam){
|
||||||
|
let cfg = CfgMan.findSkillCfg(skillid);
|
||||||
|
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);
|
||||||
|
//todo: build json -> client
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}else {
|
||||||
|
for(let i = 0; i < count; i++){
|
||||||
|
this._self.addSkill(skillid, this.onHaloChanged);
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
public newSkill(skillid: number): Skill{
|
public newSkill(skillid: number): Skill{
|
||||||
let obj = SkillMan.getSkill(skillid);
|
let obj = SkillMan.getSkill(skillid);
|
||||||
if(obj){
|
if(obj){
|
||||||
@ -157,6 +169,19 @@ export class PlayerHandler {
|
|||||||
return obj;
|
return obj;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
summonPet(petid: number, count: number = 1, exparam: SkillParam):number{
|
||||||
|
let n = -1;
|
||||||
|
for(let i = 0; i < count; i++){
|
||||||
|
let pet = this.newPet();
|
||||||
|
if(!pet){
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
n++;
|
||||||
|
pet.setParam(petid, exparam);
|
||||||
|
}
|
||||||
|
return n;
|
||||||
|
};
|
||||||
|
|
||||||
public addCard(count: number){
|
public addCard(count: number){
|
||||||
return this._owner.onPlayerAddCard(this, count, 0);
|
return this._owner.onPlayerAddCard(this, count, 0);
|
||||||
};
|
};
|
||||||
@ -182,6 +207,9 @@ export class PlayerHandler {
|
|||||||
};
|
};
|
||||||
|
|
||||||
public checkHalo(apet:PetHandler){
|
public checkHalo(apet:PetHandler){
|
||||||
|
this._pets.forEach((obj:PetHandler)=>{
|
||||||
|
obj.clearEffHalos();
|
||||||
|
});
|
||||||
this._pets.forEach((obj: PetHandler)=>{
|
this._pets.forEach((obj: PetHandler)=>{
|
||||||
if(obj != apet){
|
if(obj != apet){
|
||||||
obj.checkHalo(apet);
|
obj.checkHalo(apet);
|
||||||
@ -199,7 +227,6 @@ export class PlayerHandler {
|
|||||||
};
|
};
|
||||||
|
|
||||||
public onPetBorned(apet: PetHandler, param: SkillParam){
|
public onPetBorned(apet: PetHandler, param: SkillParam){
|
||||||
//todo: build pet init json -> client
|
|
||||||
this._owner.onAddPetNotify(apet);
|
this._owner.onAddPetNotify(apet);
|
||||||
|
|
||||||
// 战吼
|
// 战吼
|
||||||
@ -209,20 +236,25 @@ export class PlayerHandler {
|
|||||||
reslst = reslst.concat(lst);
|
reslst = reslst.concat(lst);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
this._owner.onSkillResult(reslst);
|
||||||
|
|
||||||
//todo: build bornskill json -> client
|
|
||||||
// 光环
|
|
||||||
this.checkHalo(apet);
|
|
||||||
//todo: build haloskill json -> client
|
|
||||||
};
|
};
|
||||||
|
|
||||||
public onPetDied(apet: PetHandler){
|
public onPetDied(apet: PetHandler){
|
||||||
|
this._owner.onDelPetNotify(apet);
|
||||||
|
|
||||||
|
// 遗愿
|
||||||
|
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);
|
||||||
|
});
|
||||||
|
|
||||||
|
this._owner.onSkillResult(reslst);
|
||||||
};
|
};
|
||||||
|
|
||||||
public onSkillEnd(askill: Skill, res: SkillTarget[]){
|
public onHaloChanged(apet: PetHandler){
|
||||||
|
this.checkHalo(apet);
|
||||||
};
|
};
|
||||||
|
|
||||||
public isMyPet(apet: PetHandler){
|
public isMyPet(apet: PetHandler){
|
||||||
|
@ -114,6 +114,41 @@ export class Skill {
|
|||||||
return this._data.rangeid == SkillRangeUnitType.ALL;
|
return this._data.rangeid == SkillRangeUnitType.ALL;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
isInRange(srcpet: PetHandler, dstpet: PetHandler){
|
||||||
|
switch(this._data.rangeid){
|
||||||
|
case SkillRangeUnitType.SELF:
|
||||||
|
return srcpet == dstpet;
|
||||||
|
case SkillRangeUnitType.SINGLE:
|
||||||
|
return false;
|
||||||
|
case SkillRangeUnitType.OTHER:
|
||||||
|
return false;
|
||||||
|
case SkillRangeUnitType.ALL:
|
||||||
|
return true;
|
||||||
|
case SkillRangeUnitType.ALL_EXSELF:
|
||||||
|
return srcpet != dstpet;
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
isEffSelfPet(srcpet: PetHandler, dstpet: PetHandler){
|
||||||
|
if(this._data.friendlyid != GameCampType.SELF){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
let tgok = false;
|
||||||
|
switch(this._data.targetid){
|
||||||
|
case GameUnitType.BATTLEUNIT:
|
||||||
|
tgok = this.isInRange(srcpet, dstpet);
|
||||||
|
case GameUnitType.HERO:
|
||||||
|
tgok = dstpet._isHero;
|
||||||
|
case GameUnitType.PET:
|
||||||
|
if(!dstpet._isHero){
|
||||||
|
tgok = this.isInRange(srcpet, dstpet);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return tgok;
|
||||||
|
};
|
||||||
|
|
||||||
getTargets(param: SkillParam): SkillTarget[]{
|
getTargets(param: SkillParam): SkillTarget[]{
|
||||||
return this._owner._owner.getSkillTargets(this, param);
|
return this._owner._owner.getSkillTargets(this, param);
|
||||||
};
|
};
|
||||||
@ -122,9 +157,9 @@ export class Skill {
|
|||||||
return CfgMan.calcEnhanceValue(this._data.edd_effid, this._data.edd_effnum, param.edd_cnt, param.cardpoint);
|
return CfgMan.calcEnhanceValue(this._data.edd_effid, this._data.edd_effnum, param.edd_cnt, param.cardpoint);
|
||||||
};
|
};
|
||||||
|
|
||||||
getEffValue(param: SkillParam): number{
|
getEffValue(ap?: number): number{
|
||||||
return CfgMan.calcEffectValue(this._data.eff_numtypeid,
|
return CfgMan.calcEffectValue(this._data.eff_numtypeid,
|
||||||
this._data.num_signid, this._data.eff_num, param.cardpoint);
|
this._data.num_signid, this._data.eff_num, ap? ap: this._data.eff_num);
|
||||||
};
|
};
|
||||||
|
|
||||||
trigger(param: SkillParam) {
|
trigger(param: SkillParam) {
|
||||||
@ -235,8 +270,24 @@ export class Skill {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
summon(efftype: SkillEffectType, effvalue: number, tgt: SkillTarget){
|
summon(efftype: SkillEffectType, exparam: SkillParam, tgt: SkillTarget){
|
||||||
|
let ncount = 1 + exparam.edd_cnt;
|
||||||
|
switch(efftype){
|
||||||
|
case SkillEffectType.SUMMON_NPC:
|
||||||
|
let n = tgt.srcplayer.summonPet(this._data.quoteunitid, ncount, exparam);
|
||||||
|
if(n >= 0){
|
||||||
|
tgt.success(efftype, n);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case SkillEffectType.SUMMON_SKILL:
|
||||||
|
tgt.srcplayer.useSkill(this._data.quoteskillid, ncount, exparam);
|
||||||
|
if(n >= 0){
|
||||||
|
tgt.success(efftype, n);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
addBuff(efftype: SkillEffectType, effvalue: number, tgt: SkillTarget){
|
addBuff(efftype: SkillEffectType, effvalue: number, tgt: SkillTarget){
|
||||||
|
@ -2,6 +2,7 @@ import {PlayerHandler} from "../Handler/PlayerHandler";
|
|||||||
import {PetHandler} from "../Handler/PetHandler";
|
import {PetHandler} from "../Handler/PetHandler";
|
||||||
import { Skill } from "./Skill";
|
import { Skill } from "./Skill";
|
||||||
import { GameUnitType } from "./SkillConst";
|
import { GameUnitType } from "./SkillConst";
|
||||||
|
import { SKillEffectData, SkillInfoData, SkillInfoMsg } from "message/SkillInfo";
|
||||||
|
|
||||||
export class SkillParam{
|
export class SkillParam{
|
||||||
cardid: number;
|
cardid: number;
|
||||||
@ -11,15 +12,17 @@ export class SkillParam{
|
|||||||
dstplayer: PlayerHandler;
|
dstplayer: PlayerHandler;
|
||||||
dstpet: PetHandler;
|
dstpet: PetHandler;
|
||||||
|
|
||||||
srcpet: PetHandler = null;
|
srcpet: PetHandler;
|
||||||
|
|
||||||
skill: Skill;
|
skill: Skill;
|
||||||
|
|
||||||
constructor(cardid: number, cardpoint: number, effcnt: number, srcplayer: PlayerHandler, dstplayer: PlayerHandler, dstpet: PetHandler){
|
constructor(cardid: number, cardpoint: number, effcnt: number, srcplayer: PlayerHandler, srcpet: PetHandler,
|
||||||
|
dstplayer: PlayerHandler, dstpet: PetHandler){
|
||||||
this.cardid = cardid;
|
this.cardid = cardid;
|
||||||
this.cardpoint = cardpoint;
|
this.cardpoint = cardpoint;
|
||||||
this.edd_cnt = effcnt;
|
this.edd_cnt = effcnt;
|
||||||
this.srcplayer = srcplayer;
|
this.srcplayer = srcplayer;
|
||||||
|
this.srcpet = srcpet;
|
||||||
this.dstplayer = dstplayer;
|
this.dstplayer = dstplayer;
|
||||||
this.dstpet = dstpet;
|
this.dstpet = dstpet;
|
||||||
};
|
};
|
||||||
@ -29,11 +32,13 @@ export class SkillResult{
|
|||||||
effect_type: number;
|
effect_type: number;
|
||||||
effect_res: number;
|
effect_res: number;
|
||||||
err: number;
|
err: number;
|
||||||
|
bsuccess: boolean;
|
||||||
|
|
||||||
constructor(efftype: number, effres: number, err: number = 0) {
|
constructor(efftype: number, effres: number, issuccess: boolean, err: number = 0) {
|
||||||
this.effect_type = efftype;
|
this.effect_type = efftype;
|
||||||
this.effect_res = effres;
|
this.effect_res = effres;
|
||||||
this.err = err;
|
this.err = err;
|
||||||
|
this.bsuccess = issuccess;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -62,11 +67,25 @@ export class SkillTarget{
|
|||||||
|
|
||||||
public success(efftype: number, effres: number){
|
public success(efftype: number, effres: number){
|
||||||
this.checkRes();
|
this.checkRes();
|
||||||
this.res.push(new SkillResult(efftype, effres));
|
this.res.push(new SkillResult(efftype, effres, true));
|
||||||
};
|
};
|
||||||
|
|
||||||
public fail(efftype: number, err: number){
|
public fail(efftype: number, err: number){
|
||||||
this.checkRes();
|
this.checkRes();
|
||||||
this.res.push(new SkillResult(efftype, 0, err));
|
this.res.push(new SkillResult(efftype, 0, false, err));
|
||||||
|
};
|
||||||
|
|
||||||
|
public exportData(): SkillInfoData{
|
||||||
|
let obj = new SkillInfoData();
|
||||||
|
obj.player = this.srcplayer.getId(),
|
||||||
|
obj.pos = this.srcpet? this.srcpet._idx: 0;
|
||||||
|
obj.datas = [];
|
||||||
|
this.res.forEach((item: SkillResult) => {
|
||||||
|
let ed = new SKillEffectData();
|
||||||
|
ed.effect_id = item.effect_type;
|
||||||
|
ed.val = item.bsuccess? item.effect_res: item.err;
|
||||||
|
obj.datas.push(ed);
|
||||||
|
})
|
||||||
|
return obj;
|
||||||
}
|
}
|
||||||
};
|
};
|
@ -75,7 +75,7 @@ let TriggerManager = {
|
|||||||
onTrigger(sender: Skill, param: SkillParam): SkillTarget[] {
|
onTrigger(sender: Skill, param: SkillParam): SkillTarget[] {
|
||||||
let effectid = sender._type;
|
let effectid = sender._type;
|
||||||
let env = sender.getEnhanceValue(param);
|
let env = sender.getEnhanceValue(param);
|
||||||
let effv = sender.getEffValue(param);
|
let effv = sender.getEffValue(param.cardpoint);
|
||||||
let tgts = sender.getTargets(param);
|
let tgts = sender.getTargets(param);
|
||||||
if(!tgts || !tgts.length){
|
if(!tgts || !tgts.length){
|
||||||
return null;
|
return null;
|
||||||
@ -103,7 +103,7 @@ let TriggerManager = {
|
|||||||
case SkillEffectType.SUMMON_NPC:
|
case SkillEffectType.SUMMON_NPC:
|
||||||
case SkillEffectType.SUMMON_SKILL:
|
case SkillEffectType.SUMMON_SKILL:
|
||||||
tgts.forEach((item)=>{
|
tgts.forEach((item)=>{
|
||||||
sender.summon(effectid, effv + env, item);
|
sender.summon(effectid, param, item);
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
case SkillEffectType.TAUNT:
|
case SkillEffectType.TAUNT:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user