Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions src/ScreepsHttpClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1231,8 +1231,23 @@ export class ScreepsHttpClient extends EventEmitter {
}

/**
* Fetch metadata for the current season. Only works on official servers
* when a Seasonal World competition is active or about to start.
* Fetch a list of all past, current, and upcoming
* {@link https://screeps.com/season/#!/seasons/chronicle | Seasonal World} competitions.
*
* Only works on official servers.
* @throws {@link ScreepsApiError} HTTP 404 if called on an unofficial server
* @category Endpoints: /seasons
*/
seasonsList(): Promise<Http.SeasonsListResponse> {
return this.req(ScreepsHttpMethods.Get, '/api/seasons')
}

/**
* Fetch metadata for the current
* {@link https://screeps.com/season/#!/seasons/chronicle | Seasonal World} competition.
*
* Only works on official servers when a Seasonal World competition
* is active or about to start.
*
* Endpoint: `GET /api/seasons/current`
* @throws {@link ScreepsApiError} HTTP 404 if called on an unofficial server
Expand Down
38 changes: 34 additions & 4 deletions src/http/seasons.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,47 @@
import { ScreepsResponse } from './base'

/**
* `GET /api/seasons` response
* @see {@link ScreepsHttpClient.seasonsList}
* @category HTTP API - Seasons
*/
export interface SeasonsListResponse extends ScreepsResponse {
/**
* A list of all past, current, and upcoming Seasonal World competitions,
* ordered by {@link SeasonalWorldCompetition.index} (ascending).
*/
list: SeasonalWorldCompetition[]
}

/**
* `GET /api/seasons/current` response
* @see {@link ScreepsHttpClient.seasonsCurrent}
* @category HTTP API - Seasons
*/
export interface SeasonsCurrentResponse extends ScreepsResponse {
export interface SeasonsCurrentResponse extends ScreepsResponse, SeasonalWorldCompetition {
/** The authenticated user's current ranking on the seasonal leaderboard */
rank: number
}

/**
* Metadata for a
* {@link https://screeps.com/season/#!/seasons/chronicle | Seasonal World} competition.
* @category HTTP API - Seasons
*/
export interface SeasonalWorldCompetition {
_id: string
/** Name of the season (ex: "Season 8") */
title: string
/** Your current ranking on the seasonal leaderboard */
rank: number
/** The season ordinal (ex: 5 for season 5, 8 for season 8) */
/** The season ordinal (ex: 5 for season 5, 8 for season 8, etc) */
index: number
/**
* Ostensibly reports the number of participants in the season, but instead,
* this is almost always 0
*
* The only known exception is Season 1, which reports 2121 players.
* @see {@link ScoreboardListResponse.meta.length} for an actual player count
*/
players: number
/** Season start date/time (ISO 8601 UTC) */
startDate: string
/** Season end date/time (ISO 8601 UTC) */
Expand Down