splinterlands-simulator
v3.0.28
Published
Simulator for battles in the Splinterlands game
Downloads
47
Maintainers
Readme
Splinterlands Simulator
Simulator for battles in the Splinterlands game.
Installation and Setup
To install via NPM use:
npm install splinterlands-simulator
A simple game can be created like so
const mylor = new GameSummoner(/* id */ 259, /* level */ 3);
const nectarQueen = new GameMonster(/* id */ 226, /* level */ 2);
const teamOne = new GameTeam(mylor, [nectarQueen]);
const tarsa = new GameSummoner(/* id */ 440, /* level */ 2);
const chicken = new GameMonster(/* id */ 131, /* level */ 1);
const forgottenOne = new GameMonster(/* id */ 404, /* level */ 1);
const teamTwo = new GameTeam(tarsa, [chicken, forgottenOne]);
const rules = new Set([Ruleset.BACK_TO_BASICS, Ruleset.LOST_LEGENDARIES]);
const game = new Game(teamOne, teamTwo, rules, /* shouldLog */ true);
game.playGame();
const winner = game.getWinner();
const logs = game.getBattleLogs();
Configuration
The Game constructor takes in shouldLog as an optional fourth parameter. If set to true, the game logs can be retrieved using game.getBattleLogs()
. This returns an array of BattleLogs
. The logs will contain the action, and the snapshot of the relevant monsters after the action has taken place.
It is recommended to get the cards using https://api2.splinterlands.com/cards/get_details and creating GameSummoner/GameMonsters using the cards directly. Instantiating a GameSummoner/GameMonster using card ID relies on a local version of the cards that is not guaranteed to be up to date.
Samples
- example.ts for code samples.
- Splintertools for live sample with image logs
Simulator Accuracy
This simulator is not guaranteed to be 100% accurate and there are bugs with it. The simulator logic was based on playing the game and making educated guesses on how the simulator was working. There are still many edge cases that are still missing and need to be solved. If you find a bug feel free to open a PR or open an issue. If you would like to discuss the simulator you can join us on the Splintertools discord
Feature requests
For feature requests open an issue
Contributing Code
See our Contributions readme
If you would like to contribute to the code base, please make pull requests to the feature
branch. The feature branch will be merged to master
~once a week, and the NPM package will automatically be updated.