fix: correct ua27 card number and refresh deck counts

This commit is contained in:
2026-04-08 17:30:46 +09:00
parent eed4604432
commit ebebe1b12d
2 changed files with 13 additions and 51 deletions

View File

@@ -465,60 +465,30 @@
if (searchInput && t.searchPlaceholder) searchInput.placeholder = t.searchPlaceholder; if (searchInput && t.searchPlaceholder) searchInput.placeholder = t.searchPlaceholder;
} }
function getCardTotal(cardNumber) {
return cardList.filter((c) => c.Number === cardNumber).reduce((s, c) => s + c.count, 0);
}
// 전역 핸들러 // 전역 핸들러
window.handleCount = function (imgSrc, delta, event) { window.handleCount = function (imgSrc, delta, event) {
event.stopPropagation(); event.stopPropagation();
const card = cardList.find((c) => c.imgSrc === imgSrc); const card = cardList.find((c) => c.imgSrc === imgSrc);
if (!card) return; if (!card) return;
// 1. 데이터 업데이트 let didChange = false;
const currentTotal = cardList.filter((c) => c.Number === card.Number).reduce((s, c) => s + c.count, 0); const currentTotal = getCardTotal(card.Number);
if (delta > 0 && currentTotal < (card.maxCount || 4)) { if (delta > 0 && currentTotal < (card.maxCount || 4)) {
card.count++; card.count++;
didChange = true;
} else if (delta < 0 && card.count > 0) { } else if (delta < 0 && card.count > 0) {
card.count--; card.count--;
if (card.count === 0) card.key = false; if (card.count === 0) card.key = false;
didChange = true;
} }
// 2. UI 업데이트 if (!didChange) return;
const container = document.querySelector(`.cardContainer[data-imgsrc="${imgSrc}"]`);
if (container) {
const minusBtn = container.querySelector('.minusBtn');
const plusBtn = container.querySelector('.plusBtn');
const countSpan = container.querySelector('.countText');
const keyBtn = container.querySelector('.keyBtn'); // 클래스로 직접 참조
if (countSpan) countSpan.textContent = card.count;
// 마이너스 버튼 제어
if (minusBtn) {
if (card.count > 0) {
minusBtn.classList.remove('invisible');
minusBtn.classList.add('visible');
} else {
minusBtn.classList.remove('visible');
minusBtn.classList.add('invisible');
}
}
// 플러스 버튼 제어 (isMax 결과에 따라 즉시 반영)
if (plusBtn) {
if (isMax(card)) {
plusBtn.classList.remove('visible');
plusBtn.classList.add('invisible');
} else {
plusBtn.classList.remove('invisible');
plusBtn.classList.add('visible');
}
}
// 키 버튼 상태 업데이트
if (keyBtn) {
keyBtn.className = `keyBtn w-full py-1 rounded text-[9px] lg:text-[10px] font-bold border transition-all ${card.key && card.count > 0 ? 'bg-indigo-600 border-indigo-600 text-white shadow-md' : 'bg-white border-slate-200 text-slate-400'}`;
}
}
syncToStorageAndCounters(); syncToStorageAndCounters();
updateCardList();
}; };
window.handleKey = function (imgSrc, event) { window.handleKey = function (imgSrc, event) {
@@ -533,20 +503,12 @@
card.key = true; card.key = true;
} }
const container = document.querySelector(`.cardContainer[data-imgsrc="${imgSrc}"]`);
if (container) {
// 특정 클래스(.keyBtn)를 가진 요소를 정확히 찾아 변경
const keyBtn = container.querySelector('.keyBtn');
if (keyBtn) {
keyBtn.className = `keyBtn w-full py-1 rounded text-[9px] lg:text-[10px] font-bold border transition-all ${card.key && card.count > 0 ? 'bg-indigo-600 border-indigo-600 text-white shadow-md' : 'bg-white border-slate-200 text-slate-400'}`;
}
}
syncToStorageAndCounters(); syncToStorageAndCounters();
updateCardList();
}; };
function isMax(card) { function isMax(card) {
return cardList.filter((c) => c.Number === card.Number).reduce((s, c) => s + c.count, 0) >= (card.maxCount || 4); return getCardTotal(card.Number) >= (card.maxCount || 4);
} }
function updateCardList() { function updateCardList() {

View File

@@ -942,7 +942,7 @@ export const cardList = [
}, },
{ {
imgSrc: '/ua27/EX13BT_GIM-2-059.png', imgSrc: '/ua27/EX13BT_GIM-2-059.png',
Number: 'EX13BT/GIM-2-058', Number: 'EX13BT/GIM-2-059',
count: 0, count: 0,
key: false, key: false,
color: 'Red', color: 'Red',