增加替换pet处理
This commit is contained in:
parent
5d392a0fdb
commit
d4996d97c7
@ -288,6 +288,18 @@ let CfgMan = {
|
||||
return minv;
|
||||
}
|
||||
return Math.round(Math.random() * maxv + minv);
|
||||
},
|
||||
|
||||
hasSummonPetSkill(skillids: number[]){
|
||||
let bok = false;
|
||||
for(let i=0; i<skillids.length;i++){
|
||||
let cfg = this.findSkillCfg(skillids[i]);
|
||||
if(cfg && cfg.quoteunitid && cfg.tigger_typeid == 0){
|
||||
bok = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return bok;
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -401,7 +401,7 @@ export class BattleHandler {
|
||||
|
||||
let ps = new SkillParam(obj.card, pt, obj.eff_cnt, ph, null, dstph, dstpt);
|
||||
|
||||
ph.useCard(ps);
|
||||
ph.useCard(ps, obj.oldpos);
|
||||
|
||||
this.onUseCardEnd(ps);
|
||||
|
||||
@ -438,6 +438,10 @@ export class BattleHandler {
|
||||
return ph? ph.getTransEffCardRate(): 0;
|
||||
};
|
||||
|
||||
public replacePet(playerid: string, petpos: number, petid: string){
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* 吃牌/胡牌确认[暂不用]
|
||||
* @param aplayer : 玩家
|
||||
|
@ -88,9 +88,16 @@ export class PlayerHandler {
|
||||
return pr;
|
||||
};
|
||||
|
||||
public delPet(ph: PetHandler){
|
||||
let idx = this._pets.indexOf(ph);
|
||||
public delPet(pet: PetHandler){
|
||||
if(!pet){
|
||||
return;
|
||||
}
|
||||
this.onEMChanged(pet._enmagic);//删除法强
|
||||
pet.clear();
|
||||
let idx = this._pets.indexOf(pet);
|
||||
(idx >= 0) && this._pets.splice(idx, 1);
|
||||
|
||||
this._owner.onDelPetNotify(pet);
|
||||
};
|
||||
|
||||
public getPet(pet: Pet): PetHandler{
|
||||
@ -99,6 +106,18 @@ export class PlayerHandler {
|
||||
});
|
||||
};
|
||||
|
||||
public findPet(pos: number): PetHandler{
|
||||
if(pos < 0){
|
||||
return null;
|
||||
}
|
||||
if(pos == 0){
|
||||
return this._self;
|
||||
}
|
||||
return this._pets.find((item:PetHandler)=>{
|
||||
return item._idx == pos;
|
||||
})
|
||||
};
|
||||
|
||||
public exportAllPets(skill: Skill, param: SkillParam, expet: PetHandler, dst: SkillTarget[]): SkillTarget[]{
|
||||
if(!dst){
|
||||
return null;
|
||||
@ -130,14 +149,31 @@ export class PlayerHandler {
|
||||
return dst;
|
||||
};
|
||||
|
||||
public useCard(obj: SkillParam)
|
||||
public useCard(obj: SkillParam, oldpos?: number)
|
||||
{
|
||||
let cfg = CfgMan.findEffCardCfg(obj.cardid);
|
||||
if(!cfg){
|
||||
return false;
|
||||
}
|
||||
|
||||
let lst = [];
|
||||
cfg.quoteskill1id && lst.push(cfg.quoteskill1id);
|
||||
cfg.quoteskill2id && lst.push(cfg.quoteskill2id);
|
||||
cfg.quoteskill3id && lst.push(cfg.quoteskill3id);
|
||||
cfg.quoteskill4id && lst.push(cfg.quoteskill4id);
|
||||
|
||||
let oldpet = this.findPet(oldpos);
|
||||
if(oldpet == this._self){
|
||||
oldpet = null;
|
||||
}
|
||||
|
||||
if(cfg.type_id == EffectCardType.NPC || cfg.type_id == EffectCardType.NPC_CUSTOM){
|
||||
let exap = 0;
|
||||
if(oldpet){
|
||||
exap = oldpet.totalAP();
|
||||
this.delPet(oldpet);
|
||||
}
|
||||
|
||||
let pet = this.newPet();
|
||||
if(!pet){
|
||||
return false;
|
||||
@ -148,14 +184,11 @@ export class PlayerHandler {
|
||||
obj.dstpet = pet;
|
||||
}
|
||||
}
|
||||
pet.loadData(cfg.stageunit_id, obj,
|
||||
[cfg.quoteskill1id, cfg.quoteskill2id, cfg.quoteskill3id, cfg.quoteskill4id]);
|
||||
pet.loadData(cfg.stageunit_id, obj, lst, exap);
|
||||
}else if(cfg.type_id == EffectCardType.MAGIC){
|
||||
let lst = [];
|
||||
cfg.quoteskill1id && lst.push(cfg.quoteskill1id);
|
||||
cfg.quoteskill2id && lst.push(cfg.quoteskill2id);
|
||||
cfg.quoteskill3id && lst.push(cfg.quoteskill3id);
|
||||
cfg.quoteskill4id && lst.push(cfg.quoteskill4id);
|
||||
if(oldpet && CfgMan.hasSummonPetSkill(lst)){
|
||||
this.delPet(oldpet);
|
||||
}
|
||||
this.useSkills(lst, obj);
|
||||
}
|
||||
};
|
||||
@ -334,9 +367,6 @@ export class PlayerHandler {
|
||||
}
|
||||
|
||||
if(apet.isDead()){
|
||||
this.onEMChanged(-apet._enmagic);//删除法强
|
||||
this._owner.onDelPetNotify(apet);
|
||||
apet.clear();
|
||||
this.delPet(apet);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user