-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathui.js
More file actions
35 lines (31 loc) · 1.39 KB
/
ui.js
File metadata and controls
35 lines (31 loc) · 1.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
// UI Element References
const roomNameElement = document.getElementById('room-name');
const inventoryElement = document.getElementById('inventory');
const gameMessageElement = document.getElementById('game-message');
// UI Update Function
// Needs access to: currentRoom, inventory
function updateUI(currentRoom, inventory) {
if (roomNameElement) {
roomNameElement.textContent = `Room: ${currentRoom.name}`;
}
if (inventoryElement) {
const inventoryText = inventory.length > 0 ? inventory.join(', ') : 'Empty';
inventoryElement.textContent = `Inventory: ${inventoryText}`;
}
// --- NEW: Update Spear Touch Button Visibility ---
const touchSpearButton = document.getElementById('touch-spear');
// Only try to update if the button exists (i.e., touch controls were initialized)
if (touchSpearButton) {
const hasSpear = inventory.includes('spear');
if (hasSpear) {
touchSpearButton.classList.remove('hidden');
// console.log("UI Update: Showing spear button");
} else {
touchSpearButton.classList.add('hidden');
// console.log("UI Update: Hiding spear button");
}
}
// --- End Spear Touch Button Visibility ---
// Note: gameMessageElement is updated directly in main.js for win/lose conditions
}
export { roomNameElement, inventoryElement, gameMessageElement, updateUI };