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

This commit is contained in:
zhl 2021-01-08 17:40:37 +08:00
commit f24800e8fc
3 changed files with 67 additions and 15 deletions

File diff suppressed because one or more lines are too long

View File

@ -28,6 +28,8 @@ export class BattleHandler {
private _gamestart: boolean = false;
private _cacheSkills: SkillTarget[] = [];
private _cachePets: PetHandler[] = [];
private _lastlinkph: PlayerHandler;
//--------------------对外接口--player相关---(外部调用)----------------------------
@ -412,9 +414,13 @@ export class BattleHandler {
return lst;
};
public checkPets(){
this._players.forEach((item: PlayerHandler) => {
item.checkPets(true);
public checkPets(pets: PetHandler[]){
pets.forEach((item: PetHandler) =>{
if(!item.isAlive()){
item.destroy();
}else{
item.resetBakAP();
}
});
};
@ -431,6 +437,7 @@ export class BattleHandler {
if(this._flowcount == 0){
this._sktime = 0;
this._cacheSkills.length = 0;
this._cachePets.length = 0;
}
this._flowcount++;
@ -452,9 +459,23 @@ export class BattleHandler {
this.onSkillResultNotify(this._cacheSkills);
this._cacheSkills.length = 0;
}
this.checkPets();
let nt = this._sktime * 1000;
if(this._cachePets.length > 0){
if(nt > 0){
this._room.clock.setTimeout(()=>{
this.onUpdatePets(this._cachePets, null);
this.checkPets(this._cachePets);
this._cachePets.length = 0;
}, nt);
}else{
this.onUpdatePets(this._cachePets, null);
this.checkPets(this._cachePets);
this._cachePets.length = 0;
}
}
this._flowcount = res;
return this._sktime * 1000;
return nt;
}
this._flowcount = res;
@ -755,24 +776,51 @@ export class BattleHandler {
};
public onUpdatePetNotify(apet: PetHandler, from: PetHandler){
return this._room.updatePet([apet.exportInfo()], from? from._owner.getId(): null);
this.onUpdatePets([apet], from, true);
if(this.isFlowing()){
if(!this._cachePets.includes(apet)){
this._cachePets.push(apet);
}
}else{
let lst = [apet];
this.onUpdatePets(lst, from);
this.checkPets(lst);
}
};
public onUpdatePetsNotify(pets: PetHandler[], from: PetHandler){
if(!pets || pets.length <= 0){
return;
}
let lst: PetInfo[] = [];
pets.forEach((item: PetHandler)=>{
lst.push(item.exportInfo());
});
return this._room.updatePet(lst, from? from._owner.getId(): null);
this.onUpdatePets(pets, from, true);
if(this.isFlowing()){
pets.forEach((item: PetHandler) =>{
if(!this._cachePets.includes(item)){
this._cachePets.push(item);
}
});
}else{
this.onUpdatePets(pets, from);
this.checkPets(pets);
}
};
public onUpdatePets(infos: PetUpdateProcess[]){
infos.forEach((item: PetUpdateProcess) =>{
this._room.updatePet([item.info], item.from? item.from._owner.getId(): null);
public onUpdatePets(pets: PetHandler[], from: PetHandler, isstat: boolean = false){
if(!pets || pets.length <= 0){
return;
}
let lst: PetInfo[] = [];
pets.forEach((item: PetHandler) =>{
lst.push(item.exportInfo());
});
if(isstat){
this._room.updatePetStat(lst, from? from._owner.getId(): null);
}else{
this._room.updatePet(lst, from? from._owner.getId(): null);
}
};
public onPlayerAddCardNotify(aplayer: PlayerHandler, count: number, maxcount: number,

View File

@ -70,6 +70,10 @@ export class PetHandler {
this._idx = index;
};
public destroy(){
this._owner && this._owner.delPet(this);
};
public loadData(id: number, param: SkillParam, exskillid?: number[], exap?: number){
this._id = id || 0;
this._cfg = CfgMan.findUnitCfg(this._id);