adhner
This commit is contained in:
parent
01aa316a1e
commit
74ce4ba913
@ -353,17 +353,75 @@
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
/* ── Aufgeben ───────────────────────────────────────── */
|
/* ── Aufgeben Modal ─────────────────────────────────── */
|
||||||
function handleAufgeben() {
|
function handleAufgeben() {
|
||||||
if (!confirm("Wirklich aufgeben? Du erhältst keine Punkte.")) return;
|
// Eigenes Modal statt browser confirm()
|
||||||
|
const modal = document.createElement("div");
|
||||||
|
modal.id = "surrender-modal";
|
||||||
|
modal.style.cssText = "position:fixed;inset:0;z-index:9999;background:rgba(0,0,0,0.8);display:flex;align-items:center;justify-content:center;";
|
||||||
|
modal.innerHTML = `
|
||||||
|
<div style="background:linear-gradient(#2a1a08,#1a0f04);border:2px solid #c8960c;
|
||||||
|
border-radius:14px;padding:32px 40px;text-align:center;max-width:360px;
|
||||||
|
box-shadow:0 20px 60px rgba(0,0,0,0.9);font-family:'Cinzel',serif;">
|
||||||
|
<div style="font-size:40px;margin-bottom:12px;">🏳️</div>
|
||||||
|
<div style="font-size:18px;color:#f0d060;letter-spacing:3px;margin-bottom:10px;">AUFGEBEN?</div>
|
||||||
|
<p style="color:#a08060;font-size:12px;line-height:1.7;margin-bottom:24px;">
|
||||||
|
Willst du wirklich aufgeben?<br>
|
||||||
|
Du erhältst <strong style="color:#e74c3c;">keine Punkte</strong> für dieses Match.
|
||||||
|
</p>
|
||||||
|
<div style="display:flex;gap:12px;justify-content:center;">
|
||||||
|
<button id="surrender-no" style="padding:10px 24px;background:linear-gradient(#1a4a18,#0f2a0e);
|
||||||
|
border:2px solid #4a8a3c;border-radius:8px;color:#a0e090;font-family:'Cinzel',serif;
|
||||||
|
font-size:12px;cursor:pointer;">✖ Weiterkämpfen</button>
|
||||||
|
<button id="surrender-yes" style="padding:10px 24px;background:linear-gradient(#4a1010,#2a0808);
|
||||||
|
border:2px solid #8a3030;border-radius:8px;color:#e07070;font-family:'Cinzel',serif;
|
||||||
|
font-size:12px;cursor:pointer;">🏳 Aufgeben</button>
|
||||||
|
</div>
|
||||||
|
</div>`;
|
||||||
|
document.body.appendChild(modal);
|
||||||
|
|
||||||
|
document.getElementById("surrender-no").addEventListener("click", () => modal.remove());
|
||||||
|
document.getElementById("surrender-yes").addEventListener("click", () => {
|
||||||
|
modal.remove();
|
||||||
socket.emit("player_surrender", { matchId, slot: mySlot });
|
socket.emit("player_surrender", { matchId, slot: mySlot });
|
||||||
|
// Eigene Weiterleitung nach kurzer Verzögerung
|
||||||
|
showSurrenderMessage(false);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ── Nachricht anzeigen + weiterleiten ──────────────── */
|
||||||
|
function showSurrenderMessage(iWon) {
|
||||||
|
const overlay = document.createElement("div");
|
||||||
|
overlay.style.cssText = "position:fixed;inset:0;z-index:9999;background:rgba(0,0,0,0.9);display:flex;flex-direction:column;align-items:center;justify-content:center;font-family:'Cinzel',serif;";
|
||||||
|
overlay.innerHTML = iWon
|
||||||
|
? `<div style="font-size:48px;margin-bottom:16px;">🏆</div>
|
||||||
|
<div style="font-size:28px;color:#f0d060;letter-spacing:4px;">SIEG!</div>
|
||||||
|
<p style="color:#a0e090;font-size:13px;margin-top:12px;">Dein Gegner hat aufgegeben.</p>
|
||||||
|
<p style="color:#606060;font-size:11px;margin-top:8px;">Du wirst weitergeleitet…</p>`
|
||||||
|
: `<div style="font-size:48px;margin-bottom:16px;">🏳️</div>
|
||||||
|
<div style="font-size:28px;color:#e74c3c;letter-spacing:4px;">AUFGEGEBEN</div>
|
||||||
|
<p style="color:#a08060;font-size:13px;margin-top:12px;">Du hast das Match aufgegeben.</p>
|
||||||
|
<p style="color:#606060;font-size:11px;margin-top:8px;">Du wirst weitergeleitet…</p>`;
|
||||||
|
document.body.appendChild(overlay);
|
||||||
|
|
||||||
|
setTimeout(() => {
|
||||||
|
// Immer zur Startseite (launcher) weiterleiten
|
||||||
|
if (window.parent && window.parent !== window) {
|
||||||
|
window.parent.document.getElementById("arena-backdrop")?.remove();
|
||||||
|
window.parent.document.getElementById("arena-popup")?.remove();
|
||||||
|
}
|
||||||
|
window.top.location.href = "/launcher";
|
||||||
|
}, 2500);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ── Spielende Events ───────────────────────────────── */
|
/* ── Spielende Events ───────────────────────────────── */
|
||||||
socket.on("player_surrendered", data => {
|
socket.on("player_surrendered", data => {
|
||||||
/* Overlay sofort anzeigen, Punkte kommen per match_result */
|
|
||||||
const iLost = data.slot === mySlot;
|
const iLost = data.slot === mySlot;
|
||||||
showResultOverlay(iLost ? false : true, null);
|
if (!iLost) {
|
||||||
|
// Ich habe gewonnen (Gegner hat aufgegeben)
|
||||||
|
showSurrenderMessage(true);
|
||||||
|
}
|
||||||
|
// Wenn ich selbst aufgegeben habe, läuft showSurrenderMessage(false) schon
|
||||||
});
|
});
|
||||||
|
|
||||||
/* Punkte-Ergebnis vom Server (kommt kurz nach player_surrendered) */
|
/* Punkte-Ergebnis vom Server (kommt kurz nach player_surrendered) */
|
||||||
@ -429,14 +487,13 @@
|
|||||||
.catch(() => {});
|
.catch(() => {});
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ── Popup schließen ────────────────────────────────── */
|
/* ── Popup schließen → immer zu Launcher ──────────── */
|
||||||
function closePopup() {
|
function closePopup() {
|
||||||
if (window.parent && window.parent !== window) {
|
if (window.parent && window.parent !== window) {
|
||||||
window.parent.document.getElementById("arena-backdrop")?.remove();
|
window.parent.document.getElementById("arena-backdrop")?.remove();
|
||||||
window.parent.document.getElementById("arena-popup")?.remove();
|
window.parent.document.getElementById("arena-popup")?.remove();
|
||||||
} else {
|
|
||||||
window.close();
|
|
||||||
}
|
}
|
||||||
|
window.top.location.href = "/launcher";
|
||||||
}
|
}
|
||||||
|
|
||||||
document.getElementById("result-close-btn").addEventListener("click", closePopup);
|
document.getElementById("result-close-btn").addEventListener("click", closePopup);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user