fix credits display p3 and update .env.example

This commit is contained in:
jwinterm
2026-02-20 11:11:51 -05:00
parent 101083b9c1
commit da6763886a
4 changed files with 45 additions and 4 deletions
+25
View File
@@ -203,6 +203,24 @@ CREDITS_PAYOUT_TREASURE=3.0 # Same as direct mode
#
CREDITS_PACKAGES='[{"id":"small","credits":10,"price":"900000000000","bonus":0},{"id":"medium","credits":20,"price":"1700000000000","bonus":0},{"id":"large","credits":50,"price":"4000000000000","bonus":0}]'
# =============================================================================
# SECTION 6b: EARLY ENTRY
# =============================================================================
# Early entry lets players start a game immediately without waiting for the
# next block. Risk: if a new block arrives before they escape, the game ends.
#
# Disabled by default for direct (paid-per-game) mode since players paid for
# a full block window. Useful for free and credits modes.
# Master toggle
EARLY_ENTRY_ENABLED=true
# Allow early entry in free mode?
EARLY_ENTRY_FREE_MODE=true
# Allow early entry in credits mode?
EARLY_ENTRY_CREDITS_MODE=true
# =============================================================================
# SECTION 7: PAYOUT SETTINGS
# =============================================================================
@@ -233,6 +251,9 @@ PAYOUT_MAX_RETRIES=3
# Max payouts to send in one batch (wallet RPC can timeout on large batches)
MAX_PAYOUT_BATCH_SIZE=50
# How often to retry failed/stuck payouts (milliseconds). Default: 300000 (5 min)
# PAYOUT_RETRY_INTERVAL_MS=300000
# =============================================================================
# SECTION 8: ANTI-ABUSE LIMITS
# =============================================================================
@@ -294,6 +315,10 @@ RPC_POLL_INTERVAL=2000
# Use in requests:
# curl -H "X-Admin-Key: your-key" http://localhost:3000/api/admin/...
# Allowed origins for admin API CORS (comma-separated, only needed for cross-origin)
# Same-origin requests are always allowed. Leave unset if admin panel is on same host.
# ALLOWED_ORIGINS=https://admin.example.com
# =============================================================================
# SECTION 12: SERVER & MULTI-INSTANCE
# =============================================================================
+4
View File
@@ -308,6 +308,10 @@ class PaymentConfigManager {
config.preferences.allowMixedMode = config.modes.credits.allowMixedMode;
config.preferences.preferCreditsFirst = parseBoolean(process.env.PREFER_CREDITS_FIRST, config.preferences.preferCreditsFirst);
config.earlyEntry.enabled = parseBoolean(process.env.EARLY_ENTRY_ENABLED, config.earlyEntry.enabled);
config.earlyEntry.allowInFreeMode = parseBoolean(process.env.EARLY_ENTRY_FREE_MODE, config.earlyEntry.allowInFreeMode);
config.earlyEntry.allowInCreditsMode = parseBoolean(process.env.EARLY_ENTRY_CREDITS_MODE, config.earlyEntry.allowInCreditsMode);
return config;
}
+3 -3
View File
@@ -1066,9 +1066,9 @@ class GameModeManager {
payouts: this.directPayoutMultipliers.escape > 0 || this.creditPayoutMultipliers.escape > 0
},
earlyEntry: {
enabled: paymentConfig.earlyEntry?.enabled ?? false,
allowInFreeMode: paymentConfig.earlyEntry?.allowInFreeMode ?? false,
allowInCreditsMode: paymentConfig.earlyEntry?.allowInCreditsMode ?? false
enabled: this.configSnapshot?.earlyEntry?.enabled ?? false,
allowInFreeMode: this.configSnapshot?.earlyEntry?.allowInFreeMode ?? false,
allowInCreditsMode: this.configSnapshot?.earlyEntry?.allowInCreditsMode ?? false
},
// Smirk wallet integration (disabled for Monero stagenet)
smirkEnabled: process.env.SMIRK_ENABLED !== 'false'
+13 -1
View File
@@ -443,12 +443,24 @@ class SocketHandlers {
socket.on('player_move', (moveData) => this.movementManager.handleMove(socket.id, moveData));
socket.on('disconnect', () => this.handleDisconnect(socket));
socket.on('debug_ping', (data) => this.handleDebugPing(socket, data));
socket.on('register_client', (data) => {
socket.on('register_client', async (data) => {
this.connectionHandler.handleRegisterClient(socket, data);
// Re-send game mode info after client registers handlers (fixes race condition)
if (this.gameModeManager) {
socket.emit('game_mode_info', this.gameModeManager.getGameModeInfo());
}
// Re-send credits_update (same race condition — event may arrive before handlers register)
if (this.sessionManager) {
try {
const sessionUser = await this.sessionManager.getBySocket(socket.id);
if (sessionUser) {
socket.emit('credits_update', {
balance: sessionUser.credits || 0,
creditsPerGame: this.gameModeManager?.creditsPerGameCost || 1
});
}
} catch (e) { /* ignore — credits will update on next action */ }
}
});
socket.on('auto_start', () => this.handleAutoStart(socket)); // New handler for start button
socket.on('early_entry', () => this.handleEarlyEntry(socket)); // Early entry without waiting for block