aetrh
This commit is contained in:
parent
c988486d63
commit
511fc9f17b
@ -145,11 +145,13 @@ export async function loadEvents() {
|
||||
/* ── Booster Zustand ── */
|
||||
let allCards = [];
|
||||
let isSpinning = false;
|
||||
let spinIntervals = [];
|
||||
let spinIntervals = {}; // { index: intervalId }
|
||||
let slotLocked = {}; // { index: true } → verhindert Überschreiben nach reveal
|
||||
|
||||
function clearAllIntervals() {
|
||||
spinIntervals.forEach(id => clearInterval(id));
|
||||
spinIntervals = [];
|
||||
Object.values(spinIntervals).forEach(id => clearInterval(id));
|
||||
spinIntervals = {};
|
||||
slotLocked = {};
|
||||
}
|
||||
|
||||
async function preloadCards() {
|
||||
@ -183,12 +185,13 @@ export async function loadEvents() {
|
||||
|
||||
/* ── Slot drehen – 350ms, damit man die Karten erkennt ── */
|
||||
function startSpinSlot(index) {
|
||||
slotLocked[index] = false;
|
||||
const slot = body.querySelector(`#booster-slot-${index}`);
|
||||
const inner = slot.querySelector(".booster-slot-inner");
|
||||
slot.classList.add("spinning");
|
||||
|
||||
const iv = setInterval(() => {
|
||||
if (!allCards.length) return;
|
||||
if (!allCards.length || slotLocked[index]) return;
|
||||
const rnd = allCards[Math.floor(Math.random() * allCards.length)];
|
||||
inner.innerHTML = cardHTML(rnd, true);
|
||||
}, 350);
|
||||
@ -196,14 +199,17 @@ export async function loadEvents() {
|
||||
spinIntervals[index] = iv;
|
||||
}
|
||||
|
||||
/* ── Slot enthüllen ── */
|
||||
/* ── Slot enthüllen – Sperre setzen BEVOR clearInterval ── */
|
||||
function revealSlot(index, card) {
|
||||
clearInterval(spinIntervals[index]);
|
||||
slotLocked[index] = true; // zuerst sperren
|
||||
clearInterval(spinIntervals[index]); // dann stoppen
|
||||
delete spinIntervals[index];
|
||||
|
||||
const slot = body.querySelector(`#booster-slot-${index}`);
|
||||
const inner = slot.querySelector(".booster-slot-inner");
|
||||
slot.classList.remove("spinning");
|
||||
slot.classList.add("revealed");
|
||||
inner.innerHTML = cardHTML(card, true);
|
||||
inner.innerHTML = cardHTML(card, true); // finale Karte setzen
|
||||
}
|
||||
|
||||
/* ── Stapel klicken ── */
|
||||
|
||||
Loading…
Reference in New Issue
Block a user