///
///
import { CreateGame, GameID, GameReplay, Login, MakeTurn, MapFile, NextTurn, OutgoingCommand, TeamData, TeamID, GameStatusUpdate } from './schema';
import { Game } from './game';
import { Client, ClientID } from './client';
import * as net from 'net';
import * as ws from 'ws';
/**
* Represents a game that hasn't started yet.
* TODO: this class should be combined with GameRunner somehow
*/
export declare class Lobby {
/**
* The ID of this game.
*/
id: GameID;
/**
* The teams passed in the 'create_game' message.
*/
requiredTeams: TeamData[];
/**
* The map the game will be played on.
*/
map: MapFile;
/**
* The connected players.
*/
playerTeams: [Client, TeamData][];
/**
* Clients that care about the end of this game.
*/
observers: Client[];
spectators: Client[];
debug: boolean;
isPickup: boolean;
timeoutMS: number;
status: GameStatusUpdate;
constructor(id: GameID, create: CreateGame, spectators: Client[], debug: boolean, client?: Client);
/**
* Handle a login message.
*/
login(login: Login, client: Client): GameRunner | undefined;
deleteClient(id: ClientID): boolean;
}
export declare class GameRunner {
id: GameID;
playerClients: Client[];
players: Map;
game: Game;
pastTurns: NextTurn[];
observers: Client[];
started: boolean;
winner?: TeamData;
spectators: Client[];
timeoutMS: number;
lastTurnMS: number;
timeoutHandle?: NodeJS.Timer;
status: GameStatusUpdate;
constructor(id: GameID, map: MapFile, playerTeams: [Client, TeamData][], observers: Client[], spectators: Client[], debug: boolean, timeoutMS: number, status: GameStatusUpdate);
broadcast(command: OutgoingCommand): Promise;
addSpectator(spectator: Client): Promise;
start(): Promise;
/**
* ugh
*/
private getClientForTeam(id);
startTimeout(): void;
makeTurn(turn: MakeTurn, client: Client): Promise;
makeReplay(): Promise;
makeGzippedMatchData(): Promise;
deleteClient(id: ClientID): boolean;
}
export interface ServerOpts {
tcpPort: number;
wsPort: number;
debug: boolean;
log: (string) => void;
error: (string) => void;
}
export default class Server {
games: Map;
playing: Map;
spectators: Client[];
tcp?: net.Server;
unix?: net.Server;
ws?: ws.Server;
opts: ServerOpts;
log: (s: string) => void;
error: (s: string) => void;
mapNames: string[];
constructor(opts: ServerOpts);
start(): Promise;
updateMaps(): Promise;
ensureDefaultMaps(): Promise;
loadMap(mapName: string): Promise;
private saveGame(game);
private pickupLock;
private findPickupGame();
private handleCommand;
private handleClose;
private handleLogin;
private handleMakeTurn;
private handleSpectateAll;
private handleCreateGame;
private handleListMapsRequest;
private handleListReplaysRequest;
private handleReplayRequest;
}