This commit is contained in:
cay 2026-04-07 09:45:19 +01:00
parent c2a785c10b
commit 312d04ebf7
4 changed files with 40 additions and 31 deletions

7
app.js
View File

@ -144,7 +144,7 @@ app.get("/api/building/:id", requireLogin, async (req, res) => {
const buildingInfo = info[0] || {}; const buildingInfo = info[0] || {};
res.json({ res.json({
name: buildingInfo.name || "Gebäude", name: buildingInfo.name || "Gebäude",
type: buildingId, type: Number(buildingId), // als Number damit buildingModules[type] im Frontend matcht
level: building.level, level: building.level,
points: building.points, points: building.points,
nextLevelPoints: nextLevel[0]?.required_points || null, nextLevelPoints: nextLevel[0]?.required_points || null,
@ -319,11 +319,6 @@ app.get("/api/buildings", requireLogin, async (req, res) => {
app.use(express.json()); app.use(express.json());
app.use(express.urlencoded({ extended: true })); app.use(express.urlencoded({ extended: true }));
/* ========================
Static Files
======================== */
app.use(express.static(path.join(__dirname, "public"))); app.use(express.static(path.join(__dirname, "public")));
/* ======================== /* ========================

View File

@ -259,7 +259,7 @@ async function handle1v1Click(card) {
me = await res.json(); me = await res.json();
} catch (err) { } catch (err) {
console.error("[1v1] Spielerdaten konnten nicht geladen werden:", err); console.error("[1v1] Spielerdaten konnten nicht geladen werden:", err);
showArenaError("Spielerdaten konnten nicht geladen werden."); showArenaError("Spielerdaten konnten nicht geladen werden. (Eingeloggt?)");
return; return;
} }
@ -378,16 +378,16 @@ function openArenaPopup(src, opponentName, matchId) {
/* ── UI Hilfsfunktionen ────────────────────────────────────────────────────── */ /* ── UI Hilfsfunktionen ────────────────────────────────────────────────────── */
function setCardSearching(card, searching) { function setCardSearching(card, searching) {
const label = card.querySelector(".arena-mode-label"); const label = card.querySelector(".arena-mode-label");
const desc = card.querySelector(".arena-mode-desc"); const desc = card.querySelector(".arena-mode-desc");
if (searching) { if (searching) {
card.classList.add("searching"); card.classList.add("searching");
label.textContent = "⏳ Suche…"; label.textContent = "⏳ Suche…";
desc.textContent = "Warte auf passenden Gegner…"; desc.textContent = "Warte auf passenden Gegner…";
} else { } else {
card.classList.remove("searching"); card.classList.remove("searching");
label.textContent = "1v1"; label.textContent = "1v1";
desc.textContent = "Einzelkampf Beweis deine Stärke im Duell"; desc.textContent = "Einzelkampf Beweis deine Stärke im Duell";
} }
} }
@ -396,9 +396,9 @@ function showQueueStatus(myLevel, poolSize) {
if (!box) return; if (!box) return;
const range = 5; const range = 5;
const min = Math.max(1, myLevel - range); const min = Math.max(1, myLevel - range);
const max = myLevel + range; const max = myLevel + range;
const pool = poolSize ? ` · ${poolSize} Spieler im Pool` : ""; const pool = poolSize ? ` · ${poolSize} Spieler im Pool` : "";
box.style.display = "block"; box.style.display = "block";
box.innerHTML = ` box.innerHTML = `

View File

@ -1,3 +1,4 @@
import { loadArena } from "./buildings/arena.js";
import { loadCharacterHouse } from "./buildings/character-house.js"; import { loadCharacterHouse } from "./buildings/character-house.js";
import { loadBlackmarket } from "./buildings/blackmarket.js"; import { loadBlackmarket } from "./buildings/blackmarket.js";
import { loadMine } from "./buildings/mine.js"; import { loadMine } from "./buildings/mine.js";
@ -8,12 +9,16 @@ const tooltip = document.getElementById("map-tooltip");
const tooltipCache = {}; const tooltipCache = {};
// Tooltip verstecken wenn Maus über Quickmenu, Popup oder QM-Popups fährt // Tooltip verstecken wenn Maus über Quickmenu, Popup oder QM-Popups fährt
document.getElementById("quickmenu-panel")?.addEventListener("mouseenter", () => { document
tooltip.style.display = "none"; .getElementById("quickmenu-panel")
}); ?.addEventListener("mouseenter", () => {
document.getElementById("building-popup")?.addEventListener("mouseenter", () => { tooltip.style.display = "none";
tooltip.style.display = "none"; });
}); document
.getElementById("building-popup")
?.addEventListener("mouseenter", () => {
tooltip.style.display = "none";
});
document.querySelectorAll(".qm-popup").forEach((p) => { document.querySelectorAll(".qm-popup").forEach((p) => {
p.addEventListener("mouseenter", () => { p.addEventListener("mouseenter", () => {
tooltip.style.display = "none"; tooltip.style.display = "none";
@ -24,9 +29,10 @@ document.getElementById("qm-overlay")?.addEventListener("mouseenter", () => {
}); });
const buildingModules = { const buildingModules = {
11: loadCharacterHouse, // Tabs ausblenden, eigenes UI 1: loadArena, // Arena eigenes UI, Tabs ausblenden
12: loadBlackmarket, // Tabs ausblenden, eigenes UI 10: loadMine, // Mine Tabs bleiben sichtbar
10: loadMine, // Tabs bleiben sichtbar, nur Aktionen-Tab befüllen 11: loadCharacterHouse, // Charakterhaus eigenes UI, Tabs ausblenden
12: loadBlackmarket, // Schwarzmarkt eigenes UI, Tabs ausblenden
}; };
// Gebäude die ihre eigenen Tabs behalten sollen // Gebäude die ihre eigenen Tabs behalten sollen
@ -98,7 +104,7 @@ async function openBuildingPopup(url) {
tabs.style.display = "none"; tabs.style.display = "none";
infoTab.innerHTML = `<div class="building-ui"></div>`; infoTab.innerHTML = `<div class="building-ui"></div>`;
} }
buildingModules[buildingType](url.split('/').pop()); buildingModules[buildingType](url.split("/").pop());
} }
// Punkte-Check: Upgrade nur möglich wenn genug Punkte vorhanden // Punkte-Check: Upgrade nur möglich wenn genug Punkte vorhanden
@ -132,8 +138,8 @@ async function openBuildingPopup(url) {
</div> </div>
</div> </div>
<button class="popup-upgrade-btn" id="upgrade-btn" data-building="${url.split('/').pop()}" <button class="popup-upgrade-btn" id="upgrade-btn" data-building="${url.split("/").pop()}"
${!canUpgrade ? 'disabled style="opacity:0.4;cursor:not-allowed;"' : ''}> ${!canUpgrade ? 'disabled style="opacity:0.4;cursor:not-allowed;"' : ""}>
UPGRADE STARTEN UPGRADE STARTEN
</button> </button>
${!hasEnoughPoints ? `<p style="color:#ff6666;font-size:12px;margin-top:8px;text-align:center;">Noch ${data.upgradeRequiredPoints - data.points} Punkte bis zum Upgrade.</p>` : ""} ${!hasEnoughPoints ? `<p style="color:#ff6666;font-size:12px;margin-top:8px;text-align:center;">Noch ${data.upgradeRequiredPoints - data.points} Punkte bis zum Upgrade.</p>` : ""}
@ -174,7 +180,11 @@ document.addEventListener("click", async (e) => {
const data = await res.json(); const data = await res.json();
if (!res.ok || data.error) { if (!res.ok || data.error) {
window.showNotification(data.error || "Upgrade fehlgeschlagen.", "Upgrade", "⚒️"); window.showNotification(
data.error || "Upgrade fehlgeschlagen.",
"Upgrade",
"⚒️",
);
btn.disabled = false; btn.disabled = false;
btn.textContent = "⚒ UPGRADE STARTEN ⚒"; btn.textContent = "⚒ UPGRADE STARTEN ⚒";
return; return;
@ -183,7 +193,7 @@ document.addEventListener("click", async (e) => {
window.showNotification( window.showNotification(
`Upgrade erfolgreich!\nNeues Level: ${data.newLevel}\n\nKosten: ${data.cost.wood} Holz, ${data.cost.stone} Stein, ${data.cost.gold} Gold`, `Upgrade erfolgreich!\nNeues Level: ${data.newLevel}\n\nKosten: ${data.cost.wood} Holz, ${data.cost.stone} Stein, ${data.cost.gold} Gold`,
"Upgrade", "Upgrade",
"⚒️" "⚒️",
); );
// Popup mit frischen Daten neu laden // Popup mit frischen Daten neu laden
@ -191,10 +201,13 @@ document.addEventListener("click", async (e) => {
// HUD aktualisieren // HUD aktualisieren
import("/js/hud.js").then(({ loadHud }) => loadHud()); import("/js/hud.js").then(({ loadHud }) => loadHud());
} catch (err) { } catch (err) {
console.error("Upgrade Fehler:", err); console.error("Upgrade Fehler:", err);
window.showNotification("Fehler beim Upgrade. Bitte erneut versuchen.", "Fehler", "⚠️"); window.showNotification(
"Fehler beim Upgrade. Bitte erneut versuchen.",
"Fehler",
"⚠️",
);
btn.disabled = false; btn.disabled = false;
btn.textContent = "⚒ UPGRADE STARTEN ⚒"; btn.textContent = "⚒ UPGRADE STARTEN ⚒";
} }
@ -275,7 +288,7 @@ document.querySelectorAll(".building").forEach((building) => {
if (y + th > window.innerHeight - 10) y = e.clientY - th - 10; if (y + th > window.innerHeight - 10) y = e.clientY - th - 10;
tooltip.style.left = x + "px"; tooltip.style.left = x + "px";
tooltip.style.top = y + "px"; tooltip.style.top = y + "px";
}); });
building.addEventListener("mouseleave", () => { building.addEventListener("mouseleave", () => {

View File

@ -89,6 +89,7 @@
<link rel="stylesheet" href="/css/launcher.css" /> <link rel="stylesheet" href="/css/launcher.css" />
<link rel="stylesheet" href="/css/global.css" /> <link rel="stylesheet" href="/css/global.css" />
<link rel="stylesheet" href="/css/building.css" /> <link rel="stylesheet" href="/css/building.css" />
<link rel="stylesheet" href="/css/arena.css" />
<link rel="stylesheet" href="/css/popup.css" /> <link rel="stylesheet" href="/css/popup.css" />
<link rel="stylesheet" href="/css/quickmenu.css" /> <link rel="stylesheet" href="/css/quickmenu.css" />
<link rel="stylesheet" href="/css/events.css" /> <link rel="stylesheet" href="/css/events.css" />
@ -991,12 +992,12 @@
})(); })();
</script> </script>
<script type="module" src="/js/map-ui.js"></script>
<script src="/socket.io/socket.io.js"></script> <script src="/socket.io/socket.io.js"></script>
<script> <script>
window.playerName = "<%= character.name %>"; window.playerName = "<%= character.name %>";
</script> </script>
<script src="/js/chat.js"></script> <script src="/js/chat.js"></script>
<script type="module" src="/js/map-ui.js"></script>
<script type="module" src="/js/quickmenu.js"></script> <script type="module" src="/js/quickmenu.js"></script>
<script type="module"> <script type="module">
import { loadHud } from "/js/hud.js"; import { loadHud } from "/js/hud.js";