Skip to main content

Calculate Winnings

This node calculates the total winnings from slot machine winning lines based on bet amounts and paytables.

The Calculate Winnings node processes winning combinations to determine payout amounts.

The Calculate Winnings node takes winning line data from a slot spin and calculates the total payout based on the bet amount, paytable, and payline configuration. It supports wild symbols and provides detailed information about each winning line.

Inputs

Data

DataDescription
Winning LinesArray of winning line combinations from spin results
PaytableObject defining payout multipliers for symbol combinations
PaylinesArray defining the payline patterns

Parameters

DataDescription
Bet AmountTotal bet amount (0.01-1,000,000)
Wild SymbolSymbol ID that acts as wild (default: 9)

Actions

SignalDescription
DoTriggers the winnings calculation

Outputs

Results

DataDescription
Spin WinningsTotal winnings for this spin
Winning Lines DetailsArray with detailed information about each winning line

Events

SignalDescription
DoneTriggered when calculation is complete

Usage

Calculation Process

The node performs the following steps:

  1. Validates Input Data

    • Ensures winning lines is a valid array
    • Confirms bet amount is positive
    • Verifies paytable and paylines are properly formatted
  2. Processes Each Winning Line

    • Determines the payout symbol (first non-wild symbol)
    • Calculates bet amount per line
    • Looks up payout multiplier from paytable
    • Computes line winnings
  3. Generates Detailed Results

    • Creates winning line details with positions
    • Sums total winnings across all lines
    • Provides comprehensive payout information

Winning Lines Format

Winning lines are expected in the format:

[
[lineNumber, [symbol, symbol, symbol, ...]], // First winning line
[lineNumber, [symbol, symbol, symbol, ...]], // Second winning line
// ... additional winning lines
]

Paytable Format

The paytable should be structured as:

{
"symbolId": {
"3": multiplier, // 3 symbols payout
"4": multiplier, // 4 symbols payout
"5": multiplier // 5 symbols payout
}
}

Example Use Cases

  1. Standard Slot Games: Calculate traditional payline winnings
  2. Video Slots: Process complex multi-line wins
  3. Progressive Slots: Base game winnings before bonus calculations
  4. Demo Mode: Test payout calculations with different configurations

Wild Symbol Handling

  • Wild symbols substitute for other symbols
  • First non-wild symbol determines the payout symbol
  • If all symbols are wild, special handling may apply
  • Wild symbol ID is configurable (default: 9)

Bet Distribution

  • Total bet amount is divided equally among active paylines
  • Each line win is calculated based on bet-per-line amount
  • Total winnings is the sum of all individual line wins

Error Handling

The node handles various error conditions:

  • Invalid or missing input data
  • Malformed paytable structures
  • Bet amounts outside acceptable ranges
  • Missing payline definitions

Errors are logged and the node returns zero winnings with empty details array.

Output Details

Winning Lines Details includes for each winning line:

  • Line number
  • Array of winning symbols
  • Grid positions of winning symbols
  • Individual line payout amount

Performance Considerations

  • Efficient array processing for multiple winning lines
  • Input validation to prevent calculation errors
  • Memory-efficient storage of results
  • Handles large paytables and complex payline structures