node-haxball
Version:
The most powerful and lightweight API that allows you to develop your original Haxball(www.haxball.com) host, client, and standalone applications both on node.js and browser environments and also includes every possible hack and functionality that you can
2,169 lines (1,776 loc) • 362 kB
TypeScript
declare namespace MainReturnType {
/**
* The current version number of the API.
*/
export const version: string;
/**
* This object binds event (operation) names to numbers that are
* obtained during Haxball's event mechanism, to let us understand
* what kind of message is received from the client. By nature,
* these include only those events that can be sent by a client
* and received by a host.
*/
export enum OperationType {
/**
* The operation to send announcement text. This requires
* the sender to be the host of the current room.
*/
SendAnnouncement = 0,
/**
* The operation to set a player's chat indicator status.
*/
SendChatIndicator = 1,
/**
* The operation to check whether the client is in sync
* with the host. This requires the sender to be a client
* of the current room.
*/
CheckConsistency = 2,
/**
* The operation to set your own input. (key state)
*/
SendInput = 3,
/**
* The operation to send chat text.
*/
SendChat = 4,
/**
* The operation to add a player to the current room. This
* requires the sender to be the host of the current room.
*/
JoinRoom = 5,
/**
* The operation to leave the room, or kick/ban a player.
* (This is decided by the `reason` property being `null`.)
* The kick/ban operation requires the sender to be an admin
* in the current room.
*/
KickBanPlayer = 6,
/**
* The operation to start the game. This requires the sender
* to be an admin in the current room. Also, the game must
* not be active.
*/
StartGame = 7,
/**
* The operation to stop the game. This requires the sender
* to be an admin in the current room. Also, the game must
* be active.
*/
StopGame = 8,
/**
* The operation to pause or resume the game. This requires
* the sender to be an admin in the current room. Also, the
* game must be active.
*/
PauseResumeGame = 9,
/**
* The operation to set the score/time limit of the room.
* This requires the sender to be an admin in the current
* room. Also, the game must not be active.
*/
SetGamePlayLimit = 10, // SetScoreLimit + SetTimeLimit
/**
* The operation to set the room's current stadium. This
* requires the sender to be an admin in the current room.
* Also, the game must not be active.
*/
SetStadium = 11,
/**
* The operation to move a player to a team. This requires
* the sender to be an admin in the current room. If teams
* are not locked and the game is not active, the non-admin
* players are also allowed to use this event only to
* change their own teams.
*/
SetPlayerTeam = 12,
/**
* The operation to lock/unlock the room's teams. This
* requires the sender to be an admin in the current room.
*/
SetTeamsLock = 13,
/**
* The operation to grant/take away a player's admin rights.
* This requires the sender to be an admin in the current room.
*/
SetPlayerAdmin = 14,
/**
* The operation to automatically move one player from the
* spectators team to the red team, and one player to the
* blue team. This requires the sender to be an admin in the
* current room.
*/
AutoTeams = 15,
/**
* The operation to set your own synchronization status.
*/
SetPlayerSync = 16,
/**
* The operation to inform players of the ping values of
* each player. This requires the sender to be the host
* of the current room.
*/
Ping = 17,
/**
* The operation to set your own avatar.
*/
SetAvatar = 18,
/**
* The operation to set a team's colors. This requires the
* sender to be an admin in the current room.
*/
SetTeamColors = 19,
/**
* The operation to change the ordering of the players
* in the room. This requires the sender to be the host
* of the current room.
*/
ReorderPlayers = 20,
/**
* The operation to set the room's current stadium. This
* requires the sender to be an admin in the current room.
*/
SetKickRateLimit = 21,
/**
* The operation to set a player's headless avatar. This
* requires the sender to be the host of the current room.
*/
SetHeadlessAvatar = 22,
/**
* The operation to set a disc's properties. This requires
* the sender to be the host of the current room.
*/
SetDiscProperties = 23,
/**
* The operation to trigger a custom event. This requires
* the receiver to use this API, otherwise the operation
* will not be sent to that client. This might create
* desynchronization issues for non-API clients if the
* custom event includes important changes such as
* stadium objects, names, etc.
*/
CustomEvent = 24,
/**
* The operation to trigger a binary custom event. This
* requires the receiver to use this API, otherwise the
* operation will not be sent to that client. This might
* create desynchronization issues for non-API clients
* if the custom event includes important changes such as
* stadium objects, names, etc.
*/
BinaryCustomEvent = 25,
/**
* The operation to set a player's backend identity. This
* requires the receiver to use this API, otherwise the
* operation will not be sent to that client.
*/
SetPlayerIdentity = 26
}
/**
* While writing an addon, one might want to define variables whose values
* can be altered from outside the class. This object defines the type of
* variable that is defined inside the class. If you have a GUI to alter
* these values in real-time, you will have to implement the necessary
* GUI components to be able to edit these data types.
*/
export enum VariableType {
/**
* The void type. Used to show a button. Its value should be a function that will be executed when the button is clicked.
*/
Void = 0,
/**
* The boolean type. Can be `true` or `false`.
*/
Boolean = 1,
/**
* The integer type. Can be any integer. Should be used
* with a `range` property to define its range.
*/
Integer = 2,
/**
* The number type. Can be any real number or +-Infinity or NaN.
* Should be used with a `range` property to define its range.
*/
Number = 3,
/**
* The string type. Can be any string. Should be used
* with a `range` property to define the range of its length.
*/
String = 4,
/**
* The color type. This is in fact currently an integer in
* the range [-1, 16777216). Specialized only to be edited
* with a color picker component inside a GUI environment.
*/
Color = 5,
/**
* The collision flags type. This is in fact an ordinary
* integer. Specialized only to be edited with a collision
* flags editor component inside a GUI environment.
*/
CollisionFlags = 6,
/**
* The coordinate type. This is in fact an ordinary array
* using this structure: `[x: number, y: number]` where
* `x` and `y` are assumed to be the coordinates of a point.
* Specialized to be edited with a coordinate editor
* component inside a GUI environment.
*/
Coordinate = 7,
/**
* The team type. Currently, the only accepted values for
* this type is `1` and `2` where `1` is the red team and
* `2` is the blue team. Specialized to be edited with a
* team selector component inside a GUI environment.
*/
Team = 8,
/**
* The team type. Currently, the only accepted values for
* this type is `0`, `1` and `2` where `0` is the spectators
* team, `1` is the red team and `2` is the blue team.
* Specialized to be edited with a team selector component
* inside a GUI environment.
*/
TeamWithSpec = 9,
/**
* The background type. Currently, the only accepted values for
* this type is `0`, `1` and `2` where `0` means no background
* texture, `1` means grass texture and `2` means hockey texture.
* Specialized to be edited with a background selector component
* inside a GUI environment.
*/
BgType = 10,
/**
* The camera follow type. Currently, the only accepted values for
* this type is `0` and `1` where `0` means not to follow players and
* `1` means to follow the current player. Specialized to be edited
* with a camera follow selector component inside a GUI environment.
*/
CameraFollow = 11,
/**
* The kickOffReset type. Currently, the only accepted values for
* this type is `true` and `false` where `true` means "full" kick-off
* reset and `1` means "partial" kick-off reset. Specialized to be edited
* with a camera follow selector component inside a GUI environment.
*/
KickOffReset = 12,
/**
* The flag type. This is in fact a string value that represents the
* country code of a country. Specialized to be edited with a flag
* selector component inside a GUI environment.
*/
Flag = 13,
/**
* The file type. Should be editable with a file selector component
* inside a GUI environment.
*/
File = 14,
/**
* The playerId type. Should be editable with a player selector component
* inside a GUI environment.
*/
PlayerId = 15,
/**
* The keys array type. Should be editable with a keyboard keys editor component
* inside a GUI environment.
*/
Keys = 16,
/**
* A progress indicator. Its value should be an integer between 0 and 100, and
* null should disable the progressbar component inside a GUI environment.
*/
Progress = 17,
/**
* The player position type. Its possible values are the common player positions
* in most football manager games. (Check the PlayerPositionInGame enum)
*/
PlayerPositionInGame = 18
}
/**
* These values are used to track the current state of connection while joining a room. (Designed for the `onConnInfo(state, extraInfo)` callback in the `commonParams` parameter of `Room.join` function.)
*/
export enum ConnectionState {
/**
* "Trying reverse connection"
*/
TryingReverseConnection = -1,
/**
* "Connecting to master"
*/
ConnectingToMaster = 0,
/**
* "Connecting to peer"
*/
ConnectingToPeer = 1,
/**
* "Awaiting state"
*/
AwaitingState = 2,
/**
* "Active"
*/
Active = 3,
/**
* "Connection Failed"
*/
ConnectionFailed = 4
}
/**
* These values help understand whether a user is allowed to use an addon while joining a room or creating a room. They are designed to act like flags and be used in bitwise operations.
*/
export enum AllowFlags {
/**
* Whether the addon is useable while joining a room.
*/
JoinRoom = 1,
/**
* Whether the addon is useable while creating a room.
*/
CreateRoom = 2
}
/**
* These values help understand the type of addon object we are dealing with. One of these is assigned to the "addonType" property of every Addon constructor.
*/
export enum AddonType {
/**
* The "RoomConfig" addon type
*/
RoomConfig = 0,
/**
* The "Plugin" addon type
*/
Plugin = 1,
/**
* The "Renderer" addon type
*/
Renderer = 2,
/**
* The "Library" addon type
*/
Library = 3
}
/**
* These flags are used internally in Haxball's physics engine. They are designed to act like flags and be used in bitwise operations. Most types of stadium objects have collisionMask and collisionGroup properties that directly uses these flags to decide whether collision check should happen or not.
*
* Let's say discA seemingly collided with discB. The physics engine will just skip the collision without doing any further calculation if the below condition is not satisfied:
*
* ```js
* ((discA.collisionMask & discB.collisionGroup)>0) && ((discB.collisionMask & discA.collisionGroup)>0)
* ```
*/
export enum CollisionFlags {
/**
* If defined, the object will accept collisions with other "ball"s.
*/
ball = 0,
/**
* If defined, the object will accept collisions with other "red"s.
*/
red = 1,
/**
* If defined, the object will accept collisions with other "blue"s.
*/
blue = 2,
/**
* If defined, the object will accept collisions with other "red"s only until the kick-off event happens.
*/
redKO = 3,
/**
* If defined, the object will accept collisions with other "blue"s only until the kick-off event happens.
*/
blueKO = 4,
/**
* If defined, the object will act as a wall.
*/
wall = 5,
/**
* If defined, the object will become kickable. Haxball makes a player kick some object only if this `kick` flag exists in the object and the object is near enough to the player. (`4` map units, to be precise.)
*/
kick = 6,
/**
* If defined, the object will score a goal for the opposite team if it passes a goal line.
*/
score = 7,
/**
* Free
*/
free1 = 8,
/**
* Free
*/
free2 = 9,
/**
* Free
*/
free3 = 10,
/**
* Free
*/
free4 = 11,
/**
* Free
*/
free5 = 12,
/**
* Free
*/
free6 = 13,
/**
* Free
*/
free7 = 14,
/**
* Free
*/
free8 = 15,
/**
* Free
*/
free9 = 16,
/**
* Free
*/
free10 = 17,
/**
* Free
*/
free11 = 18,
/**
* Free
*/
free12 = 19,
/**
* Free
*/
free13 = 20,
/**
* Free
*/
free14 = 21,
/**
* Free
*/
free15 = 22,
/**
* Free
*/
free16 = 23,
/**
* Free
*/
free17 = 24,
/**
* Free
*/
free18 = 25,
/**
* Free
*/
free19 = 26,
/**
* Free
*/
free20 = 27,
/**
* Free
*/
c0 = 28,
/**
* Free
*/
c1 = 29,
/**
* Free
*/
c2 = 30,
/**
* Free
*/
c3 = 31
}
declare type int = number;
declare type uint8 = number;
declare type uint16 = number;
declare type int32 = number;
declare type uint32 = number;
declare type TemplateString = string;
declare type TextToNumberMap = {
[x: string]: number;
}
declare type NumberToTemplateStringMap = {
[x: number]: TemplateString;
}
/**
* These values help understand the direction of a movement for an axis. Only designed for room.keyState function to combine seperate directions for x and y axis to generate the value of the key to press.
*/
export enum Direction {
/**
* A backward movement.
*/
Backward = -1,
/**
* No movement.
*/
Still = 0,
/**
* A forward movement.
*/
Forward = 1
}
/**
* These values help understand whether the camera will follow the player or not. This is only used as a variable in all stadiums.
*/
export enum CameraFollow {
/**
* Camera is not bound to follow any player.
*/
None = 0,
/**
* Camera is bound to follow the current player.
*/
Player = 1
}
/**
* This is the type of the variable in a stadium that defines its background texture type.
*/
export enum BackgroundType {
/**
* No background texture.
*/
None = 0,
/**
* Grass background texture.
*/
Grass = 1,
/**
* Hockey background texture.
*/
Hockey = 2
}
/**
* This type lets us understand the actual state of the game. This type only exists in a GameState object.
*/
export enum GamePlayState {
/**
* This is the state of the game when the game has started,
* but kick-off has not happened yet.
*/
BeforeKickOff = 0,
/**
* This is the state of the game when the game is active and
* kick-off has already happened.
*/
Playing = 1,
/**
* This is the state of the game when the game is active and
* a goal has been scored. `GameState.goalTickCounter` is counting
* down from its initial value `150` while in this state. The
* game state is restored to `Playing` when this counter reaches `0`.
*/
AfterGoal = 2,
/**
* This is the state of the game when the game is active and a team
* has just been declared to have won the game. `GameState.goalTickCounter`
* is counting down from its initial value `300` while in this state. The
* game is stopped when this counter reaches `0`.
*/
Ending = 3
}
/**
* These are the common player positions in most football manager games.
*/
export enum PlayerPositionInGame {
/**
* No position. Unfortunately specific to Haxball. :)
*/
None = 0,
/**
* Goalkeeper
*/
GK = 1,
/**
* Sweeper
*/
SW = 2,
/**
* Wing Back Left
*/
WBL = 3,
/**
* Defender Left
*/
DL = 4,
/**
* Defender Centre
*/
DC = 5,
/**
* Defender Right
*/
DR = 6,
/**
* Wing Back Right
*/
WBR = 7,
/**
* Defensive Midfielder Left
*/
DML = 8,
/**
* Defensive Midfielder Centre
*/
DMC = 9,
/**
* Defensive Midfielder Right
*/
DMR = 10,
/**
* Midfielder Left
*/
ML = 11,
/**
* Midfielder Centre
*/
MC = 12,
/**
* Midfielder Right
*/
MR = 13,
/**
* Attacking Midfielder Left
*/
AML = 14,
/**
* Attacking Midfielder Centre
*/
AMC = 15,
/**
* Attacking Midfielder Right
*/
AMR = 16,
/**
* Left Forward
*/
FL = 17,
/**
* Centre Forward
*/
FC = 18,
/**
* Right Forward
*/
FR = 19,
/**
* Striker
*/
ST = 20,
};
/**
* The base class for all Haxball events.
*/
declare class HaxballEvent {
/**
* Type of the event. Should not be modified.
*/
public readonly eventType: OperationType;
/**
* Id of the player who triggered this event.
*/
public byId: uint16;
/**
* Creates a copy of this event object.
*/
public copy: ()=>HaxballEvent;
};
/**
* The event message structure that is created when a consistency check has to be performed.
*/
declare class ConsistencyCheckEvent extends HaxballEvent {
/**
* The consistency data to be checked.
*/
public data: ArrayBuffer;
};
/**
* The event message structure that is created when the game is started.
*/
declare class StartGameEvent extends HaxballEvent {};
/**
* The event message structure that is created when the game is stopped.
*/
declare class StopGameEvent extends HaxballEvent {};
/**
* The event message structure that is created when auto teams button is clicked.
*/
declare class AutoTeamsEvent extends HaxballEvent {};
/**
* The event message structure that is created when a player's synchronization status changes.
*/
declare class SetPlayerSyncEvent extends HaxballEvent {
/**
* The new synchronization status of the player who sent this event.
*/
public value: boolean;
};
/**
* The event message structure that is created when an announcement is sent/received.
*/
declare class SendAnnouncementEvent extends HaxballEvent {
/**
* The announcement message. ( max length = 1000 )
*/
public msg: string;
/**
* The color of the announcement message. Range: -1 <= `color` < 16777216.
* - The color value can be converted into a rgba string via API's `Utils.numberToColor` function.
* - The special value `-1` means `transparent` color.
*/
public color: int32;
/**
* The style of the announcement message. Must be one of the following:
* - 0: use document's default font style.
* - 1: fontWeight = "bold".
* - 2: fontStyle = "italic".
* - 3: fontSize = "12px".
* - 4: fontWeight = "bold", fontSize = "12px".
* - 5: fontWeight = "italic", fontSize = "12px".
*/
public style: uint8;
/**
* The sound of the announcement message. Must be one of the following:
* - 0: no sound.
* - 1: chat sound.
* - 2: highlight sound.
*/
public sound: uint8;
/**
* Id of the player who will receive the announcement.
* If `null`, everyone receives it. Can not be modified.
*/
public readonly targetId: uint16 | null;
};
/**
* The event message structure that is created when score limit or time limit is changed.
*/
declare class SetLimitEvent extends HaxballEvent {
/**
* Type of the event.
* - If `0`, score limit is changed.
* - Otherwise, time limit is changed.
*/
public type: uint8;
/**
* The new value of the limit. (0 <= value < 100)
*/
public newValue: int;
};
/**
* The event message structure that is created when a player's admin status is changed.
*/
declare class SetPlayerAdminEvent extends HaxballEvent {
/**
* Id of the player whose admin status is changed.
*/
public playerId: uint16;
/**
* The new admin status value.
*/
public value: boolean;
};
/**
* The event message structure that is created when a player changes its avatar.
*/
declare class SetAvatarEvent extends HaxballEvent {
/**
* The new avatar. ( max length = 2 )
*/
public value: string | null;
};
/**
* The event message structure that is created when a player is moved to a team.
*/
declare class SetPlayerTeamEvent extends HaxballEvent {
/**
* Id of the player whose team is changed.
*/
public playerId: uint16;
/**
* The new team.
*/
public team: Team;
};
/**
* The event message structure that is created when the stadium is changed.
*/
declare class SetStadiumEvent extends HaxballEvent {
/**
* The new stadium.
*/
public stadium: Stadium;
};
/**
* The event message structure that is created when the team colors are being changed.
*/
declare class SetTeamColorsEvent extends HaxballEvent {
/**
* The team whose colors are being changed.
*/
public team: Team;
/**
* The new team colors.
*/
public colors: TeamColors;
};
/**
* The event message structure that is created when the teams lock status is changed.
*/
declare class SetTeamsLockEvent extends HaxballEvent {
/**
* The new teams lock status.
*/
public newValue: boolean;
};
/**
* The event message structure that is created when a new player joins the room.
*/
declare class JoinRoomEvent extends HaxballEvent {
/**
* Id of the new player.
*/
public id: uint16;
/**
* Name of the new player.
*/
public name: string | null;
/**
* Flag of the new player.
*/
public flag: string | null;
/**
* Avatar of the new player.
*/
public avatar: string | null;
/**
* Hex-encoded "connection string"(!) of the new player.
*/
public conn: string;
/**
* Auth of the new player.
*/
public auth: string;
};
/**
* The event message structure that is created when a player's headless avatar is changed.
*/
declare class SetHeadlessAvatarEvent extends HaxballEvent {
/**
* Id of the player whose headless avatar is changed.
*/
public playerId: uint16;
/**
* The new headless avatar value. ( max length = 2 )
*/
public value: string | null;
};
/**
* The event message structure that is created when the game is paused/resumed.
*/
declare class PauseResumeGameEvent extends HaxballEvent {
/**
* Whether the game is paused or not.
*/
public paused: boolean;
};
/**
* The event message structure that is created when a chat message is sent.
*/
declare class SendChatEvent extends HaxballEvent {
/**
* The chat text that is sent. ( max length = 140 )
*/
public text: string;
/**
* Id of the player who will receive the chat.
* If `null`, everyone receives it. Can not be modified.
*/
public readonly targetId: uint16 | null;
};
/**
* The event message structure that is created when a player's input changes.
*/
declare class SendInputEvent extends HaxballEvent {
/**
* The new input value. ( 0 <= input < 32 )
*/
public input: uint32;
};
/**
* The event message structure that is created when a player's chat indicator status changes.
*/
declare class SendChatIndicatorEvent extends HaxballEvent {
/**
* The new value of the chat indicator status. (0: off, 1: on)
*/
public value: uint8;
};
/**
* The event message structure that is created when a custom event is triggered by this API.
*/
declare class CustomEvent extends HaxballEvent {
/**
* Type of the custom event. This value can be anything you want.
*/
public type: uint32;
/**
* Custom data of the custom event. This value can be anything you want.
* It has to be any json object that can be `JSON.stringify`ed and `JSON.parse`d.
*/
public data: object;
};
/**
* The event message structure that is created when a binary custom event is triggered by this API.
*/
declare class BinaryCustomEvent extends HaxballEvent {
/**
* Type of the binary custom event. This value can be anything you want.
*/
public type: uint32;
/**
* Custom binary data of the binary custom event. This value can be anything you want.
*/
public data: Uint8Array;
};
/**
* The event message structure that is created when an identity event is triggered by this API.
*/
declare class IdentityEvent extends HaxballEvent {
/**
* Id of the player whose identity data is desired to be changed.
*/
public id: uint16;
/**
* The identity data that should be received from the backend. It can be any JSON object.
*/
public data: object;
};
/**
* The event message structure that is created when a player leaves the room or is kicked/banned by the host.
*/
declare class KickBanPlayerEvent extends HaxballEvent {
/**
* Id of the player who left the room.
*/
public id: uint16;
/**
* The reason of kick/ban. ( max length = 100 )
* Interpreted as leaving by himself/herself if this value is `null`.
*/
public reason: string | null;
/**
* Whether the player is banned or not.
*/
public ban: boolean;
};
/**
* The event message structure that is created when the host calls room.reorderPlayers function.
*/
declare class ReorderPlayersEvent extends HaxballEvent {
/**
* Id of the players who will be reordered in the player list.
*/
public playerIdList: uint16[];
/**
* Whether the players will be moved to the top or bottom of the list.
*/
public moveToTop: boolean;
};
/**
* The event message structure that is created when the host calls room.setDiscProperties or room.setPlayerDiscProperties function.
*/
declare class SetDiscPropertiesEvent extends HaxballEvent {
/**
* Id of the disc/player whose properties are changed.
*/
public id: uint16;
/**
* If `true`, this is triggered by room.setPlayerDiscProperties, and `id` is the player's id.
* Otherwise, this is triggered by room.setDiscProperties, and `id` is the disc's id.
*/
public type: boolean;
/**
* Contains the floating point properties that are sent, in this order:
* `[x, y, xspeed, yspeed, xgravity, ygravity, radius, bCoeff, invMass, damping]`
* If any of these values are `null`, it means that that value is not modified.
*/
public data1: (number | null)[];
/**
* Contains the integer properties that are sent, in this order:
* `[color, cMask, cGroup]`
* If any of these values are `null`, it means that that value is not modified.
*/
public data2: (int | null)[];
};
/**
* The event message structure that is created when the kick rate limit is changed.
*/
declare class SetKickRateLimitEvent extends HaxballEvent {
/**
* The `min` component of the kick rate limit.
*/
public min: int;
/**
* The `rate` component of the kick rate limit.
*/
public rate: int;
/**
* The `burst` component of the kick rate limit.
*/
public burst: int;
};
/**
* The event message structure that is automatically created by the host to indicate current ping values of players.
*/
declare class PingEvent extends HaxballEvent {
/**
* The ping values of all players in the same order as the players list.
*/
public pings: int[];
};
declare type BanEntryId = uint32;
/**
* These values help understand the type of a ban entry instance inside a room's ban list.
*/
export enum BanEntryType {
/**
* A ban rule referring to a player's id.
*/
Player = 0,
/**
* A ban rule referring to an IP address/range.
*/
IP = 1,
/**
* A ban rule referring to a player's auth string.
*/
Auth = 2
};
declare type NumericIPv4 = uint32;
declare type NumericIPv6 = BigInt;
declare type AuthString = string;
declare type BanEntry = {
id: BanEntryId;
type: BanEntryType;
value: {pId: int, pName: string, ips: string[], auth: AuthString} | NumericIPv4 | NumericIPv6 | AuthString;
};
declare type IPv4Range = {
ip: NumericIPv4,
mask: NumericIPv4
};
declare type IPv6Range = {
ip: NumericIPv6,
mask: NumericIPv6
};
/**
* A player can be identified from the stringified instance of this class that the player carries.
*/
declare type Auth = {};
/**
* A class that defines the coordinates of an object.
*/
declare type Point = {
/**
* The x coordinate.
*/
x: number;
/**
* The y coordinate.
*/
y: number;
};
/**
* A class that defines a vertex.
*/
declare type Vertex = {
/**
* The id(index) of this Vertex.
*/
id: int;
/**
* The collision group of this Vertex.
*/
cGroup: int;
/**
* The collision mask of this Vertex.
*/
cMask: int;
/**
* The bouncing coefficient of this Vertex.
*/
bCoef: number;
/**
* The position of this Vertex.
*/
pos: Point;
};
/**
* A class that defines a segment.
*/
declare type Segment = {
/**
* The first Vertex of this Segment.
*/
v0: Vertex;
/**
* The second Vertex of this Segment.
*/
v1: Vertex;
/**
* The curving angle of this Segment. (in radians)
*/
curveF: number;
/**
* The color of this Segment. Range: -1 <= `color` < 16777216.
* - This value can be converted into a rgba string via API's `Utils.numberToColor` function.
* - The special value `-1` means `transparent` color.
*/
color: int;
/**
* Whether this Segment is visible or not.
*/
vis: boolean;
/**
* Bias of this Segment.
*/
bias: number;
/**
* The bouncing coefficient of this Segment.
*/
bCoef: number;
/**
* The collision group of this Segment.
*/
cGroup: int;
/**
* The collision mask of this Segment.
*/
cMask: int;
/**
* The calculated normal vector of this Segment. Only applies to non-curved Segments.
*/
normal: Point;
/**
* The calculated normal direction of the object's tangent line at `v0`. Only applies to curved Segments.
*/
v0Normal: Point;
/**
* The calculated normal direction of the object's tangent line at `v1`. Only applies to curved Segments.
*/
v1Normal: Point;
/**
* The calculated radius of this Segment. Only applies to curved Segments.
*/
arcRadius: Point;
/**
* The calculated center point of this Segment. Only applies to curved Segments.
*/
arcCenter: Point;
};
/**
* A class that defines a plane.
*/
declare type Plane = {
/**
* The normal vector of this Plane.
*/
normal: Point;
/**
* The distance of this Plane to the origin point(0, 0).
*/
dist: number;
/**
* The bouncing coefficient of this Plane.
*/
bCoef: number;
/**
* The collision group of this Plane.
*/
cGroup: int;
/**
* The collision mask of this Plane.
*/
cMask: int;
};
/**
* A class that defines a goal.
*/
declare type Goal = {
/**
* The first point of this Goal.
*/
p0: Point;
/**
* The second point of this Goal.
*/
p1: Point;
/**
* The team that this Goal belongs to.
*/
team: Team;
};
/**
* A class that defines a disc.
*/
declare type Disc = {
/**
* The position of this Disc.
*/
pos: Point;
/**
* The radius of this Disc.
*/
radius: number;
/**
* The speed of this Disc.
*/
speed: Point;
/**
* The gravity of this Disc.
*/
gravity: Point;
/**
* The damping value of this Disc.
*/
damping: number;
/**
* The 1/mass value of this Disc.
*/
invMass: number;
/**
* The bouncing coefficient of this Disc.
*/
bCoef: number;
/**
* The color of this Disc. Range: -1 <= `color` < 16777216.
* - This value can be converted into a rgba string via API's `Utils.numberToColor` function.
* - The special value `-1` means `transparent` color.
*/
color: int;
/**
* The collision group of this Disc.
*/
cGroup: int;
/**
* The collision mask of this Disc.
*/
cMask: int;
};
/**
* A class that defines an active disc.
*/
declare type MovableDisc = {
/**
* The position of this Disc.
*/
pos: Point;
/**
* The radius of this Disc.
*/
radius: number;
/**
* The speed of this Disc.
*/
speed: Point;
/**
* The gravity(acceleration) of this Disc.
*/
gravity: Point;
/**
* The damping value of this Disc.
*/
damping: number;
/**
* The 1/mass value of this Disc.
*/
invMass: number;
/**
* The bouncing coefficient of this Disc.
*/
bCoef: number;
/**
* The color of this Disc. Range: -1 <= `color` < 16777216.
* - This value can be converted into a rgba string via API's `Utils.numberToColor` function.
* - The special value `-1` means `transparent` color.
*/
color: int;
/**
* The collision group of this Disc.
*/
cGroup: int;
/**
* The collision mask of this Disc.
*/
cMask: int;
/**
* Id of the player that owns this Disc, or `null` if it is not owned by a player.
*/
playerId: uint16 | null;
/**
* The extrapolated version of this Disc, or `null` if the data is not available.
*/
ext: MovableDisc | null;
};
/**
* A class that defines a joint.
*/
declare type Joint = {
/**
* Index of the first Disc of this Joint.
*/
d0: int;
/**
* Index of the second Disc of this Joint.
*/
d1: int;
/**
* The minimum length of this Joint.
*/
minLength: number;
/**
* The maximum length of this Joint.
*/
maxLength: number;
/**
* The strength of this Joint. (`Infinity` means rigid.)
*/
strength: number;
/**
* The color of this Joint. Range: -1 <= `color` < 16777216.
* - This value can be converted into a rgba string via API's `Utils.numberToColor` function.
* - The special value `-1` means `transparent` color.
*/
color: int;
};
/**
* A class that defines an object to store game-specific physical properties of a player.
*/
declare type PlayerPhysics = {
/**
* A value to determine how much each player is pushed back when a player kicks the ball.
*/
kickback: number;
/**
* Radius of each player's Disc.
*/
radius: number;
/**
* The collision group of each player's Disc.
*/
cGroup: int;
/**
* The constant gravity(acceleration) applied to each player's Disc all the time.
*/
gravity: Point;
/**
* The bouncing coefficient of this Vertex.
*/
bCoef: number;
/**
* The 1/mass value of each player's Disc.
*/
invMass: number;
/**
* The damping value of each player's Disc.
*/
damping: number;
/**
* The acceleration(for manual movements only) of each player's Disc.
*/
acceleration: number;
/**
* The acceleration(for manual movements only) of each player's Disc while the kick key is pressed.
*/
kickingAcceleration: number;
/**
* The damping value of each player's Disc while the kick key is pressed.
*/
kickingDamping: number;
/**
* The kicking strength of each player.
*/
kickStrength: number;
};
/**
* A class that defines a stadium.
*/
declare type Stadium = {
/**
* All vertices of this Stadium.
*/
vertices: Vertex[];
/**
* All segments of this Stadium.
*/
segments: Segment[];
/**
* All planes of this Stadium.
*/
planes: Plane[];
/**
* All goals of this Stadium.
*/
goals: Goal[];
/**
* All discs of this Stadium.
*/
discs: Disc[];
/**
* All joints of this Stadium.
*/
joints: Joint[];
/**
* All spawn points of this Stadium for the red team.
*/
redSpawnPoints: Point[];
/**
* All spawn points of this Stadium for the blue team.
*/
blueSpawnPoints: Point[];
/**
* The physics properties of all players for this Stadium.
*/
playerPhysics: PlayerPhysics;
/**
* The id(index) of this Stadium in the default stadiums array.
* This value will be 255 in custom Stadiums.
*/
defaultStadiumId: int;
/**
* The maximum view width for this Stadium. Used in Renderers.
*/
maxViewWidth: number;
/**
* Whether the camera will follow the player or not. Used in Renderers.
*/
cameraFollow: CameraFollow;
/**
* Whether this Stadium can be stored or not.
*/
canBeStored: boolean;
/**
* Whether the disc positions other than the ball are reset or not after a goal is scored.
*/
fullKickOffReset: boolean;
/**
* The name of this Stadium.
*/
name: string;
/**
* The width of this Stadium.
*/
width: number;
/**
* The height of this Stadium.
*/
height: number;
/**
* The background type of this Stadium.
*/
bgType: BackgroundType;
/**
* The background color of this Stadium. Range: -1 <= `bgColor` < 16777216.
* - This value can be converted into a rgba string via API's `Utils.numberToColor` function.
* - The special value `-1` means `transparent` color.
*/
bgColor: int;
/**
* The width for the background of this Stadium.
*/
bgWidth: number;
/**
* The height for the background of this Stadium.
*/
bgHeight: number;
/**
* The kick-off circle's radius for the background of this Stadium.
*/
bgKickOffRadius: number;
/**
* The radius of the corners for the background of this Stadium.
*/
bgCornerRadius: number;
/**
* The spawn distance of players for this Stadium.
*/
spawnDistance: number;
/**
* The goal line's horizontal distance from the default goal positions for the background of this Stadium.
*/
bgGoalLine: number;
/**
* Whether this is a custom Stadium or a default Stadium.
*/
readonly isCustom: boolean;
/**
* Creates a copy of this Stadium object.
*/
copy: ()=>Stadium;
/**
* Returns the checksum for this Stadium object.
*
* @returns The checksum string of this Stadium object, or `null` for default stadiums.
*/
calculateChecksum: ()=>string|null;
/**
* Returns the hash value for this Stadium object.
*
* @returns The hash value for this Stadium object.
*/
calculateHash: ()=>int;
};
/**
* A class that defines the colors of a team.
*/
declare type TeamColors = {
/**
* The angle of stripes shown inside the player disc object. (in radians)
*/
angle: number;
/**
* The angle of stripes shown inside the player disc object. (in degrees)
*/
readonly angleDeg: number;
/**
* Color of the avatar text. Range: -1 <= `text` < 16777216.
* - This value can be converted into a rgba string via API's `Utils.numberToColor` function.
* - The special value `-1` means `transparent` color.
*/
text: int;
/**
* Colors of the stripes. (A maximum of 3 stripes are allowed.)
* For each `value` in the array; range: -1 <= `value` < 16777216.
* - This value can be converted into a rgba string via API's `Utils.numberToColor` function.
* - The special value `-1` means `transparent` color.
*/
inner: int[];
/**
* Creates a copy of this TeamColors object.
*/
copy: ()=>TeamColors;
};
/**
* A class that defines a team.
*/
declare type Team = {
/**
* The id of this Team.
*/
id: number;
/**
* The color of this Team. Range: -1 <= `color` < 16777216.
* - This value can be converted into a rgba string via API's `Utils.numberToColor` function.
* - The special value `-1` means `transparent` color.
*/
color: int;
/**
* The default defense direction on the x axis for this Team.
*/
defenseDir: Direction;
/**
* The default cMask of this Team's player objects. (This value | 39) is
* overwritten into all of the players' cMask values whenever a goal is scored.
*/
cMask: int;
/**
* The default cGroup of this Team's player objects.
*/
cGroup: int;
};
declare namespace Team {
/**
* The Spectators Team.
*/
export const spec: Team;
/**
* The Red Team.
*/
export const red: Team;
/**
* The Blue Team.
*/
export const blue: Team;
/**
* All teams can be reached by their ids using
* this object in the following manner:
*
* `Team.byId[id]`.
*/
export const byId: Team[];
}
/**
* A class that defines a geographic location.
*/
declare type GeoLocation = {
/**
* The latitude of this GeoLocation.
*/
lat: number;
/**
* The longitude of this GeoLocation.
*/
lon: number;
/**
* The country code of this GeeLocation.
*/
flag: string;
};
/**
* A class that defines a player inside a room state.
*/
declare type Player = {
/**
* Id of this Player.
*/
id: int;
/**
* Name of this Player.
*/
name: string;
/**
* Team of this Player.
*/
team: Team;
/**
* Country code of this Player.
*/
flag: string;
/**
* Client avatar of this Player.
*/
avatar: string | null;
/**
* Headless avatar of this Player.
*/
headlessAvatar: string | null;
/**
* Whether this Player is an admin or not.
*/
isAdmin: boolean;
/**
* Avatar number of this Player. If no avatar is set, this number is shown.
*/
avatarNumber: int;
/**
* Connection string of this Player.
*/
conn: string | null;
/**
* Public auth string of this Player.
*/
auth: string | null;
/**
* Whether this Player is using this API or not.
*/
customClient: boolean;
/**
* Current ping value of this Player.
*/
ping: int;
/**
* Current key-state of this Player.
*/
input: int;
/**
* Min tick counter for kick rate of this Player.
*/
kickRateMinTickCounter: int;
/**
* Max tick counter for kick rate of this Player.
*/
kickRateMaxTickCounter: int;
/**
* Whether this Player is currently kicking the ball or not.
*/
isKicking: boolean;
/**
* Whether this Player is currently synchronized with the room's host or not.
*/
sync: boolean;
/**
* Current disc of this Player, or null if this Player is not currently playing.
*/
disc: MovableDisc | null;
/**
* The extrapolated version of this Player, or `null` if the data is not available.
*/
ext: Player | null;
/**
* The identity data of the current player that is received from a backend/proxy server.
*/
identity: object | null;
};
/**
* A class that has all the objects that are related to the physics simulation.
*/
declare type World = {
/**
* All vertices of this World.
*/
vertices: Vertex[];
/**
* All segments of this World.
*/
segments: Segment[];
/**
* All planes of this World.
*/
planes: Plane[];
/**
* All movable discs of this World.
*/
discs: MovableDisc[];
/**
* All joints of this World.
*/
joints: Joint[];
/**
* The extrapolated version of this World, or `null` if the data is not available.
*/
ext: World | null;
/**
* Creates the physical ball kicking effect. No kicking will happen if the distance between ball and player is >= 4 map units.
*
* @param pDisc The actual disc of the player that is kicking the ball.
* @param bDisc The actual disc of the ball that is being kicked.
* @param pp The current physical attributes of the players.
*
* @returns Whether the ball was kicked or not.
*/
kickBall: (pDisc: MovableDisc, bDisc: MovableDisc, pp: PlayerPhysics) => boolean;
};
/**
* A class that defines the complete game state of a room.
*/
declare type GameState = {
/**
* Counts how many ticks are left to resume the game.
* This value is set to `120` whenever the game is paused.
*/
pauseGameTickCounter: int;
/**
* The currently elapsed time in miliseconds.
*/
timeElapsed: number;
/**
* The current score of blue team.
*/
blueScore: int;
/**
* The current score of red team.
*/
redScore: int;
/**
* The current state of the actual gameplay.
*/
state: GamePlayState;
/**
* Counts how many ticks are left to reset the positions of discs.