Xgenia Slot Template Functions
This section explains the core functions used in the Xgenia Slot Template, their purpose, and how data flows between them to create the complete slot game experience.
Data Flow Diagram​
Game Launch → Get Session → Get Game → Asset Loading
↓ ↓ ↓ ↓
SessionID UserID+Token Icons+Music Download Functions
↓ ↓ ↓ ↓
Authentication API Access Symbols Image Processing
↓ ↓ ↓ ↓
Bet Transactions → Result Processing → Icon Display → UI Update
Function Flowchart​
1. Game Initialization Functions​
1.1 Launch Game​
Purpose: Initializes a new game session with the backend server and establishes secure communication.
Connections Flow:
- From String Node → Receives GameID (example: "slot_classic_01")
- From String Node → Receives initial SessionID for authentication
- To API Endpoint → Sends POST request to launch endpoint
- From API Response → Receives authoritative SessionID from server
- To Get Session Function → Provides validated SessionID for next step
Data Example:
Input: GameID = "slot_classic_01"
Output: SessionID = "sess_abc123def456"
How it Works: Launch Game sends a POST request to the server with the GameID. The server validates the game exists, creates a secure session, and returns an authoritative SessionID. This SessionID becomes the key for all subsequent API calls, ensuring secure and authenticated communication throughout the game session.
1.2 Get Session​
Purpose: Retrieves authenticated user session data including balance, tokens, and user preferences.
Connections Flow:
- From Launch Game → Receives validated SessionID
- To API Endpoint → Sends secure session request
- From API Response → Receives complete session data
- To Header Components → Provides Balance (example: 1000 credits)
- To Get Game Function → Provides UserID and Token for authentication
- To Bet Functions → Provides authentication credentials
Data Example:
Input: SessionID = "sess_abc123def456"
Output: Balance = 1000, UserID = "user123", Token = "jwt_token_here"
1.3 Get Game​
Purpose: Fetches game-specific assets and configuration data for the selected slot game.
Connections Flow:
- From Get Session → Receives UserID, Token, and authentication
- From String Node → Receives GameID for asset identification
- To API Endpoint → Sends authenticated game data request
- From API Response → Receives Icons array and Music URL
- To Download Functions → Provides URLs for asset downloading
- To Audio Components → Provides Music URL for background audio
Data Example:
Input: GameID = "slot_classic_01", UserID = "user123"
Output: Icons = [Icon1.png, Icon2.png, ...], Music = "background.mp3"
2. Asset Loading Functions​
2.1 Get Config JSON​
Purpose: Downloads the game's remote configuration file containing asset URLs and game settings.
Connections Flow:
- From String Node → Receives GameID for URL construction
- To Cloud Storage → Constructs and fetches config.json URL
- From JSON Response → Receives BackgroundURL and FrameURL
- To Download Background → Provides BackgroundURL
- To Download Frame → Provides FrameURL
Data Example:
Input: GameID = "slot_classic_01"
URL: https://storage.googleapis.com/.../slot_classic_01/config.json
Output: BackgroundURL = "background.png", FrameURL = "frame.png"
2.2 Download Background​
Purpose: Fetches and processes the game's background image for display.
Connections Flow:
- From Get Config JSON → Receives BackgroundURL
- To Image Fetch → Downloads image as blob data
- To Base64 Conversion → Converts to displayable format
- To Background Component → Provides processed image data
2.3 Download Frame​
Purpose: Fetches and processes the decorative slot machine frame image.
Connections Flow:
- From Get Config JSON → Receives FrameURL
- To Image Fetch → Downloads frame image
- To Base64 Conversion → Processes for display
- To Frame Component → Provides decorative overlay image
2.4 Download Audio​
Purpose: Fetches background music and sound effects for the current game theme.
Connections Flow:
- From Get Game → Receives Music URL based on GameID
- To Audio Fetch → Downloads audio file
- To Audio Manager → Provides processed audio data
- To Audio Controls → Enables play/pause functionality
3. Image Processing Functions​
3.1 Slice Image​
Purpose: Converts a single spritesheet image into individual slot symbol images for efficient display.
Connections Flow:
- From Get Game → Receives spritesheet URL containing all symbols
- To Canvas Processing → Slices spritesheet into individual icons
- From Grid Calculation → Uses 5x3 grid parameters (5 columns, 3 rows)
- To Icon Array → Outputs array of 15 individual symbol images
- To Icon Setter → Provides symbol library for result mapping
Data Example:
Input: Spritesheet with 15 symbols in 5x3 grid
Output: Array of 15 individual symbol images
[{ImageSrc: "data:image/png;base64...", Index: "Icon1"}, ...]
How it Works: Slice Image downloads a single spritesheet containing all game symbols, then uses HTML5 Canvas to cut it into individual symbol images. This approach improves performance by reducing the number of HTTP requests while maintaining high-quality graphics. Each sliced symbol is converted to base64 format for immediate use in the game interface.
3.2 Icon Setter From Server​
Purpose: Maps server bet results to specific slot symbols and arranges them in the 5x3 grid.
Connections Flow:
- From Bet Transactions → Receives ResultArrayOne (example: 1234567890123456)
- From Slice Image → Receives array of available symbol images
- To Result Processing → Converts numeric result to symbol positions
- To Grid Layout → Arranges symbols in 5 columns × 3 rows format
- To Slot Frame → Provides final symbol arrangement for display
Data Processing Example:
Input: ResultArrayOne = 1234567890123456
Process: Maps each digit to corresponding symbol
Output: 15 symbols arranged in 5x3 grid
Grid: [Symbol1][Symbol2][Symbol3][Symbol4][Symbol5]
[Symbol6][Symbol7][Symbol8][Symbol9][Symbol0]
[Symbol1][Symbol2][Symbol3][Symbol4][Symbol5]
How it Works: The Icon Setter takes the numeric result from the server and converts each digit into a specific symbol using a mapping algorithm. It cycles through the result digits to fill all 15 positions in the 5x3 grid, applies any necessary offsets for symbol indexing, and outputs an array of image objects ready for display by the UI repeater component.
4. Gameplay Functions​
4.1 Bet Transactions​
Purpose: Executes the core gameplay loop by processing bets and returning spin results.
Connections Flow:
- From BET Button → Receives current bet amount (example: 10 credits)
- From Get Session → Receives UserID, SessionID, and Token for authentication
- From String Node → Receives GameID for game-specific processing
- To API Endpoint → Sends secure bet request to server
- From API Response → Receives spin results and updated balance
- To Icon Setter → Provides ResultArrayOne for symbol display
- To Header Components → Provides new Balance and TotalWin amounts
- To Audio Manager → Triggers spin sound effects
Data Example:
Input: Amount = 10, GameID = "slot_classic_01", UserID = "user123"
Output: TotalWin = 50, Balance = 1040, ResultArrayOne = 1234567890123456
How it Works: When the SPIN button is pressed in API mode, Bet Transactions validates the player's balance and sends a secure request to the server. The server uses a certified random number generator to determine the spin outcome, calculates wins based on the game's paytable, updates the player's balance, and returns the results. The function then distributes this data to update the UI components.
API Response Structure:
{
"balance": 1040,
"spin_results": {
"total_payout": 50,
"payline_results": [
[["1","2","3","4","5"],["6","7","8","9","0"],["1","2","3","4","5"]]
]
},
"userID": "user123",
"sessionID": "sess_abc123def456",
"game": "slot_classic_01",
"currency": "USD",
"timestamp": "2024-01-07T10:30:00Z"
}
Bet Transactions Outputs:
- Balance → Updated player balance after spin (example: 1040)
- TotalWinText → Win amount from spin (example: 50)
- ResultArrayOne → Processed symbol result (example: 1234567890123456)
- UserID → Player identifier for session tracking
- SessionID → Current session identifier
- Currency → Player's currency code
- Transitions → Trigger for UI animations
- DefaultPos → Reset position for next spin
4.2 Local True Random Number Generator​
Purpose: Generates random spin results locally when server API is unavailable or disabled.
Connections Flow:
- From Spin Options Controller → Receives LocalSpin = true signal
- From BET Button → Receives current bet amount
- To Random Generation → Creates symbol combinations using local algorithms
- To Result Processing → Provides generated results instantly
- To UI Components → Updates display without server delay