64 lines
1.3 KiB
TypeScript
64 lines
1.3 KiB
TypeScript
import {MapSchema, SetSchema, Schema, type} from "@colyseus/schema";
|
|
import {Pet} from "./Pet";
|
|
import {Card} from "./Card";
|
|
import {singleton} from "../../common/Singleton";
|
|
import {GameEnv} from "../../cfg/GameEnv";
|
|
import {PlayerStateConst} from "../../constants/PlayerStateConst";
|
|
|
|
|
|
export class Player extends Schema {
|
|
@type("string")
|
|
id: string;
|
|
|
|
@type("number")
|
|
heroId: number;
|
|
/**
|
|
* 手牌
|
|
*/
|
|
cards = new MapSchema<Card>();
|
|
|
|
@type({ set: "string" })
|
|
cardSet = new SetSchema<string>();
|
|
/**
|
|
* 当前hp
|
|
*/
|
|
@type("number")
|
|
hp: number;
|
|
|
|
/**
|
|
* 状态
|
|
* 0: 正常状态
|
|
* 1: 已准备好
|
|
* 2: 死亡
|
|
* 3: 已换完牌
|
|
* 9: 掉线
|
|
*/
|
|
@type("number")
|
|
state: number;
|
|
/**
|
|
* 随从
|
|
*/
|
|
@type({ map: Pet })
|
|
pets = new MapSchema<Pet>();
|
|
|
|
/**
|
|
* 队伍
|
|
*/
|
|
@type("number")
|
|
team: number;
|
|
|
|
|
|
//TODO: set hp, ap from cfg
|
|
constructor(id: string, heroId: number, team: number) {
|
|
super();
|
|
this.id = id;
|
|
this.state = PlayerStateConst.PLAYER_NORMAL;
|
|
this.hp = 0;
|
|
this.heroId = heroId;
|
|
this.team = team;
|
|
for (let i = 0; i < singleton(GameEnv).maxPlayerPetCount + 1; i++) {
|
|
this.pets.set(i+'', new Pet());
|
|
}
|
|
}
|
|
}
|