Merge branch 'master' of git.kingsome.cn:node/card_svr
This commit is contained in:
commit
dd14a4d184
@ -10,6 +10,7 @@ import { Room } from "colyseus";
|
|||||||
import { Skill } from "../skill/Skill";
|
import { Skill } from "../skill/Skill";
|
||||||
import { PetHandler } from "./PetHandler";
|
import { PetHandler } from "./PetHandler";
|
||||||
import { SkillInfoMsg } from "message/SkillInfo";
|
import { SkillInfoMsg } from "message/SkillInfo";
|
||||||
|
import { PetInfo } from "message/PetInfo";
|
||||||
|
|
||||||
|
|
||||||
export class BattleHandler {
|
export class BattleHandler {
|
||||||
@ -367,6 +368,17 @@ export class BattleHandler {
|
|||||||
return this._room.updatePet([apet.exportInfo()]);
|
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,
|
public onPlayerAddCardNotify(aplayer: PlayerHandler, count: number, maxcount: number,
|
||||||
from?: PlayerHandler): number{
|
from?: PlayerHandler): number{
|
||||||
return this._room.addCard(aplayer.getId(), count, maxcount, 1, from? from.getId(): null);
|
return this._room.addCard(aplayer.getId(), count, maxcount, 1, from? from.getId(): null);
|
||||||
|
@ -38,7 +38,7 @@ export class PetHandler {
|
|||||||
_istaunt: boolean = false; // 是否是嘲讽
|
_istaunt: boolean = false; // 是否是嘲讽
|
||||||
|
|
||||||
_selfskills: number[] = [];
|
_selfskills: number[] = [];
|
||||||
_exskills: number[] = [];
|
|
||||||
_idx: number;
|
_idx: number;
|
||||||
|
|
||||||
public init(apet: Pet, owner: PlayerHandler, index: number){
|
public init(apet: Pet, owner: PlayerHandler, index: number){
|
||||||
@ -73,7 +73,7 @@ export class PetHandler {
|
|||||||
});
|
});
|
||||||
|
|
||||||
if(this._halos.length > 0){
|
if(this._halos.length > 0){
|
||||||
this._owner.onHaloChanged(this);
|
this._owner.onHaloAdd(this, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.born(param);
|
this.born(param);
|
||||||
@ -92,8 +92,12 @@ export class PetHandler {
|
|||||||
// this._exap = 0;
|
// this._exap = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
public addEffHalo(skill: Skill){
|
public addEffHalo(skill: Skill): boolean{
|
||||||
this._effhalos.push(skill);
|
if(!this.hasEffHalo(skill)){
|
||||||
|
this._effhalos.push(skill);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
// this._exap += ap;
|
// this._exap += ap;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -106,6 +110,14 @@ export class PetHandler {
|
|||||||
// return this._exap;
|
// 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){
|
public addSkill(skillid: number){
|
||||||
if(skillid > 0){
|
if(skillid > 0){
|
||||||
let obj = this._skills.get(skillid);
|
let obj = this._skills.get(skillid);
|
||||||
@ -235,7 +247,8 @@ export class PetHandler {
|
|||||||
public clear(){
|
public clear(){
|
||||||
if(this._halos.length > 0){
|
if(this._halos.length > 0){
|
||||||
this._halos.length = 0;
|
this._halos.length = 0;
|
||||||
this._owner.onHaloChanged(this);
|
this.clearEffHalos();
|
||||||
|
this._owner.onHaloRemove(this);
|
||||||
}
|
}
|
||||||
this._waitskills.length = 0;
|
this._waitskills.length = 0;
|
||||||
};
|
};
|
||||||
@ -252,16 +265,37 @@ export class PetHandler {
|
|||||||
return this._owner.summonPet(petid, count, exparam);
|
return this._owner.summonPet(petid, count, exparam);
|
||||||
};
|
};
|
||||||
|
|
||||||
public hasHalo(): boolean{
|
public hasHalo(skill: Skill): boolean{
|
||||||
return this._halos.length > 0;
|
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)=>{
|
this._halos.forEach((item: Skill)=>{
|
||||||
if(item.isEffSelfPet(this, apet)){
|
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){
|
public checkSkills(tgtype: TriggerType, tgtv: any, sp: SkillParam, cb?: any){
|
||||||
@ -280,7 +314,7 @@ export class PetHandler {
|
|||||||
player: this._owner.getId(),
|
player: this._owner.getId(),
|
||||||
harmReduce: this._exredhurt,
|
harmReduce: this._exredhurt,
|
||||||
skills: this._selfskills,
|
skills: this._selfskills,
|
||||||
extSkills: this._exskills
|
extSkills: this.getExSkills()
|
||||||
});
|
});
|
||||||
return obj;
|
return obj;
|
||||||
};
|
};
|
||||||
@ -303,7 +337,7 @@ export class PetHandler {
|
|||||||
obj.player = this._owner.getId(),
|
obj.player = this._owner.getId(),
|
||||||
obj.harmReduce = this._exredhurt,
|
obj.harmReduce = this._exredhurt,
|
||||||
obj.skills = this._selfskills,
|
obj.skills = this._selfskills,
|
||||||
obj.extSkills = this._exskills;
|
obj.extSkills = this.getExSkills();
|
||||||
return obj;
|
return obj;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -204,7 +204,7 @@ export class PlayerHandler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(bhalo){
|
if(bhalo){
|
||||||
this.onHaloChanged(pet);
|
this.onHaloAdd(pet, true);
|
||||||
}
|
}
|
||||||
if(bchged){
|
if(bchged){
|
||||||
pet.dataChanged();
|
pet.dataChanged();
|
||||||
@ -279,21 +279,79 @@ export class PlayerHandler {
|
|||||||
this._owner.onUpdatePetNotify(apet);
|
this._owner.onUpdatePetNotify(apet);
|
||||||
};
|
};
|
||||||
|
|
||||||
public onHaloChanged(apet: PetHandler){
|
public onHaloAdd(apet: PetHandler, only_checkother: boolean = false){
|
||||||
this._self.clearEffHalos();
|
let bkself = this._self._effhalos.length;
|
||||||
this._pets.forEach((obj:PetHandler)=>{
|
let bkpets: number[] = [];
|
||||||
obj.clearEffHalos();
|
|
||||||
});
|
let lst: PetHandler[] = [];
|
||||||
this._pets.forEach((obj: PetHandler)=>{
|
if(only_checkother){
|
||||||
if(obj != apet){
|
this._pets.forEach((obj: PetHandler)=>{
|
||||||
obj.checkHalo(apet);
|
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){
|
public isMyPet(apet: PetHandler){
|
||||||
|
Loading…
x
Reference in New Issue
Block a user