1.0.3 • Published 6 years ago

tournoi-ia-node-game-client v1.0.3

Weekly downloads
1
License
MIT
Repository
-
Last release
6 years ago

hackathon intech game client

Use this client to easily interact with the IA Hackathon @ InTech !

Install

npm install git+ssh://git@gitlab.intech.lu:10022/Tournois-IA/tournoi-ia-node-game-client.git

Usage

const Game = require('tournoi-ia-node-game-client');
const game = new Game({ game_url: 'localhost:8080' });

(async () => {
    const playerOne = await game.register_player('player_name');

    await playerOne.activate_shield();
    await playerOne.move({ x: 200, y: 300});

    const playerOneShip = await playerOne.ship;
    const other_ships = await playerOne.get_other_ships();
    for(const ship of other_ships) {
        if (playerOneShip.distance_with(ship) < 50 && !ship.shield_activated) {
            await playerOne.fire(ship);
            break;  // Your weapon is now on cooldown
        }
    }

    const ship = await playerOne.ship;
    console.log(ship.score);
})();

Example

raw

Once you have installed the game client, you can start a provided example like :

node example/random_move.js URL_OF_GAME:8080

Docker

You can build and use the provided docker image with your script or any provided example :

docker build -t tournoi-ia-node-game-client .
docker run -it tournoi-ia-node-game-client example/random_move.js URL_OF_GAME:8080
1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago