fix conflicts

This commit is contained in:
zhl 2020-12-02 20:06:32 +08:00
commit d83cb61e62
4 changed files with 17 additions and 9 deletions

View File

@ -3,7 +3,7 @@
"name": "card_svr",
"version": "1.0.0",
"main": "lib/index.js",
"typings" : "src/global.d.ts",
"typings": "src/global.d.ts",
"scripts": {
"start": "ts-node-dev --files src/index.ts",
"loadtest": "colyseus-loadtest loadtest/example.ts --room my_room --numClients 3",

View File

@ -10,14 +10,18 @@ import {ChangeCardCommand} from "./commands/ChangeCardCommand";
import {SelectHeroCommand} from "./commands/SelectHeroCommand";
import {EatCardCommand} from "./commands/EatCardCommand";
import {GiveUpCommand} from "./commands/GiveUpCommand";
import {BattleHandler} from "./logic/Handler/BattleHandler";
export class GeneralRoom extends Room {
dispatcher = new Dispatcher(this);
maxClients = 4;
clientMap = new Map();
battleMan = new BattleHandler();
onCreate (options: any) {
this.setState(new CardGameState());
let cs = new CardGameState();
this.setState(cs);
this.battleMan.init(cs);
this.state.gameSate = 0;
this.onMessage("play_ready_c2s", (client, message) => {
console.log('play_ready from ', client.sessionId, message);
@ -63,7 +67,8 @@ export class GeneralRoom extends Room {
onJoin (client: Client, options: any) {
this.dispatcher.dispatch(new OnJoinCommand(), {
client: client
client: client,
battle: this.battleMan,
});
this.clientMap.set(client.sessionId, client);
}

View File

@ -3,17 +3,20 @@ import {CardGameState} from "../schema/CardGameState";
import {Player} from "../schema/Player";
import {Client} from "colyseus";
import {GameStateConst} from "../../constants/GameStateConst";
import { BattleHandler } from "rooms/logic/Handler/BattleHandler";
/**
*
*/
export class OnJoinCommand extends Command<CardGameState, {
client: Client
client: Client, battle: BattleHandler
}> {
execute({client}: { client: Client }) {
execute({client, battle}: { client: Client, battle: BattleHandler }) {
let team = this.state.players.size / 2 | 0;
this.state.players.set(client.sessionId, new Player(0, team));
let player = new Player(0, team);
this.state.players.set(client.sessionId, player);
battle.addPlayer(player);
if (this.state.players.size >= this.room.maxClients) {
this.room.lock();
this.state.gameState = GameStateConst.STATE_WAIT_PREPARE;

View File

@ -2,7 +2,7 @@ import {Schema, type, filter} from "@colyseus/schema";
export class Card extends Schema {
constructor(number: number, type: string, id: string) {
constructor(number: number, type: string, id: number) {
super();
this.number = number;
this.type = type;
@ -25,8 +25,8 @@ export class Card extends Schema {
number: number;
@type("string")
owner: string;
@type("string")
id: string;
@type("number")
id: number;
@type("boolean")
played: boolean = false;
/**