codyfight-game-client
TypeScript icon, indicating that this package has built-in type declarations

1.2.14 • Public • Published

codyfight-game-client

image

A library for interacting with Codyfight game API.

Easily implement Codyfight game actions.


📜 Make sure to checkout the game API documentation.

Install

npm install codyfight-game-client --save-dev

Usage

The constructor of the class takes an optional parameter apiURL, which is a string that represents the URL of the API to be used. The default value is https://game.codyfight.com/.

import it with the following code:

import GameAPI from 'codyfight-game-client'

const gameAPI = new GameAPI(apiURL, {
  // Override default headers (optional)
  headers: {
    'Content-Type': 'application/json',
    Accept: 'application/json',
  },
})

API

The API has the following public methods:

getGameConstants

This method returns an object with the game constants.

const constants = gameAPI.getGameConstants()

init

This method initializes a game with the given parameters and returns a Promise that resolves to the data received from the API.

const data = await gameAPI.init(ckey, mode, opponent)

cast

This method casts a skill with the given parameters and returns a Promise that resolves to the data received from the API.

const data = await gameAPI.cast(ckey, skill_id, x, y)

move

This method moves a player with the given parameters and returns a Promise that resolves to the data received from the API.

const data = await gameAPI.move(ckey, x, y)

check

This method checks the status of a game with the given ckey and returns a Promise that resolves to the data received from the API.

const data = await gameAPI.check(ckey)

Readme

Keywords

none

Package Sidebar

Install

npm i codyfight-game-client

Weekly Downloads

4

Version

1.2.14

License

MIT

Unpacked Size

25.7 kB

Total Files

13

Last publish

Collaborators

  • vinimartdev
  • driule
  • tomas.balsys