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
| Data | Description |
|---|---|
| Winning Lines | Array of winning line combinations from spin results |
| Paytable | Object defining payout multipliers for symbol combinations |
| Paylines | Array defining the payline patterns |
Parameters
| Data | Description |
|---|---|
| Bet Amount | Total bet amount (0.01-1,000,000) |
| Wild Symbol | Symbol ID that acts as wild (default: 9) |
Actions
| Signal | Description |
|---|---|
| Do | Triggers the winnings calculation |
Outputs
Results
| Data | Description |
|---|---|
| Spin Winnings | Total winnings for this spin |
| Winning Lines Details | Array with detailed information about each winning line |
Events
| Signal | Description |
|---|---|
| Done | Triggered when calculation is complete |
Usage
Calculation Process
The node performs the following steps:
-
Validates Input Data
- Ensures winning lines is a valid array
- Confirms bet amount is positive
- Verifies paytable and paylines are properly formatted
-
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
-
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
- Standard Slot Games: Calculate traditional payline winnings
- Video Slots: Process complex multi-line wins
- Progressive Slots: Base game winnings before bonus calculations
- 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