@haelp/teto
Version:
A typescript-based controllable TETR.IO client.
83 lines (82 loc) • 2.64 kB
TypeScript
import { Engine } from "../../engine";
import { Game as GameTypes } from "../../types";
import { Client } from "../client";
export declare class Game {
private client;
private listeners;
private frameQueue;
private incomingGarbage;
private timeout;
private messageQueue;
private startTime;
private _target;
private tick?;
private over;
private isPractice;
/** The client's engine */
engine: Engine;
/** Data on the players in game */
players: {
name: string;
gameid: number;
userid: string;
engine: Engine;
queue: GameTypes.Replay.Frame[];
}[];
/** @deprecated - use `players` */
get opponents(): {
name: string;
gameid: number;
userid: string;
engine: Engine;
queue: GameTypes.Replay.Frame[];
}[];
/** The client's `gameid` set by the server */
gameid: number;
/** The raw game config sent by TETR.IO */
options: GameTypes.ReadyOptions;
/** The raw game config for all players, including the client's own game config */
readyData: GameTypes.Ready;
/** The targets set by the server */
serverTargets: number[];
/** The gameids of the users targeting the client */
enemies: number[];
/** The keys the client has queued to press (allows for pressing keys in the future) */
keyQueue: NonNullable<GameTypes.Tick.Out["keys"]>;
/** Whether or not targeting is allowed (changed by server). Setting target while this is `false` will throw an error. */
canTarget: boolean;
/** The Frames Per Second of the TETR.IO engine */
static fps: number;
/** Frames per message */
private static fpm;
/** @hideconstructor */
constructor(client: Client, ready: GameTypes.Ready);
private listen;
/** Kill the game. This is called automatically by the Room class when a game ends/is aborted, you don't need to use this. */
destroy(): undefined;
private init;
private start;
createEngine(options: GameTypes.ReadyOptions, gameid: number): Engine;
private flushFrames;
private tickGame;
/**
* Send raw frames to TETR.IO -
* Not recommended for normal use.
*/
pipe(...frames: GameTypes.Replay.Frame[]): void;
private handleIGE;
/**
* The current targeting strategy
*/
get target(): GameTypes.Target;
/**
* Set the current targeting strategy, throws error if targeting is not allowed
*/
set target(t: GameTypes.Target);
/**
* The game's current frame
*/
get frame(): number;
private set frame(value);
}