This commit is contained in:
cay 2026-04-13 11:56:52 +01:00
parent e60d1ab841
commit e54d9c095f
2 changed files with 34 additions and 1554 deletions

View File

@ -502,7 +502,11 @@
/* ── Karte in Hand-Slot legen ──────────────────────── */ /* ── Karte in Hand-Slot legen ──────────────────────── */
function setHandSlot(id, card) { function setHandSlot(id, card) {
handSlotState[id] = { card, currentCd: card.cooldown ?? 0 }; handSlotState[id] = {
card,
currentCd: card.cooldown ?? 0,
wasReduced: false,
};
renderHandSlot(id); renderHandSlot(id);
} }
@ -522,7 +526,30 @@
handCardIds.forEach((id) => { handCardIds.forEach((id) => {
const state = handSlotState[id]; const state = handSlotState[id];
if (!state) return; if (!state) return;
if (state.currentCd > 0) state.currentCd--;
const baseCd = Number(state.card.cooldown || 0);
// Karte war diese Runde spielbar, wurde aber NICHT gespielt
if (state.currentCd <= 0 && !state.wasReduced) {
if (baseCd > 0) {
let reduced = Math.floor(baseCd / 2);
if (reduced < 1) reduced = 1;
state.currentCd = reduced;
} else {
state.currentCd = 0;
}
state.wasReduced = true;
}
// Normales Cooldown runterzählen
else {
if (state.currentCd > 0) {
state.currentCd--;
}
}
renderHandSlot(id); renderHandSlot(id);
}); });
} }
@ -552,15 +579,16 @@
} }
// Erste 3 in die Hand // Erste 3 in die Hand
handCardIds.forEach((id, i) => { for (let i = 0; i < 3; i++) {
if (expanded[i]) setHandSlot(id, expanded[i]); if (expanded[i]) {
}); setHandSlot(handCardIds[i], expanded[i]);
}
}
// Rest als Deck-Queue // Rest als Deck-Queue
deckQueue = expanded.slice(3); deckQueue = expanded.slice(3);
const countEl = document.getElementById("deck-count"); const countEl = document.getElementById("deck-count");
if (countEl) countEl.textContent = deckQueue.length; if (countEl) countEl.textContent = deckQueue.length;
showMulliganOverlay();
} catch (e) { } catch (e) {
console.error("[Battlefield] Deck laden:", e); console.error("[Battlefield] Deck laden:", e);
} }
@ -1446,58 +1474,6 @@
); );
}); });
// ═════════════════════════════════════════════
// MULLIGAN SYSTEM (2x komplette neue Hand)
// ═════════════════════════════════════════════
let mulliganLeft = 2;
let mulliganDone = false;
function showMulliganOverlay() {
const overlay = document.createElement("div");
overlay.id = "mulligan-overlay";
overlay.style.cssText = "position:fixed;inset:0;background:rgba(0,0,0,.88);z-index:9999;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:20px;font-family:'Cinzel',serif;";
overlay.innerHTML = `
<div style="font-size:34px;color:#ffd750;letter-spacing:4px;">STARTHAND</div>
<div style="font-size:14px;color:#ccc;">Du kannst deine 3 Startkarten bis zu 2x komplett neu ziehen</div>
<div style="display:flex;gap:14px;" id="mulligan-cards"></div>
<div style="display:flex;gap:12px;margin-top:10px;">
<button id="btn-mulligan-redraw" style="padding:12px 28px;background:#2e6d2e;color:#fff;border:none;border-radius:8px;cursor:pointer;">Neue Hand (${mulliganLeft})</button>
<button id="btn-mulligan-ready" style="padding:12px 28px;background:#8b1a1a;color:#fff;border:none;border-radius:8px;cursor:pointer;">Bereit</button>
</div>`;
document.body.appendChild(overlay);
renderMulliganCards();
document.getElementById("btn-mulligan-redraw").addEventListener("click", doMulligan);
document.getElementById("btn-mulligan-ready").addEventListener("click", finishMulligan);
}
function renderMulliganCards() {
const wrap=document.getElementById("mulligan-cards"); if(!wrap) return;
wrap.innerHTML="";
for(let i=0;i<3;i++){
const state=handSlotState[handCardIds[i]]; if(!state) continue;
const card=state.card;
const el=document.createElement("div");
el.style.cssText="width:130px;height:190px;border-radius:10px;overflow:hidden;border:2px solid rgba(255,215,80,.4);background:#111;box-shadow:0 8px 20px rgba(0,0,0,.5);";
el.innerHTML=`<img src="/images/cards/${card.image}" style="width:100%;height:100%;object-fit:cover;" onerror="this.src='/images/items/rueckseite.png'">`;
wrap.appendChild(el);
}
}
function doMulligan() {
if(mulliganLeft<=0) return;
for(let i=0;i<3;i++){
const id=handCardIds[i], state=handSlotState[id];
if(state){ deckQueue.push(state.card); handSlotState[id]=null; renderHandSlot(id); }
}
for(let i=deckQueue.length-1;i>0;i--){ const j=Math.floor(Math.random()*(i+1)); [deckQueue[i],deckQueue[j]]=[deckQueue[j],deckQueue[i]]; }
for(let i=0;i<3;i++) drawNextCard();
mulliganLeft--;
renderMulliganCards();
const btn=document.getElementById("btn-mulligan-redraw");
if(btn){ btn.textContent=`Neue Hand (${mulliganLeft})`; if(mulliganLeft<=0){btn.disabled=true;btn.style.opacity=".45";}}
}
function finishMulligan(){ mulliganDone=true; document.getElementById("mulligan-overlay")?.remove(); }
/* ── Event-Listener ─────────────────────────────────── */ /* ── Event-Listener ─────────────────────────────────── */
document document
.getElementById("bereit-btn") .getElementById("bereit-btn")

File diff suppressed because it is too large Load Diff