slot-machine.js
v1.0.7
Published
Slot machine frames.
Downloads
10
Maintainers
Readme
Slot Machine
Rolls a 3 x 3 slot machine where one can input custom elements to be displayed. The returned object returns 4 frames of the "spinning" of the slots. These frames can be used to create a slow, retro style animation whether for a simple game command or a discord bot command. Note any public program or application using this package must give credit to "andrew1991" somewhere in the program or application. Thank You.
#Install
npm i slot-machine.js
#Usage
const slots = require('slot-machine.js');
var results = slots.roll(<elements>, <separator>, <left-arrow>, <right-arrow>)
console.log(results)
##Parameters Elements: (required) an array that must contain more than 3 elements, each element should be a string, these are all the type of "images" that will be displayed on the slot machine while rolling. Keep in mind, the more elements you add, the chances of winning exponentially reduce.
Separator: (optional) this is what goes between each element in a frame, this is mainly for aesthetic appeal. If not supplied, ":" will be default.
Left-Arrow: (optional) this is the "arrow" to indicate the middle row, default is ">".
Right-Arrow: (optional) same as left arrow except for the right side, default is "<".
Note: Separator, left-arrow, and right-arrow are all optional parameters, however if supplied, they must all be strings no longer than 1 character in length. Look at Examples to understand better of how these parameters must be supplied.
Examples
const slots = require('slot-machine.js');
var results = slots.roll(['1', '2', '3', '4', '5'], ':', '>', '<')
console.log(results)
//Expected output
//{ frame:
// [ ': 5 : 4 : 5 :\n\n> 5 : 3 : 3 <\n\n: 1 : 1 : 3 :',
// ': 5 : 3 : 3 :\n\n> 1 : 1 : 3 <\n\n: 2 : 5 : 2 :',
// ': 5 : 1 : 3 :\n\n> 1 : 5 : 2 <\n\n: 2 : 2 : 3 :',
// ': 5 : 1 : 2 :\n\n> 1 : 5 : 3 <\n\n: 2 : 2 : 4 :' ],
// outcome: false }
Each frame is an element of an array. If outcome is true, that means that all three elements in the middle row on the 4th frame match which means a win.
var results = slots.roll(['1', '2', '3', '4', '5'], ':', '>', '<')
console.log(results.frame[1])
//Expected output
//: 5 : 3 : 3 :
//
//> 5 : 4 : 5 <
//
//: 1 : 3 : 4 :
Above is an example of the 2nd frame in a roll.