player增加英雄id

This commit is contained in:
zhl 2020-12-01 09:37:21 +08:00
parent d2f5fc8315
commit 0a7146d200
4 changed files with 7 additions and 3 deletions

1
.gitignore vendored
View File

@ -1,2 +1,3 @@
node_modules node_modules
.idea .idea
.DS_Store

View File

@ -1,6 +1,6 @@
{ {
"private": true, "private": true,
"name": "my-app", "name": "card_svr",
"version": "1.0.0", "version": "1.0.0",
"description": "npm init template for bootstrapping an empty Colyseus project", "description": "npm init template for bootstrapping an empty Colyseus project",
"main": "lib/index.js", "main": "lib/index.js",

View File

@ -8,7 +8,7 @@ export class OnJoinCommand extends Command<CardGameState, {
}> { }> {
execute({client}: { client: Client }) { execute({client}: { client: Client }) {
this.state.players.set(client.sessionId, new Player()); this.state.players.set(client.sessionId, new Player(0));
if (this.state.players.size >= this.room.maxClients) { if (this.state.players.size >= this.room.maxClients) {
this.room.lock(); this.room.lock();
this.state.gameState = 1; this.state.gameState = 1;

View File

@ -3,6 +3,8 @@ import {Card} from "./Card";
import {Pet} from "./Pet"; import {Pet} from "./Pet";
export class Player extends Schema { export class Player extends Schema {
@type("number")
heroId: number;
/** /**
* *
*/ */
@ -37,11 +39,12 @@ export class Player extends Schema {
//TODO: set hp, ap from cfg //TODO: set hp, ap from cfg
constructor() { constructor(heroId: number) {
super(); super();
this.state = 0; this.state = 0;
this.hp = 200; this.hp = 200;
this.ap = 30; this.ap = 30;
this.heroId = heroId;
for (let i = 0; i < 6; i++) { for (let i = 0; i < 6; i++) {
this.pets.set(i+'', new Pet()); this.pets.set(i+'', new Pet());
} }