@tive-labs/hangedman-game
v0.1.16
Published
## Installation
Downloads
3
Keywords
Readme
hangedman-game
How to install hangedman-game library
- To install hangedman-game library in your project just run the following command:
npm i @tive-labs/hangedman-game;
How to use hangedman-game library
Parameters
- This game support two categories: 1 - animals, 2 - numbers
- This game support three levels: 1 - easy, 2 - medium, 3 - hard
Import the library
import {initHangedMan} from "@tive-labs/hangedman-game";
Create an instance of hangedman-game
- Use the method initHangedMan(category, level) for create an instance of hangedman-game.
const hangedman = initHangedMan('1', '1');
Play
- To play use the method play(letter) an re asign the instance with the result.
hangedman = hangedman.play('A');
Verify all status value
- To verify all status value, run this method, will return this value: { GAME_STARTED: 1, WON_GAME: 2, LOST_GAME: 3 }
const status = hangedman.getAllStatus();
Verify the status game
- To verify the status game, run this method.
const status = hangedman.getStatus();
Verify quantity of attempts fails
- To verify if the play was lost use the method isLost(), return true if you lost, you lost when you quantity of attempts fails are three or more.
const fails = hangedman.getAttemptsFailed();
Class Diagram
HANGEDMAN CONSOLE GAME
Installation
npm install
Run
npm start
Test
npm test
How to play
- Select a category option
- Select a level option
- Write letter until fill al underscore spaces
- You can fail only three times.