UNPKG

salesman-minigames

Version:

A minigame library made with NodeJS.

93 lines (62 loc) 1.92 kB
# salesman-minigames A minigame library made with NodeJS. ## Features * Russian Roulette game simulation * Rock-Paper-Scissors Minus One game * Dice Roll Challenge * Coin Flip Duel ## Installation Install the package via npm: ``` npm install salesman-minigames ``` ## Changelog - Patch Update - **Fixed the mistakes**: Fixed the mistakes that was in the package.json and code. - **Fixed type problems**: No description for this yet. ## Usage Import the classes you want to use: ```js // CommonJS const { RussianRoulette, RPSMinusOne, DiceRollChallenge, CoinFlipDuel } = require('salesman-minigames'); // ES Module import { RussianRoulette, RPSMinusOne, DiceRollChallenge, CoinFlipDuel } from 'salesman-minigames'; ``` ### Russian Roulette Create a new game instance: ```js const game = new RussianRoulette(); ``` Get the result: ```js console.log(game.getStat()); // "Un-Exploded" or "Exploded" ``` ### Rock-Paper-Scissors Minus One Each player picks two choices from "rock", "paper", or "scissors". Then they remove one choice and play with the remaining one: ```js const game = new RPSMinusOne(['rock', 'scissors'], 1, ['paper', 'rock'], 0); ``` Check the winner and status: ```js console.log(game.getWinner()); // "player1", "player2", or "draw" console.log(game.getStatus()); ``` ### Dice Roll Challenge Each player rolls a dice (number 1 to 6): ```js const game = new DiceRollChallenge(4, 5); ``` Check the winner and status: ```js console.log(game.getWinner()); // "player1", "player2", or "draw" console.log(game.getStatus()); ``` ### Coin Flip Duel Each player chooses "heads" or "tails": ```js const game = new CoinFlipDuel('heads', 'tails'); ``` Check the winner and status: ```js console.log(game.getWinner()); // "player1", "player2", or "draw" console.log(game.getStatus()); ```