@peacockproject/core
Version:
Type definitions for Peacock's core.
198 lines (197 loc) • 7.88 kB
TypeScript
import type { NextFunction, Response } from "express";
import type { GameVersion, MissionManifestObjective, RepositoryId, RequestWithJwt, ServerVersion, Unlockable, UserProfile } from "./types/types";
import { AxiosError } from "axios";
/**
* True if the server is being run by the launcher, false otherwise.
*/
export declare const IS_LAUNCHER: boolean;
export declare const ServerVer: ServerVersion;
export declare const PEACOCKVERSTRING: string;
export declare const uuidRegex: RegExp;
export declare const contractTypes: string[];
/**
* A list of game versions, except scpc.
*/
export declare const versions: Exclude<GameVersion, "scpc">[];
export declare const contractCreationTutorialId = "d7e2607c-6916-48e2-9588-976c7d8998bb";
/**
* The latest profile version, this should be changed in conjunction with the updating mechanism.
*
* See docs/USER_PROFILES.md for more.
*/
export declare const LATEST_PROFILE_VERSION = 2;
export declare function checkForUpdates(): Promise<void>;
export * from "semver";
export declare function getRemoteService(gameVersion: GameVersion): string | undefined;
/**
* Middleware that validates the authentication token sent by the client.
*
* @param req The express request object.
* @param res The express response object.
* @param next The express next function.
*/
export declare function extractToken(req: RequestWithJwt, res?: Response, next?: NextFunction): void;
export declare const DEFAULT_MASTERY_MAXLEVEL = 20;
export declare const XP_PER_LEVEL = 6000;
export declare function getMaxProfileLevel(gameVersion: GameVersion): number;
/**
* Calculates the level for the given XP based on xpPerLevel (defaults to XP_PER_LEVEL).
* Minimum level returned is 1.
*/
export declare function levelForXp(xp: number, xpPerLevel?: number): number;
/**
* Calculates the required XP for the given level based on xpPerLevel (defaults to XP_PER_LEVEL).
* Minimum XP returned is 0.
*/
export declare function xpRequiredForLevel(level: number, xpPerLevel?: number): number;
export declare const EVERGREEN_LEVEL_INFO: number[];
export declare function evergreenLevelForXp(xp: number): number;
/**
* Get the amount of XP needed to reach a mastery level in Evergreen.
*
* @param level
* @returns The XP, as a number.
*/
export declare function xpRequiredForEvergreenLevel(level: number): number;
export declare const SNIPER_LEVEL_INFO: number[];
export declare function sniperLevelForXp(xp: number): number;
/**
* Get the amount of XP needed to reach a mastery level in sniper missions.
*
* @param level
* @returns The XP, as a number.
*/
export declare function xpRequiredForSniperLevel(level: number): number;
/**
* Clamps the given value between a minimum and maximum value.
*/
export declare function clampValue(value: number, min: number, max: number): number;
/**
* Returns whether a location is a sniper location. Works for both parent and child locations.
*
* @param location The location ID string.
* @returns A boolean denoting the result.
*/
export declare function isSniperLocation(location: string): boolean;
export declare function castUserProfile(profile: UserProfile, gameVersion: GameVersion, path?: string): UserProfile;
export declare const defaultSuits: {
LOCATION_PARENT_ICA_FACILITY: string;
LOCATION_PARENT_PARIS: string;
LOCATION_PARENT_COASTALTOWN: string;
LOCATION_COASTALTOWN_MOVIESET: string;
LOCATION_COASTALTOWN_EBOLA: string;
LOCATION_PARENT_MARRAKECH: string;
LOCATION_PARENT_BANGKOK: string;
LOCATION_PARENT_COLORADO: string;
LOCATION_PARENT_HOKKAIDO: string;
LOCATION_PARENT_NEWZEALAND: string;
LOCATION_PARENT_MIAMI: string;
LOCATION_PARENT_COLOMBIA: string;
LOCATION_PARENT_MUMBAI: string;
LOCATION_PARENT_NORTHAMERICA: string;
LOCATION_PARENT_NORTHSEA: string;
LOCATION_PARENT_GREEDY: string;
LOCATION_PARENT_OPULENT: string;
LOCATION_PARENT_GOLDEN: string;
LOCATION_PARENT_ANCESTRAL: string;
LOCATION_ANCESTRAL_SMOOTHSNAKE: string;
LOCATION_PARENT_EDGY: string;
LOCATION_PARENT_WET: string;
LOCATION_PARENT_ELEGANT: string;
LOCATION_PARENT_TRAPPED: string;
LOCATION_PARENT_ROCKY: string;
};
/**
* Default suits that are attainable via challenges or mastery in this version.
*
* NOTE: Currently this is hardcoded. To allow for flexibility and extensibility, this should be generated in real-time
* using the Drops of challenges and masteries. However, that would require looping through all challenges and masteries
* for all default suits, which is slow. This is a trade-off.
*
* @param gameVersion The game version.
* @returns The default suits that are attainable via challenges or mastery.
*/
export declare function attainableDefaults(gameVersion: GameVersion): string[];
/**
* Gets the default suit for a given sub-location and parent location.
* Priority is given to the sub-location, then the parent location, then 47's signature suit.
*
* @param subLocation The sub-location.
* @param gameVersion The game version.
* @param suitOverride A default suit override for this contract.
* @returns The default suit for the given sub-location and parent location.
*/
export declare function getDefaultSuitFor(subLocation: Unlockable, gameVersion: GameVersion, suitOverride?: string | undefined): string;
export declare const nilUuid = "00000000-0000-0000-0000-000000000000";
export declare const hitmapsUrl = "https://backend.rdil.rocks/partners/hitmaps/contract";
export declare const vrTutorialId = "47fdffe9-c453-45ad-ad96-ac6f63494c40";
export declare function isObjectiveActive(objective: MissionManifestObjective, doneObjectives: Set<RepositoryId>): boolean;
export declare const jokes: string[];
/**
* The current game difficulty.
*/
export declare const gameDifficulty: {
/**
* The game isn't on a set difficulty (missions with no difficulties data?).
*/
readonly unset: 0;
/**
* Casual mode.
*/
readonly casual: 1;
/**
* Alias for {@link casual}.
*/
readonly easy: 1;
/**
* Professional (normal) mode.
*/
readonly normal: 2;
/**
* Master mode.
*/
readonly master: 4;
/**
* Alias for {@link master}.
*/
readonly hard: 4;
};
export declare function difficultyToString(difficulty: number): string;
/**
* Handle an {@link AxiosError} from axios.
*
* @see https://axios-http.com/docs/handling_errors
* @param error The error from axios.
*/
export declare function handleAxiosError(error: AxiosError): void;
export declare function unlockOrderComparer(a: Unlockable, b: Unlockable): number;
export declare function unlockLevelComparer(a: Unlockable, b: Unlockable): number;
/**
* Converts a contract's public ID as a long-form number into the version with dashes.
*
* @param publicId The ID without dashes.
* @returns The ID with dashes.
*/
export declare function addDashesToPublicId(publicId: string): string;
/**
* A fast implementation of deep object cloning.
*
* @param item The item to clone.
* @returns The new item.
*/
export declare function fastClone<T>(item: T): T;
/**
* Returns if the specified repository ID is a suit.
*
* @param repoId The repository ID.
* @returns If the repository ID points to a suit.
*/
export declare function isSuit(repoId: string): boolean;
type SublocationMap = {
[parentId: string]: string[];
};
export declare function getSublocations(gameVersion: GameVersion): SublocationMap;
export declare function isTrueForEveryElement<Type>(iter: Iterable<Type>, test: (elem: Type) => boolean): boolean;
export declare function extractServerVersion(serverVersion: string | undefined): ServerVersion | undefined;
export declare function extractResourcesVersion(resourcesServerVersion: string | undefined): ServerVersion | undefined;
export declare function parsePageNumber(page: unknown): number;