条件处理+光环处理

This commit is contained in:
y.x 2020-12-30 02:26:24 +08:00
parent 949fa8d2f2
commit c99684abb0
4 changed files with 91 additions and 50 deletions

View File

@ -108,7 +108,7 @@ export class PetHandler {
this.addSkill(skillid); this.addSkill(skillid);
}); });
this._owner.onHaloAdd(this, false); this._owner.onHaloAdd(this);
this.born(param); this.born(param);
}; };
@ -121,10 +121,6 @@ export class PetHandler {
return enid == EnhanceEffectType.EN_POWER_BYCFG || enid == EnhanceEffectType.EN_POWER_BYAP; return enid == EnhanceEffectType.EN_POWER_BYCFG || enid == EnhanceEffectType.EN_POWER_BYAP;
}; };
public addHalo(halo: Skill){
this._halos.push(halo);
};
public clearEffHalos(){ public clearEffHalos(){
this._effhalos.length = 0; this._effhalos.length = 0;
// this._exap = 0; // this._exap = 0;
@ -156,21 +152,29 @@ export class PetHandler {
return lst; return lst;
}; };
public addSkill(skillid: number, count: number = 1): Skill[]{ public addSkill(skillid: number, count: number = 1, sender?: PetHandler): Skill[]{
let lst; let lst;
if(skillid > 0){ if(skillid > 0){
if(sender){
let sk = this._skills.find((item: Skill) =>{
return item._id == skillid && item._sender == sender;
});
if(sk){
return lst;
}
}
lst = []; lst = [];
for(let i = 0; i < count;i++){ for(let i = 0; i < count;i++){
let obj = this._owner.newSkill(skillid); let obj = this._owner.newSkill(skillid);
if(obj){ if(obj){
obj.setOrignParam(this._orignEffCnt, this._orignCardPoint); obj.setOrignParam(this._orignEffCnt, this._orignCardPoint, sender? sender: this);
this._skills.push(obj); this._skills.push(obj);
this._selfskills.push(skillid); this._selfskills.push(skillid);
if(obj.isBornSkill()){ if(obj.isBornSkill()){
this._bornSkills.push(obj); this._bornSkills.push(obj);
}else if(obj.isDieSkill()){ }else if(obj.isDieSkill()){
this._dieSkills.push(obj); this._dieSkills.push(obj);
}else if(obj.isHaloSkill()){ }else if(obj.isAPHaloSkill() || obj.isBuffHaloSkill()){
this._halos.push(obj); this._halos.push(obj);
}else{ }else{
this._waitskills.push(obj); this._waitskills.push(obj);
@ -183,36 +187,40 @@ export class PetHandler {
return lst; return lst;
}; };
public delSkill(skillid:number, halocb?: any){ public delSkill(sk:Skill, baseidx: number){
if(skillid > 0){ if(sk){
let idx = this._skills.findIndex((item:Skill) => { let obj = sk;
return item._id == skillid; let idx = this._bornSkills.indexOf(obj);
});
if(idx >= 0){ if(idx >= 0){
let baseidx = idx; this._bornSkills.splice(idx, 1);
let obj = this._skills[idx]; }
idx = this._bornSkills.indexOf(obj); idx = this._dieSkills.indexOf(obj);
if(idx >= 0){ if(idx >= 0){
this._bornSkills.splice(idx, 1); this._dieSkills.splice(idx, 1);
} }
idx = this._dieSkills.indexOf(obj); idx = this._halos.indexOf(obj);
if(idx >= 0){ if(idx >= 0){
this._dieSkills.splice(idx, 1); this._halos.splice(idx, 1);
} }
idx = this._halos.indexOf(obj); idx = this._waitskills.indexOf(obj);
if(idx >= 0){ if(idx >= 0){
this._halos.splice(idx, 1); this._waitskills.splice(idx, 1);
halocb && halocb(this); }
}
idx = this._waitskills.indexOf(obj); this._skills.splice(baseidx, 1);
if(idx >= 0){
this._waitskills.splice(idx, 1); return true;
} }
this._skills.splice(baseidx, 1); 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; let bok = false;
this._halos.forEach((item: Skill)=>{ this._halos.forEach((item: Skill)=>{
if(item.isEffSelfPet(this, apet)){ if(item.isEffSelfPet(this, apet)){
if(apet._addEffHalo(item)){ if(item.isAPHaloSkill()){
bok = true; 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; return bok;
}; };
// remove掉apet的光环
public removeEffHalo(apet: PetHandler): boolean{ public removeEffHalo(apet: PetHandler): boolean{
let bok = false; let bok = false;
for(let i = this._effhalos.length - 1; i >=0;i--){ for(let i = this._effhalos.length - 1; i >=0;i--){
@ -471,6 +485,7 @@ export class PetHandler {
bok = true; bok = true;
} }
} }
(apet != this) && this.delSkills(apet);
return bok; return bok;
}; };

View File

@ -28,6 +28,8 @@ export class PlayerHandler {
public _friend: PlayerHandler; public _friend: PlayerHandler;
public _cardstate: CondType = CondType.NO_COND;
_totalcc: number = 0; _totalcc: number = 0;
private _totalem: number = 0; private _totalem: number = 0;
@ -223,8 +225,8 @@ export class PlayerHandler {
return obj; return obj;
}; };
public addSkill(skillid: number, count: number = 1): Skill[]{ public addSkill(skillid: number, count: number = 1, sender?: PetHandler): Skill[]{
return this._self? this._self.addSkill(skillid, count): null; return this._self? this._self.addSkill(skillid, count, sender): null;
}; };
public handleSkill(skillid: number, count: number, param: SkillParam, pet: PetHandler):SkillTarget[]{ public handleSkill(skillid: number, count: number, param: SkillParam, pet: PetHandler):SkillTarget[]{
@ -251,7 +253,7 @@ export class PlayerHandler {
lst.push(obj); lst.push(obj);
}else if(obj.isDieSkill()){ }else if(obj.isDieSkill()){
//nothing to do //nothing to do
}else if(obj.isHaloSkill()){ }else if(obj.isAPHaloSkill() || obj.isBuffHaloSkill()){
//only handle halo, not handle skill //only handle halo, not handle skill
bhalo = true; bhalo = true;
}else{ }else{
@ -397,7 +399,7 @@ export class PlayerHandler {
/** /**
* *
* @param apet : 新增的光环怪 * @param apet : 新增的光环怪
* @param only_checkother : 只检查别人加给pet的光环 * @param only_checkother : 只检查apet加给别人的光环
*/ */
public onHaloAdd(apet: PetHandler, only_checkother: boolean = false){ public onHaloAdd(apet: PetHandler, only_checkother: boolean = false){
let lst: PetHandler[] = []; let lst: PetHandler[] = [];
@ -414,8 +416,10 @@ export class PlayerHandler {
} }
} }
}else{ }else{
// apet加给自己
apet.addEffHalo(apet); apet.addEffHalo(apet);
// apet加给别人/别人加给apet
this._pets.forEach((obj: PetHandler)=>{ this._pets.forEach((obj: PetHandler)=>{
if(obj != apet){ if(obj != apet){
obj.addEffHalo(apet); obj.addEffHalo(apet);
@ -425,6 +429,7 @@ export class PlayerHandler {
} }
}); });
// _self加给apet/apet加给_self
if(this._self != apet && this._self){ if(this._self != apet && this._self){
this._self.addEffHalo(apet); this._self.addEffHalo(apet);
if(apet.addEffHalo(this._self)){ if(apet.addEffHalo(this._self)){
@ -547,6 +552,7 @@ export class PlayerHandler {
}; };
onCardLinkEnd(linkcards: Card[], fromplayer: 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); this.checkSkills(TriggerType.CARD_LINK_AFTER, fromplayer);
}; };
@ -565,6 +571,7 @@ export class PlayerHandler {
onUseCardEnd(sp: SkillParam){ onUseCardEnd(sp: SkillParam){
this.checkSkills(TriggerType.CARD_USED, 0, sp); this.checkSkills(TriggerType.CARD_USED, 0, sp);
this._cardstate = CondType.NO_COND; // 重置状态
}; };
onRoundStart(){ onRoundStart(){
@ -573,6 +580,7 @@ export class PlayerHandler {
onRoundEnd(){ onRoundEnd(){
this.checkSkills(TriggerType.ROUND_END_MYSELF); this.checkSkills(TriggerType.ROUND_END_MYSELF);
this._cardstate = CondType.NO_COND; // 重置状态
}; };
checkSkills(tgttype: TriggerType, tgtvalue?: any, tgtsp?: SkillParam){ checkSkills(tgttype: TriggerType, tgtvalue?: any, tgtsp?: SkillParam){

View File

@ -35,9 +35,11 @@ export class Condition {
v = tg_owner.getTotalCardCount(this._cdt, this._v); v = tg_owner.getTotalCardCount(this._cdt, this._v);
return this._isok(v,this._v,this._cdt); return this._isok(v,this._v,this._cdt);
case CondType.CARD_ACTION_LINK_OTHER: case CondType.CARD_ACTION_LINK_OTHER:
return !!tg_value;
case CondType.CARD_ACTION_LINK_SELF: 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: default:
break; break;
} }

View File

@ -31,6 +31,8 @@ export class Skill {
_orign_cardpt: number = 0; _orign_cardpt: number = 0;
private _subskill: Skill; private _subskill: Skill;
_sender: PetHandler;
// LIFE-CYCLE CALLBACKS: // LIFE-CYCLE CALLBACKS:
// onLoad () {}; // onLoad () {};
@ -93,7 +95,7 @@ export class Skill {
return this._type == SkillType.DEAD; return this._type == SkillType.DEAD;
}; };
isHaloSkill(){ isAPHaloSkill(){
return this._type == SkillType.HALO; return this._type == SkillType.HALO;
}; };
@ -118,6 +120,10 @@ export class Skill {
return this._data.effect_typeid == SkillEffectType.REBORN; return this._data.effect_typeid == SkillEffectType.REBORN;
}; };
isBuffHaloSkill(){
return false;
};
isSingleTarget(){ isSingleTarget(){
switch(this._data.rangeid){ switch(this._data.rangeid){
case SkillRangeUnitType.ALL: case SkillRangeUnitType.ALL:
@ -200,7 +206,7 @@ export class Skill {
}; };
getHaloValue(): number{ getHaloValue(): number{
if(!this.isHaloSkill()){ if(!this.isAPHaloSkill()){
return 0; return 0;
} }
this.checkHaloValue(); this.checkHaloValue();
@ -467,12 +473,21 @@ export class Skill {
ncount = 1; ncount = 1;
} }
let obj; 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){ if(this._data.skill_owners){
obj = tgt.dst; obj = tgt.dst;
}else{ }else{
obj = tgt.srcpet? tgt.srcpet: tgt.srcplayer; 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){ if(n){
tgt.success(efftype, this._data.getskillid); tgt.success(efftype, this._data.getskillid);
}else{ }else{
@ -592,9 +607,10 @@ export class Skill {
this._cb = cb; this._cb = cb;
}; };
setOrignParam(effcnt: number, cardpoint: number){ setOrignParam(effcnt: number, cardpoint: number, sender: PetHandler){
this._orign_effcnt = effcnt; this._orign_effcnt = effcnt;
this._orign_cardpt = cardpoint; this._orign_cardpt = cardpoint;
this._sender = sender;
}; };
isTotalCardSkill(){ isTotalCardSkill(){