From 787d6af948552ed45bd4485cd26f5a1b417ccaef Mon Sep 17 00:00:00 2001 From: zhl Date: Tue, 2 Feb 2021 10:42:32 +0800 Subject: [PATCH 1/5] =?UTF-8?q?=E6=9A=82=E6=97=B6=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=E6=96=B0=E6=89=8B=E5=85=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/rooms/commands/BeginGameCommand.ts | 13 ++++++++----- src/utils/game.util.ts | 13 ++++++++++++- 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/src/rooms/commands/BeginGameCommand.ts b/src/rooms/commands/BeginGameCommand.ts index 6537844..a2f9b89 100644 --- a/src/rooms/commands/BeginGameCommand.ts +++ b/src/rooms/commands/BeginGameCommand.ts @@ -14,11 +14,14 @@ export class BeginGameCommand extends Command { async execute() { this.state.maxCardId = 0; - let card0 = gameUtil.initCardQue(1); - let card1 = gameUtil.initCardQue(card0.length + 1); - let cardAll = card0.concat(card1); - cardAll.randomSort(); - this.state.cardQueue = cardAll; + // let card0 = gameUtil.initCardQue(1); + // let card1 = gameUtil.initCardQue(card0.length + 1); + // let cardAll = card0.concat(card1); + // cardAll.randomSort(); + let card0 = gameUtil.initSampleCards(1) + // let card1 = gameUtil.initSampleCards(card0.length + 1) + // let cardAll = card0.concat(card1) + this.state.cardQueue = card0; let i = 0; for (let [id] of this.state.players) { this.room.addCard(id, new GameEnv().playerInitNums[i++], 0); diff --git a/src/utils/game.util.ts b/src/utils/game.util.ts index 477b08b..948debb 100644 --- a/src/utils/game.util.ts +++ b/src/utils/game.util.ts @@ -4,7 +4,7 @@ import {Player} from "../rooms/schema/Player"; import {BaseConst} from "../constants/BaseConst"; import {SystemCardCfg} from "../cfg/parsers/SystemCardCfg"; import {EffectCardCfg} from "../cfg/parsers/EffectCardCfg"; -import {cardLog, error} from "../common/Debug"; +import { cardLog, debugRoom, error } from '../common/Debug' import {Room} from "colyseus"; import {PlayerStateConst} from "../constants/PlayerStateConst"; import {GameEnv} from "../cfg/GameEnv"; @@ -39,6 +39,17 @@ let gameUtil = { cards.randomSort(); return cards; }, + initSampleCards(beginNum: number) { + let cardArr = [[1, 1, 20012, 1], [2, 3, 20102, 11], [3, 4, 20032, 1], [4, 10, 20102, 11], [5, 10, 20042, 1], [6, 1, 20012, 1], [7, 3, 20102, 11], [8, 4, 20032, 1], [9, 5, 20102, 11], [10, 6, 20102, 11], [11, 1, 20012, 1], [12, 5, 20102, 11], [13, 5, 20032, 1], [14, 5, 20102, 11], [15, 5, 20102, 11], [16, 6, 20102, 11], [17, 1, 20012, 1], [18, 3, 20102, 11], [19, 5, 20102, 11], [20, 7, 20102, 11], [21, 8, 20042, 1], [22, 10, 20102, 11], [23, 4, 20102, 11], [24, 7, 20052, 1], [25, 3, 20102, 11], [26, 7, 20052, 1], [27, 6, 20072, 1], [28, 1, 20052, 1], [29, 5, 20102, 11], [30, 4, 20052, 1], [31, 0, 20112, 2], [32, 5, 20102, 11], [33, 5, 20062, 1], [34, 2, 20102, 11], [35, 4, 20062, 1], [36, 1, 20072, 1], [37, 1, 20102, 11], [38, 1, 20062, 1], [39, 9, 20042, 1], [40, 0, 20112, 2], [41, 6, 20102, 11], [42, 8, 20072, 1], [43, 0, 20112, 2], [44, 0, 20112, 2], [45, 0, 20112, 2], [46, 0, 20112, 2], [47, 0, 20112, 2], [48, 0, 20112, 2], [49, 10, 20042, 1], [50, 0, 20112, 2], [51, 5, 20102, 11], [52, 5, 20082, 1], [53, 5, 20102, 11], [54, 5, 20052, 1], [55, 0, 20122, 3], [56, 0, 20122, 3], [57, 0, 20122, 3], [58, 0, 20122, 3], [59, 0, 20122, 3], [60, 0, 20122, 3], [61, 0, 20122, 3], [62, 0, 20122, 3], [63, 0, 20112, 2], [64, 0, 20112, 2], [65, 0, 20112, 2], [66, 0, 20112, 2], [67, 0, 20112, 2], [68, 0, 20112, 2]] + let cards: Card[] = []; + for (let i = cardArr.length - 1; i >=0; i--) { + let subarr = cardArr[i] + let card = new Card(subarr[0], subarr[1], subarr[3], subarr[2]) + cards.push(card) + } + debugRoom(cards) + return cards + }, /** * 随机生成一张指定效果的卡 * @param effectId From 314bce21457236a68ceb1c4a3d1f9907806a49df Mon Sep 17 00:00:00 2001 From: zhl Date: Tue, 2 Feb 2021 11:04:40 +0800 Subject: [PATCH 2/5] =?UTF-8?q?=E6=96=B0=E6=89=8B=E5=85=B3=E7=AD=89?= =?UTF-8?q?=E5=BE=85=E6=97=B6=E9=97=B4*1000?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/rooms/GeneralRoom.ts | 3 ++- src/rooms/commands/BeginGameCommand.ts | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/rooms/GeneralRoom.ts b/src/rooms/GeneralRoom.ts index e82f038..681191e 100644 --- a/src/rooms/GeneralRoom.ts +++ b/src/rooms/GeneralRoom.ts @@ -196,7 +196,8 @@ export class GeneralRoom extends Room { let timeOverFun = function () { handler && handler(); } - this.gameClock.set(name, this.clock.setTimeout(timeOverFun, millisecond , name)); + //FixMe:: 移除*1000 + this.gameClock.set(name, this.clock.setTimeout(timeOverFun, millisecond * 1000 , name)); } /** diff --git a/src/rooms/commands/BeginGameCommand.ts b/src/rooms/commands/BeginGameCommand.ts index a2f9b89..717c6e0 100644 --- a/src/rooms/commands/BeginGameCommand.ts +++ b/src/rooms/commands/BeginGameCommand.ts @@ -18,6 +18,7 @@ export class BeginGameCommand extends Command { // let card1 = gameUtil.initCardQue(card0.length + 1); // let cardAll = card0.concat(card1); // cardAll.randomSort(); + //FixMe:: 移除 let card0 = gameUtil.initSampleCards(1) // let card1 = gameUtil.initSampleCards(card0.length + 1) // let cardAll = card0.concat(card1) From fca8dbeb56b71c5cfabead84cf4e43f83d1ceed9 Mon Sep 17 00:00:00 2001 From: zhl Date: Tue, 2 Feb 2021 11:41:33 +0800 Subject: [PATCH 3/5] =?UTF-8?q?=E7=A7=BB=E9=99=A4=E6=96=B0=E6=89=8B?= =?UTF-8?q?=E5=85=B3=E7=9B=B8=E5=85=B3=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/rooms/GeneralRoom.ts | 3 +-- src/rooms/commands/BeginGameCommand.ts | 14 ++++++-------- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/src/rooms/GeneralRoom.ts b/src/rooms/GeneralRoom.ts index 681191e..e82f038 100644 --- a/src/rooms/GeneralRoom.ts +++ b/src/rooms/GeneralRoom.ts @@ -196,8 +196,7 @@ export class GeneralRoom extends Room { let timeOverFun = function () { handler && handler(); } - //FixMe:: 移除*1000 - this.gameClock.set(name, this.clock.setTimeout(timeOverFun, millisecond * 1000 , name)); + this.gameClock.set(name, this.clock.setTimeout(timeOverFun, millisecond , name)); } /** diff --git a/src/rooms/commands/BeginGameCommand.ts b/src/rooms/commands/BeginGameCommand.ts index 717c6e0..4a5312d 100644 --- a/src/rooms/commands/BeginGameCommand.ts +++ b/src/rooms/commands/BeginGameCommand.ts @@ -14,15 +14,13 @@ export class BeginGameCommand extends Command { async execute() { this.state.maxCardId = 0; - // let card0 = gameUtil.initCardQue(1); - // let card1 = gameUtil.initCardQue(card0.length + 1); - // let cardAll = card0.concat(card1); - // cardAll.randomSort(); + let card0 = gameUtil.initCardQue(1); + let card1 = gameUtil.initCardQue(card0.length + 1); + let cardAll = card0.concat(card1); + cardAll.randomSort(); //FixMe:: 移除 - let card0 = gameUtil.initSampleCards(1) - // let card1 = gameUtil.initSampleCards(card0.length + 1) - // let cardAll = card0.concat(card1) - this.state.cardQueue = card0; + // let card0 = gameUtil.initSampleCards(1) + // this.state.cardQueue = card0; let i = 0; for (let [id] of this.state.players) { this.room.addCard(id, new GameEnv().playerInitNums[i++], 0); From 6e51f44245dc03346a76d7609e7b653db6136181 Mon Sep 17 00:00:00 2001 From: zhl Date: Tue, 2 Feb 2021 17:01:33 +0800 Subject: [PATCH 4/5] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E4=B8=80=E4=B8=AA?= =?UTF-8?q?=E5=B9=BF=E6=92=AD=E6=B6=88=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/rooms/GeneralRoom.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/rooms/GeneralRoom.ts b/src/rooms/GeneralRoom.ts index e82f038..77b71a6 100644 --- a/src/rooms/GeneralRoom.ts +++ b/src/rooms/GeneralRoom.ts @@ -102,6 +102,13 @@ export class GeneralRoom extends Room { msgLog('change pet from ', client.sessionId, JSON.stringify(message)); this.dispatcher.dispatch(new ChangePetCommand(), {client, pos: message.pos, petId: message.petId}); }); + /** + * broadcast_c2s的消息, 原样广播出去 + */ + this.onMessage("broadcast_c2s", (client, message) => { + msgLog('broadcast_c2s from ', client.sessionId, JSON.stringify(message)); + this.broadcast("broadcast_s2c", message, {except: client}); + }); this.onMessage("*", (client, type, message) => { // From 446f57cbacbfe94319c975199d9a3badaf89eae3 Mon Sep 17 00:00:00 2001 From: zhl Date: Tue, 2 Feb 2021 17:31:22 +0800 Subject: [PATCH 5/5] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E5=8D=A1=E7=BB=84?= =?UTF-8?q?=E6=B2=A1=E6=9C=89=E6=AD=A3=E5=B8=B8=E5=88=9D=E5=A7=8B=E5=8C=96?= =?UTF-8?q?=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/rooms/commands/BeginGameCommand.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/rooms/commands/BeginGameCommand.ts b/src/rooms/commands/BeginGameCommand.ts index 4a5312d..e6a9892 100644 --- a/src/rooms/commands/BeginGameCommand.ts +++ b/src/rooms/commands/BeginGameCommand.ts @@ -21,6 +21,7 @@ export class BeginGameCommand extends Command { //FixMe:: 移除 // let card0 = gameUtil.initSampleCards(1) // this.state.cardQueue = card0; + this.state.cardQueue = cardAll; let i = 0; for (let [id] of this.state.players) { this.room.addCard(id, new GameEnv().playerInitNums[i++], 0);