dgfjnfgxy
This commit is contained in:
parent
d1cc1ab733
commit
e60d1ab841
@ -502,11 +502,7 @@
|
|||||||
|
|
||||||
/* ── Karte in Hand-Slot legen ──────────────────────── */
|
/* ── Karte in Hand-Slot legen ──────────────────────── */
|
||||||
function setHandSlot(id, card) {
|
function setHandSlot(id, card) {
|
||||||
handSlotState[id] = {
|
handSlotState[id] = { card, currentCd: card.cooldown ?? 0 };
|
||||||
card,
|
|
||||||
currentCd: card.cooldown ?? 0,
|
|
||||||
wasReduced: false,
|
|
||||||
};
|
|
||||||
renderHandSlot(id);
|
renderHandSlot(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -526,30 +522,7 @@
|
|||||||
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);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -579,16 +552,15 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Erste 3 in die Hand
|
// Erste 3 in die Hand
|
||||||
for (let i = 0; i < 3; i++) {
|
handCardIds.forEach((id, i) => {
|
||||||
if (expanded[i]) {
|
if (expanded[i]) setHandSlot(id, 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);
|
||||||
}
|
}
|
||||||
@ -1474,6 +1446,58 @@
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
// ═════════════════════════════════════════════
|
||||||
|
// 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")
|
||||||
|
|||||||
1496
views/1v1-battlefield.ejs_old
Normal file
1496
views/1v1-battlefield.ejs_old
Normal file
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user