diff --git a/src/global.d.ts b/src/global.d.ts index 8a2b03f..5032c7a 100644 --- a/src/global.d.ts +++ b/src/global.d.ts @@ -127,6 +127,14 @@ declare module "colyseus" { * @param options */ bGameResult(data?: any, options?: any): void; + + /** + * 发送换卡消息 + * @param client + * @param data + */ + sChangeCard(client: Client, data?: any):void; + /** * 发送给个人的消息列表 * @param client diff --git a/src/rooms/MSender.ts b/src/rooms/MSender.ts index 4d10517..53691f6 100644 --- a/src/rooms/MSender.ts +++ b/src/rooms/MSender.ts @@ -36,7 +36,7 @@ Object.defineProperties(Room.prototype, { */ sSelectHero: { value: function (client: Client, data?: any) { - client.send('select_hero_s2c', data); + client && client.send('select_hero_s2c', data); }, writable: true }, @@ -56,7 +56,7 @@ Object.defineProperties(Room.prototype, { */ sDrawCard: { value: function (client: Client, data?: any) { - client.send('draw_card_s2c', data); + client && client.send('draw_card_s2c', data); } }, /** @@ -108,7 +108,7 @@ Object.defineProperties(Room.prototype, { */ sMsgQueue: { value: function (client:Client, datas?: IMsg) { - client.send("msg_queue_s2c", datas); + client && client.send("msg_queue_s2c", datas); } }, /** @@ -151,7 +151,7 @@ Object.defineProperties(Room.prototype, { */ sStealCard: { value: function (client: Client, data?: any) { - client.send("steal_card_s2c", data, {afterNextPatch: true}); + client && client.send("steal_card_s2c", data, {afterNextPatch: true}); } }, /** @@ -161,7 +161,7 @@ Object.defineProperties(Room.prototype, { */ bRemoveCard: { value: function (client: Client, data?: any) { - client.send("remove_card_s2c", data); + client && client.send("remove_card_s2c", data); } }, /** @@ -209,6 +209,12 @@ Object.defineProperties(Room.prototype, { value: function (data?: any, options?: any) { this.broadcast('game_result_s2c', data, options); } + }, + + sChangeCard: { + value: function (client: Client, data?: any) { + client && client.send("change_card_s2c", data); + } } }); diff --git a/src/rooms/commands/ChangeCardCommand.ts b/src/rooms/commands/ChangeCardCommand.ts index 710a894..e139360 100644 --- a/src/rooms/commands/ChangeCardCommand.ts +++ b/src/rooms/commands/ChangeCardCommand.ts @@ -22,16 +22,16 @@ export class ChangeCardCommand extends Command maxCount) { - client.send('change_card_s2c', {errcode: 3, errmsg: '换卡数量超过限制'}); + this.room.sChangeCard(client,{errcode: 3, errmsg: '换卡数量超过限制'}); return; } @@ -43,7 +43,7 @@ export class ChangeCardCommand extends Command { self.room.dispatcher.dispatch(new EatConfirmCommand(), {timeUp: true}); } this.room.beginSchedule(time, timeOverEat, `eat_round`); - // this.room.mainClock = this.clock.setTimeout(function () { - // debugRoom('吃牌时间到, 进入下一轮') - // self.room.mainClock.clear(); - // // self.room.dispatcher.dispatch(new TurnEndCommand()); - // self.room.dispatcher.dispatch(new EatConfirmCommand(), {timeUp: true}); - // }, time); } }