223 lines
5.9 KiB
TypeScript
223 lines
5.9 KiB
TypeScript
import {IMsg} from "./message/IMsg";
|
|
import {Client, Room} from "colyseus";
|
|
import {PetInfo, PetInfoMsg} from "./message/PetInfo";
|
|
import {BattleHandler} from "./rooms/logic/Handler/BattleHandler";
|
|
import {SkillInfoMsg} from "./message/SkillInfo";
|
|
import {PartResultMsg} from "./message/PartResult";
|
|
import {RemovePetMsg} from "./message/RemovePetMsg";
|
|
import {Dispatcher} from "@colyseus/command";
|
|
import {Delayed} from "@gamestdio/timer/lib/Delayed";
|
|
import {Player} from "./rooms/schema/Player";
|
|
|
|
export {};
|
|
|
|
declare global {
|
|
namespace NodeJS {
|
|
interface Global {
|
|
NODE_ENV: string
|
|
ROOT_PATH: string
|
|
$cfg: any
|
|
}
|
|
}
|
|
}
|
|
|
|
/**
|
|
* GeneralRoom 扩展方法
|
|
*/
|
|
declare module "colyseus" {
|
|
interface Room {
|
|
battleMan: BattleHandler;
|
|
dispatcher: Dispatcher;
|
|
mainClock: Delayed;
|
|
/**
|
|
* 根据sessionId获取client
|
|
* @param player 玩家id或者玩家的对象
|
|
*/
|
|
getClient(player: string | Player): Client;
|
|
// >>>>>>>>> Begin of extend send message <<<<<<<<<<<<<
|
|
/**
|
|
* 广播玩家加入房间
|
|
* @param data
|
|
* @param options
|
|
*/
|
|
bUserJoin(data?: any, options?: any): void;
|
|
|
|
/**
|
|
* 广播玩家离开
|
|
* @param data
|
|
*/
|
|
bUserLeft(data?: any): void;
|
|
|
|
/**
|
|
* 给指定用户下发英雄选择结果
|
|
* @param client
|
|
* @param data
|
|
*/
|
|
sSelectHero(client: Client, data?: any):void;
|
|
|
|
/**
|
|
* 广播英雄选择结果
|
|
* @param data
|
|
*/
|
|
bSelectHero(data?: any):void;
|
|
|
|
/**
|
|
* 下发抽牌信息
|
|
* @param client
|
|
* @param data
|
|
*/
|
|
sDrawCard(client: Client, data?: any):void;
|
|
|
|
|
|
/**
|
|
* 增加一个随从
|
|
* @param data
|
|
*/
|
|
bAddPet(data?: PetInfoMsg): void;
|
|
|
|
/**
|
|
* 施放一个技能
|
|
* @param data
|
|
*/
|
|
bCastSkill(data?: SkillInfoMsg): void;
|
|
|
|
/**
|
|
* 广播偷卡信息
|
|
* @param data
|
|
* @param options
|
|
*/
|
|
bStealCard(data?: any, options?: any):void;
|
|
|
|
/**
|
|
* 单独下发一个偷卡信息
|
|
* @param data
|
|
*/
|
|
sStealCard(data?: any):void;
|
|
|
|
/**
|
|
* 广播一个抽卡信息
|
|
* @param data
|
|
* @param options
|
|
*/
|
|
bDrawCard(data?: any, options?: any):void;
|
|
|
|
/**
|
|
* 广播一个弃卡信息
|
|
* @param data
|
|
* @param options
|
|
*/
|
|
bRemoveCard(data?: any, options?: any):void;
|
|
|
|
/**
|
|
* 移除随从
|
|
* @param data
|
|
* @param options
|
|
*/
|
|
bRemovePet(data?: RemovePetMsg, options?: any): void;
|
|
/**
|
|
* 广播游戏进行中的决斗结果
|
|
* @param data
|
|
* @param options
|
|
*/
|
|
bPartResult(data?: PartResultMsg, options?: any): void;
|
|
|
|
/**
|
|
* 广播游戏最终结果
|
|
* @param data
|
|
* @param options
|
|
*/
|
|
bGameResult(data?: any, options?: any): void;
|
|
/**
|
|
* 发送给个人的消息列表
|
|
* @param client
|
|
* @param data
|
|
*/
|
|
sMsgQueue(client: Client, data: IMsg[]): void;
|
|
|
|
|
|
/**
|
|
* 广播的消息列表
|
|
* 例:
|
|
* let datas:IMsg[] = [];
|
|
* datas.push({errcode: 0, type: '消息类型', data: {pid: 1}});
|
|
* this.room.bMsgQueue(datas);
|
|
* @param datas
|
|
* @param options
|
|
*/
|
|
bMsgQueue(datas: IMsg[], options?: any): void;
|
|
|
|
|
|
// >>>>>>>>> End of extend send message <<<<<<<<<<<<<
|
|
|
|
// >>>>>>>>> Begin of extend functions <<<<<<<<<<<<<
|
|
|
|
/**
|
|
* 随机从一个玩家那里抽一定数量的卡, 并将抽卡信息广播出去
|
|
* @param srcplayer
|
|
* @param dstplayer 目标玩家
|
|
* @param count 抽卡数量
|
|
*/
|
|
drawCardFromPlayer(srcplayer: string, dstplayer: string, count: number) :number;
|
|
|
|
/**
|
|
* 弃卡, 并广播消息
|
|
* @param dstplayer 目标玩家
|
|
* @param count
|
|
*/
|
|
giveUpCard(dstplayer: string, count: number): boolean;
|
|
|
|
/**
|
|
* 补卡, 并广播消息
|
|
* @param dstplayer 目标玩家
|
|
* @param count 补多少张, 该值和max_count至少一个不为0
|
|
* @param max_count 补到多少张, 如果count和max_count都不为0, 则抽 Math.min(count, (max_count - 当前手牌数))
|
|
* @param source 0: 正常抽卡, 1: 技能, 2: gm命令抽的卡
|
|
* @param fromplayer
|
|
* @param extData 将抽到的卡变成特定的效果
|
|
*/
|
|
addCard(dstplayer: string, count: number, max_count: number, source?: number, fromplayer?: string, extData?: {}): number;
|
|
|
|
/**
|
|
* 更新玩家血量
|
|
* @param dstplayer
|
|
* @param hp
|
|
*/
|
|
updateHp(dstplayer: string, hp: number): number;
|
|
|
|
/**
|
|
* 更新随从信息
|
|
* @param datas
|
|
*/
|
|
updatePet(datas: PetInfo[]): void;
|
|
|
|
/**
|
|
* 给room.mainClock设定任务
|
|
* mainClock任何时候只有一个可执行的任务
|
|
* @param millisecond
|
|
* @param handler
|
|
* @param name
|
|
*/
|
|
beginSchedule(millisecond: number, handler: Function, name: string): void;
|
|
|
|
/**
|
|
* 取消当前room.mainClock的任务
|
|
* mainClock任何时候只有一个可执行的任务
|
|
* 返回当前剩余的毫秒数
|
|
* @param name
|
|
*/
|
|
stopSchedule(name: string): number;
|
|
/**
|
|
* 给room.mainClock增加n秒
|
|
* @param name
|
|
* @param millisecond
|
|
* @param reason
|
|
*/
|
|
addScheduleTime(millisecond: number, reason?: string, name?: string, ): void;
|
|
|
|
addRobot():void;
|
|
|
|
}
|
|
}
|
|
|
|
|