player增加id
This commit is contained in:
parent
43c60b415b
commit
69c364c0f9
@ -14,7 +14,7 @@ export class OnJoinCommand extends Command<CardGameState, {
|
|||||||
}> {
|
}> {
|
||||||
execute({client} = this.payload) {
|
execute({client} = this.payload) {
|
||||||
let team = this.state.players.size / 2 | 0;
|
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);
|
this.state.players.set(client.sessionId, player);
|
||||||
if (this.state.players.size >= this.room.maxClients) {
|
if (this.state.players.size >= this.room.maxClients) {
|
||||||
this.room.lock();
|
this.room.lock();
|
||||||
|
@ -6,6 +6,9 @@ import {GameEnv} from "../../cfg/GameEnv";
|
|||||||
|
|
||||||
|
|
||||||
export class Player extends Schema {
|
export class Player extends Schema {
|
||||||
|
@type("string")
|
||||||
|
id: number;
|
||||||
|
|
||||||
@type("number")
|
@type("number")
|
||||||
heroId: number;
|
heroId: number;
|
||||||
/**
|
/**
|
||||||
@ -49,12 +52,13 @@ export class Player extends Schema {
|
|||||||
|
|
||||||
|
|
||||||
//TODO: set hp, ap from cfg
|
//TODO: set hp, ap from cfg
|
||||||
constructor(heroId: number, team: number) {
|
constructor(id: string, heroId: number, team: number) {
|
||||||
super();
|
super();
|
||||||
this.state = 0;
|
this.state = 0;
|
||||||
this.hp = 200;
|
this.hp = 200;
|
||||||
this.ap = 30;
|
this.ap = 30;
|
||||||
this.heroId = heroId;
|
this.heroId = heroId;
|
||||||
|
this.team = team;
|
||||||
for (let i = 0; i < singleton(GameEnv).maxPlayerPetCount; i++) {
|
for (let i = 0; i < singleton(GameEnv).maxPlayerPetCount; i++) {
|
||||||
this.pets.set(i+'', new Pet());
|
this.pets.set(i+'', new Pet());
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user