{"id":18057372,"url":"https://github.com/1computer1/slot-machine","last_synced_at":"2025-10-04T16:38:52.229Z","repository":{"id":57363313,"uuid":"73428222","full_name":"1Computer1/slot-machine","owner":"1Computer1","description":"A JS module for playing a slot machine. Also on NPM https://www.npmjs.com/package/slot-machine.","archived":false,"fork":false,"pushed_at":"2017-04-19T01:45:06.000Z","size":19,"stargazers_count":13,"open_issues_count":1,"forks_count":5,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-04-02T19:42:46.819Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/1Computer1.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-11-10T23:02:19.000Z","updated_at":"2024-12-11T12:45:11.000Z","dependencies_parsed_at":"2022-09-13T01:10:17.391Z","dependency_job_id":null,"html_url":"https://github.com/1Computer1/slot-machine","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/1Computer1%2Fslot-machine","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/1Computer1%2Fslot-machine/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/1Computer1%2Fslot-machine/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/1Computer1%2Fslot-machine/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/1Computer1","download_url":"https://codeload.github.com/1Computer1/slot-machine/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248345276,"owners_count":21088242,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-31T02:07:34.344Z","updated_at":"2025-10-04T16:38:47.174Z","avatar_url":"https://github.com/1Computer1.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# About\r\n\r\nA slot machine that's not accurate to real life at all.  \r\n\r\n# Example\r\n\r\n```js\r\nconst { SlotMachine, SlotSymbol } = require('../src/index');\r\n\r\nconst cherry = new SlotSymbol('cherry', {\r\n    display: '🍒',\r\n    points: 10,\r\n    weight: 100\r\n});\r\n\r\nconst money = new SlotSymbol('money', {\r\n    display: '💰',\r\n    points: 100,\r\n    weight: 50\r\n});\r\n\r\nconst wild = new SlotSymbol('wild', {\r\n    display: '❔',\r\n    points: 10,\r\n    weight: 50,\r\n    wildcard: true\r\n});\r\n\r\nconst machine = new SlotMachine(3, [cherry, money, wild]);\r\nconst results = machine.play();\r\n\r\nconsole.log(results.visualize());\r\n```\r\n\r\n# Docs\r\n\r\n### `SlotSymbol(name[, options])`\r\n\r\n- `name` A unique name for the symbol.\r\n- `options.display` A character to use for displaying.\r\n- `options.points` Amount of points the symbol gives.\r\n- `options.weight` Chance of symbol appearing relative to others.\r\n- `options.wildcard` Whether or not the symbol is a wildcard.\r\n\r\nCreates a new SlotSymbol instance:  \r\n\r\n- `name` The symbol's name.\r\n- `display` The character for display.\r\n- `points` Amount of points the symbol gives.\r\n- `weight` Chance of symbol appearing.\r\n- `wildcard` Whether or not the symbol is a wildcard.\r\n\r\n### `SlotMachine(size, symbols[, random])`\r\n\r\n- `size` Size of grid, must be odd number above 3.\r\n- `symbols` Array of SlotSymbols to use.\r\n- `random` Function returning number [0, 1).\r\n\r\nCreates a new SlotMachine instance:  \r\n\r\n- `size` Size of grid.\r\n- `symbols` Symbols to be used.\r\n- `random` Function returning number [0, 1).\r\n\r\n##### `\u003cSlotMachine\u003e.play()`\r\n\r\nPlays the slot machine and returns the results.  \r\n`=\u003e Results`  \r\n\r\n##### `\u003cSlotMachine\u003e.chanceOf(name)`\r\n\r\n- `name` Name of a SlotSymbol.\r\n\r\nGets the chance of a symbol appearing.  \r\n`=\u003e number`\r\n\r\n### `\u003cResults\u003e`\r\n\r\nThe results of a slot machine play:\r\n\r\n- `lines` The lines generated from the play, where the last two are the major and minor diagonals.\r\n- `totalPoints` Total amount of points from won lines.\r\n- `winCount` Amount of lines that have been won.\r\n\r\n##### `\u003cResults\u003e.visualize([includeDiagonals])`\r\n\r\n- `includeDiagonals` Whether or not to include diagonals in the visualization.\r\n\r\nCreates a formatted string from the results.  \r\n`=\u003e string`  \r\n\r\n### `\u003cEvaluatedLine\u003e`\r\n\r\nThe lines from a slot machine play:\r\n\r\n- `symbols` The symbols in the line.\r\n- `diagonal` Whether or not the line is a diagonal.\r\n- `isWon` Whether or not the line is won.\r\n- `points` The amount of points this line would give.\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F1computer1%2Fslot-machine","html_url":"https://awesome.ecosyste.ms/projects/github.com%2F1computer1%2Fslot-machine","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F1computer1%2Fslot-machine/lists"}