The GameApi class provides methods to interact with a game's server. It supports operations like retrieving game tokens, searching for games, and fetching game details.

Constructors

  • Creates an instance of the GameApi class.

    Parameters

    • apiClient: Record<string, any>

      An object that handles sending requests to the backend API.

    Returns GameApi

Properties

availableServerLanguages: string[]

Supported server languages for filtering games.

Methods

  • Fetches advanced game details based on state and state-specific options.

    Parameters

    • gameID: number

      The unique identifier for the game.

    • stateID: number = 0

      The state ID to fetch. Defaults to 0 which equals all.

    • stateOption: null | number = null

      Additional state option. Optional.

    Returns Promise<any>

    A promise resolving to the game details or an error if the game is not found.

  • Fetches all newspapers for a game (stateID 2).

    Parameters

    • gameID: number

      The unique identifier for the game.

    Returns Promise<
        {
            elapsedTime: number;
            result: any[];
            resultCode: number;
            resultMessage: string;
            version: string;
        },
    >

    A promise resolving to all the game newspapers or an error if the game is not found.

  • Fetches game details with all states (stateID 0).

    Parameters

    • gameID: number

      The unique identifier for the game.

    Returns Promise<any>

    A promise resolving to the game details or an error if the game is not found.

  • Fetches a map with province statistics for a given game (stateID 3).

    Parameters

    • gameID: number

      The unique identifier for the game.

    Returns Promise<any>

    A promise resolving to the map with province statistics or an error if the game is not found.

  • Fetches the newspaper for a specific day in the game (stateID 2).

    Parameters

    • gameID: number

      The unique identifier for the game.

    • day: number

      The day to fetch the newspaper for.

    Returns Promise<any>

    A promise resolving to the game newspaper or an error if the game is not found.

  • Fetches a detailed overview of a game, including properties and player details.

    Parameters

    • gameID: number

      The unique identifier for the game.

    Returns Promise<any>

    A promise resolving to the game overview or an error if the game is not found.

  • Fetches original game overview. This call takes exceedingly longer, which is why getOverview was created.

    Parameters

    • gameID: number

      The unique identifier for the game.

    Returns Promise<any>

    A promise resolving to the game overview.

  • Fetches an overview of a game, only including properties.

    Parameters

    • gameID: number

      The unique identifier for the game.

    Returns Promise<any>

    A promise resolving to the game overview or an error if the game is not found.

  • Fetches players for a given game (stateID 1).

    Parameters

    • gameID: number

      The unique identifier for the game.

    Returns Promise<any>

    A promise resolving to the game players or an error if the game is not found.

  • Fetches provinces data for a given game (stateID 3).

    Parameters

    • gameID: number

      The unique identifier for the game.

    Returns Promise<any>

    A promise resolving to the provinces data or an error if the game is not found.

  • Fetches the scenario statistics for a game (stateID 12).

    Parameters

    • gameID: number

      The unique identifier for the game.

    Returns Promise<any>

    A promise resolving to the scenario statistics or an error if the game is not found.

  • Fetches game-related statistics (stateID 30).

    Parameters

    • gameID: number

      The unique identifier for the game.

    Returns Promise<any>

    A promise resolving to the game statistics or an error if the game is not found.

  • Retrieves the token for a specific game.

    Parameters

    • gameID: number

      The identifier of the game.

    Returns Promise<any>

    A promise resolving to the game token or an error if the game is not found.

  • Searches for games based on various filters.

    Parameters

    • numEntries: number = 10

      Number of entries to fetch (min 5, max 50). Defaults to 10.

    • page: number = 0

      The page number to fetch. Defaults to 0.

    • lang: string = "en"

      Language filter. Defaults to "en".

    • filter: string = ""

      Search string for filtering. Optional.

    • scenarioID: null | number = null

      Scenario ID for filtering. Optional.

    Returns Promise<any>

    A promise resolving to the search results.