This commit is contained in:
Eden Kirin
2023-03-27 14:28:15 +02:00
parent b5a49fb53b
commit 0e8775bd08
3 changed files with 15 additions and 4 deletions

View File

@ -34,6 +34,13 @@
</body>
<script>
const BOARD_ICONS = {
PLAYER: "😀",
PLAYER_ON_DESTINATION: "😎",
OBSTACLE: "🔥",
DESTINATION: "🏠",
};
function createBoard(board) {
let html = "";
for (let y = 0; y < board.height; y++) {
@ -76,7 +83,7 @@
function renderPlayers(players) {
players.filter(player => player.active).forEach(player => {
const cell = findCell(player.position);
const playerIcon = player.reached_destination ? "😎" : "😀";
const playerIcon = player.reached_destination ? BOARD_ICONS.PLAYER_ON_DESTINATION : BOARD_ICONS.PLAYER;
if (cell) {
const html = `
<div class="player-tooltip">${player.name}</div>
@ -98,12 +105,12 @@
function renderObstacles(layers) {
const objects = getLayerObjectsOfType(layers, "OBSTACLE");
objects.forEach(obj => {
renderCellContent(obj.position, "🔥");
renderCellContent(obj.position, BOARD_ICONS.OBSTACLE);
});
}
function renderDestination(position) {
renderCellContent(position, "🏠");
renderCellContent(position, BOARD_ICONS.DESTINATION);
}