diff --git a/src/rooms/logic/Handler/PetHandler.ts b/src/rooms/logic/Handler/PetHandler.ts index bc7b038..aac1833 100644 --- a/src/rooms/logic/Handler/PetHandler.ts +++ b/src/rooms/logic/Handler/PetHandler.ts @@ -108,7 +108,7 @@ export class PetHandler { this.addSkill(skillid); }); - this._owner.onHaloAdd(this, false); + this._owner.onHaloAdd(this); this.born(param); }; @@ -121,10 +121,6 @@ export class PetHandler { return enid == EnhanceEffectType.EN_POWER_BYCFG || enid == EnhanceEffectType.EN_POWER_BYAP; }; - public addHalo(halo: Skill){ - this._halos.push(halo); - }; - public clearEffHalos(){ this._effhalos.length = 0; // this._exap = 0; @@ -156,21 +152,29 @@ export class PetHandler { return lst; }; - public addSkill(skillid: number, count: number = 1): Skill[]{ + public addSkill(skillid: number, count: number = 1, sender?: PetHandler): Skill[]{ let lst; if(skillid > 0){ + if(sender){ + let sk = this._skills.find((item: Skill) =>{ + return item._id == skillid && item._sender == sender; + }); + if(sk){ + return lst; + } + } lst = []; for(let i = 0; i < count;i++){ let obj = this._owner.newSkill(skillid); if(obj){ - obj.setOrignParam(this._orignEffCnt, this._orignCardPoint); + obj.setOrignParam(this._orignEffCnt, this._orignCardPoint, sender? sender: this); this._skills.push(obj); this._selfskills.push(skillid); if(obj.isBornSkill()){ this._bornSkills.push(obj); }else if(obj.isDieSkill()){ this._dieSkills.push(obj); - }else if(obj.isHaloSkill()){ + }else if(obj.isAPHaloSkill() || obj.isBuffHaloSkill()){ this._halos.push(obj); }else{ this._waitskills.push(obj); @@ -183,36 +187,40 @@ export class PetHandler { return lst; }; - public delSkill(skillid:number, halocb?: any){ - if(skillid > 0){ - let idx = this._skills.findIndex((item:Skill) => { - return item._id == skillid; - }); - + public delSkill(sk:Skill, baseidx: number){ + if(sk){ + let obj = sk; + let idx = this._bornSkills.indexOf(obj); if(idx >= 0){ - let baseidx = idx; - let obj = this._skills[idx]; - idx = this._bornSkills.indexOf(obj); - if(idx >= 0){ - this._bornSkills.splice(idx, 1); - } - idx = this._dieSkills.indexOf(obj); - if(idx >= 0){ - this._dieSkills.splice(idx, 1); - } - idx = this._halos.indexOf(obj); - if(idx >= 0){ - this._halos.splice(idx, 1); - halocb && halocb(this); - } - idx = this._waitskills.indexOf(obj); - if(idx >= 0){ - this._waitskills.splice(idx, 1); - } - - this._skills.splice(baseidx, 1); + this._bornSkills.splice(idx, 1); + } + idx = this._dieSkills.indexOf(obj); + if(idx >= 0){ + this._dieSkills.splice(idx, 1); + } + idx = this._halos.indexOf(obj); + if(idx >= 0){ + this._halos.splice(idx, 1); + } + idx = this._waitskills.indexOf(obj); + if(idx >= 0){ + this._waitskills.splice(idx, 1); + } + + this._skills.splice(baseidx, 1); + + return true; + } + + return false; + }; + + public delSkills(sender: PetHandler){ + for(let i = this._skills.length - 1; i >=0 ; i--){ + let obj = this._skills[i]; + if(obj._sender == sender){ + this.delSkill(obj, i); } - } }; @@ -454,14 +462,20 @@ export class PetHandler { let bok = false; this._halos.forEach((item: Skill)=>{ if(item.isEffSelfPet(this, apet)){ - if(apet._addEffHalo(item)){ - bok = true; - } // 暂时都加战力 + if(item.isAPHaloSkill()){ + if(apet._addEffHalo(item)){ + bok = true; + } // 加战力 + }else if(item.isBuffHaloSkill()){ + item.trigger(new SkillParam(0, 0, 0, this._owner, + this, apet._owner, apet)); + } // 触发技能 } }); return bok; }; + // remove掉apet的光环 public removeEffHalo(apet: PetHandler): boolean{ let bok = false; for(let i = this._effhalos.length - 1; i >=0;i--){ @@ -471,6 +485,7 @@ export class PetHandler { bok = true; } } + (apet != this) && this.delSkills(apet); return bok; }; diff --git a/src/rooms/logic/Handler/PlayerHandler.ts b/src/rooms/logic/Handler/PlayerHandler.ts index decc119..f076d11 100644 --- a/src/rooms/logic/Handler/PlayerHandler.ts +++ b/src/rooms/logic/Handler/PlayerHandler.ts @@ -28,6 +28,8 @@ export class PlayerHandler { public _friend: PlayerHandler; + public _cardstate: CondType = CondType.NO_COND; + _totalcc: number = 0; private _totalem: number = 0; @@ -223,8 +225,8 @@ export class PlayerHandler { return obj; }; - public addSkill(skillid: number, count: number = 1): Skill[]{ - return this._self? this._self.addSkill(skillid, count): null; + public addSkill(skillid: number, count: number = 1, sender?: PetHandler): Skill[]{ + return this._self? this._self.addSkill(skillid, count, sender): null; }; public handleSkill(skillid: number, count: number, param: SkillParam, pet: PetHandler):SkillTarget[]{ @@ -251,7 +253,7 @@ export class PlayerHandler { lst.push(obj); }else if(obj.isDieSkill()){ //nothing to do - }else if(obj.isHaloSkill()){ + }else if(obj.isAPHaloSkill() || obj.isBuffHaloSkill()){ //only handle halo, not handle skill bhalo = true; }else{ @@ -397,7 +399,7 @@ export class PlayerHandler { /** * * @param apet : 新增的光环怪 - * @param only_checkother : 只检查别人加给pet的光环 + * @param only_checkother : 只检查apet加给别人的光环 */ public onHaloAdd(apet: PetHandler, only_checkother: boolean = false){ let lst: PetHandler[] = []; @@ -414,8 +416,10 @@ export class PlayerHandler { } } }else{ + // apet加给自己 apet.addEffHalo(apet); - + + // apet加给别人/别人加给apet this._pets.forEach((obj: PetHandler)=>{ if(obj != apet){ obj.addEffHalo(apet); @@ -425,6 +429,7 @@ export class PlayerHandler { } }); + // _self加给apet/apet加给_self if(this._self != apet && this._self){ this._self.addEffHalo(apet); if(apet.addEffHalo(this._self)){ @@ -547,6 +552,7 @@ export class PlayerHandler { }; onCardLinkEnd(linkcards: Card[], fromplayer: PlayerHandler){ + this._cardstate = fromplayer? CondType.CARD_ACTION_LINK_OTHER: CondType.CARD_ACTION_LINK_SELF; this.checkSkills(TriggerType.CARD_LINK_AFTER, fromplayer); }; @@ -565,6 +571,7 @@ export class PlayerHandler { onUseCardEnd(sp: SkillParam){ this.checkSkills(TriggerType.CARD_USED, 0, sp); + this._cardstate = CondType.NO_COND; // 重置状态 }; onRoundStart(){ @@ -573,6 +580,7 @@ export class PlayerHandler { onRoundEnd(){ this.checkSkills(TriggerType.ROUND_END_MYSELF); + this._cardstate = CondType.NO_COND; // 重置状态 }; checkSkills(tgttype: TriggerType, tgtvalue?: any, tgtsp?: SkillParam){ diff --git a/src/rooms/logic/skill/Condition.ts b/src/rooms/logic/skill/Condition.ts index 8806c93..45f95cb 100644 --- a/src/rooms/logic/skill/Condition.ts +++ b/src/rooms/logic/skill/Condition.ts @@ -35,9 +35,11 @@ export class Condition { v = tg_owner.getTotalCardCount(this._cdt, this._v); return this._isok(v,this._v,this._cdt); case CondType.CARD_ACTION_LINK_OTHER: - return !!tg_value; case CondType.CARD_ACTION_LINK_SELF: - return !tg_value; + return tg_owner._cardstate == this._type; + case CondType.CARD_ACTION_LINK: + return tg_owner._cardstate == CondType.CARD_ACTION_LINK_OTHER || + tg_owner._cardstate == CondType.CARD_ACTION_LINK_SELF; default: break; } diff --git a/src/rooms/logic/skill/Skill.ts b/src/rooms/logic/skill/Skill.ts index 4867886..a323155 100644 --- a/src/rooms/logic/skill/Skill.ts +++ b/src/rooms/logic/skill/Skill.ts @@ -31,6 +31,8 @@ export class Skill { _orign_cardpt: number = 0; private _subskill: Skill; + + _sender: PetHandler; // LIFE-CYCLE CALLBACKS: // onLoad () {}; @@ -93,7 +95,7 @@ export class Skill { return this._type == SkillType.DEAD; }; - isHaloSkill(){ + isAPHaloSkill(){ return this._type == SkillType.HALO; }; @@ -118,6 +120,10 @@ export class Skill { return this._data.effect_typeid == SkillEffectType.REBORN; }; + isBuffHaloSkill(){ + return false; + }; + isSingleTarget(){ switch(this._data.rangeid){ case SkillRangeUnitType.ALL: @@ -200,7 +206,7 @@ export class Skill { }; getHaloValue(): number{ - if(!this.isHaloSkill()){ + if(!this.isAPHaloSkill()){ return 0; } this.checkHaloValue(); @@ -467,12 +473,21 @@ export class Skill { ncount = 1; } let obj; + let sender: PetHandler = null; + if(this.isBuffHaloSkill()){ + if(tgt.srcpet){ + sender = tgt.srcpet; + }else if(tgt.srcplayer){ + sender = tgt.srcplayer._self; + } + } if(this._data.skill_owners){ obj = tgt.dst; }else{ obj = tgt.srcpet? tgt.srcpet: tgt.srcplayer; } - let n = obj? obj.addSkill(this._data.getskillid, ncount): 0; + + let n = obj? obj.addSkill(this._data.getskillid, ncount, sender): 0; if(n){ tgt.success(efftype, this._data.getskillid); }else{ @@ -592,9 +607,10 @@ export class Skill { this._cb = cb; }; - setOrignParam(effcnt: number, cardpoint: number){ + setOrignParam(effcnt: number, cardpoint: number, sender: PetHandler){ this._orign_effcnt = effcnt; this._orign_cardpt = cardpoint; + this._sender = sender; }; isTotalCardSkill(){