A library for interacting with Codyfight game API.
Easily implement Codyfight game actions.
📜 Make sure to checkout the game API documentation.
npm install codyfight-game-client --save-dev
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',
},
})
The API has the following public methods:
This method returns an object with the game constants.
const constants = gameAPI.getGameConstants()
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)
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)
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)
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)