Merge branch 'master' of http://git.kingsome.cn/node/card_svr
This commit is contained in:
commit
4c080c1141
@ -13,6 +13,9 @@ import {GiveUpCommand} from "./commands/GiveUpCommand";
|
|||||||
import {BattleHandler} from "./logic/Handler/BattleHandler";
|
import {BattleHandler} from "./logic/Handler/BattleHandler";
|
||||||
import {debugRoom} from "../common/Debug";
|
import {debugRoom} from "../common/Debug";
|
||||||
import {Delayed} from "@gamestdio/timer/lib/Delayed";
|
import {Delayed} from "@gamestdio/timer/lib/Delayed";
|
||||||
|
import {IncomingMessage} from "http";
|
||||||
|
import {BaseConst} from "../constants/BaseConst";
|
||||||
|
import {PlayerStateConst} from "../constants/PlayerStateConst";
|
||||||
|
|
||||||
|
|
||||||
export class GeneralRoom extends Room {
|
export class GeneralRoom extends Room {
|
||||||
@ -22,7 +25,13 @@ export class GeneralRoom extends Room {
|
|||||||
battleMan = new BattleHandler();
|
battleMan = new BattleHandler();
|
||||||
// 用于游戏过程中各种计时器, 使用该计时器的前提是, 只针对当前操作玩家
|
// 用于游戏过程中各种计时器, 使用该计时器的前提是, 只针对当前操作玩家
|
||||||
mainClock: Delayed;
|
mainClock: Delayed;
|
||||||
|
async onAuth (client:Client, options: any, request: IncomingMessage) {
|
||||||
|
console.log(options);
|
||||||
|
// TODO: 验证用户信息
|
||||||
|
// client.auth.accountId = options.accountId;
|
||||||
|
// client.auth.sessionId = options.sessionId;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
onCreate (options: any) {
|
onCreate (options: any) {
|
||||||
let cs = new CardGameState();
|
let cs = new CardGameState();
|
||||||
this.setState(cs);
|
this.setState(cs);
|
||||||
@ -72,13 +81,26 @@ export class GeneralRoom extends Room {
|
|||||||
}
|
}
|
||||||
|
|
||||||
onJoin (client: Client, options: any) {
|
onJoin (client: Client, options: any) {
|
||||||
this.dispatcher.dispatch(new OnJoinCommand(), {
|
let data = {
|
||||||
client: client
|
client: client
|
||||||
});
|
};
|
||||||
|
this.dispatcher.dispatch(new OnJoinCommand(), data);
|
||||||
this.clientMap.set(client.sessionId, client);
|
this.clientMap.set(client.sessionId, client);
|
||||||
}
|
}
|
||||||
|
//TODO: 掉线逻辑
|
||||||
|
async onLeave (client: Client, consented: boolean) {
|
||||||
|
this.state.players.get(client.sessionId).state = PlayerStateConst.PLAYER_OFFLINE;
|
||||||
|
|
||||||
onLeave (client: Client, consented: boolean) {
|
try {
|
||||||
|
if (consented) {
|
||||||
|
throw new Error("consented leave");
|
||||||
|
}
|
||||||
|
await this.allowReconnection(client, 60);
|
||||||
|
this.state.players.get(client.sessionId).state = PlayerStateConst.PLAYER_NORMAL;
|
||||||
|
|
||||||
|
} catch (e) {
|
||||||
|
this.state.players.delete(client.sessionId);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onDispose() {
|
onDispose() {
|
||||||
|
@ -35,6 +35,7 @@ export class Player extends Schema {
|
|||||||
* 1: 已准备好
|
* 1: 已准备好
|
||||||
* 2: 死亡
|
* 2: 死亡
|
||||||
* 3: 已换完牌
|
* 3: 已换完牌
|
||||||
|
* 4: 玩家已选择英雄
|
||||||
* 9: 掉线
|
* 9: 掉线
|
||||||
*/
|
*/
|
||||||
@type("number")
|
@type("number")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user