ddnet
Version:
A typescript npm package for interacting with data from ddnet.org
101 lines (100 loc) • 2.75 kB
TypeScript
import { RankAvailableRegion, Type } from '../../util.js';
import { Map } from '../maps/Map.js';
/**
* Base class representing a player's map stats.
*/
export declare abstract class MapStatsBase {
/**
* The map name.
*/
mapName: string;
/**
* The server type of this map.
*/
mapType: Type;
/**
* The amount of points awarded for completing this map.
*/
points: number;
constructor(data: {
mapName: string;
mapType: Type;
pointsReward: number;
});
/**
* Returns a new {@link Map} object from the {@link mapName} of this finish.
*/
toMap(
/**
* The region to pull ranks from in the `toMap` function from the returned value. Omit for global ranks.
*/
rankSource?: RankAvailableRegion | null,
/**
* Wether to bypass the cache.
*/
force?: boolean): Promise<Map>;
}
/**
* Represents a player's unfinished map stats.
*/
export declare class UncompletedMapStats extends MapStatsBase {
/**
* The amount of finishes on this map.
*
* @remarks This will always be 0.
*/
finishCount: number;
/**
* Construct a new {@link UncompletedMapStats} instance.
*/
constructor(data: ConstructorParameters<typeof MapStatsBase>[0]);
}
/**
* Represents a player's finished map stats.
*/
export declare class CompletedMapStats extends MapStatsBase {
/**
* The placement obtained on this map.
*/
placement: number;
/**
* Timestamp for the first ever finish on this map.
*/
firstFinishTimestamp: number;
/**
* Best finish time for this map in seconds.
*/
bestTimeSeconds: number;
/**
* The string formatted best finish time for this map.
*
* @example "03:23"
*/
bestTimeString: string;
/**
* The amount of finishes on this map.
*/
finishCount: number;
/**
* The team rank obtained on this map.
*/
teamRank: number | null;
/**
* Construct a new {@link CompletedMapStats} instance.
*/
constructor(data: ConstructorParameters<typeof MapStatsBase>[0] & {
rank: number;
firstFinishTimestamp: number;
bestTimeSeconds: number;
finishCount: number;
teamRank?: number;
});
}
/**
* Helper function to assert if a given map stats object is {@link CompletedMapStats}.
*/
export declare function isCompletedMapStats(stats: UncompletedMapStats | CompletedMapStats): stats is CompletedMapStats;
/**
* Helper function to assert if a given map stats object is {@link UncompletedMapStats}.
*/
export declare function isUncompletedMapStats(stats: UncompletedMapStats | CompletedMapStats): stats is UncompletedMapStats;