card_svr/src/rooms/schema/Player.ts
2020-11-30 14:45:21 +08:00

50 lines
913 B
TypeScript

import {MapSchema, SetSchema, Schema, type} from "@colyseus/schema";
import {Card} from "./Card";
import {Pet} from "./Pet";
export class Player extends Schema {
/**
* 手牌
*/
cards = new MapSchema<Card>();
@type({ set: "string" })
cardSet = new SetSchema<string>();
/**
* 当前hp
*/
@type("number")
hp: number;
/**
* 当前点数
*/
@type("number")
ap: number;
/**
* 状态
* 0: 正常状态
* 1: 已准备好
* 2: 死亡
* 9: 掉线
*/
@type("number")
state: number;
/**
* 随从
*/
@type({ map: Pet })
pets = new MapSchema<Pet>();
//TODO: set hp, ap from cfg
constructor() {
super();
this.state = 0;
this.hp = 200;
this.ap = 30;
for (let i = 0; i < 6; i++) {
this.pets.set(i+'', new Pet());
}
}
}