重构代码, 移除一些warning
This commit is contained in:
parent
002cc8fc35
commit
79a002afea
17
src/global.d.ts
vendored
17
src/global.d.ts
vendored
@ -1,4 +1,12 @@
|
|||||||
import {IMsg} from "./message/IMsg";
|
import {IMsg} from "./message/IMsg";
|
||||||
|
import {Client, Room} from "colyseus";
|
||||||
|
import {PetInfoMsg} from "./message/PetInfo";
|
||||||
|
import {BattleHandler} from "./rooms/logic/Handler/BattleHandler";
|
||||||
|
import {SkillInfoMsg} from "./message/SkillInfo";
|
||||||
|
import {PartResultMsg} from "./message/PartResult";
|
||||||
|
import {RemovePetMsg} from "./message/RemovePetMsg";
|
||||||
|
import {Dispatcher} from "@colyseus/command";
|
||||||
|
import {Delayed} from "@gamestdio/timer/lib/Delayed";
|
||||||
|
|
||||||
export {};
|
export {};
|
||||||
|
|
||||||
@ -12,15 +20,6 @@ declare global {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
import {Client, Room} from "colyseus";
|
|
||||||
import {PetInfoMsg} from "./message/PetInfo";
|
|
||||||
import {BattleHandler} from "./rooms/logic/Handler/BattleHandler";
|
|
||||||
import {SkillInfoData, SkillInfoMsg} from "./message/SkillInfo";
|
|
||||||
import {PartResultMsg} from "./message/PartResult";
|
|
||||||
import {RemovePetMsg} from "./message/RemovePetMsg";
|
|
||||||
import {Dispatcher} from "@colyseus/command";
|
|
||||||
import {Delayed} from "@gamestdio/timer/lib/Delayed";
|
|
||||||
import {Player} from "./rooms/schema/Player";
|
|
||||||
/**
|
/**
|
||||||
* GeneralRoom 扩展方法
|
* GeneralRoom 扩展方法
|
||||||
*/
|
*/
|
||||||
|
@ -1,20 +1,18 @@
|
|||||||
import { Room, Client } from "colyseus";
|
import {Client, Room} from "colyseus";
|
||||||
import { CardGameState } from "./schema/CardGameState";
|
import {CardGameState} from "./schema/CardGameState";
|
||||||
import { OnJoinCommand } from "./commands/OnJoinCommand";
|
import {OnJoinCommand} from "./commands/OnJoinCommand";
|
||||||
import { PlayReadyCommand} from "./commands/PlayReadyCommand";
|
import {PlayReadyCommand} from "./commands/PlayReadyCommand";
|
||||||
import { Dispatcher } from "@colyseus/command";
|
import {Dispatcher} from "@colyseus/command";
|
||||||
import {DiscardCommand} from "./commands/DiscardCommand";
|
import {DiscardCommand} from "./commands/DiscardCommand";
|
||||||
import {NextSubCommand} from "./commands/NextSubCommand";
|
|
||||||
import {SelectPetCommand} from "./commands/SelectPetCommand";
|
import {SelectPetCommand} from "./commands/SelectPetCommand";
|
||||||
import {ChangeCardCommand} from "./commands/ChangeCardCommand";
|
import {ChangeCardCommand} from "./commands/ChangeCardCommand";
|
||||||
import {SelectHeroCommand} from "./commands/SelectHeroCommand";
|
import {SelectHeroCommand} from "./commands/SelectHeroCommand";
|
||||||
import {EatCardCommand} from "./commands/EatCardCommand";
|
import {EatCardCommand} from "./commands/EatCardCommand";
|
||||||
import {GiveUpCommand} from "./commands/GiveUpCommand";
|
import {GiveUpCommand} from "./commands/GiveUpCommand";
|
||||||
import {BattleHandler} from "./logic/Handler/BattleHandler";
|
import {BattleHandler} from "./logic/Handler/BattleHandler";
|
||||||
import {debugRoom, msgLog} from "../common/Debug";
|
import {msgLog} from "../common/Debug";
|
||||||
import {Delayed} from "@gamestdio/timer/lib/Delayed";
|
import {Delayed} from "@gamestdio/timer/lib/Delayed";
|
||||||
import {IncomingMessage} from "http";
|
import {IncomingMessage} from "http";
|
||||||
import {BaseConst} from "../constants/BaseConst";
|
|
||||||
import {PlayerStateConst} from "../constants/PlayerStateConst";
|
import {PlayerStateConst} from "../constants/PlayerStateConst";
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,10 +1,7 @@
|
|||||||
import {Client, Room} from "colyseus";
|
import {Room} from "colyseus";
|
||||||
import gameUtil from "../utils/game.util";
|
import gameUtil from "../utils/game.util";
|
||||||
import {singleton} from "../common/Singleton";
|
|
||||||
import {GameEnv} from "../cfg/GameEnv";
|
|
||||||
import {error} from "../common/Debug";
|
import {error} from "../common/Debug";
|
||||||
import {PlayerStateConst} from "../constants/PlayerStateConst";
|
import {PlayerStateConst} from "../constants/PlayerStateConst";
|
||||||
import {Player} from "./schema/Player";
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 一些常用的方法
|
* 一些常用的方法
|
||||||
|
@ -1,9 +0,0 @@
|
|||||||
import { Command } from "@colyseus/command";
|
|
||||||
import { CardGameState } from "../schema/CardGameState";
|
|
||||||
import {Wait} from "./Wait";
|
|
||||||
|
|
||||||
export class AsyncSequence extends Command {
|
|
||||||
execute() {
|
|
||||||
return [new Wait().setPayload(1), new Wait().setPayload(2), new Wait().setPayload(3)];
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,11 +1,9 @@
|
|||||||
|
|
||||||
import {Command} from "@colyseus/command";
|
import {Command} from "@colyseus/command";
|
||||||
import {CardGameState} from "../schema/CardGameState";
|
import {CardGameState} from "../schema/CardGameState";
|
||||||
import {GameStateConst} from "../../constants/GameStateConst";
|
import {GameStateConst} from "../../constants/GameStateConst";
|
||||||
import gameUtil from "../../utils/game.util";
|
import gameUtil from "../../utils/game.util";
|
||||||
import {singleton} from "../../common/Singleton";
|
import {singleton} from "../../common/Singleton";
|
||||||
import {GameEnv} from "../../cfg/GameEnv";
|
import {GameEnv} from "../../cfg/GameEnv";
|
||||||
import {Wait} from "./Wait";
|
|
||||||
import {NextTurnCommand} from "./NextTurnCommand";
|
import {NextTurnCommand} from "./NextTurnCommand";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -46,7 +46,7 @@ export class ChangeCardCommand extends Command<CardGameState, { client: Client,
|
|||||||
client.send('change_card_s2c', {errcode:0, errmsg: '', cards: newCards});
|
client.send('change_card_s2c', {errcode:0, errmsg: '', cards: newCards});
|
||||||
player.state = PlayerStateConst.PLAYER_CHANGE_CARD;
|
player.state = PlayerStateConst.PLAYER_CHANGE_CARD;
|
||||||
let finishCount = 0;
|
let finishCount = 0;
|
||||||
for (let [sessionId, player] of this.state.players) {
|
for (let [, player] of this.state.players) {
|
||||||
if (player.state === PlayerStateConst.PLAYER_CHANGE_CARD) {
|
if (player.state === PlayerStateConst.PLAYER_CHANGE_CARD) {
|
||||||
finishCount++;
|
finishCount++;
|
||||||
}
|
}
|
||||||
|
@ -2,8 +2,7 @@ import {Command} from "@colyseus/command";
|
|||||||
import {CardGameState} from "../schema/CardGameState";
|
import {CardGameState} from "../schema/CardGameState";
|
||||||
import {singleton} from "../../common/Singleton";
|
import {singleton} from "../../common/Singleton";
|
||||||
import {GameEnv} from "../../cfg/GameEnv";
|
import {GameEnv} from "../../cfg/GameEnv";
|
||||||
import gameUtil from "../../utils/game.util";
|
import {debugRoom} from "../../common/Debug";
|
||||||
import {debugRoom, error} from "../../common/Debug";
|
|
||||||
import {DiscardCommand} from "./DiscardCommand";
|
import {DiscardCommand} from "./DiscardCommand";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -3,10 +3,6 @@ import {CardGameState} from "../schema/CardGameState";
|
|||||||
import {Client} from "colyseus";
|
import {Client} from "colyseus";
|
||||||
import gameUtil from "../../utils/game.util";
|
import gameUtil from "../../utils/game.util";
|
||||||
import {GameStateConst} from "../../constants/GameStateConst";
|
import {GameStateConst} from "../../constants/GameStateConst";
|
||||||
import {singleton} from "../../common/Singleton";
|
|
||||||
import {GameEnv} from "../../cfg/GameEnv";
|
|
||||||
import {debugRoom} from "../../common/Debug";
|
|
||||||
import {TurnEndCommand} from "./TurnEndCommand";
|
|
||||||
import {EatConfirmCommand} from "./EatConfirmCommand";
|
import {EatConfirmCommand} from "./EatConfirmCommand";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
import {Command} from "@colyseus/command";
|
import {Command} from "@colyseus/command";
|
||||||
import {Client, Room} from "colyseus";
|
|
||||||
import {CardGameState} from "../schema/CardGameState";
|
import {CardGameState} from "../schema/CardGameState";
|
||||||
import {GameStateConst} from "../../constants/GameStateConst";
|
import {GameStateConst} from "../../constants/GameStateConst";
|
||||||
import {singleton} from "../../common/Singleton";
|
import {singleton} from "../../common/Singleton";
|
||||||
@ -25,7 +24,7 @@ export class EatConfirmCommand extends Command<CardGameState, { timeUp: boolean
|
|||||||
let pids = arrUtil.moveElement(sessionIds, -sessionIds.indexOf(this.state.currentTurn));
|
let pids = arrUtil.moveElement(sessionIds, -sessionIds.indexOf(this.state.currentTurn));
|
||||||
|
|
||||||
let tmpActionMap = this.state.tmpActionMap;
|
let tmpActionMap = this.state.tmpActionMap;
|
||||||
for (let [key, val] of tmpActionMap) {
|
for (let [, val] of tmpActionMap) {
|
||||||
if (typeof val == 'number') {
|
if (typeof val == 'number') {
|
||||||
giveUpCount++;
|
giveUpCount++;
|
||||||
}
|
}
|
||||||
|
@ -3,9 +3,7 @@ import {CardGameState} from "../schema/CardGameState";
|
|||||||
import {GameStateConst} from "../../constants/GameStateConst";
|
import {GameStateConst} from "../../constants/GameStateConst";
|
||||||
import {singleton} from "../../common/Singleton";
|
import {singleton} from "../../common/Singleton";
|
||||||
import {GameEnv} from "../../cfg/GameEnv";
|
import {GameEnv} from "../../cfg/GameEnv";
|
||||||
import {NextTurnCommand} from "./NextTurnCommand";
|
import {debugRoom} from "../../common/Debug";
|
||||||
import {TurnEndCommand} from "./TurnEndCommand";
|
|
||||||
import {debugRoom, error} from "../../common/Debug";
|
|
||||||
import {EatConfirmCommand} from "./EatConfirmCommand";
|
import {EatConfirmCommand} from "./EatConfirmCommand";
|
||||||
import {PlayerStateConst} from "../../constants/PlayerStateConst";
|
import {PlayerStateConst} from "../../constants/PlayerStateConst";
|
||||||
|
|
||||||
|
@ -27,7 +27,7 @@ export class NextTurnCommand extends Command<CardGameState, {}> {
|
|||||||
if (this.state.round > 0) {
|
if (this.state.round > 0) {
|
||||||
let moreRoundTime = singleton(GameEnv).roundExtTime * 1000;
|
let moreRoundTime = singleton(GameEnv).roundExtTime * 1000;
|
||||||
let maxTime = 20 * 1000;
|
let maxTime = 20 * 1000;
|
||||||
for (let [key, p] of this.state.players) {
|
for (let [, p] of this.state.players) {
|
||||||
p.extraTime = Math.min(p.extraTime + moreRoundTime * 1000, maxTime);
|
p.extraTime = Math.min(p.extraTime + moreRoundTime * 1000, maxTime);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,8 +3,6 @@ import {CardGameState} from "../schema/CardGameState";
|
|||||||
import {Player} from "../schema/Player";
|
import {Player} from "../schema/Player";
|
||||||
import {Client} from "colyseus";
|
import {Client} from "colyseus";
|
||||||
import {GameStateConst} from "../../constants/GameStateConst";
|
import {GameStateConst} from "../../constants/GameStateConst";
|
||||||
import { BattleHandler } from "rooms/logic/Handler/BattleHandler";
|
|
||||||
import {BaseConst} from "../../constants/BaseConst";
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 玩家成功加入房间
|
* 玩家成功加入房间
|
||||||
@ -17,7 +15,7 @@ export class OnJoinCommand extends Command<CardGameState, {
|
|||||||
let player = new Player(client.sessionId, 0, team);
|
let player = new Player(client.sessionId, 0, team);
|
||||||
this.state.players.set(client.sessionId, player);
|
this.state.players.set(client.sessionId, player);
|
||||||
if (this.state.players.size >= this.room.maxClients) {
|
if (this.state.players.size >= this.room.maxClients) {
|
||||||
this.room.lock();
|
this.room.lock().then(() => {});
|
||||||
this.state.gameState = GameStateConst.STATE_WAIT_PREPARE;
|
this.state.gameState = GameStateConst.STATE_WAIT_PREPARE;
|
||||||
}
|
}
|
||||||
this.room.bUserJoin(`${client.sessionId}`, {except: client});
|
this.room.bUserJoin(`${client.sessionId}`, {except: client});
|
||||||
|
@ -97,7 +97,7 @@ export class PartResultCommand extends Command<CardGameState, {}> {
|
|||||||
|
|
||||||
let t0 = [];
|
let t0 = [];
|
||||||
let t1 = [];
|
let t1 = [];
|
||||||
for (let [sessionId, player] of this.state.players) {
|
for (let [, player] of this.state.players) {
|
||||||
if (player.team == 0) {
|
if (player.team == 0) {
|
||||||
t0.push(player);
|
t0.push(player);
|
||||||
} else {
|
} else {
|
||||||
@ -123,7 +123,7 @@ export class PartResultCommand extends Command<CardGameState, {}> {
|
|||||||
|
|
||||||
let deadCount0 = 0;
|
let deadCount0 = 0;
|
||||||
let deadCount1 = 0;
|
let deadCount1 = 0;
|
||||||
for (let [sessionId, player] of this.state.players) {
|
for (let [, player] of this.state.players) {
|
||||||
if (player.team == 0 && player.state == PlayerStateConst.PLAYER_DEAD ) {
|
if (player.team == 0 && player.state == PlayerStateConst.PLAYER_DEAD ) {
|
||||||
deadCount0 ++;
|
deadCount0 ++;
|
||||||
} else if (player.team == 1 && player.state == PlayerStateConst.PLAYER_DEAD ){
|
} else if (player.team == 1 && player.state == PlayerStateConst.PLAYER_DEAD ){
|
||||||
|
@ -15,7 +15,7 @@ export class PlayReadyCommand extends Command<CardGameState, {
|
|||||||
this.state.players.get(client.sessionId).state = PlayerStateConst.PLAYER_READY;
|
this.state.players.get(client.sessionId).state = PlayerStateConst.PLAYER_READY;
|
||||||
this.room.broadcast("player_ready_s2c", {player: client.sessionId}, {except: client});
|
this.room.broadcast("player_ready_s2c", {player: client.sessionId}, {except: client});
|
||||||
let readyCount = 0;
|
let readyCount = 0;
|
||||||
for (let [sessionId, player] of this.state.players) {
|
for (let [, player] of this.state.players) {
|
||||||
if (player.state === PlayerStateConst.PLAYER_READY) {
|
if (player.state === PlayerStateConst.PLAYER_READY) {
|
||||||
readyCount++;
|
readyCount++;
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,6 @@ import {CardGameState} from "../schema/CardGameState";
|
|||||||
import {Client} from "colyseus";
|
import {Client} from "colyseus";
|
||||||
import {PlayerStateConst} from "../../constants/PlayerStateConst";
|
import {PlayerStateConst} from "../../constants/PlayerStateConst";
|
||||||
import {BeginGameCommand} from "./BeginGameCommand";
|
import {BeginGameCommand} from "./BeginGameCommand";
|
||||||
import {BattleHandler} from "../logic/Handler/BattleHandler";
|
|
||||||
import {BaseConst} from "../../constants/BaseConst";
|
import {BaseConst} from "../../constants/BaseConst";
|
||||||
import {error} from "../../common/Debug";
|
import {error} from "../../common/Debug";
|
||||||
import {singleton} from "../../common/Singleton";
|
import {singleton} from "../../common/Singleton";
|
||||||
|
@ -1,11 +1,7 @@
|
|||||||
import { Command } from "@colyseus/command";
|
import {Command} from "@colyseus/command";
|
||||||
import { CardGameState } from "../schema/CardGameState";
|
import {CardGameState} from "../schema/CardGameState";
|
||||||
import {Client} from "colyseus";
|
import {Client} from "colyseus";
|
||||||
import {NextTurnCommand} from "./NextTurnCommand";
|
|
||||||
import {TurnEndCommand} from "./TurnEndCommand";
|
import {TurnEndCommand} from "./TurnEndCommand";
|
||||||
import {Player} from "../schema/Player";
|
|
||||||
import {Card} from "../schema/Card";
|
|
||||||
import {Pet} from "../schema/Pet";
|
|
||||||
import {singleton} from "../../common/Singleton";
|
import {singleton} from "../../common/Singleton";
|
||||||
import {GameEnv} from "../../cfg/GameEnv";
|
import {GameEnv} from "../../cfg/GameEnv";
|
||||||
|
|
||||||
|
@ -4,7 +4,6 @@ import {singleton} from "../../common/Singleton";
|
|||||||
import {GameEnv} from "../../cfg/GameEnv";
|
import {GameEnv} from "../../cfg/GameEnv";
|
||||||
import {PartResultCommand} from "./PartResultCommand";
|
import {PartResultCommand} from "./PartResultCommand";
|
||||||
import {NextTurnCommand} from "./NextTurnCommand";
|
import {NextTurnCommand} from "./NextTurnCommand";
|
||||||
import {GameResultCommand} from "./GameResultCommand";
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 一轮结束
|
* 一轮结束
|
||||||
|
@ -1,12 +0,0 @@
|
|||||||
import { Command } from "@colyseus/command";
|
|
||||||
import { CardGameState } from "../schema/CardGameState";
|
|
||||||
|
|
||||||
export class ValidationCommand extends Command<CardGameState, number> {
|
|
||||||
validate(n = this.payload) {
|
|
||||||
return n === 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
execute() {
|
|
||||||
throw new Error("This should never execute!")
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,4 +1,4 @@
|
|||||||
import {Schema, type, filter} from "@colyseus/schema";
|
import {Schema, type} from "@colyseus/schema";
|
||||||
|
|
||||||
export class Card extends Schema {
|
export class Card extends Schema {
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user