player增加id

This commit is contained in:
zhl 2020-12-04 16:51:38 +08:00
parent 43c60b415b
commit 69c364c0f9
2 changed files with 6 additions and 2 deletions

View File

@ -14,7 +14,7 @@ export class OnJoinCommand extends Command<CardGameState, {
}> {
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();

View File

@ -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());
}