Files
GetiyoSimpleAIVisual/server/ModuleServerApi.d.ts
2025-04-30 18:58:08 +02:00

1939 lines
52 KiB
TypeScript

// ---------------- ModuleServerAPI ----------------
declare const Getiyo: Getiyo;
interface ModuleServerApi {
/**Get the library packages. */
Libs: Libs;
GameLib: GameLib;
// --- A P I D A T A ---
/**Get the module class. */
getModule: getModule;
// --- C O M M U N I C A T I O N ---
/**Register a listener for incoming packets. */
on: on;
/**Broadcast a message to all connected module clients. */
broadcast: broadcast;
// --- C L I E N T S ---
/**Get all connected clients */
getClients: getClients;
/**Get a connected client. */
getClient: getClient;
/** Check if client is connceted. */
hasClient: hasClient;
/**Register a listener for when a new module client connects.
* @deprecated For better name continuity replaced by 'onClientConnects'
*/
onNewClient: onNewClient;
/**Register a listener for when a module client connects. */
onClientConnects: onClientConnects;
/**Register a listener for when a module client connects. */
onClientDisconnects: onClientDisconnects;
// --- E V E N T S ---
/**Register a listener for when a module property is updated. */
onModulePropertyUpdate: onModulePropertyUpdate;
/**Register a listener for when a reference property is updated. */
onReferencePropertyUpdate: onReferencePropertyUpdate;
/**Register a listener to be triggered when the module instance is loaded but the module references not. */
onInit: onInit;
/**Register a listener for when a trigger. */
onTrigger: onTrigger;
/**Register a listener for when a scene change occurs with a reference of this module in the origin or desination scene. */
onSceneChange: onSceneChange;
/**Register a listener for when a user has upload a file to the module. */
onFileUpload: onFileUpload;
// --- L A S T S T A T E ---
/**Get the last state of the module. */
getLastState: getLastState;
/**Set the last state of the module. */
setLastState: setLastState;
// --- S T O R A G E ---
/**Adds a listener for when the storage was restored from a snapshot.
* @deprecated For better name continuity replaced by 'onSnapshotRestore'
*/
onRuntimeStorageRestored: onruntimestoragerestored;
/**Register a listener that will be called when a snapshot is recalled and the runtime storage is restored. */
onSnapshotRestore: onsnapshotrestore;
/**Register a listener that will be called before a snapshot is taken, this makes it possible to add variable to the storage before the snapshot happens. */
onSnapshotCreate: onsnapshotcreate;
/**Get the variable storage object. */
getRuntimeStorage: getruntimestorage;
// --- M O D U L E P R O P E R T I E S ---
/**Get all module properties. */
getModuleProperties: getModuleProperties;
/**Get a module property. */
getModuleProperty: getModuleProperty;
/**Checks if the module has a property. */
hasModuleProperty: hasModuleProperty;
// --- R E F E R E N C E P R O P E R T I E S ---
/**Get all reference properties of a scene. */
getReferenceProperties: getReferenceProperties;
/**Get a reference property. */
getReferenceProperty: getReferenceProperty;
/**Checks if a module reference has a property. */
hasReferenceProperty: hasReferenceProperty;
// --- F I L E S Y S T E M ---
/**Read a json file. */
readJSON: readJSON;
/**Write a json file. */
writeJSON: writeJSON;
/**Write a file. */
writeFile: writeFile;
/**Checks if a file exists. */
fileExists: fileExists;
/**
* @deprecated
* Make a file reachable from a url. */
hostFile: hostFile;
/**Create a new host */
addHost: addHost;
/**
* @deprecated
* Stop a file from being hosted. */
removeHostFile: removeHostFile;
/**Remove a host */
removeHost: removeHost;
/**
* @deprecated
* Check if a hostID is active. */
hasHostFile: hasHostFile;
/** Check if a host is active. */
hasHost: hasHost;
// --- C O N D I T I O N S ---
/**Finishes a server condition. */
finishServerCondition: finishServerCondition;
/**Finishes a client condition inside a scene without reaching the target. */
forceClientCondition: forceClientCondition;
// --- S C E N E S ---
/**
* @deprecated
* Get a list of all scenes this module is in. */
getScenes: getScenes;
/**Get a list of all scenes this module is in. */
getModuleScenes: getModuleScenes;
// --- S T A G E ---
//** */
getResolution: getResolution;
}
// - - - - - - - - - - - - - - - A P I D A T A - - - - - - - - - - - - - - -
interface getModule {
/**
* Get the module class.
* @return {object} module
*/
(): object;
}
// - - - - - - - - - - - - - - - C O M M U N I C A T I O N - - - - - - - - - - - - - - -
interface on {
/**
* Register a listener for incoming packets.
* @param {string} header The header to listen for.
* @param {on_callback} callback Function to handle the incomming message.
*/
(header: string, callback: on_callback): void;
}
interface on_callback {
/**
* Callback for when a packet is received.
* @param {Client} Client Instance of the module client.
* @param {...any} arg Additional data in the same order as when it was send.
*/
(client: Client, ...args: any): void;
}
interface broadcast {
/**
* Broadcast a message to all connected module clients.
* @param {string} header Header of the message.
* @param {...any} arg Additional data.
*/
(property: string, ...value: any): void;
}
// - - - - - - - - - - - - - - - C L I E N T S - - - - - - - - - - - - - - -
interface getClients {
/** Get all connected clients.
* @param {string[]} displays? Array of displays to check, leave empty for all.
* @returns { [clientId: string]: Client } Client list;
*/
(displays?: string): { [clientId: string]: Client };
}
interface getClient {
/** Get a connected client.
* @param {string} clientId The id of the client.
* @returns { Client } Client object
* */
(clientId: string): Client;
}
interface hasClient {
/** Check if a client is online.
* @param {string} clientId The id of the client.
* @returns { boolean } CLient is online.
* */
(clientId: string): boolean;
}
interface onNewClient {
/**
* Register a listener for when a new module client connects.
* @param {onNewClient_callback} callback This function will be called when a new client connects.
*/
(callback: onNewClient_callback): void;
}
interface onNewClient_callback {
/**
* The callback for when a new client connects.
* @param {ModuleServerApi.Client} Client The instance of the module client.
*/
(client: Client): void;
}
interface onClientConnects {
/**
* Register a listener for when a module client connects.
* @param {onClientConnects_callback} callback This function will be called when a client connects.
*/
(callback: onClientConnects_callback): void;
}
interface onClientConnects_callback {
/**
* The callback for when a client connects.
* @param {ModuleServerApi.Client} Client The instance of the module client.
*/
(client: Client): void;
}
interface onClientDisconnects {
/**
* Register a listener for when a module client disconnects.
* @param {onClientDisconnects_callback} callback This function will be called when a client disconnects.
*/
(callback: onClientDisconnects_callback): void;
}
interface onClientDisconnects_callback {
/**
* The callback for when a client disconnects.
* @param {ModuleServerApi.Client} Client The instance of the module client.
*/
(client: Client): void;
}
// - - - - - - - - - - - - - - - E V E N T S - - - - - - - - - - - - - - -
interface onModulePropertyUpdate {
/**
* Register a listener for when a module property is updated.
* @param {string} property The name of the property.
* @param {onModulePropertyUpdate_callback} callback This function will be called when any updates to a property of this module have been made.
*/
(property: string, callback: onModulePropertyUpdate_callback): void;
}
interface onModulePropertyUpdate_callback {
/**
* The callback for when a module property is updates.
* @param {any} value The new value of the property.
*/
(value: any): void;
}
interface onReferencePropertyUpdate {
/**
* Register a listener for when a reference property is updated.
* @param {string} property The name of the property.
* @param {onReferencePropertyUpdate_callback} callback This function will be called when any updates to a property of a reference module have been made.
*/
(property: string, callback: onReferencePropertyUpdate_callback): void;
}
interface onReferencePropertyUpdate_callback {
/**
* The callback for when a reference property is updates.
* @param {any} value The new value of the property.
*/
(sceneID: string, value: any): void;
}
interface onInit {
/**
* (Optional) Register a listener to be triggered when the module instance is loaded but the module references not. It is very important that you call ready() when you finish you initializiation.
* @param {function} callback Will be called when module is loaded.
*/
(callback: onInit_callback): void;
}
interface onInit_callback {
/**
* The callback for when the module instance had loaded.
* @param {Function} ready Call this function when you finished the intialization.
*/
(ready: Function): void;
}
interface onTrigger {
/**
* Register a listener for when a trigger.
* @param {string} trigger The name of the trigger.
* @param {onTrigger_callback} callback This function will be called when trigger is called by the timeline.
*/
(trigger: string, callback: onTrigger_callback): void;
}
interface onTrigger_callback {
/**
* Callback for the trigger is called by the time.line.
* @param {Function} finish Finish the trigger and let the timeline continue.
* @param {onTrigger_callback_status} status Update the status.
* @param {...any} args Additional variables send by the timeline.
*/
(finish?: Function, status?: onTrigger_callback_status, ...args: any): void;
}
interface onTrigger_callback_status {
/**
* Update the status field in the timeline.
* @param {string} text Status text
*/
(text: string): void;
}
interface onSceneChange {
/**
* Register a listener for when a scene change occurs with a reference of this module in the origin or desination scene.
* @param {onSceneChange_callback} callback This function will be called when trigger is called by the timeline.
*/
(callback: onSceneChange_callback): void;
}
interface onSceneChange_callback {
/**
* The callback for when a scene change occurs.
* @param {string} display The id of the display where the change occured.
* @param {string|null} origin The id of the origin scene.
* @param {string|null} destination The id of the destination scene.
*/
(display: string, origin: string, destination: string): void;
}
interface onFileUpload {
/**
* Register a listener for when a user uploads a file to the module..
* @param {onFileUpload_callback} callback This function will be called when the file upload is finished and finalized..
*/
(callback: onFileUpload_callback): void;
}
interface onFileUpload_callback {
/**
* The callback for when a file finished uploading and is finalized.
* @param {Array} files List of upload files.
*/
(
files: {
filename: string;
originalFilename: string;
byUser: string;
size: number;
}[]
): void;
}
// - - - - - - - - - - - - - - - L A S T S T A T E - - - - - - - - - - - - - - -
interface getLastState {
/**
* Get the last state of the module. This is last version that has been edited, this is used for the default data for a new reference of this modules.
* @returns {LastState} The last state of the module.
*/
(): LastState;
}
interface setLastState {
/**
* Set the last state of the module. This is used for the default data for new reference of this modules.
* @param {LastState} state The last state of the module.
*/
(state: LastState): void;
}
interface LastState {
location: { x: property; y: property };
size: { width: property; height: property };
appearance: { rotation: property; warp: property; transparency: property };
properties: { [key: string]: property };
}
// - - - - - - - - - - - - - - - S T O R A G E - - - - - - - - - - - - - - -
interface onruntimestoragerestored {
/**
* @deprecated For better name continuity replaced by 'onSnapshotRestore'
* Adds a listener for when the storage was restored from a snapshot.
* @param {Function} callback Callback will be called when a snapshot is restored.
*/
(callback: onruntimestoragerestored_callback): void;
}
interface onruntimestoragerestored_callback {
/**
* Snapshot is restored
*/
(): void;
}
interface onsnapshotrestore {
/**
* Register a listener that will be called when a snapshot is recalled and the runtime storage is restored.
* @param {Function} callback Callback will be called when a snapshot is restored.
*/
(callback: onsnapshotrestore_callback): void;
}
interface onsnapshotrestore_callback {
/**
* Snapshot is restored
*/
(): void;
}
interface onsnapshotcreate {
/**
* Register a listener that will be called before a snapshot is taken, this makes it possible to add variable to the storage before the snapshot happens.
* @param {Function} callback Callback will be called before the snapshot is created.
*/
(callback: onsnapshotcreate_callback): void;
}
interface onsnapshotcreate_callback {
/**
* Snapshot is about to be created
*/
(): void;
}
interface getruntimestorage {
/**
/* Get the variable storage object.
* @return {ModuleRuntimeStorage} Storage object
*/
(): ModuleRuntimeStorage;
}
interface ModuleRuntimeStorage {
/**
* @readonly
* Unix timestamp when the last snapshot was made.
*/
_lastSnapshot: number;
/**
* @readonly
* List of all variable keys inside the storage.
*/
_keys: string[];
/**
* @readonly
* The amount of variables inside the storage.
*/
_size: number;
/**
* Using the storage without an interface will work but is not generally advised. Please extent storage interfaca with an interface containing specific properties.
* @author Mees van der Wijk
* @deprecated
*/
[key: string]: any;
}
// - - - - - - - - - - - - - - - P R O P E R T Y - - - - - - - - - - - - - - -
/** The property class. */
interface property {
/**
* Get the value of the property.
* @returns {any} value
*/
getValue: () => any;
/**
* Set the value of the property.
* @param {any} value
*/
setValue: (value: any) => void;
/**
* Get the value as string.
*/
asString: () => string;
/**
* Get the value as number.
*/
asNumber: () => number;
/**
* Get the value as boolean.
*/
asBoolean: () => boolean;
/**
* Get the value as file.
*/
asFile: () => { address: string; name: string };
/**
* Get the value as giphy.
*/
asGiphy: () => { address: string; name: string };
//**The type of property. */
type:
| 'text'
| 'textarea'
| 'number'
| 'slider'
| 'checkbox'
| 'select'
| 'file'
| 'time'
| 'date'
| 'datetime'
| 'giphy';
//**The visual title in editor. */
title: string;
//**Raw value of property. */
value: any;
//**The description of the property, used for the question mark in the editor. */
description?: string;
//**The minimum value of the property. */
min?: number;
//**The maximum value of the property. */
max?: number;
//**The step in which to increament/decremeant the value of the property. */
step?: number;
//**The allowed values of the property. */
allowedValues?: { id: string; text: string }[];
}
// - - - - - - - - - - - - - - - M O D U L E P R O P E R T I E S - - - - - - - - - - - - - - -
interface getModuleProperties {
/**
* Get all module properties.
* @returns {Object.<string, any>} A list of all module properties.
*/
(): { [key: string]: property };
}
interface getModuleProperty {
/**
* Get a module property.
* @param {string} property The name of the property.
* @return {property} A property object.
*/
(propertyKey: string): property;
}
interface hasModuleProperty {
/**
* Checks if the module has a property.
* @param {string} property The name of the property.
* @return {boolean} The module has a property with this name.
*/
(property: string): boolean;
}
// - - - - - - - - - - - - - - - R E F E R E N C E P R O P E R T I E S - - - - - - - - - - - - - - -
interface getReferenceProperties {
/**
* Get all reference properties of a scene.
* @param {string} sceneID
* @returns {Object.<string, any>} A list of all reference properties.
*/
(sceneID: string): { [key: string]: property };
}
interface getReferenceProperty {
/**
* Get a reference property.
* @param {string} sceneID The id of the scene.
* @param {string} property The name of the property.
* @return {property} A property object.
*/
(sceneID: string, property: string): property;
}
interface hasReferenceProperty {
/**
* Checks if a module reference has a property.
* @param {string} sceneID The id of the scene.
* @param {string} property The name of the property.
* @return {boolean} The module has a property with this name.
*/
(sceneID: string, propertyKey: string): boolean;
}
// - - - - - - - - - - - - - - - F I L E S Y S T E M - - - - - - - - - - - - - - -
interface readJSON {
/**
* Read a json file.
* @param {"channel"|"module"} scope The scope in which you want to load the json file. Can be either module for access by only this module instance or channel for access by all modules in this channel.
* @param {string} filename The filename and extention of the json file you want to read.
* @param {readJSON_callback} callback The function to be called when the reading of the json file is complete.
*/
(
scope: 'channel' | 'module',
filename: string,
callback: readJSON_callback
): void;
}
interface readJSON_callback {
/**
* The callback for when the reading of the json file is completed.
* @param {object} json The json data of the file.
*/
(json: Object): void;
}
interface writeJSON {
/**
* Write a json file.
* @param {"channel"|"module"} scope The scope in which you want to write the json file. Can be either module for access by only this module instance or channel for access by all modules in this channel.
* @param {string} filename The filename and extention of the json file you want to read.
* @param {object} json The json object you want to write.
* @param {function} [callback] The function to be called when the writing of the json file is complete.
*/
(
scope: 'channel' | 'module',
filename: string,
json: object,
callback?: () => void
): void;
}
interface writeFile {
/**
* Write a file.
* For more data on the data and options parameters see {@link https://nodejs.org/api/fs.html#fs_fs_writefile_file_data_options_callback|fs.writeFile}
* @param {"channel"|"module"} scope The scope in which you want to write the file. Can be either module for access by only this module instance or channel for access by all modules in this channel.
* @param {string} filename The filename and extention of the file you want to write.
* @param {string|Buffer|TypedArray|DataView|Object} data The data to be written.
* @param {Object|string} options Which writing options to use.
* @param {function} [callback] The function to be called when the writing of the file is complete.
*/
(
scope: 'channel' | 'module',
filename: string,
data: any,
options: Object | string,
callback: Function
): void;
}
interface fileExists {
/**
* Checks if a file exists.
* @param {"channel"|"module"} scope The scope in which you want to check the file. Can be either module for access by only this module instance or channel for access by all modules in this channel.
* @param {string} filename The filename and extention of the file you want to check.
* @param {fileExists_callback} callback The function to be called when the checking of the file is complete.
*/
(
scope: 'channel' | 'module',
filename: string,
callback: (exists: boolean) => void
): void;
}
interface fileExists_callback {
/**
* Callback for when the checking of file existens is complete
* @param {string} exists The file exists.
*/
(exists: boolean): void;
}
interface addHost {
/**
* Make a file reachable from a url.
* @param {"channel"|"module"} scope The scope in which the host file is. This can be either module for access by only this module instance or channel for access by all modules in this channel.
* @param {string} filename The filename and extention of the file you want to host.
* @return {host} The host data.
*/
(scope: 'channel' | 'module' | 'static', filename: string): host;
}
interface hostFile extends addHost {
/**
* @deprecated
*/
}
interface host {
/**The relative url from where the file can be loaded. */
relativeUrl: string;
/**The relative url from where the file can be downloaded. */
downloadUrl: string;
/**The host id, used to remove the hosted file. */
hostID: string;
}
interface removeHost {
/**
* Stop a file from being hosted.
* @param {string} hostID The id of the hosted file.
*/
(hostID: string): void;
}
interface removeHostFile extends removeHost {
/**
* @deprecated
*/
}
interface hasHost {
/**
* Check if a hostID is active.
* @param {string} hostID The id of the hosted file.
* @returns {boolean} The host ID is active.
*/
(hostID: string): boolean;
}
interface hasHostFile extends hasHost {
/**
* @deprecated
*/
}
// - - - - - - - - - - - - - - - C O N D I T I O N S - - - - - - - - - - - - - - -
interface finishServerCondition {
/**
* Finishes a server condition. These can be used in the timeline to wait to certain module callbacks.
* @param {string} condition The server condition name
*/
(condition: string): void;
}
interface forceClientCondition {
/**
* Finishes a client condition inside a scene without reaching the target. These can be used in the timeline to wait to certain module callbacks.
* @param {string} sceneID The scene in which you want to force the condition.
* @param {string} condition The server condition name.
*/
(sceneID: number, condition: string): void;
}
// - - - - - - - - - - - - - - - S C E N E S - - - - - - - - - - - - - - -
interface getScenes {
/**
* @deprecated Replaced by getModuleScenes()
* Get a list of all scenes this module is in.
* @return {string[]} Array of scene IDs.
*/
(): string[];
}
interface getModuleScenes {
/**
* Get a list of all scenes this module is in.
* @return {{sceneId:string, name:string}[]} Array of scene IDs.
*/
(): { sceneId: string; name: string }[];
}
// - - - - - - - - - - - - - - - S T A G E - - - - - - - - - - - - - - -
interface getResolution {
/**
* Get the resolution of the stage.
* @return {getResolution_resolution} Stage resolution.
*/
(): getResolution_resolution;
}
interface getResolution_resolution {
/**The width of the stage. */
width: number;
/**The height of the stage. */
height: number;
}
// ---------------- Client ----------------
interface Client {
/**Send a message to the client. */
send: clientSend;
/**Check if client is authorized. */
isAuthorized: clientAuthorized;
/**Get the client scene ID. */
getSceneID: getSceneID;
/**Get the client display ID. */
getDisplayID: getDisplayID;
/**Get the client ID. */
getClientID: getClientID;
/**Get the client nickname */
getNickname: getNickname;
/**@deprecated Get the client user ID. */
getUserID: getUserID;
}
interface clientSend {
/**
* Send a packet to the module client.
* @param {string} header The header for the message.
* @param {...any} arg Additional data.
*/
(header: string, ...args: any): void;
}
interface clientAuthorized {
/**
* Checks if a user has permissions for this channel.
* @return {boolean} Client is authorized
*/
(): boolean;
}
interface getSceneID {
/**
* Get the scene ID this client is in.
* @return {string|null} The ID of the scene the client is in.
*/
(): string | null;
}
interface getDisplayID {
/**
* Get the display ID this client is in.
* @return {string|null} The ID of the display the client is in.
*/
(): string | null;
}
interface getClientID {
/**
* Get the ID of this client.
* @return {string} The ID of the client.
*/
(): string;
}
interface getUserID {
/**
* @deprecated REPLACED BY getClientID()
* Get the user ID of this client.
* @return {string} The user ID of the client.
*/
(): string;
}
interface getNickname {
/**
* Get the nickname of the user. This only work via api.getClient() or api.getClients()
* @return {string} The nickname of the client.
*/
(): string;
}
// ---------------- Libs ----------------
interface Libs {
/**Get the WebSocket lib. */
WebSocket: LibWebSocket;
getAxios: any;
getRedis: any;
getIoRedis: any;
getGoogleSpreadsheet: any;
}
// ---------------- LibWebSocket ----------------
interface LibWebSocket {
/**Register a listener for incoming packets. */
on: LibWebSocket_on;
/**Register a listener for when a new module client connects. */
onClientConnect: LibWebSocket_onClientConnect;
/**Register a listener for when a new module client connects. */
onClientDisconnect: LibWebSocket_onClientDisconnect;
/**Get a object with all connected LibWebSocket clients. */
getClients: LibWebSocket_getClients;
/**Get a LibWebSocket client. */
getClient: LibWebSocket_getClient;
/**Get a LibWebSocket client. */
broadcast: LibWebSocket_broadcast;
/**Get a LibWebSocket client. */
rawBroadcast: LibWebSocket_rawBroadcast;
}
interface LibWebSocket_on {
/**
* Register a listener for incoming packets.
* @param {string} header The header to listen for.
* @param {on_callback} callback Function to handle the incomming message.
*/
(header: string, callback: LibWebSocket_on_callback): void;
}
interface LibWebSocket_on_callback {
/**
* Callback for when a packet is received.
* @param {LibWebSocketClient} Client Instance of the LibWebSocket client.
* @param {...any} arg Additional data in the same order as when it was send.
*/
(client: LibWebSocketClient, ...args: any): void;
}
interface LibWebSocket_onClientConnect {
/**
* Register a listener for when a new LibWebSocket client connects.
* @param {LibWebSocket_onClientConnect_callback} callback This function will be called when a new client connects.
*/
(callback: LibWebSocket_onClientConnect_callback): void;
}
interface LibWebSocket_onClientConnect_callback {
/**
* The callback for when a new client connects.
* @param {LibWebSocketClient} Client The instance of the LibWebSocket client.
*/
(client: LibWebSocketClient): void;
}
interface LibWebSocket_onClientDisconnect {
/**
* Register a listener for when a LibWebSocket client disconnect.
* @param {LibWebSocket_onClientDisconnect_callback} callback This function will be called when a client disconnects.
*/
(callback: LibWebSocket_onClientDisconnect_callback): void;
}
interface LibWebSocket_onClientDisconnect_callback {
/**
* The callback for when new client disconnects.
* @param {string} socketId The id LibWebSocket client.
*/
(socketId: string): void;
}
interface LibWebSocket_getClients {
/**
* Get a object with all connected LibWebSocket clients.
* @returns {LibWebSocket_getClients_clients} The object with LibWebSocket clients.
*/
(): LibWebSocket_getClients_clients;
}
interface LibWebSocket_getClients_clients {
[socketId: string]: LibWebSocketClient;
}
interface LibWebSocket_getClient {
/**
* Get a object with all connected LibWebSocket clients.
* @param {LibWebSocketClient} socketId The id of the LibWebSocket clients.
* @returns {LibWebSocket_getClients_client} The object with LibWebSocket clients.
*/
(): LibWebSocketClient;
}
interface LibWebSocket_broadcast {
/**
* Send a message to all connected LibWebSocket clients.
* @param {string} header The header for the message.
* @param {...any} args Additional data.
*/
(header: string, ...args: string[]): LibWebSocketClient;
}
interface LibWebSocket_rawBroadcast {
/**
* Send raw a message to all connected LibWebSocket clients.
* @param {BufferLike} data The data of the message.
*/
(data: BufferLike): LibWebSocketClient;
}
// ---------------- LibWebSocketClient ----------------
interface LibWebSocketClient {
/**Id of the LibWebSocket client. */
id: string;
/**Send a message to the LibWebSocket client. */
send: LibWebSocketClient_send;
/**Send a message to the LibWebSocket client. */
rawSend: LibWebSocketClient_rawSend;
}
interface LibWebSocketClient_send {
/**
* Send a packet to the LibWebSocket client.
* @param {string} header The header for the message.
* @param {...any} args Additional data.
*/
(header: string, ...args: any): void;
}
interface LibWebSocketClient_rawSend {
/**
* Send a packet to the LibWebSocket client.
* @param {BufferLike} header The header for the message.
* @param {...any} args Additional data.
*/
(data: BufferLike): void;
}
// ---------------- GameLib ----------------
interface GameLib {
Timing: ModuleGameTiming;
Collision: ModuleGameCollision;
hasRoom: GameLib_hasRoom;
getRoom: GameLib_getRoom;
}
interface GameLib_hasRoom {
/**
* Check if a room exists.
* @param {string} roomID The room ID.
* @return {boolean} Room exists.
*/
(roomID: string): boolean;
}
interface GameLib_getRoom {
/**
* Get a room.
* @param {string} roomID The room ID.
* @return {GameRoom} The room.
*/
(roomID: string): GameRoom;
}
// ---------------- Game Collision ----------------
interface ModuleGameCollision {
toSpace: ModuleGameCollision_toSpace;
getObjectsInSpace: ModuleGameCollision_getObjectsInSpace;
isOverlapping: ModuleGameCollision_isOverlapping;
getDistance: ModuleGameCollision_getDistance;
}
interface CollisionSpace {
id?: string;
xLeft: number;
xRight: number;
yTop: number;
yBottom: number;
}
interface ModuleGameCollision_toSpace {
/** Create a new space object.
* @param {number} x The x coordinate of the top-left corner of the element you want to make a space from.
* @param {number} y The y coordinate of the top-left corner of the element you want to make a space from.
* @param {number} width The width of the element you want to make a space from.
* @param {number} height The height of the element you want to make a space from.
* @param {string} id (Optional) The id of the element you want to make a space from.
* @returns {CollisionSpace} A space object.
*/
(
x: number,
y: number,
width: number,
height: number,
id?: string
): CollisionSpace;
}
interface ModuleGameCollision_getObjectsInSpace {
/** Get all objects in a space.
* @param {CollisionSpace} space The space object you want to get objects from.
* @param {CollisionSpace[]} objects An array of space objects.
* @returns {CollisionSpace[]} An array of space objects.
*/
(space: CollisionSpace, objects: CollisionSpace[]): CollisionSpace[];
}
interface ModuleGameCollision_isOverlapping {
/** Check if two spaces are overlapping.
* @param {CollisionSpace} space1 The first space object.
* @param {CollisionSpace} space2 The second space object.
* @returns {boolean} True if the spaces are overlapping, false otherwise.
*/
(space1: CollisionSpace, space2: CollisionSpace): boolean;
}
interface ModuleGameCollision_getDistance {
/** Get the distance between two spaces.
* @param {CollisionSpace} space1 The first space object.
* @param {CollisionSpace} space2 The second space object.
* @returns {number} The distance between the two spaces.
*/
(space1: CollisionSpace, space2: CollisionSpace): number;
}
// ---------------- Game Timing ----------------
interface ModuleGameTiming {
toTimeSpan: ModuleGameTimings_toTimeSpan;
toFrameCycle: ModuleGameTimings_toFrameCycle;
getCurrentFrameIndex: ModuleGameTimings_getCurrentFrameIndex;
getFrameIndexAtTimestamp: ModuleGameTimings_getFrameIndexAtTimestamp;
getCurrentTimeSpanRatio: ModuleGameTimings_getCurrentTimeSpanRatio;
getTimeSpanRatioAtTimestamp: ModuleGameTimings_getTimeSpanRatioAtTimestamp;
toRatio: ModuleGameTimings_toRatio;
}
interface ModuleGameTimings_toTimeSpan {
/**Creates a timespan object.
* @param {number} duration The duration of the timespan in milliseconds.
* @param {number} startTimestamp (Optional) The start timestamp of the timespan in milliseconds.
* @returns {TimeSpan} The timespan object.
*/
(duration: number, startTimestamp?: number): TimeSpan;
}
interface ModuleGameTimings_toFrameCycle {
/**Creates a frame cycle object.
* @param {number} startTimestamp The start timestamp of the frame cycle in milliseconds.
* @param {number} frameInterval The interval between frames in milliseconds.
* @param {number} totalFrames The total number of frames in the cycle.
* @param {number} startFrame (Optional) The start frame of the cycle.
* @returns {FrameCycle} The frame cycle object.
*/
(
startTimestamp: number,
frameInterval: number,
totalFrames: number,
startFrame?: number
): TimeSpan;
}
interface ModuleGameTimings_getCurrentFrameIndex {
/**Gets the current frame index of the frame cycle.
* @param {FrameCycle} cycle The frame cycle object.
* @returns {number} The current frame index.
*/
(cycle: FrameCycle): number;
}
interface ModuleGameTimings_getFrameIndexAtTimestamp {
/**Gets the frame index at the given timestamp.
* @param {FrameCycle} cycle The frame cycle object.
* @param {number} timestamp The timestamp to get the frame index at.
* @returns {number} The frame index at the given timestamp.
*/
(cycle: FrameCycle, timestamp: number): number;
}
interface ModuleGameTimings_getCurrentTimeSpanRatio {
/**Gets the ratio of the current time span.
* @param {TimeSpan} span The timespan object.
* @returns {Ratio} The ratio of the current time span.
*/
(span: TimeSpan): Ratio;
}
interface ModuleGameTimings_getTimeSpanRatioAtTimestamp {
/**Gets the ratio of the time span at the given timestamp.
* @param {TimeSpan} span The timespan object.
* @param {number} timestamp The timestamp to get the ratio at.
* @returns {Ratio} The ratio of the time span at the given timestamp.
*/
(span: TimeSpan, timestamp: number): Ratio;
}
interface ModuleGameTimings_toRatio {
/**Creates a ratio object.
* @param {number} value The value of the ratio.
* @returns {Ratio} The ratio object.
*/
(value: number): Ratio;
}
interface TimeSpan {
startTimestamp: number;
endTimestamp: number;
}
interface FrameCycle {
startTimestamp: number;
frameInterval: number;
totalFrames: number;
startFrame?: number;
}
// ---------------- Game Timing Ratio ----------------
interface Ratio extends Number {
easeInSine: Ratio_easeInSine;
easeInCubic: Ratio_easeInCubic;
easeInQuint: Ratio_easeInQuint;
easeInCirc: Ratio_easeInCirc;
easeInElastic: Ratio_easeInElastic;
easeOutSine: Ratio_easeOutSine;
easeOutCubic: Ratio_easeOutCubic;
easeOutQuint: Ratio_easeOutQuint;
easeOutCirc: Ratio_easeOutCirc;
easeOutElastic: Ratio_easeOutElastic;
easeInOutSine: Ratio_easeInOutSine;
easeInOutCubic: Ratio_easeInOutCubic;
easeInOutQuint: Ratio_easeInOutQuint;
easeInOutCirc: Ratio_easeInOutCirc;
easeInOutElastic: Ratio_easeInOutElastic;
easeInQuad: Ratio_easeInQuad;
easeInQuart: Ratio_easeInQuart;
easeInExpo: Ratio_easeInExpo;
easeInBack: Ratio_easeInBack;
easeInBounce: Ratio_easeInBounce;
easeOutQuad: Ratio_easeOutQuad;
easeOutQuart: Ratio_easeOutQuart;
easeOutExpo: Ratio_easeOutExpo;
easeOutBack: Ratio_easeOutBack;
easeOutBounce: Ratio_easeOutBounce;
easeInOutQuad: Ratio_easeInOutQuad;
easeInOutQuart: Ratio_easeInOutQuart;
easeInOutExpo: Ratio_easeInOutExpo;
easeInOutBack: Ratio_easeInOutBack;
easeInOutBounce: Ratio_easeInOutBounce;
bezier: Ratio_bezier;
invert: Ratio_invert;
steps: Ratio_steps;
toAbsolute: Ratio_toAbsolute;
toPercentage: Ratio_toPercentage;
}
interface Ratio_easeInSine {
/**Calculate the ratio with the ease-in-sine easing function.
* https://easings.net/#easeInSine
*
* To view overview of all easing functions: https://easings.net
* @returns {Ratio} The new ratio.
*/
(): Ratio;
}
interface Ratio_easeInCubic {
/**Calculate the ratio with the ease-in-cubic easing function.
* https://easings.net/#easeInCubic
*
* To view overview of all easing functions: https://easings.net
* @returns {Ratio} The new ratio.
*/
(): Ratio;
}
interface Ratio_easeInQuint {
/**Calculate the ratio with the ease-in-quint easing function.
* https://easings.net/#easeInQuint
*
* To view overview of all easing functions: https://easings.net
* @returns {Ratio} The new ratio.
*/
(): Ratio;
}
interface Ratio_easeInCirc {
/**Calculate the ratio with the ease-in-circ easing function.
* https://easings.net/#easeInCirc
*
* To view overview of all easing functions: https://easings.net
* @returns {Ratio} The new ratio.
*/
(): Ratio;
}
interface Ratio_easeInElastic {
/**Calculate the ratio with the ease-in-elastic easing function.
* https://easings.net/#easeInElastic
*
* To view overview of all easing functions: https://easings.net
* @returns {Ratio} The new ratio.
*/
(): Ratio;
}
interface Ratio_easeOutSine {
/**Calculate the ratio with the ease-out-sine easing function.
* https://easings.net/#easeOutSine
*
* To view overview of all easing functions: https://easings.net
* @param {Ratio} ratio The new ratio.
*/
(): Ratio;
}
interface Ratio_easeOutCubic {
/**Calculate the ratio with the ease-out-cubic easing function.
* https://easings.net/#easeOutCubic
*
* To view overview of all easing functions: https://easings.net
* @returns {Ratio} The new ratio.
*/
(): Ratio;
}
interface Ratio_easeOutQuint {
/**Calculate the ratio with the ease-out-quint easing function.
* https://easings.net/#easeOutQuint
*
* To view overview of all easing functions: https://easings.net
* @returns {Ratio} The new ratio.
*/
(): Ratio;
}
interface Ratio_easeOutCirc {
/**Calculate the ratio with the ease-out-circ easing function.
* https://easings.net/#easeOutCirc
*
* To view overview of all easing functions: https://easings.net
* @returns {Ratio} The new ratio.
*/
(): Ratio;
}
interface Ratio_easeOutElastic {
/**Calculate the ratio with the ease-out-elastic easing function.
* https://easings.net/#easeOutElastic
*
* To view overview of all easing functions: https://easings.net
* @returns {Ratio} The new ratio.
*/
(): Ratio;
}
interface Ratio_easeInOutSine {
/**Calculate the ratio with the ease-in-out-sine easing function.
* https://easings.net/#easeInOutSine
*
* To view overview of all easing functions: https://easings.net
* @returns {Ratio} The new ratio.
*/
(): Ratio;
}
interface Ratio_easeInOutCubic {
/**Calculate the ratio with the ease-in-out-cubic easing function.
* https://easings.net/#easeInOutCubic
*
* To view overview of all easing functions: https://easings.net
* @returns {Ratio} The new ratio.
*/
(): Ratio;
}
interface Ratio_easeInOutQuint {
/**Calculate the ratio with the ease-in-out-quint easing function.
* https://easings.net/#easeInOutQuint
*
* To view overview of all easing functions: https://easings.net
* @returns {Ratio} The new ratio.
*/
(): Ratio;
}
interface Ratio_easeInOutCirc {
/**Calculate the ratio with the ease-in-out-circ easing function.
* https://easings.net/#easeInOutCirc
*
* To view overview of all easing functions: https://easings.net
* @returns {Ratio} The new ratio.
*/
(): Ratio;
}
interface Ratio_easeInOutElastic {
/**Calculate the ratio with the ease-in-out-elastic easing function.
* https://easings.net/#easeInOutElastic
*
* To view overview of all easing functions: https://easings.net
* @returns {Ratio} The new ratio.
*/
(): Ratio;
}
interface Ratio_easeInQuad {
/**Calculate the ratio with the ease-in-quad easing function.
* https://easings.net/#easeInQuad
*
* To view overview of all easing functions: https://easings.net
* @returns {Ratio} The new ratio.
*/
(): Ratio;
}
interface Ratio_easeInQuart {
/**Calculate the ratio with the ease-in-quart easing function.
* https://easings.net/#easeInQuart
*
* To view overview of all easing functions: https://easings.net
* @returns {Ratio} The new ratio.
*/
(): Ratio;
}
interface Ratio_easeInExpo {
/**Calculate the ratio with the ease-in-expo easing function.
* https://easings.net/#easeInExpo
*
* To view overview of all easing functions: https://easings.net
* @returns {Ratio} The new ratio.
*/
(): Ratio;
}
interface Ratio_easeInBack {
/**Calculate the ratio with the ease-in-back easing function.
* https://easings.net/#easeInBack
*
* To view overview of all easing functions: https://easings.net
* @returns {Ratio} The new ratio.
*/
(): Ratio;
}
interface Ratio_easeInBounce {
/**Calculate the ratio with the ease-in-bounce easing function.
* https://easings.net/#easeInBounce
*
* To view overview of all easing functions: https://easings.net
* @returns {Ratio} The new ratio.
*/
(): Ratio;
}
interface Ratio_easeOutQuad {
/**Calculate the ratio with the ease-out-quad easing function.
* https://easings.net/#easeOutQuad
*
* To view overview of all easing functions: https://easings.net
* @returns {Ratio} The new ratio.
*/
(): Ratio;
}
interface Ratio_easeOutQuart {
/**Calculate the ratio with the ease-out-quart easing function.
* https://easings.net/#easeOutQuart
*
* To view overview of all easing functions: https://easings.net
* @returns {Ratio} The new ratio.
*/
(): Ratio;
}
interface Ratio_easeOutExpo {
/**Calculate the ratio with the ease-out-expo easing function.
* https://easings.net/#easeOutExpo
*
* To view overview of all easing functions: https://easings.net
* @returns {Ratio} The new ratio.
*/
(): Ratio;
}
interface Ratio_easeOutBack {
/**Calculate the ratio with the ease-out-back easing function.
* https://easings.net/#easeOutBack
*
* To view overview of all easing functions: https://easings.net
* @returns {Ratio} The new ratio.
*/
(): Ratio;
}
interface Ratio_easeOutBounce {
/**Calculate the ratio with the ease-out-bounce easing function.
* https://easings.net/#easeOutBounce
*
* To view overview of all easing functions: https://easings.net
* @returns {Ratio} The new ratio.
*/
(): Ratio;
}
interface Ratio_easeInOutQuad {
/**Calculate the ratio with the ease-in-out-quad easing function.
* https://easings.net/#easeInOutQuad
*
* To view overview of all easing functions: https://easings.net
* @returns {Ratio} The new ratio.
*/
(): Ratio;
}
interface Ratio_easeInOutQuart {
/**Calculate the ratio with the ease-in-out-quart easing function.
* https://easings.net/#easeInOutQuart
*
* To view overview of all easing functions: https://easings.net
* @returns {Ratio} The new ratio.
*/
(): Ratio;
}
interface Ratio_easeInOutExpo {
/**Calculate the ratio with the ease-in-out-expo easing function.
* https://easings.net/#easeInOutExpo
*
* To view overview of all easing functions: https://easings.net
* @returns {Ratio} The new ratio.
*/
(): Ratio;
}
interface Ratio_easeInOutBack {
/**Calculate the ratio with the ease-in-out-back easing function.
* https://easings.net/#easeInOutBack
*
* To view overview of all easing functions: https://easings.net
* @returns {Ratio} The new ratio.
*/
(): Ratio;
}
interface Ratio_easeInOutBounce {
/**Calculate the ratio with the ease-in-out-bounce easing function.
* https://easings.net/#easeInOutBounce
*
* To view overview of all easing functions: https://easings.net
* @returns {Ratio} The new ratio.
*/
(): Ratio;
}
interface Ratio_bezier {
/**Calculate the ratio with the bezier curve easing function.
*
* To generate a bezier curve easing visually you can use tools like: https://cubic-bezier.com
* @param {number} x1 The x coordinate of the first control point.
* @param {number} y1 The y coordinate of the first control point.
* @param {number} x2 The x coordinate of the second control point.
* @param {number} y2 The y coordinate of the second control point.
* @returns {Ratio} The new ratio.
*/
(x1: number, y1: number, x2: number, y2: number): Ratio;
}
interface Ratio_invert {
/**Invert the ratio.
* @returns {Ratio} The new ratio.
*/
(): Ratio;
}
interface Ratio_steps {
/**Calculate the ratio with the steps easing function.
* @param {number} steps The number of steps.
* @returns {Ratio} The new ratio.
*/
(steps: number): Ratio;
}
interface Ratio_toAbsolute {
/**Calculate the ratio of an absolute value.
* @returns {number} The calculated value.
*/
(total: number): number;
}
interface Ratio_toPercentage {
/**Convert the ratio to a percentage.
* @returns {number} The calculated percentage.
*/
(): number;
}
// ---------------- GameRoom ----------------
interface GameRoom {
newGame: GameRoom_newGame;
clearQueue: GameRoom_clearQueue;
on: GameRoom_on;
}
interface GameRoom_newGame {
/**
* Create a new game.
* @param {GameDetails} details The details of the game.
*/
(details: GameDetails): Game;
}
interface GameRoom_clearQueue {
/**
* Clear the queue.
*/
(): void;
}
interface GameRoom_on {
/**
* Register a listener for game room events.
* @param {GameRoomEvents} events The events to listen for.
* @param {Function} listener The listener to call when the event is triggered.
*/
<U extends keyof GameRoomEvents>(
events: U,
listener: GameRoomEvents[U]
): void;
}
interface GameRoomEvents {
playerJoinQueue: (player: GamePlayer) => void;
playerLeaveQueue: (player: GamePlayer) => void;
queueUpdate: (queue: GamePlayer[]) => void;
activeGameChanged: (gameDetails: GameDetails) => void;
mainScoreboardUpdate: (state: GameScoreboardState) => void;
anyScoreboardUpdate: (state: GameScoreboardState) => void;
}
// ---------------- Game ----------------
interface Game {
readonly details: GameDetails;
start: Game_start;
stop: Game_stop;
requestScoreboard: Game_requestScoreboard;
setMainScoreboard: Game_setMainScoreboard;
getPlayers: Game_getPlayers;
getPlayer: Game_getPlayer;
hasPlayer: Game_hasPlayer;
removePlayer: Game_removePlayer;
requestFromQueue: Game_requestFromQueue;
on: Game_on;
}
interface GameDetails {
name: string;
description: string;
hints: string[];
controls: GameDetails_Controls;
icon?: string;
}
type GameDetails_Controls = GameDetails_Control[];
type GameDetails_Control =
| GameDetails_ControlNormalBinary
| GameDetails_ControlCustomBinary
| GameDetails_ControlNormalAnalog
| GameDetails_ControlCustomAnalog;
interface GameDetails_ControlBase {
type: 'normal' | 'custom';
mode: 'binary' | 'analog';
}
interface GameDetails_ControlNormalBinary extends GameDetails_ControlBase {
type: 'normal';
action: Controller_call_actions;
mode: 'binary';
}
interface GameDetails_ControlCustomBinary extends GameDetails_ControlBase {
type: 'custom';
action: string;
mode: 'binary';
}
interface GameDetails_ControlNormalAnalog extends GameDetails_ControlBase {
type: 'normal';
action: Controller_call_actions;
mode: 'analog';
steps?: number;
}
interface GameDetails_ControlCustomAnalog extends GameDetails_ControlBase {
type: 'custom';
action: string;
mode: 'analog';
steps?: number;
}
interface Game_start {
/**
* Start the game, advertise it to the control and make player requesting possible.
*/
(): void;
}
interface Game_stop {
/**
* Stop the game, remove all players and stop advertising to the control.
*/
(): void;
}
interface Game_requestScoreboard {
/**
* Get a scoreboard for the game.
*/
(details: GameScoreboardDetails): GameScoreboard;
}
interface Game_setMainScoreboard {
/**
* Set the main scoreboard for the game.
*/
(scoreboard: ScoreboardIdentifier): void;
}
type ScoreboardIdentifier = GameScoreboard | string;
interface Game_getPlayer {
/**
* Get a player in the game.
* @param {string} clientId The player UUID.
* @return {GamePlayer} The player in the game.
*/
(clientId: string): GamePlayer;
}
interface Game_getPlayers {
/**
* Get the players in the game.
* @return {GamePlayer[]} The players in the game.
*/
(): GamePlayer[];
}
interface Game_hasPlayer {
/**
* Check if a player is in the game.
* @param {string} clientId The player UUID.
* @return {boolean} Player is in the game.
*/
(clientId: string): boolean;
}
interface Game_removePlayer {
/**
* Remove a player from the game.
* @param {string} clientId The player UUID.
* @param {GameEndScreen} endScreen optional The end screen to show the player.
*/
(clientId: string, endScreen?: GameEndScreen): void;
}
interface GameEndScreen {
title: string;
text?: string;
stats?: { name: string; value: number | string }[];
footer?: string;
}
interface Game_requestFromQueue {
/**
* Request a player from the queue. When the queue is empty it will return null.
* @return {GamePlayer} The player from the queue.
*/
(): GamePlayer;
}
interface Game_on {
/**
* Register a listener for game events.
* @param {GameEvents} events The events to listen for.
* @param {Function} listener The listener to call when the event is triggered.
*/
<U extends keyof GameEvents>(events: U, listener: GameEvents[U]): void;
}
interface GameEvents {
playerJoinGame: (player: GamePlayer) => void;
playerLeaveGame: (player: GamePlayer) => void;
action: (
player: GamePlayer,
action: Controller_call_actions,
mode: 'on' | 'off',
intensity?: number
) => void;
customAction: (
player: GamePlayer,
action: string,
mode: 'on' | 'off',
intensity?: number
) => void;
}
interface GameScoreboardState {
name: string;
gameId: string;
scoreboardId: string;
entries: GameScoreboardStateEntry[];
}
interface GameScoreboardStateEntry {
uuid: string;
name: string;
displayValue: string;
value: number;
}
type Controller_call_actions =
| 'left'
| 'right'
| 'up'
| 'down'
| 'upleft'
| 'upright'
| 'downleft'
| 'downright'
| 'start'
| 'select'
| 'back'
| 'identify';
// ---------------- Game Scoreboard----------------
interface GameScoreboard {
/**The id of the scoreboard. */
readonly id: string;
/**The name of the scoreboard. */
readonly name: string;
/**The formatting of the scoreboard. */
readonly formatting: 'number' | 'duration';
/**The sorting of the scoreboard. */
readonly sorting: 'LOW_TO_HIGH' | 'HIGH_TO_LOW';
/**The show count of the scoreboard. */
readonly showCount: number;
clear: GameScoreboard_clear;
setScore: GameScoreboard_setScore;
getScore: GameScoreboard_getScore;
hasScore: GameScoreboard_hasScore;
increaseScore: GameScoreboard_increaseScore;
decreaseScore: GameScoreboard_decreaseScore;
updateUnderCondition: GameScoreboard_updateUnderCondition;
}
interface GameScoreboardDetails {
id: string;
name: string;
formatting: 'number' | 'duration';
sorting: 'LOW_TO_HIGH' | 'HIGH_TO_LOW';
showCount: number;
}
type Condition = 'VALUE_IS_LOWER' | 'VALUE_IS_HIGHER';
interface GameScoreboard_clear {
/**
* Clear the scoreboard.
*/
(): void;
}
interface GameScoreboard_setScore {
/**
* Set the score of a player.
* @param {GamePlayer} player The player to set the score for.
* @param {number} score The score to set.
*/
(player: GamePlayer, score: number): void;
}
interface GameScoreboard_getScore {
/**
* Get the score of a player.
* @param {GamePlayer} player The player to get the score from.
* @return {number} The score of the player.
*/
(player: GamePlayer): number;
}
interface GameScoreboard_hasScore {
/**
* Check if a player has a score.
* @param {GamePlayer} player The player to check.
* @return {boolean} Player has a score.
*/
(player: GamePlayer): boolean;
}
interface GameScoreboard_increaseScore {
/**
* Increase the score of a player.
* @param {GamePlayer} player The player to increase the score for.
* @param {number} amount The amount to increase the score with.
*/
(player: GamePlayer, amount: number): void;
}
interface GameScoreboard_decreaseScore {
/**
* Decrease the score of a player.
* @param {GamePlayer} player The player to decrease the score for.
* @param {number} amount The amount to decrease the score with.
*/
(player: GamePlayer, amount: number): void;
}
interface GameScoreboard_updateUnderCondition {
/**
* Update the score of a player under a condition.
* @param {Condition} condition The condition to check.
* @param {GamePlayer} player The player to update the score for.
* @param {number} value The new value of the score.
*/
(condition: Condition, player: GamePlayer, value: number): void;
}
// ---------------- Game Player----------------
interface GamePlayer {
/**The player UUID. */
readonly clientId: string;
/**The player name. */
readonly name: string;
/**The player organization. */
readonly organization: string;
/**The player avatar. */
readonly avatar: string;
send: GamePlayer_send;
}
interface GamePlayer_send {
/**
* Send a message to the player.
* @param {string} header The header for the message.
* @param {...any} args Additional data.
*/
(header: string, ...args: any): void;
}
// ---------------- Getiyo ----------------
interface Getiyo {
rawLog: (...args: any[]) => void;
log: (level: 'info' | 'error' | 'warn' | 'crit', ...args: any[]) => void;
}
// ---------------- Util ----------------
type BufferLike =
| string
| Buffer
| DataView
| number
| ArrayBufferView
| Uint8Array
| ArrayBuffer
| SharedArrayBuffer
| ReadonlyArray<any>
| ReadonlyArray<number>
| { valueOf(): ArrayBuffer }
| { valueOf(): SharedArrayBuffer }
| { valueOf(): Uint8Array }
| { valueOf(): ReadonlyArray<number> }
| { valueOf(): string }
| { [Symbol.toPrimitive](hint: string): string };