Options
All
  • Public
  • Public/Protected
  • All
Menu

Module contexts/api/GameApiContext

This file defines API context for communication with game contract. The context allows this communication in a user-friendly manner and listens and reacts to received game events.

Type aliases

ItemRef

ItemRef: string

PlayerRef

PlayerRef: Address

Functions

Const createGameApiContext

  • Function for creating Game API subcontext. This function should be called exactly once through the whole application, when the connection to the blockchain is successfully established, and it also depends on contract API subcontext, database and notification global contexts. It is therefore called as part of the createApiContext function.

    Parameters

    • db: DatabaseContext

      Global database context for caching received information

    • contracts: ContractApiContext

      Contract API subcontext for type-safe interaction with contracts

    • notify: NotifyContext

      Global notification context for notifying user

    Returns GameApiContext

    Game API subcontext

Const parseLocation

  • parseLocation(loc: object): Vector2
  • Converts string representation of xy coordinates to the numeric one

    Parameters

    • loc: object
      • x: string
      • y: string

    Returns Vector2

Const parseMined

  • parseMined(mined: PlayerMinedEventLog): MinedInfo
  • Converts information about mined tiles from mostly string values to the numeric ones.

    Parameters

    • mined: PlayerMinedEventLog

    Returns MinedInfo

Const parsePlayerInfo

  • parsePlayerInfo(info: object): object
  • Converts (mostly string) player data as received from blockchain to their numeric representation

    Parameters

    • info: object
      • location: object
        • x: string
        • y: string
      • resources: object
        • common: string
        • product: string
        • rare: string
        • uncommon: string
      • stats: object
        • combat: string
        • mining: string
        • moving: string

    Returns object

    • location: Vector2
    • resources: object
      • common: number
      • product: number
      • rare: number
      • uncommon: number
    • stats: object
      • combat: number
      • mining: number
      • moving: number

Generated using TypeDoc