Gambling System
The Gambling System adds a fully-featured casino to EliteMobs. Players can wager their Elite Coins across four different minigames, go into debt when they run out of money, and face the consequences when the Debt Collector comes knocking. Server administrators can configure every aspect of the system, from payout multipliers to debt limits.
Setup
The gambling system is accessed through specially configured NPCs. Each game and display has its own NPC interaction type.
To set up a gambling NPC, create an NPC configuration file and set the interactionType to one of the following values:
| Interaction Type | Description |
|---|---|
GAMBLING_BLACKJACK | Opens the betting menu for Blackjack |
GAMBLING_COINFLIP | Opens the betting menu for Coin Flip |
GAMBLING_SLOTS | Opens the betting menu for Slot Machine |
GAMBLING_HIGHERLOWER | Opens the betting menu for Higher or Lower |
The Gambling Den Owner NPC does not use a special interaction type. To set it up, create an NPC with the filename gambling_den_owner.yml. The house earnings display will appear above the NPC automatically based on this filename.
Games
Blackjack
Standard Blackjack rules apply. The goal is to get as close to 21 as possible without going over.
Rules
- Both the player and dealer are dealt two cards.
- The dealer's second card is hidden until the player stands.
- Aces count as 11 or 1 (automatically adjusted to prevent busting when possible).
- Face cards (Jack, Queen, King) count as 10.
- The dealer stands on 17.
- Players can hold up to 5 cards.
Actions
| Action | Description |
|---|---|
| Hit | Draw another card. |
| Stand | Keep your current hand; the dealer then plays. |
| Double Down | Double your bet, draw exactly one card, then automatically stand. Only available on your first action (when you have 2 cards) and only if you can afford to double your bet. |
Payouts
| Outcome | Default Multiplier |
|---|---|
| Normal Win (player's total beats dealer, or dealer busts) | 2.0x |
| Blackjack (21 with the first two cards) | 2.5x |
| Push (tie) | 1.0x (bet returned) |
| Loss (player busts or dealer's total is higher) | 0x (bet lost) |
Closing the Menu
If a player closes the menu during the dealer's turn, the dealer's hand is played out automatically and the result is resolved. If a player closes the menu before standing, the bet is forfeited.
Coin Flip
A simple 50/50 game. Pick Heads or Tails, and the coin decides your fate.
How to Play
- The game opens with a Heads button and a Tails button.
- Click one to make your choice.
- A coin flip animation plays.
- The result is shown.
Payouts
| Outcome | Default Multiplier |
|---|---|
| Correct guess | 1.9x |
| Edge (coin lands on its edge) | 10.0x |
| Wrong guess | 0x (bet lost) |
The Edge Outcome
There is a 1% chance the coin lands on its edge instead of Heads or Tails. When this happens, the player always wins regardless of their choice, and receives a 10x payout on their bet. A special chat message and visual display are shown for this rare event.
Closing the Menu
If a player closes the menu before making a choice, the bet is forfeited.
Slot Machine
Spin three reels and match symbols to win. Rarer symbols pay more.
How to Play
- The game opens with a 3x3 reel grid and a Spin button.
- Click Spin to start the reels.
- Each reel stops in sequence with an animation.
- The middle row (payline) determines the result.
Symbols and Payouts
Each symbol has a weight that determines how often it appears. The payout multiplier for matching three of a symbol is calculated as 100 / weight. Matching two symbols pays 25% of the three-match payout for that symbol.
| Symbol | Weight | Chance | 3-Match Payout | 2-Match Payout |
|---|---|---|---|---|
| Cherry | 35 | 35% | 2.86x | 0.71x |
| Lemon | 28 | 28% | 3.57x | 0.89x |
| Orange | 20 | 20% | 5.0x | 1.25x |
| Golden Bell | 10 | 10% | 10.0x | 2.5x |
| Silver Bar | 5 | 5% | 20.0x | 5.0x |
| Lucky 7 | 2 | 2% | 50.0x | 12.5x |
Three Lucky 7s is the Jackpot and receives a special visual and sound effect.
Closing the Menu
If a player closes the menu before spinning, the bet is forfeited.
Higher or Lower
A streak-based card game. Guess whether the next card is higher or lower than the current one, and build up a multiplier. Cash out at any time or risk it all.
How to Play
- A card is drawn and shown (values range from 2 to 14, where Ace = 14).
- Guess whether the next card will be Higher or Lower than the current card.
- If you guess correctly, your multiplier increases and the revealed card becomes the new current card.
- You can Cash Out at any time after at least one correct guess.
- If you guess wrong, you lose your entire bet.
- If the next card is equal to the current card, it counts as a loss.
Streak Multiplier
Each correct guess multiplies your winnings by the configured multiplier (default 1.5x). The multiplier stacks:
| Streak | Multiplier (default) | Payout on 100 Coin Bet |
|---|---|---|
| 1 | 1.5x | 150 |
| 2 | 2.25x | 225 |
| 3 | 3.375x | 337.5 |
| 4 | 5.0625x | 506.25 |
| 5 | 7.59x | 759 |
| ... | ... | ... |
| 12 | ~129.75x | ~12,975 |
Max Streak and Auto-Cashout
The maximum streak is 12. When a player reaches 12 correct guesses, they are automatically cashed out and their winnings are awarded. This prevents runaway multipliers.
Closing the Menu
If a player closes the menu while they have a winning streak, they are automatically cashed out and receive their current winnings. If they close before making any guess, the bet is forfeited.
Betting
Before any game starts, the player is presented with a betting menu to select their wager.
Bet Limits
| Setting | Default Value |
|---|---|
| Minimum Bet | 10 |
| Maximum Bet | 1000 |
Betting Menu Controls
The betting menu provides several controls:
- Increment Buttons -- Three sizes of increase and decrease buttons. If the player has at least 100 coins and no debt, increments are percentage-based (5%, 10%, 25% of balance). Otherwise, fixed amounts of 10, 50, and 100 are used.
- All In -- Sets the bet to the maximum the player can afford (including available credit).
- Reset -- Resets the bet to the minimum.
- Play -- Starts the game with the current bet. Only active if the player can afford the bet.
- Cancel -- Closes the menu without betting.
The menu shows the player's current balance, any existing debt, and available credit.
Debt System
Players can bet beyond their balance by going into debt. The casino extends credit up to a configurable limit.
How Debt Works
- When a player places a bet that exceeds their balance, the remaining amount is added as gambling debt.
- The maximum debt a player can accumulate is 500 coins by default.
- Players cannot place bets that would push their debt beyond the maximum.
- When a player wins, their winnings are first applied to pay off debt before being added to their balance.
Available Credit
A player's available credit is calculated as: maxDebt - currentDebt. This is displayed in the betting menu.
Debt Warning
When a player goes into debt, they receive a warning message. The Debt Collector may come for them while they carry outstanding debt.
Debt Collector Boss
The Debt Collector is a custom boss that spawns to hunt down players who are in gambling debt.
Spawn Conditions
- The player must have outstanding gambling debt.
- A periodic check runs every 60 minutes (configurable) for all online players.
- Each check has a 50% chance (configurable) to spawn the Debt Collector for an eligible player.
- Only one Debt Collector can be active per player at a time.
- The Debt Collector uses the custom boss file
debt_collector.yml.
Level Scaling
The Debt Collector's level is based on the target player's combat level. Its health is multiplied by a configurable health multiplier (default 5.0x) and its damage by a damage multiplier (default 1.0x).
Behavior
- The Debt Collector spawns 5 to 10 blocks away from the player.
- It immediately targets the player it was spawned for.
- It has a timeout of 600 seconds (10 minutes) by default. If not killed within that time, it despawns and warns the player it will return.
Outcomes
| Outcome | Effect |
|---|---|
| Player kills the Debt Collector | The boss despawns. The player's debt is not reduced, but they receive a message that it will return. |
| Debt Collector kills the player | The player's debt is reduced by 50 coins (configurable). If this clears the debt entirely, the player is notified. The Debt Collector despawns after 5 seconds. |
| Timeout (not killed in time) | The Debt Collector despawns and sends a warning message. It will attempt to spawn again on the next check. |
Gambling Den Owner
The Gambling Den Owner is a special NPC that displays the House Earnings above its head as a floating text display. This shows the total profit or loss the house has accumulated from all gambling activity.
- Positive earnings are shown in green (e.g.,
+1234.56). - Negative earnings (players winning more than losing) are shown in red (e.g.,
-567.89). - The display updates every second.
- House earnings are persisted to
house_earnings.ymland survive server restarts.
Configuration
All gambling settings are stored in GamblingSettings.yml. Below are the key gameplay-affecting settings.
General Settings
| Key | Description | Default |
|---|---|---|
gamblingEnabled | Enables or disables the entire gambling system. When disabled, gambling NPCs will not work and the Debt Collector will not spawn. | true |
maxDebt | Maximum amount of debt a player can accumulate from gambling. | 500.0 |
minBet | Minimum bet amount for all gambling games. | 10 |
maxBet | Maximum bet amount for all gambling games. | 1000 |
Payout Multipliers
| Key | Description | Default |
|---|---|---|
payouts.blackjack.normal | Payout multiplier for a normal Blackjack win. | 2.0 |
payouts.blackjack.blackjack | Payout multiplier for getting a natural Blackjack (21 with first two cards). | 2.5 |
payouts.coinFlip | Payout multiplier for winning a Coin Flip. Set below 2.0 for house edge (1.9 = 5% house edge). | 1.9 |
payouts.higherLower.multiplier | Multiplier applied per correct guess in Higher/Lower. Stacks multiplicatively. | 1.5 |
Slot Machine Payouts
Slot machine payouts are not configurable. They are calculated automatically from symbol weights using the formula 100 / weight:
| Symbol | Weight | 3-Match Payout | 2-Match Payout |
|---|---|---|---|
| Cherry | 35 | 2.86x | 0.71x |
| Lemon | 28 | 3.57x | 0.89x |
| Orange | 20 | 5.0x | 1.25x |
| Bell | 10 | 10.0x | 2.50x |
| Bar | 5 | 20.0x | 5.00x |
| Lucky 7 | 2 | 50.0x | 12.50x |
The payouts.slots.* keys exist in GamblingSettings.yml but are not used by the game logic. Actual payouts are always weight-based.
Debt Collector Settings
| Key | Description | Default |
|---|---|---|
debtCollector.spawnChance | Chance (0.0 to 1.0) that the Debt Collector spawns on each check. | 0.5 |
debtCollector.checkIntervalMinutes | How often (in minutes) to check if the Debt Collector should spawn for players in debt. | 60 |
debtCollector.timeoutSeconds | How long (in seconds) before the Debt Collector despawns if not killed. | 600 |
debtCollector.healthMultiplier | Health multiplier for the Debt Collector boss. | 5.0 |
debtCollector.damageMultiplier | Damage multiplier for the Debt Collector boss. | 1.0 |
debtCollector.debtReductionOnPlayerDeath | Amount of debt reduced when the Debt Collector kills the player. | 50.0 |
Economy Safety
The gambling system uses a safety-first transaction model. All bets are deducted and outcomes are financially resolved before any visual animations play. This prevents exploits where a player could disconnect mid-animation to avoid a loss or duplicate a win. If a player disconnects at any point during or after an animation, their financial state is already correct.