UNPKG

@peacockproject/core

Version:

Type definitions for Peacock's core.

91 lines (90 loc) 3.8 kB
import { ClientToServerEvent, ContractSession, GameVersion, MissionManifestObjective, ServerToClientEvent } from "./types/types"; import { ManifestScoringModule } from "./types/scoring"; declare const eventRouter: import("express-serve-static-core").Router; /** * Enqueue a server to client push message. * It will be sent back the next time the client calls `SaveAndSynchronizeEvents4`. * * @param userId The push message's target user. * @param message The raw push message to send. * @see enqueueEvent */ export declare function enqueuePushMessage(userId: string, message: unknown): void; /** * Register a listener for an objective. Allows server-side tracking of the objective's state as events come in. * * @param session The contract session. * @param objective The objective object. */ export declare function registerObjectiveListener(session: ContractSession, objective: MissionManifestObjective): void; /** * Sets up scoring state machines. * * @param session The contract session. * @param modules Array of scoring modules. */ export declare function setupScoring(session: ContractSession, modules: ManifestScoringModule[]): void; /** * Enqueue a server to client event. * It will be sent back the next time the client calls `SaveAndSynchronizeEvents4`. * * @param userId The event's target user. * @param event The event to send. * @see enqueuePushMessage */ export declare function enqueueEvent(userId: string, event: ServerToClientEvent): void; /** * Like the game's internal enum for EDeathContext. * * @see https://github.com/OrfeasZ/ZHMModSDK/blob/ba9512092a37d3b1f4de047bdd6acf15a7b9ac7c/ZHMModSDK/Include/Glacier/Enums.h#L6158 */ export declare const enum EDeathContext { eDC_UNDEFINED = 0, eDC_NOT_HERO = 1, eDC_HIDDEN = 2, eDC_ACCIDENT = 3, eDC_MURDER = 4 } export declare const contractSessions: Map<string, ContractSession>; /** * Get the current state of an objective. * * @param sessionId The session ID. * @param objectiveId The objective ID. */ export declare function getCurrentState(sessionId: string, objectiveId: string): string | undefined; /** * Creates a new contract session. * * @param sessionId The ID for the session. * @param contractId The ID of the contract the session is for. * @param userId The ID of the user playing the session. * @param difficulty The difficulty of the game. * @param gameVersion The game version. * @param doScoring If true, this will be treated like a normal session. If false, this session will not be scored/put on the leaderboards. This should be false if we don't have full session details, e.g. if this is a save from the official servers loaded on Peacock. */ export declare function newSession(sessionId: string, contractId: string, userId: string, difficulty: number, gameVersion: GameVersion, doScoring?: boolean): void; export type SSE3Response = { SavedTokens: string[] | null; NewEvents: ServerToClientEvent[] | null; NextPoll: number; }; export type SSE4Response = SSE3Response & { PushMessages: string[] | null; }; export declare function saveAndSyncEvents(version: 3 | 4, userId: string, gameVersion: GameVersion, lastEventTicks: number | string, values: ClientToServerEvent[], lastPushDt?: number | string): SSE3Response | SSE4Response; /** * Gets the active session's ID for the specified user (by their ID). * * @param uId The user's ID. * @returns The ID for the user's active session. */ export declare function getActiveSessionIdForUser(uId: string): string | undefined; /** * Gets the active session for the specified user (by their ID). * * @param uId The user's ID. * @returns The user's active contract session. */ export declare function getSession(uId: string): ContractSession | undefined; export { eventRouter };