玩家可看到自己牌的详情

This commit is contained in:
zhl 2020-12-07 17:04:47 +08:00
parent 10cb2a1362
commit 3e506bad45
3 changed files with 16 additions and 3 deletions

View File

@ -3,13 +3,20 @@ import {CardGameState} from "../schema/CardGameState";
import {singleton} from "../../common/Singleton";
import {GameEnv} from "../../cfg/GameEnv";
import gameUtil from "../../utils/game.util";
import {error} from "../../common/Debug";
/**
*
*/
export class DrawCommand extends Command<CardGameState, {}> {
execute() {
async execute() {
let sessionId = this.state.currentTurn;
this.room.addCard(sessionId, singleton(GameEnv).roundDrawNum, 0);
let maxTime = singleton(GameEnv).maxDiscardTime;
await this.delay(maxTime * 1000);
if (sessionId == this.state.currentTurn) {
error('出牌时间到, 自动出牌');
//TODO: 自动出牌
}
}
}

View File

@ -5,13 +5,15 @@ import {GameStateConst} from "../../constants/GameStateConst";
import {PlayerStateConst} from "../../constants/PlayerStateConst";
import {error} from "../../common/Debug";
import {TurnEndCommand} from "./TurnEndCommand";
import {singleton} from "../../common/Singleton";
import {GameEnv} from "../../cfg/GameEnv";
/**
*
*/
export class NextTurnCommand extends Command<CardGameState, {}> {
execute() {
async execute() {
this.state.gameState = GameStateConst.STATE_BEGIN_DRAW;
const sessionIds = [...this.state.players.keys()];
if (!this.state.currentTurn) {

View File

@ -1,4 +1,4 @@
import {MapSchema, SetSchema, Schema, type} from "@colyseus/schema";
import {MapSchema, SetSchema, Schema, type, filter} from "@colyseus/schema";
import {Pet} from "./Pet";
import {Card} from "./Card";
import {singleton} from "../../common/Singleton";
@ -15,6 +15,10 @@ export class Player extends Schema {
/**
*
*/
@filter(function(this: Player, client, value, root) {
return (client.sessionId == this.id);
})
@type({ map: Card })
cards = new MapSchema<Card>();
@type({ set: "string" })