From 626524eecf0f1e7a093c04bc69de7acceff88347 Mon Sep 17 00:00:00 2001 From: zhl Date: Mon, 7 Dec 2020 13:25:34 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=B8=B8=E6=88=8F=E7=BB=93?= =?UTF-8?q?=E6=9D=9F=E7=9A=84=E5=B9=BF=E6=92=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/global.d.ts | 7 +++++++ src/rooms/MSender.ts | 10 ++++++++++ src/rooms/commands/GameResultCommand.ts | 1 + 3 files changed, 18 insertions(+) diff --git a/src/global.d.ts b/src/global.d.ts index 72bc077..bfa48d3 100644 --- a/src/global.d.ts +++ b/src/global.d.ts @@ -111,6 +111,13 @@ declare module "colyseus" { * @param options */ bPartResult(data?: PartResultMsg, options?: any): void; + + /** + * 广播游戏最终结果 + * @param data + * @param options + */ + bGameResult(data?: any, options: any): void; /** * 发送给个人的消息列表 * @param client diff --git a/src/rooms/MSender.ts b/src/rooms/MSender.ts index 0eb8076..4c84cce 100644 --- a/src/rooms/MSender.ts +++ b/src/rooms/MSender.ts @@ -189,6 +189,16 @@ Object.defineProperties(Room.prototype, { value: function (data?: PartResultMsg, options?: any) { this.broadcast('part_result_s2c', data, options); } + }, + /** + * 广播游戏最终结果 + * @param data + * @param options + */ + bGameResult: { + value: function (data?: any, options?: any) { + this.broadcast('game_result_s2c', data, options); + } } }); diff --git a/src/rooms/commands/GameResultCommand.ts b/src/rooms/commands/GameResultCommand.ts index 33b2f5a..cd5dae8 100644 --- a/src/rooms/commands/GameResultCommand.ts +++ b/src/rooms/commands/GameResultCommand.ts @@ -8,6 +8,7 @@ import {GameStateConst} from "../../constants/GameStateConst"; export class GameResultCommand extends Command { execute() { + this.room.bGameResult({}); this.state.gameState = GameStateConst.STATE_GAME_OVER; }