slot-machine
Advanced tools
Comparing version 1.0.1 to 1.1.0
@@ -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 @@ } |
{ | ||
"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" | ||
} |
@@ -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. |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
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
89
1
0
44
0