Commit 4b53d32b authored by 水濑真白's avatar 水濑真白

fix room host assignment on first join

parent 7454c2da
Pipeline #43473 passed with stages
in 2 minutes and 26 seconds
...@@ -391,6 +391,9 @@ export class Room { ...@@ -391,6 +391,9 @@ export class Room {
firstEmptyPlayerSlot >= 0 && firstEmptyPlayerSlot >= 0 &&
this.duelStage === DuelStage.Begin; this.duelStage === DuelStage.Begin;
// 记录进房前是否已经有玩家,用于判定首个玩家为房主
const hasPlayerBeforeJoin = this.playingPlayers.length > 0;
if (isPlayer) { if (isPlayer) {
this.players[firstEmptyPlayerSlot] = client; this.players[firstEmptyPlayerSlot] = client;
client.pos = firstEmptyPlayerSlot; client.pos = firstEmptyPlayerSlot;
...@@ -404,9 +407,7 @@ export class Room { ...@@ -404,9 +407,7 @@ export class Room {
client.roomName = this.name; client.roomName = this.name;
client.isHost = this.noHost client.isHost = !this.noHost && isPlayer && !hasPlayerBeforeJoin;
? false
: isPlayer && !this.playingPlayers.length;
// send to client // send to client
await client.send(this.joinGameMessage); await client.send(this.joinGameMessage);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment