diff --git a/src/rooms/commands/OnJoinCommand.ts b/src/rooms/commands/OnJoinCommand.ts index a6fd36c..13c7140 100644 --- a/src/rooms/commands/OnJoinCommand.ts +++ b/src/rooms/commands/OnJoinCommand.ts @@ -14,7 +14,7 @@ export class OnJoinCommand extends Command { execute({client} = this.payload) { let team = this.state.players.size / 2 | 0; - let player = new Player(0, team); + let player = new Player(client.sessionId, 0, team); this.state.players.set(client.sessionId, player); if (this.state.players.size >= this.room.maxClients) { this.room.lock(); diff --git a/src/rooms/schema/Player.ts b/src/rooms/schema/Player.ts index 0f26b6e..71273b1 100644 --- a/src/rooms/schema/Player.ts +++ b/src/rooms/schema/Player.ts @@ -6,6 +6,9 @@ import {GameEnv} from "../../cfg/GameEnv"; export class Player extends Schema { + @type("string") + id: number; + @type("number") heroId: number; /** @@ -49,12 +52,13 @@ export class Player extends Schema { //TODO: set hp, ap from cfg - constructor(heroId: number, team: number) { + constructor(id: string, heroId: number, team: number) { super(); this.state = 0; this.hp = 200; this.ap = 30; this.heroId = heroId; + this.team = team; for (let i = 0; i < singleton(GameEnv).maxPlayerPetCount; i++) { this.pets.set(i+'', new Pet()); }