增加玩家离线和在线的状态

This commit is contained in:
zhl 2021-02-05 18:30:55 +08:00
parent 3a3d79b5d7
commit d824206902
2 changed files with 5 additions and 3 deletions

View File

@ -138,7 +138,7 @@ export class GeneralRoom extends Room {
} }
this.bUserLeft(client.sessionId); this.bUserLeft(client.sessionId);
} else { } else {
this.state.players.get(client.sessionId).state = PlayerStateConst.PLAYER_OFFLINE; this.state.players.get(client.sessionId).online = false;
let assistClient = this.getAssistClient(client.sessionId); let assistClient = this.getAssistClient(client.sessionId);
assistClient.active = true; assistClient.active = true;
try { try {
@ -148,7 +148,7 @@ export class GeneralRoom extends Room {
await this.allowReconnection(client, 10 * 60); await this.allowReconnection(client, 10 * 60);
debugRoom(`${client.sessionId} 重连`); debugRoom(`${client.sessionId} 重连`);
assistClient.active = false; assistClient.active = false;
this.state.players.get(client.sessionId).state = PlayerStateConst.PLAYER_NORMAL; this.state.players.get(client.sessionId).online = true;
} }
} catch (e) { } catch (e) {
debugRoom(`player realy level :${client.sessionId}, try add robot`); debugRoom(`player realy level :${client.sessionId}, try add robot`);

View File

@ -62,10 +62,11 @@ export class Player extends Schema {
* 2: 死亡 * 2: 死亡
* 3: 已换完牌 * 3: 已换完牌
* 4: 玩家已选择英雄 * 4: 玩家已选择英雄
* 9: 掉线
*/ */
@type("number") @type("number")
state: number; state: number;
online: boolean = true;
/** /**
* *
*/ */
@ -128,6 +129,7 @@ export class Player extends Schema {
this.team = team; this.team = team;
this.countTotal = 0; this.countTotal = 0;
this.countPresent = 0; this.countPresent = 0;
this.online = true;
for (let i = 0; i < new GameEnv().maxPlayerPetCount + 1; i++) { for (let i = 0; i < new GameEnv().maxPlayerPetCount + 1; i++) {
let pet = new Pet(i); let pet = new Pet(i);
pet.state = 0; pet.state = 0;