Skip to content

Easily implement Codyfight game actions. A library for interacting with game API.

License

Notifications You must be signed in to change notification settings

codyfight/codyfight-game-client

Repository files navigation

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)

About

Easily implement Codyfight game actions. A library for interacting with game API.

Resources

License

Stars

Watchers

Forks

Packages

No packages published