实现移除随从的方法
This commit is contained in:
parent
edc9d78a36
commit
4c0aa66ca2
3
src/global.d.ts
vendored
3
src/global.d.ts
vendored
@ -17,6 +17,7 @@ import {PetInfoMsg} from "./message/PetInfo";
|
|||||||
import {BattleHandler} from "./rooms/logic/Handler/BattleHandler";
|
import {BattleHandler} from "./rooms/logic/Handler/BattleHandler";
|
||||||
import {SkillInfoData, SkillInfoMsg} from "./message/SkillInfo";
|
import {SkillInfoData, SkillInfoMsg} from "./message/SkillInfo";
|
||||||
import {PartResultMsg} from "./message/PartResult";
|
import {PartResultMsg} from "./message/PartResult";
|
||||||
|
import {RemovePetMsg} from "./message/RemovePetMsg";
|
||||||
/**
|
/**
|
||||||
* GeneralRoom 扩展方法
|
* GeneralRoom 扩展方法
|
||||||
*/
|
*/
|
||||||
@ -102,7 +103,7 @@ declare module "colyseus" {
|
|||||||
* @param data
|
* @param data
|
||||||
* @param options
|
* @param options
|
||||||
*/
|
*/
|
||||||
bRemovePet(data?: any, options?: any): void;
|
bRemovePet(data?: RemovePetMsg, options?: any): void;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 广播游戏进行中的决斗结果
|
* 广播游戏进行中的决斗结果
|
||||||
|
21
src/message/RemovePetMsg.ts
Normal file
21
src/message/RemovePetMsg.ts
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
import {IMsg} from "./IMsg";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 移除随从的消息
|
||||||
|
*/
|
||||||
|
export class RemovePetMsg implements IMsg {
|
||||||
|
data: any;
|
||||||
|
errcode: number;
|
||||||
|
errmsg?: string;
|
||||||
|
type?: string;
|
||||||
|
|
||||||
|
|
||||||
|
constructor(data: {
|
||||||
|
id: number,
|
||||||
|
player: string,
|
||||||
|
pos: number,
|
||||||
|
}) {
|
||||||
|
this.errcode = 0;
|
||||||
|
this.data = data;
|
||||||
|
}
|
||||||
|
}
|
@ -4,6 +4,7 @@ import {PetInfoMsg} from "../message/PetInfo";
|
|||||||
import {SkillInfoMsg} from "../message/SkillInfo";
|
import {SkillInfoMsg} from "../message/SkillInfo";
|
||||||
import {Pet} from "./schema/Pet";
|
import {Pet} from "./schema/Pet";
|
||||||
import {PartResultMsg} from "../message/PartResult";
|
import {PartResultMsg} from "../message/PartResult";
|
||||||
|
import {RemovePetMsg} from "../message/RemovePetMsg";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 一些封装了的下发消息的方法
|
* 一些封装了的下发消息的方法
|
||||||
@ -161,8 +162,20 @@ Object.defineProperties(Room.prototype, {
|
|||||||
* @param options
|
* @param options
|
||||||
*/
|
*/
|
||||||
bRemovePet: {
|
bRemovePet: {
|
||||||
value: function (data?: any, options?: any) {
|
value: function (data?: RemovePetMsg, options?: any) {
|
||||||
|
let obj = data.data;
|
||||||
|
let pid = obj.player;
|
||||||
|
let player = this.state.players.get(pid);
|
||||||
|
if (!player) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
let pet = player.pets.get(obj.pos);
|
||||||
|
if (!pet) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
pet.ap = 0;
|
||||||
|
pet.state = 2;
|
||||||
|
player.pets.set(obj.pos + '', pet);
|
||||||
this.broadcast('remove_pet_s2c', data, options);
|
this.broadcast('remove_pet_s2c', data, options);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
Loading…
x
Reference in New Issue
Block a user