Skip to content

cornel-pe/casino-mine

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

mines-game

Mines game server. Handles RNG, game logic, and serves the game UI. Communicates with the casino platform server for all wallet operations.

Setup

npm install
npm run dev   # development with auto-reload
npm start     # production

Runs on http://localhost:3000

Platform server must be running on http://localhost:3001


How it works

  1. Platform generates a session token and opens this game in an iframe:
    http://localhost:3000?token=<session-token>
    
  2. Game reads token from URL, player places bet
  3. Game server validates token with platform, calls /wallet/debit
  4. RNG runs — mine positions generated using crypto.randomBytes, stored server-side only
  5. Player clicks tiles — each reveal checked against stored positions
  6. On cashout → game server calls /wallet/credit with payout
  7. On mine hit → round ends, no credit call (platform already has the bet)

API Reference

POST /round/start

Start a new round. Validates token, debits bet, runs RNG.

Request:

{ "token": "session-token", "betAmount": 5.00, "mineCount": 5 }

Response:

{
  "ok": true,
  "roundId": "round_abc123",
  "gridSize": 25,
  "mineCount": 5,
  "newBalance": 95.00
}

Mine positions are NOT returned — stored server-side only.


POST /round/reveal

Reveal a tile.

Request:

{ "roundId": "round_abc123", "tileIndex": 12 }

Response (safe):

{
  "ok": true,
  "result": "safe",
  "tileIndex": 12,
  "multiplier": 1.24,
  "potentialPayout": 6.20,
  "safeRevealed": 2,
  "totalSafe": 20
}

Response (mine):

{
  "ok": true,
  "result": "mine",
  "tileIndex": 12,
  "minePositions": [3, 7, 12, 18, 22],
  "roundId": "round_abc123"
}

POST /round/cashout

Cash out current winnings.

Request:

{ "roundId": "round_abc123" }

Response:

{
  "ok": true,
  "payout": 8.75,
  "multiplier": 1.75,
  "newBalance": 103.75,
  "xp": 5
}

GET /round/:roundId

Get current round state (reconnect support).


Multiplier formula

Uses probability-based calculation with 3% house edge:

multiplier = 0.97 / P(surviving N reveals with M mines on 25 tiles)

More mines = faster multiplier growth = higher risk/reward.


Environment variables

Variable Default Description
PORT 3000 Game server port
PLATFORM_URL http://localhost:3001 Casino platform URL

Releases

No releases published

Packages

 
 
 

Contributors