feat: Add universal victory celebration modal, chamber item requirements, and fix broom & cauldron displays
This commit is contained in:
+46
-16
@@ -35,7 +35,10 @@
|
||||
|
||||
window.startFlight = function() {
|
||||
const overlay = document.getElementById('broomStartOverlay');
|
||||
if (overlay) overlay.style.display = 'none';
|
||||
if (overlay) {
|
||||
overlay.classList.add('hidden');
|
||||
overlay.style.display = 'none';
|
||||
}
|
||||
|
||||
rings.length = 0;
|
||||
rings.push({ x: width + 60, y: height * 0.4, radius: 25, speed: 3.5, golden: false, collected: false, scale: 1, alpha: 1, pulse: 0 });
|
||||
@@ -57,6 +60,20 @@
|
||||
if (window.navigator && window.navigator.vibrate) window.navigator.vibrate(40);
|
||||
};
|
||||
|
||||
// Explicitly bind click and pointerdown to start button for instant mobile activation
|
||||
const startFlightBtn = document.getElementById('startFlightBtn');
|
||||
if (startFlightBtn) {
|
||||
const onStartTrigger = (e) => {
|
||||
if (e) {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
}
|
||||
window.startFlight();
|
||||
};
|
||||
startFlightBtn.addEventListener('click', onStartTrigger);
|
||||
startFlightBtn.addEventListener('pointerdown', onStartTrigger);
|
||||
}
|
||||
|
||||
// Player (Broomstick)
|
||||
const player = {
|
||||
x: 90,
|
||||
@@ -505,7 +522,7 @@
|
||||
requestAnimationFrame(loop);
|
||||
|
||||
async function onCourseWin(elapsedSec) {
|
||||
if (window.soundFX) window.soundFX.playMagicSuccess();
|
||||
let newItem = null;
|
||||
try {
|
||||
const res = await fetch('/api/broom/complete', {
|
||||
method: 'POST',
|
||||
@@ -513,23 +530,36 @@
|
||||
body: JSON.stringify({ score: score, time_taken: elapsedSec })
|
||||
});
|
||||
const data = await res.json();
|
||||
if (data.new_item && window.notifyNewItem) {
|
||||
window.notifyNewItem(data.new_item);
|
||||
}
|
||||
if (data.new_item) newItem = data.new_item;
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
|
||||
modalTitle.innerText = "🏆 Ring-Parcours Gemeistert!";
|
||||
modalText.innerHTML = `
|
||||
Mit atemberaubenden Manövern hast du alle <strong>${TOTAL_RINGS_NEEDED} goldenen Ringe</strong> durchflogen!<br><br>
|
||||
<strong>Flugzeit:</strong> ${elapsedSec} Sekunden<br>
|
||||
<strong>Punkte:</strong> ${score}<br><br>
|
||||
Madam Hooch nickt anerkennend und überreicht dir die Flug-Auszeichnung!<br>
|
||||
Das Tor zur nächsten Kammer steht offen!
|
||||
`;
|
||||
modalBtn.innerText = "Weiter zum Zauberspruch-Duell 🪄";
|
||||
modalBtn.onclick = () => { window.location.href = '/duel'; };
|
||||
modalBackdrop.classList.add('show');
|
||||
if (!newItem) {
|
||||
newItem = {
|
||||
id: "winged_key",
|
||||
name: "Geflügelter Schlüssel",
|
||||
icon: "🗝️",
|
||||
desc: "Ein surrender Schlüssel mit Libellenflügeln. Er öffnet die Tür zur Duellier-Kammer!"
|
||||
};
|
||||
}
|
||||
|
||||
if (window.showChamberVictory) {
|
||||
window.showChamberVictory({
|
||||
chamberBadge: "Kammer I: Ring-Flug",
|
||||
title: "🏆 Ring-Parcours Gemeistert!",
|
||||
statsHtml: `<span>⏱️ Flugzeit: <strong>${elapsedSec}s</strong></span><span>✨ Punkte: <strong>${score} Pkt</strong></span><span>⭕ Ringe: <strong>${TOTAL_RINGS_NEEDED}/${TOTAL_RINGS_NEEDED}</strong></span>`,
|
||||
item: newItem,
|
||||
storyText: "Mit einem meisterhaften Sturzflug fängst du den surrenden <strong>geflügelten Schlüssel</strong>! Madam Hoochs Silberpfeife ertönt anerkennend über dem Schloss. Die massive Eichentür zur verzauberten <strong>Duellier-Kammer</strong> öffnet sich!",
|
||||
nextUrl: "/duel",
|
||||
nextBtnText: "➔ Weiter zu Kammer II: Spruch-Duell 🪄"
|
||||
});
|
||||
} else {
|
||||
modalTitle.innerText = "🏆 Ring-Parcours Gemeistert!";
|
||||
modalText.innerHTML = `Mit atemberaubenden Manövern hast du alle <strong>${TOTAL_RINGS_NEEDED} goldenen Ringe</strong> durchflogen!<br>Flugzeit: ${elapsedSec}s · Punkte: ${score}`;
|
||||
modalBtn.innerText = "Weiter zum Zauberspruch-Duell 🪄";
|
||||
modalBtn.onclick = () => { window.location.href = '/duel'; };
|
||||
modalBackdrop.classList.add('show');
|
||||
}
|
||||
}
|
||||
})();
|
||||
|
||||
Reference in New Issue
Block a user