player增加英雄id
This commit is contained in:
parent
d2f5fc8315
commit
0a7146d200
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,2 +1,3 @@
|
||||
node_modules
|
||||
.idea
|
||||
.DS_Store
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"private": true,
|
||||
"name": "my-app",
|
||||
"name": "card_svr",
|
||||
"version": "1.0.0",
|
||||
"description": "npm init template for bootstrapping an empty Colyseus project",
|
||||
"main": "lib/index.js",
|
||||
|
@ -8,7 +8,7 @@ export class OnJoinCommand extends Command<CardGameState, {
|
||||
}> {
|
||||
|
||||
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) {
|
||||
this.room.lock();
|
||||
this.state.gameState = 1;
|
||||
|
@ -3,6 +3,8 @@ import {Card} from "./Card";
|
||||
import {Pet} from "./Pet";
|
||||
|
||||
export class Player extends Schema {
|
||||
@type("number")
|
||||
heroId: number;
|
||||
/**
|
||||
* 手牌
|
||||
*/
|
||||
@ -37,11 +39,12 @@ export class Player extends Schema {
|
||||
|
||||
|
||||
//TODO: set hp, ap from cfg
|
||||
constructor() {
|
||||
constructor(heroId: number) {
|
||||
super();
|
||||
this.state = 0;
|
||||
this.hp = 200;
|
||||
this.ap = 30;
|
||||
this.heroId = heroId;
|
||||
for (let i = 0; i < 6; i++) {
|
||||
this.pets.set(i+'', new Pet());
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user