Commit 59d32ebf authored by Mahmoud Aglan's avatar Mahmoud Aglan

fix: move all game init inside DOMContentLoaded to fix local mode

External scripts load after inline code; LudoConstants was referenced
before its script tag was parsed in local mode.
Co-Authored-By: 's avatarClaude Opus 4.6 <noreply@anthropic.com>
parent 1dcfdbc8
......@@ -29,7 +29,7 @@ $extraJs = ['/public/js/ludo-constants.js', '/public/js/ludo-ui.js', '/public/js
</div>
<script>
(function() {
document.addEventListener('DOMContentLoaded', function() {
var params = new URLSearchParams(window.location.search);
var mode = params.get('mode') || 'local';
var playerCount = parseInt(params.get('players') || '4', 10);
......@@ -56,12 +56,11 @@ $extraJs = ['/public/js/ludo-constants.js', '/public/js/ludo-ui.js', '/public/js
activePlayers = allPlayers.slice(0, playerCount);
bots = {};
playerNames = {};
activePlayers.forEach(function(p, idx) {
activePlayers.forEach(function(p) {
playerNames[p] = LudoConstants.PLAYER_LABELS[p];
});
}
document.addEventListener('DOMContentLoaded', function() {
LudoUI.renderBoard('#ludo-board');
var isMobile = window.innerWidth < 768;
......@@ -93,15 +92,13 @@ $extraJs = ['/public/js/ludo-constants.js', '/public/js/ludo-ui.js', '/public/js
mode: mode,
bots: bots,
difficulty: difficulty,
playerNames: playerNames,
onGameEnd: arguments.callee
playerNames: playerNames
});
});
}
}
});
});
})();
});
</script>
<?php require __DIR__ . '/../includes/footer.php'; ?>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment