refactor: extract magic numbers to named constants

Frontend: choreography selection ratios, morph trigger chances,
creator cameo/ultimate chances, dodge/counter probabilities.
Server: HP, K-factors, Elo divisor, tier thresholds, fight loop interval.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Dorian
2026-03-08 23:34:05 +00:00
co-authored by Claude Opus 4.6
parent 1731a64ae8
commit 7c8e404cf1
8 changed files with 129 additions and 45 deletions
+33
View File
@@ -0,0 +1,33 @@
// ═══════════════════════════════════════════════════════════════
// Server constants — all tunable magic numbers in one place
// ═══════════════════════════════════════════════════════════════
// --- Fight rules ---
export const MAX_ROUNDS = 10
export const KO_THRESHOLD = 0
export const STARTING_HP = 200
export const MAX_RESPONSE_BYTES = 10 * 1024 // 10KB
export const MAX_ANSWER_LENGTH = 2000
export const MAX_TRASH_TALK_LENGTH = 200
// --- Elo ---
export const ELO_K_FACTOR = 32 // K-factor for real fights
export const ELO_K_FACTOR_MOCK = 12 // Dampened K-factor for mock/classic fights
export const ELO_DIVISOR = 400 // Standard Elo divisor
// --- Tier thresholds ---
export const TIER_THRESHOLDS = [
{ tier: 6, elo: 1900, wins: 40 }, // Legend
{ tier: 5, elo: 1700, wins: 25 }, // Diamond
{ tier: 4, elo: 1500, wins: 15 }, // Platinum
{ tier: 3, elo: 1350, wins: 7 }, // Gold
{ tier: 2, elo: 1200, wins: 3 }, // Silver
{ tier: 1, elo: 0, wins: 1 }, // Bronze
] as const
// --- Default challenge timeout ---
export const DEFAULT_CHALLENGE_TIMEOUT_MS = 8000
// --- Fight loop ---
export const FIGHT_LOOP_INTERVAL_MS = 8000
export const ELO_MATCHING_RANDOMNESS = 150