/* Copyright (c) 2024 Rune AI Inc. All rights reserved. This code is proprietary to Rune AI Inc. The code may be used solely for accessing the Service provided by Rune AI Inc. following the Rune AI Inc. Terms of Service ("Terms") accessible at rune.ai/eula. You may not use this code for any use or purpose other than as expressly permitted by the Terms. Restrictions set forth in the Terms include, but is not limited to, that you may not copy, adapt, modify, prepare derivative works based upon, distribute, license, sell, transfer, publicly display, publicly perform, transmit, stream, broadcast, attempt to discover any source code, reverse engineer, decompile, dissemble, or otherwise exploit the code as a whole or any portion of the code. */ type PersistedPlayers = Record; type GameStateWithPersisted = GameState & { persisted: PersistedPlayers; }; type UntypedInitLogicAction = (params?: any) => void; type UntypedInitLogicActions = Record; type PlayerId = string; type Player = { playerId: PlayerId; displayName: string; avatarUrl: string; }; type Players = Record; type Base64Png = string; type AIPromptResponse = { requestId: string; response: string; }; type AIPromptMessageContent = { type: "text"; text: string; } | { type: "image_data"; image_url: string; }; type AIPromptRequestData = { messages: { role: string; content: string | AIPromptMessageContent[]; }[]; }; type AIPromptRequestFunction = (data: AIPromptRequestData) => { requestId: string; }; type ContextWithGameState = Context & { game: PersistedData extends false ? GameState : GameStateWithPersisted; }; type EventContext = { allPlayerIds: PlayerId[]; }; type UpdateContext = { allPlayerIds: PlayerId[]; }; type ActionContext = { playerId: PlayerId; allPlayerIds: PlayerId[]; }; type InitLogicAIResponse = (responseData: AIPromptResponse, eventContext: ContextWithGameState) => void; type InitLogicEvent = (playerId: PlayerId, eventContext: ContextWithGameState) => void; type InitLogicEvents = { playerJoined?: InitLogicEvent; playerLeft?: InitLogicEvent; }; type InitLogicUpdate = (updateContext: ContextWithGameState) => void; type InitLogicActions = { [key in keyof GameActions]: (params: Parameters[0], actionContext: ContextWithGameState) => void; }; type InitLogicParams = { minPlayers: number; maxPlayers: number; landscape?: boolean; updatesPerSecond?: number; setup: (allPlayerIds: PlayerId[], context: PersistedData extends false ? undefined : { game: { persisted: PersistedPlayers; }; }) => GameState; actions: InitLogicActions; events?: InitLogicEvents; update?: InitLogicUpdate; inputDelay?: number; reactive?: boolean; ai?: { promptResponse: InitLogicAIResponse; }; } & (PersistedData extends false ? { persistPlayerData?: false; } : { persistPlayerData: true; }); type SharedSdk = { initLogic: (params: InitLogicParams) => void; invalidAction: () => Error; gameOver: (options?: GameOverOptions) => void; /** @deprecated, use gameTime() */ gameTimeInSeconds: () => number; gameTime: () => number; worldTime: () => number; ai: { promptRequest: AIPromptRequestFunction; }; }; type OnChangeAction = { [Key in keyof GameActions]: { action?: Key; name: Key; playerId: PlayerId; params: Parameters[0]; }; }[keyof GameActions]; type OnChangeStateSyncEvent = { event: "stateSync"; isNewGame: boolean; }; type OnChangePlayerJoinedEvent = { event: "playerJoined"; params: { playerId: PlayerId; }; }; type OnChangePlayerLeftEvent = { event: "playerLeft"; params: { playerId: PlayerId; }; }; type OnChangeAIPromptResponseEvent = { event: "aiPromptResponse"; params: { requestId: string; response: any; }; }; type OnChangeTimeSyncEvent = { event: "timeSync"; }; type OnChangeUpdateEvent = { event: "update"; }; type NameAndEvent = Omit & { name: N; /** @deprecated Use .name instead of .event */ event?: N; }; type OnChangeEvent = NameAndEvent | NameAndEvent | NameAndEvent | NameAndEvent | NameAndEvent | NameAndEvent; type InterpolatorFactory = () => Interpolator; type Interpolator = { update: (params: { game: Dimensions; futureGame: Dimensions; }) => void; getPosition: () => Dimensions; }; type InterpolatorLatencyFactory = (config: { maxSpeed: number; timeToMaxSpeed?: number; }) => InterpolatorLatency; type InterpolatorLatency = { update: (params: { game: Dimensions; futureGame: Dimensions; }) => void; getPosition: () => Dimensions; jump: (game: Dimensions) => void; }; type OnChangeParams = { game: PersistedData extends false ? GameState : GameStateWithPersisted; action?: OnChangeAction; event?: OnChangeEvent; yourPlayerId: PlayerId | undefined; allPlayerIds: PlayerId[]; rollbacks: OnChangeAction[]; previousGame: PersistedData extends false ? GameState : GameStateWithPersisted; futureGame?: PersistedData extends false ? GameState : GameStateWithPersisted; /** @deprecated Use allPlayerIds in combination with getPlayerInfo() */ players: Players; }; type OnChange = (params: OnChangeParams) => void; type Sdk = { initClient: (params: { onChange: OnChange; }) => void; actions: GameActions; version: string; showGameOverPopUp: () => void; showInvitePlayers: () => void; showShareImage: (img: Base64Png) => Promise; timeSinceLastUpdate: () => number; msPerUpdate: number; interpolator: InterpolatorFactory; interpolatorLatency: InterpolatorLatencyFactory; getPlayerInfo: (playerId: PlayerId) => Player; /** * Used to translate static text in the game to the player's language. * * You can include dynamic values in the text by using interpolation, for example: * * ```ts * const score = 100; * const message = sdk.t("You scored {{score}} points!", { score: score.toString() }); * ``` * * This will replace `{{score}}` in the translated string with the value of the `score` variable. * * This function does not work with dynamic text that. * * incorrect: * ```ts * const dynamicKey = "WELCOME_MESSAGE"; * const message = sdk.t(dynamicKey); // This will not be translated correctly * ``` * * correct: * ```ts * const message = sdk.t("WELCOME_MESSAGE"); // Use a static key for translation * ``` * * @param defaultValue The default English text to be translated. * @param interpolatedValues An optional object containing key-value pairs for interpolation. * @returns The translated string in the player's language, with interpolated values if provided. */ t: (defaultValue: string, interpolatedValues?: Record) => string; } & SharedSdk; type RuneClient = Sdk; /** @deprecated Please use `npx rune-games-cli@latest dusk-to-rune` or follow migration guide: https://developers.rune.ai/docs/move-to-rune */ type DuskClient = Sdk; type GameOverResult = "WON" | "LOST" | "TIE" | number; type GameOverOptions = { delayPopUp?: boolean; minimizePopUp?: boolean; } & ({ players: { [playerId: PlayerId]: GameOverResult; }; everyone?: never; } | { players?: never; everyone: GameOverResult; }); declare const _default: null; export { DuskClient, GameOverOptions, GameOverResult, GameStateWithPersisted, Interpolator, InterpolatorLatency, OnChange, OnChangeParams, PersistedPlayers, Player, PlayerId, Players, RuneClient, _default as default };