mirror of
https://github.com/Such-Software/wownerogue.git
synced 2026-10-20 23:58:33 +02:00
fix: tiny anti-instant-death grace on block timeout (random timing preserved)
Random block timing is the core mechanic and is intentionally NOT softened — early entry is a knowingly-risky bet. The only change is a small configurable grace (GAME_START_GRACE_MS, default 2000ms, 0 to disable) so a block landing in the same instant a game starts can't kill the player before the dungeon even renders or before their first move is possible (100ms move cooldown). (Replaces an earlier over-reaching "uniform time budget" idea that would have defeated the random-timing mechanic.)
This commit is contained in:
@@ -348,6 +348,12 @@ RPC_POLL_INTERVAL=2000
|
||||
# req.ip. Leave unset/false for direct exposure, otherwise clients could spoof their IP.
|
||||
# TRUST_PROXY=true
|
||||
|
||||
# Anti-instant-death grace (ms) before a block-timeout can end a game. This is NOT a
|
||||
# fairness floor — random block timing is the core mechanic. It only prevents the
|
||||
# degenerate case where a block lands the instant a game starts (before the dungeon
|
||||
# renders / before the first move is possible). Default 2000 (2s); set 0 to disable.
|
||||
# GAME_START_GRACE_MS=2000
|
||||
|
||||
# =============================================================================
|
||||
# SECTION 12: SERVER & MULTI-INSTANCE
|
||||
# =============================================================================
|
||||
|
||||
@@ -1038,10 +1038,18 @@ class SocketHandlers {
|
||||
// Snapshot the entries first: handleGameOver mutates activeGames (it deletes the
|
||||
// entry), so iterating the live Map could skip games. Process sequentially and
|
||||
// await each game-over rather than firing them all off concurrently on one tick.
|
||||
// Anti-instant-death guard ONLY (default 2s, set 0 to disable). Random block timing
|
||||
// is the game's core mechanic and is deliberately preserved — this is not a fairness
|
||||
// floor. It only avoids the degenerate case where a block lands in the same instant
|
||||
// the game starts and the player dies before the dungeon even renders / before their
|
||||
// first move is possible (100ms move cooldown).
|
||||
const graceMs = (() => { const v = parseInt(process.env.GAME_START_GRACE_MS, 10); return Number.isFinite(v) ? v : 2000; })();
|
||||
const now = Date.now();
|
||||
const snapshot = Array.from(this.activeGames.entries());
|
||||
for (const [socketId, game] of snapshot) {
|
||||
const user = this.connectionHandler.getUserBySocket(socketId);
|
||||
if (user && user.blockRec && currentHeight > user.blockRec) {
|
||||
const elapsedMs = now - (game.startedAt || now);
|
||||
if (user && user.blockRec && currentHeight > user.blockRec && elapsedMs >= graceMs) {
|
||||
if (this.debugManager.CONSOLE_LOGGING) {
|
||||
console.log(`💀 GAME TIMEOUT for player ${socketId}: entered on block ${user.blockRec}, died on block ${currentHeight}`);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user