Neptune's Potato Monsters

    engine-slot
    TypeScript icon, indicating that this package has built-in type declarations

    0.0.6 • Public • Published

    engine-blackjack

    A NodeJs or Web library to create slot machines.

    Philosophy

    • configurable any number of reels/rows must be possible
    • testable payout, symbols and lines and RTP must be testable
    • composable no complex classes or states, all dependencies are injected
    • less code when it gets cryptographic, just write the comment

    Motivation

    I've been working with slots since half of a decad right now. Most of the engines are (perfectly working in production) very complex and full of death features that honestly makes the entire projects annoying to read and work with.

    With this side-project, I want to implement some of the functionalities that I have been working with and try to understand how to create better slots in the future.

    How it works

    At the very basics, a configuration file is required. Understand the configuration file, which can be a simple JSON file implementing the IConfig interface, which is key to run execute the slot.

    Functionalities

    • Create any grid layout you want 5x3, 3x3 NxN
    • Configure the payout on each symbol
    • Add any line and relative path you like (on top of the grid layout)
    • Wild Symbols (to complete combinations)
    • Free Spins Symbols
    • Multiplier Symbols
    • Scatter Symbols

    Life Cycle

    • The configuration produces the grid
    • The grid produces the prizes for the current spin and the future storage
    • The post grid processes considers the previous storage to generate the exit state

    A workflow, without persistent state

    1. create or load the configuration const config: IConfig = ...
    2. create a cached configuration const cache = buildCache(config)
    3. load the storage (state relative to your context) const storage: IStorage = {}
    4. generate the grid (random occurs here) let spin: IGrid = grid(config, cache)
    5. create the line mask: let lines = mask(config, spin)
    6. process the grid across lines const result: IResult = execute(config.m.length, 1,config, spin, lines, storage)
    7. repeat 4 -> 5 -> 6 until is necessary...

    In the above example the storage is an empty object that has no previous state to pass to the process function

    A workflow, with persistent state (Example Free Spins)

    In this case, we assume the result: IResult, because of the config: IConfig, produces some Free Spins. Before to go ahead, please consider that Free spins have some basic, built-in rules:

    • free spin is FS;
    • FSs depends on symbols;
    • symbols that give FSS are across the grid, never considered on the line;
    • FSs can have multiplier (default value 1) that will boosts the prizes gained over FS;
    • FS is applied on the next spin, the spin that won FS

    If you are interested in how free spins are handled, check out the IConfig interface and the grid function.

    1. create or load the configuration const config: IConfig = ...
    2. create a cached configuration const cache = buildCache(config)
    3. load the storage (state relative to your context) const storage: IStorage = {}
    4. generate the grid (random occurs here) let spin: IGrid = grid(config, cache)
    5. create the line mask: let lines = mask(config, spin)
    6. process the grid across lines let result: IResult = execute(config.m.length, 1,config, spin, lines, storage)
    7. repeat 4 -> 5 -> and 6 but this time override the last parameter of the process function (the storage) with the result.exitStorage

    The IResult.exitStorage implements the IStorage interface, which is mutated during the process function. In a non-test environment you probably are storing the result, associated to some user information, in order to restore the state of the slot machine, continuing with the game.

    License

    engine-slot Copyright (C) 2016 Marco Casula

    This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; version 2 of the License.

    This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

    You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.

    Credits

    Thanks @webpty for logos

    Install

    npm i engine-slot

    DownloadsWeekly Downloads

    3

    Version

    0.0.6

    License

    GPL-2.0

    Unpacked Size

    17.1 kB

    Total Files

    6

    Last publish

    Collaborators

    • kedoska