diff --git a/src/rooms/GeneralRoom.ts b/src/rooms/GeneralRoom.ts index 868d4eb..4ad8e4f 100644 --- a/src/rooms/GeneralRoom.ts +++ b/src/rooms/GeneralRoom.ts @@ -25,7 +25,7 @@ import { Service } from '../service/Service' export class GeneralRoom extends Room { dispatcher = new Dispatcher(this); - maxClients = 4; + maxClients = 2; score = 0; battleMan = new BattleHandler(); // 用于游戏过程中各种计时器, 使用该计时器的前提是, 只针对当前操作玩家 @@ -44,6 +44,9 @@ export class GeneralRoom extends Room { } onCreate (options: any) { let cs = new CardGameState(); + if (options.clients) { + this.maxClients = options.clients + } this.setState(cs); this.setPrivate(true); if (options.count) { @@ -300,7 +303,7 @@ export class GeneralRoom extends Room { return null; } let idx = this.state.players.get(playerId).idx; - let opposIdx = (2 + idx) % 4; + let opposIdx = ((this.maxClients / 2 | 0) + idx) % this.maxClients; return this.getPlayerByIdx(opposIdx); } } diff --git a/src/rooms/commands/OnJoinCommand.ts b/src/rooms/commands/OnJoinCommand.ts index c338604..bc3dd21 100644 --- a/src/rooms/commands/OnJoinCommand.ts +++ b/src/rooms/commands/OnJoinCommand.ts @@ -40,7 +40,12 @@ export class OnJoinCommand extends Command = new Map() for (let [, player] of state.players) { - if (player.team == 0 && player.state == PlayerStateConst.PLAYER_DEAD) { - deadCount0++ - } else if (player.team == 1 && player.state == PlayerStateConst.PLAYER_DEAD) { - deadCount1++ + if (player.state != PlayerStateConst.PLAYER_DEAD) { + teamMap.inc(player.team, 1) } } + const roundNum = new GameEnv().duelRoundNum const totalRound = roundNum * new GameEnv().maxDuelNum - return (deadCount0 == 2 || deadCount1 == 2) || (state.round >= totalRound - 1) + return (teamMap.size <= 1) || (state.round >= totalRound - 1) } }