Merge branch 'master' of git.kingsome.cn:node/card_svr

This commit is contained in:
zhl 2020-12-09 12:03:13 +08:00
commit a0c87cd98f
6 changed files with 369 additions and 163 deletions

View File

@ -78,6 +78,24 @@ export class BattleHandler {
}
};
public getFinalTarget(players: PlayerHandler[], apet: PetHandler, ct: GameUnitType,
checktaunt: boolean=false): PetHandler
{
let pet = apet;
let bok = this.petIsValid(pet, players, ct);
if(checktaunt && (!bok || !pet._istaunt)){
for(let i = 0; i < players.length;i++){
let obj = players[i].findTauntPet();
if(obj){
pet = obj;
bok = true;
break;
}
}
}
return bok? pet: null;
};
public getSkillTargets(skill: Skill, param: SkillParam): SkillTarget[]{
let lst: SkillTarget[] = [];
let players = this.getTargetPlayers(skill._data.friendlyid, param.srcplayer, param.dstplayer);
@ -92,10 +110,10 @@ export class BattleHandler {
case GameUnitType.HERO:
case GameUnitType.PET:
if(skill.isSingleTarget()){
if(param.dstpet && this.petIsValid(param.dstpet, players, skill._data.targetid)){
lst.push(new SkillTarget(skill, param.srcplayer, param.srcpet,
param.dstpet, param.dstpet._isHero? GameUnitType.HERO: GameUnitType.PET));
}
let pet = this.getFinalTarget(players, param.dstpet, skill._data.targetid,
skill.isHurtPowerSkill());
pet && lst.push(new SkillTarget(skill, param.srcplayer, param.srcpet,
pet, pet._isHero? GameUnitType.HERO: GameUnitType.PET));
}else{
if(skill.isAllTarget()){
players.forEach((item: PlayerHandler)=>{
@ -127,34 +145,40 @@ export class BattleHandler {
let lst: PlayerHandler[] = [];
switch(gct){
case GameCampType.SELF:
lst.push(src);
if(src && src.isAlive()){
lst.push(src);
}
break;
case GameCampType.FRIEND:
let obj = this.getFriend(src);
obj && lst.push(obj);
if(obj && obj.isAlive()){
lst.push(obj);
}
break;
case GameCampType.MYTEAM:
if(src){
lst.push(src);
src.isAlive() && lst.push(src);
let obj = this.getFriend(src);
obj && lst.push(obj);
obj && obj.isAlive() && lst.push(obj);
}
break;
case GameCampType.ENEMY:
if(dst && dst._friend != src){
if(dst && dst._friend != src && dst.isAlive()){
lst.push(dst);
}
break;
case GameCampType.ENEMYTEAM:
for(let [key, obj] of this._players){
if(obj != src && obj != src._friend){
if(obj != src && obj != src._friend && obj.isAlive()){
lst.push(obj);
}
}
break;
case GameCampType.ALL:
for(let [key, obj] of this._players){
lst.push(obj);
if(obj && obj.isAlive()){
lst.push(obj);
}
}
break;
default:
@ -170,9 +194,9 @@ export class BattleHandler {
*/
public useCard(obj:
{srcplayer: Player, card: number, cardpoint: number, dbpt_cnt: number, eff_cnt: number, dstplayer: Player, dstpet: Pet})
{
:number{
if(!obj || !obj.card){
return false;
return 0;
}
let ph = this.getPlayer(obj.srcplayer);
@ -182,7 +206,7 @@ export class BattleHandler {
let dstpt = dstph? dstph.getPet(obj.dstpet): null;
if(!ph){
return false;
return 0;
}
let pt = obj.cardpoint;
@ -197,6 +221,8 @@ export class BattleHandler {
ph.useCard(ps);
this.onUseCardEnd(ps);
return 0;
};
/**
@ -308,15 +334,19 @@ export class BattleHandler {
// --------------------调用外部接口函数--------------------------
public onAddPetNotify(apet: PetHandler){
return this._room.bAddPet(apet.exportData());
return this._room.bAddPet(apet.exportInfoMsg());
};
public onDelPetNotify(apet: PetHandler){
return this._room.bRemovePet(apet.exportRemoveData());
return this._room.bRemovePet(apet.exportRemoveMsg());
};
public onPlayerAddCardNotify(aplayer: PlayerHandler, count: number, maxcount: number){
return this._room.addCard(aplayer.getId(), count, maxcount);
public onUpdatePetNotify(apet: PetHandler){
return this._room.updatePet([apet.exportInfo()])
};
public onPlayerAddCardNotify(aplayer: PlayerHandler, count: number, maxcount: number, from?: PlayerHandler){
return this._room.addCard(aplayer.getId(), count, maxcount, 1, from? from.getId(): null);
};
public onPlayerStealCardNotify(srcplayer: PlayerHandler, dstplayer: PlayerHandler, count: number){
@ -328,15 +358,23 @@ export class BattleHandler {
return;
}
let lst: SkillInfoMsg[] = [];
let difflst: SkillTarget[] = [];
skillres.forEach((item: SkillTarget)=>{
lst.push(item.exportData());
if(!difflst.includes(item)){
difflst.push(item);
}
});
let tm = 0;
difflst.forEach((item: SkillTarget) =>{
tm += item.getLastTime();
});
//todo:
this._room.bMsgQueue(lst);
};
public onPlayerAddHPNotify(aplayer: PlayerHandler, addhp: number){
//todo:
return addhp;
return this._room.updateHp(aplayer.getId(), addhp);
}
//end------------------------------------------------
}

View File

@ -7,9 +7,10 @@ import SkillMan from "../skill/SkillMan";
import { EnhanceEffectType, PowerValueType, TriggerType } from "../skill/SkillConst";
import { PlayerHandler } from "./PlayerHandler";
import { PetInfoMsg } from "../../../message/PetInfo";
import { SkillParam } from "../skill/SkillParam";
import { PetInfo, PetInfoMsg } from "../../../message/PetInfo";
import { SkillParam, SkillTarget } from "../skill/SkillParam";
import { RemovePetMsg } from "../../../message/RemovePetMsg";
import { SKillEffectData } from "message/SkillInfo";
export class PetHandler {
_pet: Pet;
@ -28,7 +29,7 @@ export class PetHandler {
_baseap: number; // 基础
_exap: number = 0; // 额外
// _exap: number = 0; // 额外
_exredhurt: number = 0; // 减伤
@ -46,7 +47,7 @@ export class PetHandler {
this._idx = index;
};
public setParam(id: number, param?: SkillParam, exskillid?: number[]){
public loadData(id: number, param?: SkillParam, exskillid?: number[]){
this._id = id || 0;
this._cfg = CfgMan.findUnitCfg(this._id);
if(!param || !param.cardpoint){
@ -87,21 +88,30 @@ export class PetHandler {
};
public clearEffHalos(){
// this._effhalos.length = 0;
this._exap = 0;
this._effhalos.length = 0;
// this._exap = 0;
};
public addEffHalo(skill: Skill, ap: number){
this._exap += ap;
public addEffHalo(skill: Skill){
this._effhalos.push(skill);
// this._exap += ap;
};
public addSkill(skillid: number, halocb?: any){
public getEffHaloV(): number{
let n = 0;
this._effhalos.forEach((item: Skill) => {
n += item.getHaloValue();
});
return n;
// return this._exap;
};
public addSkill(skillid: number){
if(skillid > 0){
let obj = this._skills.get(skillid);
if(!obj){
obj = SkillMan.getSkill(skillid);
obj = this._owner.newSkill(skillid);
if(obj){
obj.setOwner(this._owner);
this._skills.set(skillid, obj);
this._selfskills.push(skillid);
if(obj.isBornSkill()){
@ -110,7 +120,6 @@ export class PetHandler {
this._dieSkills.push(obj);
}else if(obj.isHaloSkill()){
this._halos.push(obj);
halocb && halocb(this);
}else{
this._waitskills.push(obj);
}
@ -149,41 +158,68 @@ export class PetHandler {
}
};
public addAP(value: number){
this._exap += value;
if(this._exap < 0){
this._baseap += this._exap;
this._exap = 0;
public useSkill(skillid: number, count: number, obj: SkillParam): SkillTarget[]{
return this._owner.handleSkill(skillid, count, obj, this);
};
public subAP(value: number):number {
// this._exap += value;
// if(this._exap < 0){
// this._baseap += this._exap;
// this._exap = 0;
// }
if(value <= 0){
return 0;
}
let n = -value;
for(let i = 0; i < this._effhalos.length;i++){
let dv = this._effhalos[i].addHaloValue(n);
n -= dv;
if(n >= 0){
break;
}
}
if(n < 0){
this._baseap += n;
}
this.dataChanged();
if(this._baseap < 0){
this.die();
}
return value;
};
public addBaseAP(value: number){
public addBaseAP(value: number): number{
if(value == 0){
return 0;
}
this._baseap += value;
this.dataChanged();
if(this._baseap < 0){
this.die();
}
return value;
};
public addExAP(value: number){
return this.addAP(value);
public addExAP(value: number, skill: Skill){
// return this.addAP(value);
};
public totalAP(){
return this._baseap + this._exap;
return this._baseap + this.getEffHaloV();
};
public beHurt(value: number){
let res = value * this._exredhurt;
return this.addAP(-res);
public beHurt(value: number): number{
let res = value - value * this._exredhurt;
if(res < 0){
return 0;
}
return this.subAP(res);
};
public addReduceHurt(value: number){
this._exredhurt += value;
(value != 0) && this.dataChanged();
return value;
};
@ -197,8 +233,23 @@ export class PetHandler {
};
public clear(){
this._halos.length = 0;
this._owner.onHaloChanged(this);
if(this._halos.length > 0){
this._halos.length = 0;
this._owner.onHaloChanged(this);
}
this._waitskills.length = 0;
};
public taunt(){
this._istaunt = true;
};
public taunt_cancel(){
this._istaunt = false;
};
public summonPet(petid: number, count: number = 1, exparam: SkillParam):number{
return this._owner.summonPet(petid, count, exparam);
};
public hasHalo(): boolean{
@ -208,7 +259,7 @@ export class PetHandler {
public checkHalo(apet: PetHandler){
this._halos.forEach((item: Skill)=>{
if(item.isEffSelfPet(this, apet)){
this.addEffHalo(item, item.getEffValue()); // 暂时都加战力
this.addEffHalo(item); // 暂时都加战力
}
});
};
@ -219,12 +270,12 @@ export class PetHandler {
});
};
public exportData(): PetInfoMsg{
public exportInfoMsg(): PetInfoMsg{
let obj = new PetInfoMsg({
id: this._id,
isHero: this._isHero,
ap: this._baseap,
extAp: this._exap,
extAp: this.getEffHaloV(),
pos: this._idx,
player: this._owner.getId(),
harmReduce: this._exredhurt,
@ -234,11 +285,29 @@ export class PetHandler {
return obj;
};
public exportRemoveData(): RemovePetMsg{
public exportRemoveMsg(): RemovePetMsg{
return new RemovePetMsg({
id: this._id,
player: this._owner.getId(),
pos: this._idx
})
};
public exportInfo(): PetInfo{
let obj = new PetInfo();
obj.id = this._id,
obj.isHero = this._isHero,
obj.ap = this._baseap,
obj.extAp = this.getEffHaloV(),
obj.pos = this._idx,
obj.player = this._owner.getId(),
obj.harmReduce = this._exredhurt,
obj.skills = this._selfskills,
obj.extSkills = this._exskills;
return obj;
};
public dataChanged(){
this._owner && this._owner.onPetChanged(this);
}
}

View File

@ -37,10 +37,15 @@ export class PlayerHandler {
this._self._isHero = true;
let lst = this._playercfg.ex_skill? [this._playercfg.ex_skill]: null;
let ps = new SkillParam(0, 0, 0, this, this._self, null, null);
this._self.setParam(this._playercfg.herounit_id, ps, lst);
this._self.loadData(this._playercfg.herounit_id, ps, lst);
this._unitcfg = this._playercfg && CfgMan.findUnitCfg(this._playercfg.herounit_id);
};
public clear(){
this._self = null;
this._pets.length = 0;
};
public getCurrCardCount(){
return this._player.cards.size;
};
@ -76,6 +81,11 @@ export class PlayerHandler {
return pr;
};
public delPet(ph: PetHandler){
let idx = this._pets.indexOf(ph);
(idx >= 0) && this._pets.splice(idx, 1);
};
public getPet(pet: Pet){
return this._pets.find((item:PetHandler)=>{
return item._pet == pet;
@ -125,7 +135,7 @@ export class PlayerHandler {
return false;
}
obj.srcpet = pet;
pet.setParam(cfg.stageunit_id, obj,
pet.loadData(cfg.stageunit_id, obj,
[cfg.quoteskill1id, cfg.quoteskill2id, cfg.quoteskill3id, cfg.quoteskill4id]);
}else if(cfg.type_id == EffectCardType.MAGIC){
this.useSkills([cfg.quoteskill1id, cfg.quoteskill2id, cfg.quoteskill3id, cfg.quoteskill4id], obj);
@ -144,27 +154,7 @@ export class PlayerHandler {
};
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);
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
}
}else {
for(let i = 0; i < count; i++){
this._self.addSkill(skillid, this.onHaloChanged);
}
}
return lst;
return this.handleSkill(skillid, count, obj, this._self);
};
public newSkill(skillid: number): Skill{
@ -175,7 +165,45 @@ export class PlayerHandler {
return obj;
};
summonPet(petid: number, count: number = 1, exparam: SkillParam):number{
public handleSkill(skillid: number, count: number, param: SkillParam, pet: PetHandler):SkillTarget[]{
let cfg = CfgMan.findSkillCfg(skillid);
let lst: Skill[] = [];
if(cfg.skill_typeid == SkillType.MAGIC){
for(let i = 0; i < count; i++){
let sk = this.newSkill(skillid);
lst.push(sk);
}
// this._owner.onSkillResultNotify(lst);
}else {
let bhalo = false;
let bchged = false;
for(let i = 0; i < count; i++){
let obj = pet.addSkill(skillid);
if(obj){
bchged = true;
if(obj.isBornSkill()){
lst.push(obj);
}else if(obj.isDieSkill()){
//nothing to do
}else if(obj.isHaloSkill()){
//only handle halo, not handle skill
bhalo = true;
}else{
lst.push(obj);
}
}
}
if(bhalo){
this.onHaloChanged(pet);
}
if(bchged){
pet.dataChanged();
}
}
return this.simpleCheckSkills(lst, pet, param);
};
public summonPet(petid: number, count: number = 1, exparam: SkillParam):number{
let n = -1;
for(let i = 0; i < count; i++){
let pet = this.newPet();
@ -183,17 +211,17 @@ export class PlayerHandler {
break;
}
n++;
pet.setParam(petid, exparam);
pet.loadData(petid, exparam);
}
return n;
};
public addCard(count: number){
return this._owner.onPlayerAddCardNotify(this, count, 0);
public addCard(count: number, from?: PlayerHandler){
return this._owner.onPlayerAddCardNotify(this, count, 0, from);
};
public addCardLimit(maxcount: number){
return this._owner.onPlayerAddCardNotify(this, 0, maxcount);
public addCardLimit(maxcount: number, from?: PlayerHandler){
return this._owner.onPlayerAddCardNotify(this, 0, maxcount, from);
};
public stealCard(dstplayer: PlayerHandler, count: number){
@ -208,7 +236,41 @@ export class PlayerHandler {
return this._player.hp;
};
public checkHalo(apet:PetHandler){
public setFriend(aplayer: PlayerHandler){
this._friend = aplayer;
};
public die(){
this.clear();
//todo:
};
public isAlive(): boolean{
return this._player.state != 2;
};
public onPetBorned(apet: PetHandler, param: SkillParam){
this._owner.onAddPetNotify(apet);
// 战吼
this.simpleCheckSkills(apet._bornSkills, apet, param);
};
public onPetDied(apet: PetHandler){
this._owner.onDelPetNotify(apet);
// 遗愿
this.simpleCheckSkills(apet._dieSkills, apet);
this.delPet(apet);
};
public onPetChanged(apet: PetHandler){
this._owner.onUpdatePetNotify(apet);
};
public onHaloChanged(apet: PetHandler){
this._self.clearEffHalos();
this._pets.forEach((obj:PetHandler)=>{
obj.clearEffHalos();
});
@ -218,70 +280,28 @@ export class PlayerHandler {
}
apet.checkHalo(obj);
});
};
public setFriend(aplayer: PlayerHandler){
this._friend = aplayer;
};
public die(){
//todo:
};
public isDead(){
this._player.state == 2;
};
public onPetBorned(apet: PetHandler, param: SkillParam){
this._owner.onAddPetNotify(apet);
// 战吼
let reslst: SkillTarget[] = [];
apet._bornSkills.forEach((item: Skill)=>{
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.onSkillResultNotify(reslst);
};
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)=>{
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.onSkillResultNotify(reslst);
};
public onHaloChanged(apet: PetHandler){
this.checkHalo(apet);
if(this._self != apet){
this._self.checkHalo(apet);
apet.checkHalo(this._self);
}
};
public isMyPet(apet: PetHandler){
if(apet == this._self){
return true;
}
return this._pets.includes(apet);
};
public findTauntPet(): PetHandler{
if(this._self && this._self._istaunt){
return this._self;
}
return this._pets.find((item: PetHandler) =>{
return item._istaunt;
})
};
public hasTransEffCardSkill(): boolean{
if(!this._self){
return false;
@ -357,6 +377,26 @@ export class PlayerHandler {
this._owner.onSkillResultNotify(reslst);
};
simpleCheckSkills(skills: Skill[], apet?: PetHandler, param?: SkillParam): SkillTarget[]{
let ps = param? param: new SkillParam(0, 0, 0, this, apet, null, null);
let reslst: SkillTarget[] = [];
skills.forEach((item: Skill)=>{
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.onSkillResultNotify(reslst);
return reslst;
};
resetTotalCard(){
this._totalcc = 0;
}

View File

@ -23,7 +23,7 @@ export class Skill {
_start: boolean;
_cb: any;
ap: number = 0;
halo_v: number = -1;
rd: number = 0;
// LIFE-CYCLE CALLBACKS:
@ -99,6 +99,10 @@ export class Skill {
return this._data.effect_typeid == SkillEffectType.CARD_CHG_EN;
};
isHurtPowerSkill(){
return this._data.effect_typeid == SkillEffectType.HURT_POWER;
};
isSingleTarget(){
switch(this._data.rangeid){
case SkillRangeUnitType.SELF:
@ -131,6 +135,7 @@ export class Skill {
}
};
// 是否能影响自己
isEffSelfPet(srcpet: PetHandler, dstpet: PetHandler){
if(this._data.friendlyid != GameCampType.SELF){
return false;
@ -162,6 +167,33 @@ export class Skill {
this._data.num_signid, this._data.eff_num, ap? ap: this._data.eff_num);
};
getHaloValue(ap?: number): number{
if(!this.isHaloSkill()){
return 0;
}
if(this.halo_v < 0){
this.halo_v = this.getEffValue(ap);
}
return this.halo_v;
};
addHaloValue(v: number): number{
if(this.halo_v < 0){
this.halo_v = this.getEffValue();
}
if(this.halo_v > 0){
let tmp = this.halo_v;
this.halo_v += v;
if(this.halo_v < 0){
this.halo_v = 0;
return -tmp;
}else{
return v;
}
}
return 0;
};
trigger(param: SkillParam, cb?: any) {
//触发buff效果
let res = TriggerManager.onTrigger(this, param);
@ -204,7 +236,7 @@ export class Skill {
switch(efftype){
case SkillEffectType.CARD_ADD:
if(tgt.dsttype == GameUnitType.PLAYER){
let n = tgt.dst.addCard(res);
let n = tgt.dst.addCard(res, tgt.srcplayer);
if(n >= 0){
tgt.success(efftype, n);
}
@ -214,7 +246,7 @@ export class Skill {
break;
case SkillEffectType.CARD_ADD_LIMIT:
if(tgt.dsttype == GameUnitType.PLAYER){
let n = tgt.dst.addCardLimit(res);
let n = tgt.dst.addCardLimit(res, tgt.srcplayer);
if(n >= 0){
tgt.success(efftype, n);
}
@ -245,7 +277,7 @@ export class Skill {
case SkillEffectType.POWER_ENHANCE:
case SkillEffectType.POWEREX_ENHANCE:
if(tgt.dsttype != GameUnitType.NONE && tgt.dsttype != GameUnitType.PLAYER){
let n = efftype == SkillEffectType.POWER_ENHANCE? tgt.dst.addBaseAP(effvalue): tgt.dst.addExAP(effvalue);
let n = efftype == SkillEffectType.POWER_ENHANCE? tgt.dst.addBaseAP(effvalue): tgt.dst.addExAP(effvalue, this);
tgt.success(efftype, n);
}else{
tgt.fail(efftype, -1);
@ -264,14 +296,13 @@ export class Skill {
}
};
handleHP(efftype: SkillEffectType, effvalue: number, tgt: SkillTarget){
if(efftype == SkillEffectType.HURT_HP){
if(tgt.dsttype == GameUnitType.PLAYER){
let n = tgt.dst.addHp(effvalue);
tgt.success(efftype, n);
}else{
tgt.fail(efftype, -1);
}
handleHP(effvalue: number, tgt: SkillTarget){
let efftype = SkillEffectType.HURT_HP;
if(tgt.dsttype == GameUnitType.PLAYER){
let n = tgt.dst.addHp(effvalue);
tgt.success(efftype, n);
}else{
tgt.fail(efftype, -1);
}
};
@ -279,13 +310,13 @@ export class Skill {
let ncount = 1 + exparam.edd_cnt;
switch(efftype){
case SkillEffectType.SUMMON_NPC:
let n = tgt.srcplayer.summonPet(this._data.quoteunitid, ncount, exparam);
let n = tgt.dst.summonPet(this._data.quoteunitid, ncount, exparam);
if(n >= 0){
tgt.success(efftype, n);
}
break;
case SkillEffectType.SUMMON_SKILL:
let res = tgt.srcplayer.useSkill(this._data.quoteskillid, ncount, exparam);
let res = tgt.dst.useSkill(this._data.quoteskillid, ncount, exparam);
if(res){
tgt.success(efftype, res.length);
}
@ -295,18 +326,27 @@ export class Skill {
}
};
taunt(tgt:SkillTarget){
let efftype = SkillEffectType.TAUNT;
if(tgt.dsttype != GameUnitType.NONE && tgt.dsttype != GameUnitType.PLAYER){
tgt.dst.taunt();
tgt.success(efftype, 1);
}else{
tgt.fail(efftype, -1);
}
};
addBuff(efftype: SkillEffectType, effvalue: number, tgt: SkillTarget){
};
reduceHurt(efftype: SkillEffectType, effvalue: number, tgt: SkillTarget){
if(efftype == SkillEffectType.HURT_REDUCE){
if(tgt.dsttype != GameUnitType.NONE && tgt.dsttype != GameUnitType.PLAYER){
let n = tgt.dst.addReduceHurt(effvalue);
tgt.success(efftype, n);
}else{
tgt.fail(efftype, -1);
}
reduceHurt(effvalue: number, tgt: SkillTarget){
let efftype = SkillEffectType.HURT_REDUCE;
if(tgt.dsttype != GameUnitType.NONE && tgt.dsttype != GameUnitType.PLAYER){
let n = tgt.dst.addReduceHurt(effvalue);
tgt.success(efftype, n);
}else{
tgt.fail(efftype, -1);
}
};

View File

@ -50,6 +50,9 @@ export class SkillTarget{
dst: any;
dsttype: GameUnitType;
lasttime: number;
bresok: boolean = false;
res: SkillResult[];
constructor(skill: Skill, splayer?: PlayerHandler, spet?: PetHandler, dstobj?: any, dsttype?: GameUnitType) {
@ -59,6 +62,7 @@ export class SkillTarget{
this.srcskillid = skill._id;
this.dst = dstobj;
this.dsttype = dsttype;
this.lasttime = skill._data.indicate_time;
};
public LoadParam(sp: SkillParam){
@ -82,6 +86,7 @@ export class SkillTarget{
public success(efftype: number, effres: number){
this.checkRes();
this.res.push(new SkillResult(efftype, effres, true));
this.bresok = true;
};
public fail(efftype: number, err: number){
@ -89,6 +94,10 @@ export class SkillTarget{
this.res.push(new SkillResult(efftype, 0, false, err));
};
public getLastTime(){
return this.bresok? this.lasttime: 0;
};
public exportData(): SkillInfoMsg{
let msg = new SkillInfoMsg();
msg.data = new SkillInfoData();
@ -102,6 +111,14 @@ export class SkillTarget{
}else{
this.res.forEach((item: SkillResult) => {
let ed = new SKillEffectData();
if(this.dsttype == GameUnitType.PLAYER){
ed.pos = 0;
ed.player = this.dst.getId();
}else {
ed.pos = this.dst._idx;
ed.player = this.dst._owner.getId();
}
ed.pos = this.dsttype != GameUnitType.PLAYER? this.dst:
ed.effect_id = item.effect_type;
ed.val = item.bsuccess? item.effect_res: item.err;
ed.result = item.bsuccess? 0: -1;

View File

@ -107,10 +107,12 @@ let TriggerManager = {
});
break;
case SkillEffectType.TAUNT:
//todo: 不处理
tgts.forEach((item)=>{
sender.taunt(item);
});
case SkillEffectType.HURT_HP:
tgts.forEach((item)=>{
sender.handleHP(effectid, effv + env, item);
sender.handleHP(effv + env, item);
});
break;
case SkillEffectType.POWER_ADD_BUFF:
@ -120,7 +122,7 @@ let TriggerManager = {
break;
case SkillEffectType.HURT_REDUCE:
tgts.forEach((item)=>{
sender.reduceHurt(effectid, effv + env, item);
sender.reduceHurt(effv + env, item);
});
break;
default: