slot-machine
Advanced tools
+7
-1
@@ -63,2 +63,3 @@ let Symbol = require('./symbol.js'); | ||
| lines[i] = {symbols, win, points: symbols.reduce((a, b) => a + b.points, 0)}; | ||
| lines[i].diagonal = false; | ||
@@ -77,6 +78,11 @@ if (i === lines.length - 1 || i === lines.length - 2){ | ||
| * @param lines - An array of arrays containing Symbols, or an array of rows containing points and results. | ||
| * @param includeDiagonals - Whether or not to include diagonals. Only works with calculated lines. | ||
| * @return A formatted slot machine game. | ||
| */ | ||
| module.exports.format = (lines) => { | ||
| module.exports.format = (lines, includeDiagonals = true) => { | ||
| if (lines.calculated){ | ||
| if (!includeDiagonals){ | ||
| lines = lines.filter((l) => !l.diagonal); | ||
| } | ||
| return lines.map((l) => l.symbols.map((s) => s.symbol).join(' ') + ' ' + (l.diagonal ? 'Diagonal ' : '') + (l.win ? 'Win!' : '')).join('\n'); | ||
@@ -83,0 +89,0 @@ } |
+11
-2
| { | ||
| "name": "slot-machine", | ||
| "version": "1.0.1", | ||
| "version": "1.1.0", | ||
| "description": "A functioning slot machine!", | ||
| "main": "index.js", | ||
| "keywords": ["slot machine", "slots", "gambling", "rng"], | ||
| "author": "1Computer", | ||
| "license": "MIT" | ||
| "license": "MIT", | ||
| "repository": { | ||
| "type": "git", | ||
| "url": "https://github.com/1Computer1/slot-machine.git" | ||
| }, | ||
| "bugs": { | ||
| "url": "https://github.com/1Computer1/slot-machine/issues" | ||
| }, | ||
| "homepage": "https://github.com/1Computer1/slot-machine" | ||
| } |
+8
-7
@@ -1,2 +0,2 @@ | ||
| Basic usage: | ||
| ### Usage | ||
| ```js | ||
@@ -24,4 +24,4 @@ const slotMachine = require('slot-machine'); | ||
| ``` | ||
| `Symbol(name, symbol[, points, weight, wildcard])` | ||
| ### Documentation | ||
| ##### `Symbol(name, symbol[, points = 1, weight = 1, wild = false])` | ||
| `name` A unique name. | ||
@@ -31,5 +31,5 @@ `symbol` A symbol for display. | ||
| `weight` Chance of this Symbol appearing. | ||
| `wildcard` Match with any other Symbol. | ||
| `wild` Whether or not the Symbol can match with any other Symbol. | ||
| `play(symbols[, size])` | ||
| ##### `play(symbols[, size = 3])` | ||
| `symbols` An array of Symbols. | ||
@@ -39,8 +39,9 @@ `size` Grid size, will round to nearest odd number above 3. | ||
| `calculate(lines)` | ||
| ##### `calculate(lines)` | ||
| `lines` An array of arrays containing Symbols. | ||
| Returns an array, containing the points and results of the lines inputted. | ||
| `format(lines)` | ||
| ##### `format(lines[, includeDiagonals = true])` | ||
| `lines` An array of arrays containing Symbols, or calculated lines. | ||
| `includeDiagonals` Whether or not to include diagonals. Only works with calculated lines. | ||
| Returns a formatted slot machine game. |
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
No website
QualityPackage does not have a website.
Found 1 instance in 1 package
5316
16.12%89
5.95%1
-50%0
-100%44
2.33%0
-100%