Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

slot-machine

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

slot-machine - npm Package Compare versions

Comparing version 1.1.1 to 2.0.0

.eslintrc.json

6

package.json
{
"name": "slot-machine",
"version": "1.1.1",
"description": "A functioning slot machine!",
"main": "index.js",
"version": "2.0.0",
"description": "An OOP slot machine.",
"main": "src/index.js",
"keywords": ["slot machine", "slots", "gambling", "rng"],

@@ -7,0 +7,0 @@ "author": "1Computer",

### Usage
```js
const slotMachine = require('slot-machine');
const Symbol = slotMachine.Symbol;
const { SlotMachine, Symbol } = require('slot-machine');
let cherry = new Symbol('cherry', '🍒', 1, 10);
let money = new Symbol('money', '💰', 10, 5);
let wildcard = new Symbol('wildcard', '❔', 5, 1, true);
const cherry = new Symbol('cherry', {
display: '🍒',
points: 10,
weight: 100
});
let results = slotMachine.play([cherry, money, wildcard], 3);
const money = new Symbol('money', {
display: '💰',
points: 100,
weight: 50
});
console.log(results[0].win); // false
console.log(results[1].symbols); // [money, money, cherry]
console.log(results[2].points); // 7
console.log(results[3].diagonal); // true
const wild = new Symbol('wild', {
display: '❔',
points: 10,
weight: 50,
wildcard: true
});
console.log(slotMachine.format(results));
const machine = new SlotMachine(3, [cherry, money, wild]);
const results = machine.play();
results.visualize(true);
// 🍒 🍒 💰
// 💰 💰 🍒
// ❔ 🍒 🍒 Win!
// 🍒 💰 🍒 Diagonal
// ❔ 💰 💰 Diagonal Win!
// ❔ 🍒 🍒
//
// 🍒 💰 🍒
// ❔ 💰 💰
results.totalPoints; // 240
results.winCount; // 2
results.lines[0].symbols; // [cherry, cherry, money]
results.lines[1].points; // 0
results.lines[2].isWon; // true
results.lines[3].diagonal; // true
```
### Documentation
##### Symbol(name, symbol[, points = 1, weight = 1, wild = false])
`name` A unique name.
`symbol` A symbol for display.
`points` How many points this Symbol gives.
`weight` Chance of this Symbol appearing.
`wild` Whether or not the Symbol can match with any other Symbol.
*Creates a Symbol.*
##### play(symbols[, size = 3])
`symbols` An array of Symbols.
`size` Grid size, will round to nearest odd number above 3.
*Returns an array of rows in the slot game, plus two representing diagonals.*
##### calculate(lines)
`lines` An array of arrays containing Symbols.
*Returns an array, containing the points and results of the lines inputted.*
##### 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.*

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc