risiko-dande

1.0.1 • Public • Published

Simple dice battle system manager

With this npm you can integrate a simple battle manager in your project. The starting idea was to simulate a Risiko battle, but it could be extended to any other type of battle system thanks to some tiny features explained below.

Install

$ npm install risiko-dande

Usage

Then, with the well known syntax you can call a const on your project: const risiko = require ('risiko-dande');

Now, you just have to use only two method calls for this package to work.

Setting dice sides

With this method you can set the sides of the dice used in the battle system. It can be every number at your choice so be careful if you want to have a coherent and working thing. risiko.setSides(sides);

Making great battles

With the second method, you can actually play the battle: risiko.doBattle(atkUnits, defUnits); You must pass two parameters, one for the attacking units, and the other for the defensive units which will take part of the battle.

Returns

This method will return a JSON object with some easy to spot parameters:

  • atkUnits: the attacking units which take part in the battle
  • defUnits: the defensive units which take part in the battle
  • atkDices: the dices result for the attackers, sorted ascending way
  • defDices: the dices result for the defenders, sorted ascending way
  • atkLoss: the units lost by the attackers
  • defLoss: the units lost by the defenders

Package Sidebar

Install

npm i risiko-dande

Weekly Downloads

1

Version

1.0.1

License

ISC

Unpacked Size

3.01 kB

Total Files

3

Last publish

Collaborators

  • dandelionsam