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

This commit is contained in:
zhl 2020-12-09 20:13:28 +08:00
commit dd14a4d184
3 changed files with 129 additions and 25 deletions

View File

@ -10,6 +10,7 @@ import { Room } from "colyseus";
import { Skill } from "../skill/Skill";
import { PetHandler } from "./PetHandler";
import { SkillInfoMsg } from "message/SkillInfo";
import { PetInfo } from "message/PetInfo";
export class BattleHandler {
@ -367,6 +368,17 @@ export class BattleHandler {
return this._room.updatePet([apet.exportInfo()]);
};
public onUpdatePetsNotify(pets: PetHandler[]){
if(!pets || pets.length <= 0){
return;
}
let lst: PetInfo[] = [];
pets.forEach((item: PetHandler)=>{
lst.push(item.exportInfo());
});
return this._room.updatePet(lst);
};
public onPlayerAddCardNotify(aplayer: PlayerHandler, count: number, maxcount: number,
from?: PlayerHandler): number{
return this._room.addCard(aplayer.getId(), count, maxcount, 1, from? from.getId(): null);

View File

@ -38,7 +38,7 @@ export class PetHandler {
_istaunt: boolean = false; // 是否是嘲讽
_selfskills: number[] = [];
_exskills: number[] = [];
_idx: number;
public init(apet: Pet, owner: PlayerHandler, index: number){
@ -73,7 +73,7 @@ export class PetHandler {
});
if(this._halos.length > 0){
this._owner.onHaloChanged(this);
this._owner.onHaloAdd(this, false);
}
this.born(param);
@ -92,8 +92,12 @@ export class PetHandler {
// this._exap = 0;
};
public addEffHalo(skill: Skill){
this._effhalos.push(skill);
public addEffHalo(skill: Skill): boolean{
if(!this.hasEffHalo(skill)){
this._effhalos.push(skill);
return true;
}
return false;
// this._exap += ap;
};
@ -106,6 +110,14 @@ export class PetHandler {
// return this._exap;
};
public getExSkills(): number[]{
let lst: number[] = [];
this._effhalos.forEach((item: Skill) =>{
lst.push(item._data.id);
});
return lst;
};
public addSkill(skillid: number){
if(skillid > 0){
let obj = this._skills.get(skillid);
@ -235,7 +247,8 @@ export class PetHandler {
public clear(){
if(this._halos.length > 0){
this._halos.length = 0;
this._owner.onHaloChanged(this);
this.clearEffHalos();
this._owner.onHaloRemove(this);
}
this._waitskills.length = 0;
};
@ -252,16 +265,37 @@ export class PetHandler {
return this._owner.summonPet(petid, count, exparam);
};
public hasHalo(): boolean{
return this._halos.length > 0;
public hasHalo(skill: Skill): boolean{
return this._halos.includes(skill);
};
public checkHalo(apet: PetHandler){
public hasEffHalo(skill: Skill): boolean{
return this._effhalos.includes(skill);
};
// 自己的光环是否加到apet上
public checkHalo(apet: PetHandler): boolean{
let bok = false;
this._halos.forEach((item: Skill)=>{
if(item.isEffSelfPet(this, apet)){
this.addEffHalo(item); // 暂时都加战力
if(apet.addEffHalo(item)){
bok = true;
} // 暂时都加战力
}
});
return bok;
};
public removeEffHalo(apet: PetHandler): boolean{
let bok = false;
for(let i = this._effhalos.length - 1; i >=0;i--){
let sk = this._effhalos[i];
if(apet.hasHalo(sk)){
this._effhalos.splice(i, 1);
bok = true;
}
}
return bok;
};
public checkSkills(tgtype: TriggerType, tgtv: any, sp: SkillParam, cb?: any){
@ -280,7 +314,7 @@ export class PetHandler {
player: this._owner.getId(),
harmReduce: this._exredhurt,
skills: this._selfskills,
extSkills: this._exskills
extSkills: this.getExSkills()
});
return obj;
};
@ -303,7 +337,7 @@ export class PetHandler {
obj.player = this._owner.getId(),
obj.harmReduce = this._exredhurt,
obj.skills = this._selfskills,
obj.extSkills = this._exskills;
obj.extSkills = this.getExSkills();
return obj;
};

View File

@ -204,7 +204,7 @@ export class PlayerHandler {
}
}
if(bhalo){
this.onHaloChanged(pet);
this.onHaloAdd(pet, true);
}
if(bchged){
pet.dataChanged();
@ -279,21 +279,79 @@ export class PlayerHandler {
this._owner.onUpdatePetNotify(apet);
};
public onHaloChanged(apet: PetHandler){
this._self.clearEffHalos();
this._pets.forEach((obj:PetHandler)=>{
obj.clearEffHalos();
});
this._pets.forEach((obj: PetHandler)=>{
if(obj != apet){
obj.checkHalo(apet);
public onHaloAdd(apet: PetHandler, only_checkother: boolean = false){
let bkself = this._self._effhalos.length;
let bkpets: number[] = [];
let lst: PetHandler[] = [];
if(only_checkother){
this._pets.forEach((obj: PetHandler)=>{
if(apet.checkHalo(obj)){
lst.push(obj);
}
});
if(this._self != apet){
if(apet.checkHalo(this._self)){
lst.push(this._self);
}
}
}else{
this._self.clearEffHalos();
this._pets.forEach((obj:PetHandler)=>{
bkpets.push(obj._effhalos.length);
obj.clearEffHalos();
});
apet.checkHalo(apet);
this._pets.forEach((obj: PetHandler)=>{
if(obj != apet){
obj.checkHalo(apet);
apet.checkHalo(obj);
}
});
if(this._self != apet){
this._self.checkHalo(apet);
apet.checkHalo(this._self);
}
if(bkself != this._self._effhalos.length){
if(this._self != apet){
lst.push(this._self);
}
}
for(let i = 0; i < bkpets.length; i++){
let bk = bkpets[i];
let obj = this._pets[i];
if(obj != apet && obj._effhalos.length != bk){
lst.push(obj);
}
}
apet.checkHalo(obj);
});
if(this._self != apet){
this._self.checkHalo(apet);
apet.checkHalo(this._self);
}
this._owner.onUpdatePetsNotify(lst);
};
public onHaloRemove(apet: PetHandler){
let lst: PetHandler[] = [];
this._pets.forEach((obj: PetHandler)=>{
if(apet != obj){
if(obj.removeEffHalo(apet)){
lst.push(obj);
}
}
});
if(this._self != apet){
if(this._self.removeEffHalo(apet)){
lst.push(this._self);
}
}
this._owner.onUpdatePetsNotify(lst);
};
public isMyPet(apet: PetHandler){