2020-12-02 23:20:24 +08:00

46 lines
1.2 KiB
TypeScript

import {Schema, type, filter} from "@colyseus/schema";
export class Card extends Schema {
constructor(number: number, type: number, id: number, effect: number) {
super();
this.number = number;
this.type = type;
this.id = id;
this.played = false;
}
/**
* 点数
*/
// @filter(function(
// this: Card, // the instance of the class `@filter` has been defined (instance of `Card`)
// client: Client, // the Room's `client` instance which this data is going to be filtered to
// value: Card['number'], // the value of the field to be filtered. (value of `number` field)
// root: Schema // the root state Schema instance
// ) {
// return !this.played || this.owner === client.sessionId;
// })
@type("number")
number: number;
@type("string")
owner: string;
@type("number")
id: number;
@type("boolean")
played: boolean = false;
/**
* 类型
* 1: 普通牌
* 2: 效果强化卡
* 3: 点数加倍卡
*/
@type("number")
type: number;
/**
* 对应的效果强化牌id
*/
@type("number")
effect: number;
}