feat: Card Kingdom prices, shopping cart export, and hover panel fixes (#73)

* feat: add CK prices, shopping cart export, and hover panel fixes

* fix: include commander in Buy This Deck cart export
This commit is contained in:
mwisnowski 2026-04-04 19:59:03 -07:00 committed by GitHub
parent dd996939e6
commit 69d84cc414
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
24 changed files with 899 additions and 146 deletions

View file

@ -82,6 +82,17 @@ async def _lifespan(app: FastAPI): # pragma: no cover - simple infra glue
get_similarity() # Pre-initialize singleton (one-time cost: ~2-3s)
except Exception:
pass
# Warm up price cache in background so first deck view request is fast
try:
import threading as _threading
from .services.price_service import get_price_service as _get_ps
_ps = _get_ps()
_t = _threading.Thread(target=_ps._ensure_loaded, daemon=True, name="price-cache-warmup")
_t.start()
_t2 = _threading.Thread(target=_ps._ensure_ck_loaded, daemon=True, name="ck-price-cache-warmup")
_t2.start()
except Exception:
pass
# Start price auto-refresh scheduler (optional, 1 AM UTC daily)
if PRICE_AUTO_REFRESH:
try:

View file

@ -601,6 +601,13 @@ async def decks_pickups(request: Request, name: str) -> HTMLResponse:
except Exception:
pass
owned: set[str] = set()
try:
from ..services.build_utils import owned_set as _owned_set
owned = _owned_set()
except Exception:
pass
return templates.TemplateResponse(
"decks/pickups.html",
{
@ -612,6 +619,7 @@ async def decks_pickups(request: Request, name: str) -> HTMLResponse:
"error": error_msg,
"stale_prices": stale_prices,
"stale_prices_global": stale_prices_global,
"owned_names": owned,
},
)

View file

@ -68,9 +68,11 @@ async def get_card_price(
name = unquote(card_name).strip()
svc = get_price_service()
price = svc.get_price(name, region=region, foil=foil)
ck_price = svc.get_ck_price(name)
return JSONResponse({
"card_name": name,
"price": price,
"ck_price": ck_price,
"region": region,
"foil": foil,
"found": price is not None,

View file

@ -468,15 +468,18 @@ class BudgetEvaluatorService(BaseService):
# Batch price lookup for all candidates
candidate_names = list(candidates.keys())
prices = self._price_svc.get_prices_batch(candidate_names, region=region, foil=foil)
ck_prices = self._price_svc.get_ck_prices_batch(candidate_names)
results = []
for name, info in candidates.items():
price = prices.get(name)
if price is None or price > max_price:
continue
ck_price = ck_prices.get(name)
results.append({
"name": name,
"price": round(price, 2),
"ck_price": round(ck_price, 2) if ck_price is not None else None,
"tags": info["tags"],
"shared_tags": sorted(info["shared_tags"]),
})
@ -540,13 +543,11 @@ class BudgetEvaluatorService(BaseService):
def _get_card_tags(self, card_name: str) -> List[str]:
"""Look up theme tags for a single card from the card index."""
try:
from code.web.services.card_index import maybe_build_index, _CARD_INDEX
from code.web.services.card_index import maybe_build_index, lookup_card
maybe_build_index()
needle = card_name.lower()
for cards in _CARD_INDEX.values():
for c in cards:
if c.get("name", "").lower() == needle:
return list(c.get("tags", []))
entry = lookup_card(card_name)
if entry:
return list(entry.get("tags", []))
except Exception:
pass
return []
@ -554,17 +555,14 @@ class BudgetEvaluatorService(BaseService):
def _get_card_broad_type(self, card_name: str) -> Optional[str]:
"""Return the first matching broad MTG type for a card (e.g. 'Land', 'Creature')."""
try:
from code.web.services.card_index import maybe_build_index, _CARD_INDEX
from code.web.services.card_index import maybe_build_index, lookup_card
maybe_build_index()
needle = card_name.lower()
for cards in _CARD_INDEX.values():
for c in cards:
if c.get("name", "").lower() == needle:
type_line = c.get("type_line", "")
for broad in _BROAD_TYPES:
if broad in type_line:
return broad
return None
entry = lookup_card(card_name)
if entry:
type_line = entry.get("type_line", "")
for broad in _BROAD_TYPES:
if broad in type_line:
return broad
except Exception:
pass
return None
@ -620,16 +618,13 @@ class BudgetEvaluatorService(BaseService):
# Collect all unique tags from the current deck
deck_tags: Set[str] = set()
try:
from code.web.services.card_index import maybe_build_index, _CARD_INDEX
from code.web.services.card_index import maybe_build_index, _CARD_INDEX, lookup_card
maybe_build_index()
for name in decklist:
needle = name.lower()
for cards in _CARD_INDEX.values():
for c in cards:
if c.get("name", "").lower() == needle:
deck_tags.update(c.get("tags", []))
break
card_entry = lookup_card(name)
if card_entry:
deck_tags.update(card_entry.get("tags", []))
if not deck_tags:
return []
@ -664,6 +659,7 @@ class BudgetEvaluatorService(BaseService):
top_candidates = sorted(candidates.values(), key=lambda x: x["score"], reverse=True)[:200]
names = [c["name"] for c in top_candidates]
prices = self._price_svc.get_prices_batch(names, region=region, foil=foil)
ck_prices = self._price_svc.get_ck_prices_batch(names)
tier_ceilings = self.calculate_tier_ceilings(budget_remaining)
pickups: List[Pickup] = []
@ -679,9 +675,11 @@ class BudgetEvaluatorService(BaseService):
tier = "M"
if price <= tier_ceilings["S"]:
tier = "S"
ck_price = ck_prices.get(c["name"])
pickups.append({
"card": c["name"],
"price": round(price, 2),
"ck_price": round(ck_price, 2) if ck_price is not None else None,
"tier": tier,
"priority": c["score"],
"tags": c["tags"],

View file

@ -27,6 +27,8 @@ RARITY_COL = "rarity"
_CARD_INDEX: Dict[str, List[Dict[str, Any]]] = {}
_CARD_INDEX_MTIME: float | None = None
# Reverse lookup: lowercase card name → card dict (first occurrence per name)
_NAME_INDEX: Dict[str, Dict[str, Any]] = {}
_RARITY_NORM = {
"mythic rare": "mythic",
@ -50,7 +52,7 @@ def maybe_build_index() -> None:
M4: Loads from all_cards.parquet instead of CSV files.
"""
global _CARD_INDEX, _CARD_INDEX_MTIME
global _CARD_INDEX, _CARD_INDEX_MTIME, _NAME_INDEX
try:
from path_util import get_processed_cards_path
@ -99,6 +101,14 @@ def maybe_build_index() -> None:
})
_CARD_INDEX = new_index
# Build name → card reverse index for O(1) lookups
new_name_index: Dict[str, Dict[str, Any]] = {}
for cards in new_index.values():
for c in cards:
key = c.get("name", "").lower()
if key and key not in new_name_index:
new_name_index[key] = c
_NAME_INDEX = new_name_index
_CARD_INDEX_MTIME = latest
except Exception:
# Defensive: if anything fails, leave index unchanged
@ -107,9 +117,20 @@ def maybe_build_index() -> None:
def get_tag_pool(tag: str) -> List[Dict[str, Any]]:
return _CARD_INDEX.get(tag, [])
def lookup_card(name: str) -> Optional[Dict[str, Any]]:
"""O(1) lookup of a card dict by name. Returns None if not found."""
return _NAME_INDEX.get(name.lower().strip()) if name else None
def lookup_commander(name: Optional[str]) -> Optional[Dict[str, Any]]:
if not name:
return None
# Fast path via name index
result = _NAME_INDEX.get(name.lower().strip())
if result is not None:
return result
# Fallback: full scan (handles index not yet built)
needle = name.lower().strip()
for tag_cards in _CARD_INDEX.values():
for c in tag_cards:

View file

@ -30,6 +30,8 @@ logger.addHandler(logging_util.stream_handler)
_CACHE_TTL_SECONDS = 86400 # 24 hours
_BULK_DATA_FILENAME = "scryfall_bulk_data.json"
_PRICE_CACHE_FILENAME = "prices_cache.json"
_CK_CACHE_FILENAME = "ck_prices_cache.json"
_CK_API_URL = "https://api.cardkingdom.com/api/v2/pricelist"
class PriceService(BaseService):
@ -68,6 +70,14 @@ class PriceService(BaseService):
self._miss_count = 0
self._refresh_thread: Optional[threading.Thread] = None
# CK price cache: {normalized_card_name: float (cheapest non-foil retail)}
self._ck_cache_path: str = os.path.join(card_files_dir(), _CK_CACHE_FILENAME)
self._ck_cache: Dict[str, float] = {}
self._ck_loaded: bool = False
# scryfall_id map built during _rebuild_cache: {name.lower(): scryfall_id}
self._scryfall_id_map: Dict[str, str] = {}
# ------------------------------------------------------------------
# Public API
# ------------------------------------------------------------------
@ -157,6 +167,35 @@ class PriceService(BaseService):
"bulk_data_available": os.path.exists(self._bulk_path),
}
# ------------------------------------------------------------------
# CK Public API
# ------------------------------------------------------------------
def get_ck_price(self, card_name: str) -> Optional[float]:
"""Return the Card Kingdom retail price for *card_name*, or None."""
self._ensure_ck_loaded()
return self._ck_cache.get(card_name.lower().strip())
def get_ck_prices_batch(self, card_names: List[str]) -> Dict[str, Optional[float]]:
"""Return a mapping of card name → CK retail price for all requested cards."""
self._ensure_ck_loaded()
return {
name: self._ck_cache.get(name.lower().strip())
for name in card_names
}
def get_ck_built_at(self) -> Optional[str]:
"""Return a human-readable CK cache build date, or None if unavailable."""
try:
if os.path.exists(self._ck_cache_path):
import datetime
built = os.path.getmtime(self._ck_cache_path)
dt = datetime.datetime.fromtimestamp(built, tz=datetime.timezone.utc)
return dt.strftime("%B %d, %Y")
except Exception:
pass
return None
def refresh_cache_background(self) -> None:
"""Spawn a daemon thread to rebuild the price cache asynchronously.
@ -412,6 +451,7 @@ class PriceService(BaseService):
logger.info("Building price cache from %s ...", self._bulk_path)
new_cache: Dict[str, Dict[str, float]] = {}
new_scryfall_id_map: Dict[str, str] = {}
built_at = time.time()
try:
@ -426,6 +466,7 @@ class PriceService(BaseService):
continue
name: str = card.get("name", "")
scryfall_id: str = card.get("id", "")
prices: Dict[str, Any] = card.get("prices") or {}
if not name:
continue
@ -446,6 +487,9 @@ class PriceService(BaseService):
new_usd = entry.get("usd", 9999.0)
if existing is None or new_usd < existing.get("usd", 9999.0):
new_cache[key] = entry
# Track the scryfall_id of the cheapest-priced printing
if scryfall_id:
new_scryfall_id_map[key] = scryfall_id
except Exception as exc:
logger.error("Failed to parse bulk data: %s", exc)
@ -466,6 +510,7 @@ class PriceService(BaseService):
with self._lock:
self._cache = new_cache
self._scryfall_id_map = new_scryfall_id_map
self._last_refresh = built_at
# Stamp all keys as fresh so get_stale_cards() reflects the rebuild.
# _lazy_ts may not exist if start_lazy_refresh() was never called
@ -476,9 +521,102 @@ class PriceService(BaseService):
self._lazy_ts[key] = built_at
self._save_lazy_ts()
# ------------------------------------------------------------------
# CK internal helpers
# ------------------------------------------------------------------
def _ensure_ck_loaded(self) -> None:
"""Lazy-load the CK price cache on first access (double-checked lock)."""
if self._ck_loaded:
return
with self._lock:
if self._ck_loaded:
return
if os.path.exists(self._ck_cache_path):
try:
age = time.time() - os.path.getmtime(self._ck_cache_path)
if age < self._ttl:
self._load_ck_from_cache()
logger.info("Loaded %d CK prices from cache (age %.1fh)", len(self._ck_cache), age / 3600)
self._ck_loaded = True
return
except Exception as exc:
logger.warning("CK cache unreadable: %s", exc)
# No fresh cache — set loaded flag anyway so we degrade gracefully
# rather than blocking every request. CK rebuild happens via Setup page.
self._ck_loaded = True
def _rebuild_ck_cache(self) -> None:
"""Fetch the Card Kingdom price list and cache retail prices by card name.
Fetches https://api.cardkingdom.com/api/v2/pricelist, takes the cheapest
non-foil price_retail per card name (across all printings), and writes
ck_prices_cache.json atomically.
"""
import urllib.request as _urllib
logger.info("Fetching CK price list from %s ...", _CK_API_URL)
try:
req = _urllib.Request(_CK_API_URL, headers={"User-Agent": "MTGPythonDeckbuilder/1.0"})
with _urllib.urlopen(req, timeout=30) as resp:
data = json.loads(resp.read().decode())
except Exception as exc:
logger.warning("CK price fetch failed: %s", exc)
return
items = data.get("data", [])
meta_created_at = data.get("meta", {}).get("created_at", "")
new_ck: Dict[str, float] = {}
for item in items:
if item.get("is_foil") == "true":
continue
name = item.get("name", "")
price_str = item.get("price_retail", "")
if not name or not price_str:
continue
try:
price = float(price_str)
except (ValueError, TypeError):
continue
if price <= 0:
continue
# Index by full name and each face for split/DFC cards
keys_to_index = [name.lower()]
if " // " in name:
keys_to_index += [part.strip().lower() for part in name.split(" // ")]
for key in keys_to_index:
if key not in new_ck or price < new_ck[key]:
new_ck[key] = price
# Write cache atomically
try:
cache_data = {"ck_prices": new_ck, "built_at": time.time(), "meta_created_at": meta_created_at}
tmp = self._ck_cache_path + ".tmp"
os.makedirs(os.path.dirname(self._ck_cache_path), exist_ok=True)
with open(tmp, "w", encoding="utf-8") as fh:
json.dump(cache_data, fh, separators=(",", ":"))
os.replace(tmp, self._ck_cache_path)
logger.info("CK price cache written: %d cards → %s", len(new_ck), self._ck_cache_path)
except Exception as exc:
logger.error("Failed to write CK price cache: %s", exc)
return
with self._lock:
self._ck_cache = new_ck
self._ck_loaded = True
def _load_ck_from_cache(self) -> None:
"""Deserialize the CK prices cache JSON into memory."""
with open(self._ck_cache_path, "r", encoding="utf-8") as fh:
data = json.load(fh)
self._ck_cache = data.get("ck_prices", {})
@staticmethod
def _extract_prices(prices: Dict[str, Any]) -> Dict[str, float]:
"""Convert raw Scryfall prices dict to {region_key: float} entries."""
result: Dict[str, float] = {}
for key in ("usd", "usd_foil", "eur", "eur_foil"):
raw = prices.get(key)

View file

@ -5993,6 +5993,45 @@ footer.site-footer {
color: var(--muted, #b6b8bd);
}
.owned-badge {
display: inline-block;
padding: .1rem .45rem;
border-radius: 4px;
font-size: .75rem;
font-weight: 600;
color: var(--ok, #16a34a);
border: 1px solid var(--ok, #16a34a);
background: transparent;
}
/* Dual-price source labels (TCG / CK) */
.price-src-label {
font-size: .65rem;
font-weight: 600;
opacity: .65;
letter-spacing: .04em;
text-transform: uppercase;
}
.price-sep {
opacity: .4;
}
.alt-prices {
font-size: 11px;
opacity: .7;
font-weight: normal;
}
/* Price source legend (TCG = TCGPlayer · CK = Card Kingdom) */
.price-legend {
font-size: .7rem;
opacity: .55;
letter-spacing: .02em;
}
/* Inline price tooltip on card names */
.card-name-price-hover {
@ -6382,6 +6421,104 @@ footer.site-footer {
font-size: .92rem;
}
/* Shopping cart toolbar — pickups page */
.cart-toolbar {
display: flex;
align-items: center;
gap: .6rem;
flex-wrap: wrap;
margin-bottom: .75rem;
padding: .45rem .6rem;
background: var(--panel, #1a1f2e);
border: 1px solid var(--border, #333);
border-radius: 6px;
}
.cart-toolbar .cart-label {
font-size: .82rem;
color: var(--muted, #94a3b8);
white-space: nowrap;
}
.cart-copy-feedback {
font-size: .8rem;
font-weight: 600;
color: #34d399;
margin-left: .25rem;
}
.cart-copy-feedback.error {
color: #f87171;
}
.cart-fallback-wrap {
margin-top: .6rem;
padding: .5rem .6rem;
background: var(--panel, #1a1f2e);
border: 1px solid var(--border, #333);
border-radius: 6px;
}
.cart-fallback-wrap p {
font-size: .8rem;
color: var(--muted, #94a3b8);
margin: 0 0 .4rem 0;
}
.cart-fallback-textarea {
width: 100%;
min-height: 110px;
font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
font-size: .8rem;
padding: .4rem .5rem;
background: var(--bg, #0f172a);
color: var(--text, #e5e7eb);
border: 1px solid var(--border, #333);
border-radius: 4px;
resize: vertical;
box-sizing: border-box;
}
.cart-cb-th {
width: 2.2rem;
text-align: center;
padding: .4rem .25rem;
border-bottom: 1px solid var(--border, #333);
}
.cart-cb-td {
text-align: center;
padding: .35rem .25rem;
border-bottom: 1px solid var(--border-subtle, #222);
}
/* Top-center toast for buy/cart copy confirmation */
.cart-toast-top {
position: fixed;
top: 1.25rem;
left: 50%;
transform: translateX(-50%);
background: var(--panel, #1a1f2e);
color: var(--text, #e5e7eb);
border: 1px solid #34d399;
border-radius: 10px;
padding: .6rem 1.4rem;
font-size: 1rem;
font-weight: 600;
box-shadow: 0 8px 28px rgba(0,0,0,.45);
z-index: 10000;
white-space: nowrap;
pointer-events: none;
transition: opacity .25s ease, transform .25s ease;
}
.cart-toast-top.hide {
opacity: 0;
transform: translateX(-50%) translateY(-6px);
}
.hover\:text-gray-700:hover {
--tw-text-opacity: 1;
color: rgb(55 65 81 / var(--tw-text-opacity, 1));
@ -6422,3 +6559,4 @@ footer.site-footer {
}
}

View file

@ -3728,6 +3728,43 @@ footer.site-footer {
color: var(--muted, #b6b8bd);
}
.owned-badge {
display: inline-block;
padding: .1rem .45rem;
border-radius: 4px;
font-size: .75rem;
font-weight: 600;
color: var(--ok, #16a34a);
border: 1px solid var(--ok, #16a34a);
background: transparent;
}
/* Dual-price source labels (TCG / CK) */
.price-src-label {
font-size: .65rem;
font-weight: 600;
opacity: .65;
letter-spacing: .04em;
text-transform: uppercase;
}
.price-sep {
opacity: .4;
}
.alt-prices {
font-size: 11px;
opacity: .7;
font-weight: normal;
}
/* Price source legend (TCG = TCGPlayer · CK = Card Kingdom) */
.price-legend {
font-size: .7rem;
opacity: .55;
letter-spacing: .02em;
}
/* Inline price tooltip on card names */
.card-name-price-hover {
cursor: default;
@ -3957,3 +3994,86 @@ footer.site-footer {
font-size: .92rem;
}
/* Shopping cart toolbar — pickups page */
.cart-toolbar {
display: flex;
align-items: center;
gap: .6rem;
flex-wrap: wrap;
margin-bottom: .75rem;
padding: .45rem .6rem;
background: var(--panel, #1a1f2e);
border: 1px solid var(--border, #333);
border-radius: 6px;
}
.cart-toolbar .cart-label {
font-size: .82rem;
color: var(--muted, #94a3b8);
white-space: nowrap;
}
.cart-copy-feedback {
font-size: .8rem;
font-weight: 600;
color: #34d399;
margin-left: .25rem;
}
.cart-copy-feedback.error { color: #f87171; }
.cart-fallback-wrap {
margin-top: .6rem;
padding: .5rem .6rem;
background: var(--panel, #1a1f2e);
border: 1px solid var(--border, #333);
border-radius: 6px;
}
.cart-fallback-wrap p {
font-size: .8rem;
color: var(--muted, #94a3b8);
margin: 0 0 .4rem 0;
}
.cart-fallback-textarea {
width: 100%;
min-height: 110px;
font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
font-size: .8rem;
padding: .4rem .5rem;
background: var(--bg, #0f172a);
color: var(--text, #e5e7eb);
border: 1px solid var(--border, #333);
border-radius: 4px;
resize: vertical;
box-sizing: border-box;
}
.cart-cb-th {
width: 2.2rem;
text-align: center;
padding: .4rem .25rem;
border-bottom: 1px solid var(--border, #333);
}
.cart-cb-td {
text-align: center;
padding: .35rem .25rem;
border-bottom: 1px solid var(--border-subtle, #222);
}
/* Top-center toast for buy/cart copy confirmation */
.cart-toast-top {
position: fixed;
top: 1.25rem;
left: 50%;
transform: translateX(-50%);
background: var(--panel, #1a1f2e);
color: var(--text, #e5e7eb);
border: 1px solid #34d399;
border-radius: 10px;
padding: .6rem 1.4rem;
font-size: 1rem;
font-weight: 600;
box-shadow: 0 8px 28px rgba(0,0,0,.45);
z-index: 10000;
white-space: nowrap;
pointer-events: none;
transition: opacity .25s ease, transform .25s ease;
}
.cart-toast-top.hide { opacity: 0; transform: translateX(-50%) translateY(-6px); }

View file

@ -396,12 +396,24 @@ interface PointerEventLike {
nameEl.textContent = nm;
rarityEl.textContent = rarity;
if (priceEl) {
const priceRaw = (attr('data-price') || '').trim();
const priceNum = priceRaw ? parseFloat(priceRaw) : NaN;
const isStale = attr('data-stale') === '1';
priceEl.innerHTML = !isNaN(priceNum)
? '$' + priceNum.toFixed(2) + (isStale ? ' <span style="color:#f59e0b;font-size:10px;" title="Price may be outdated (>24h)">\u23F1</span>' : '')
: '';
const staleSpan = isStale ? ' <span style="color:#f59e0b;font-size:10px;" title="Price may be outdated (>24h)">\u23F1</span>' : '';
// Prefer the shared price cache (populated by initPriceDisplay with both TCG+CK)
const globalCache = (window as any)._priceNum as Record<string, {tcg: number|null, ck: number|null}|null> | undefined;
const cached = globalCache && globalCache[nm];
if (cached && (cached.tcg !== null || cached.ck !== null)) {
const parts: string[] = [];
if (cached.tcg !== null) parts.push('<span class="price-src-label">TCG</span> $' + (cached.tcg as number).toFixed(2) + staleSpan);
if (cached.ck !== null) parts.push('<span class="price-src-label">CK</span> $' + (cached.ck as number).toFixed(2));
priceEl.innerHTML = parts.join(' <span class="price-sep">\u00B7</span> ');
} else {
// Fallback: data-price (TCG only, set server-side in _step5.html)
const priceRaw = (attr('data-price') || '').trim();
const priceNum = priceRaw ? parseFloat(priceRaw) : NaN;
priceEl.innerHTML = !isNaN(priceNum)
? '<span class="price-src-label">TCG</span> $' + priceNum.toFixed(2) + staleSpan
: '';
}
}
const roleLabel = displayLabel(role);
@ -680,7 +692,12 @@ interface PointerEventLike {
// Recognized container classes
const container = el.closest && el.closest('.card-sample, .commander-cell, .commander-thumb, .commander-card, .candidate-tile, .card-preview, .stack-card');
if (container) return container;
if (container) {
// .card-preview is also used as a plain layout aside (no data-card-name on it);
// only treat it as a hover target when the attribute lives directly on the element.
if (container.classList.contains('card-preview') && !container.hasAttribute('data-card-name')) return null;
return container;
}
// Image-based detection (any card image carrying data-card-name)
if (el.matches && (el.matches('img.card-thumb') || el.matches('img[data-card-name]') || el.classList.contains('commander-img'))) {

View file

@ -434,7 +434,10 @@
fetch('/api/price/' + encodeURIComponent(name))
.then(function(r){ return r.ok ? r.json() : null; })
.then(function(d){
var label = (d && d.found && d.price != null) ? ('$' + parseFloat(d.price).toFixed(2)) : 'Price unavailable';
var parts = [];
if (d && d.found && d.price != null) parts.push('TCG: $' + parseFloat(d.price).toFixed(2));
if (d && d.ck_price != null) parts.push('CK: $' + parseFloat(d.ck_price).toFixed(2));
var label = parts.length ? parts.join(' ') : 'Price unavailable';
_priceCache[name] = label;
_showTip(el, label);
})
@ -454,7 +457,8 @@
'Snow-Covered Plains','Snow-Covered Island','Snow-Covered Swamp',
'Snow-Covered Mountain','Snow-Covered Forest'
]);
var _priceNum = {}; // card name -> float|null
var _priceNum = {}; // card name -> {tcg, ck}|null
window._priceNum = _priceNum; // expose for cardHover.js
var _deckPrices = {}; // accumulated across build stages: card name -> float
var _buildToken = null;
function _fetchNum(name) {
@ -462,9 +466,12 @@
return fetch('/api/price/' + encodeURIComponent(name))
.then(function(r){ return r.ok ? r.json() : null; })
.then(function(d){
var p = (d && d.found && d.price != null) ? parseFloat(d.price) : null;
_priceNum[name] = p; return p;
}).catch(function(){ _priceNum[name] = null; return null; });
var obj = {
tcg: (d && d.found && d.price != null) ? parseFloat(d.price) : null,
ck: (d && d.ck_price != null) ? parseFloat(d.ck_price) : null,
};
_priceNum[name] = obj; return obj;
}).catch(function(){ var obj = {tcg:null,ck:null}; _priceNum[name] = obj; return obj; });
}
function _getBuildToken() {
var el = document.querySelector('[data-build-id]');
@ -507,17 +514,24 @@
var prevTotal = Object.values(_deckPrices).reduce(function(s,p){ return s + (p||0); }, 0);
var promises = [];
toFetch.forEach(function(name){ promises.push(_fetchNum(name).then(function(p){ return {name:name,price:p}; })); });
toFetch.forEach(function(name){ promises.push(_fetchNum(name).then(function(obj){ return {name:name,price:obj}; })); });
Promise.all(promises).then(function(results){
var map = {};
var prevTotal2 = Object.values(_deckPrices).reduce(function(s,p){ return s + (p||0); }, 0);
results.forEach(function(r){ map[r.name] = r.price; if (r.price !== null) _deckPrices[r.name] = r.price; });
results.forEach(function(r){ map[r.name] = r.price; if (r.price && r.price.tcg !== null) _deckPrices[r.name] = r.price.tcg; });
overlays.forEach(function(el){
var name = el.dataset.priceFor;
if (!name || BASIC_LANDS.has(name)) { el.style.display='none'; return; }
var p = map[name];
el.textContent = p !== null ? ('$' + p.toFixed(2)) : '';
if (ceiling !== null && p !== null && p > ceiling) {
var obj = map[name];
var tcg = obj ? obj.tcg : null;
var ck = obj ? obj.ck : null;
if (tcg !== null || ck !== null) {
var parts = [];
if (tcg !== null) parts.push('<span class="price-src-label">TCG</span> $' + tcg.toFixed(2));
if (ck !== null) parts.push('<span class="price-src-label">CK</span> $' + ck.toFixed(2));
el.innerHTML = parts.join('<br>');
} else { el.innerHTML = ''; }
if (ceiling !== null && tcg !== null && tcg > ceiling) {
var tile = el.closest('.card-tile,.stack-card');
if (tile) tile.classList.add('over-budget');
}
@ -525,9 +539,16 @@
inlines.forEach(function(el){
var name = el.dataset.priceFor;
if (!name || BASIC_LANDS.has(name)) { el.style.display='none'; return; }
var p = map[name];
el.textContent = p !== null ? ('$' + p.toFixed(2)) : '';
if (ceiling !== null && p !== null && p > ceiling) {
var obj = map[name];
var tcg = obj ? obj.tcg : null;
var ck = obj ? obj.ck : null;
if (tcg !== null || ck !== null) {
var parts = [];
if (tcg !== null) parts.push('<span class="price-src-label">TCG</span> $' + tcg.toFixed(2));
if (ck !== null) parts.push('<span class="price-src-label">CK</span> $' + ck.toFixed(2));
el.innerHTML = parts.join(' <span class="price-sep">·</span> ');
} else { el.innerHTML = ''; }
if (ceiling !== null && tcg !== null && tcg > ceiling) {
var row = el.closest('.list-row');
if (row) row.classList.add('over-budget');
}
@ -543,7 +564,7 @@
var n = el.dataset.priceFor;
if (n && !BASIC_LANDS.has(n) && !allNames.has(n)) {
allNames.add(n);
sumTotal += (map[n] || 0);
sumTotal += (map[n] ? (map[n].tcg || 0) : 0);
}
});
if (totalCap !== null) {

View file

@ -19,6 +19,9 @@
{{ card.name }}
</div>
{# Price overlay #}
<div class="card-price-overlay" data-price-for="{{ card.name }}" aria-hidden="true"></div>
{# Owned indicator #}
{% if card.is_owned %}
<div style="position:absolute; top:4px; right:4px; background:rgba(34,197,94,0.9); color:white; padding:2px 6px; border-radius:4px; font-size:12px; font-weight:600;">

View file

@ -84,6 +84,7 @@
cursor: pointer;
border-radius: 8px;
transition: transform 0.2s;
position: relative;
}
.similar-card-image:hover {
@ -235,6 +236,8 @@
<div class="similar-card-tile card-tile" data-card-name="{{ card.name }}">
<!-- Card Image (uses hover system for preview) -->
<div class="similar-card-image">
{# Price overlay #}
<div class="card-price-overlay" data-price-for="{{ card.name }}" aria-hidden="true"></div>
<img src="{{ card.name|card_image('normal') }}"
alt="{{ card.name }}"
loading="lazy"

View file

@ -247,7 +247,29 @@
<span class="card-stat-value">{{ card.rarity | capitalize }}</span>
</div>
{% endif %}
<div class="card-stat" id="card-detail-price-wrap" style="display:none;">
<span class="card-stat-label">Price</span>
<span class="card-stat-value" id="card-detail-price-display"></span>
</div>
</div>
<script>
(function(){
var name = {{ card.name | tojson }};
fetch('/api/price/' + encodeURIComponent(name))
.then(function(r){ return r.ok ? r.json() : null; })
.then(function(d){
if (!d) return;
var parts = [];
if (d.price != null) parts.push('<span class="price-src-label">TCG</span> $' + parseFloat(d.price).toFixed(2));
if (d.ck_price != null) parts.push('<span class="price-src-label">CK</span> $' + parseFloat(d.ck_price).toFixed(2));
if (parts.length) {
document.getElementById('card-detail-price-display').innerHTML = parts.join(' <span class="price-sep">\u00B7</span> ');
document.getElementById('card-detail-price-wrap').style.display = '';
}
}).catch(function(){});
})();
</script>
<!-- Oracle Text -->
{% if card.text %}

View file

@ -39,7 +39,7 @@
hx-target="closest .alts"
hx-swap="outerHTML"
title="Lock this alternative and unlock the current pick">
{{ it.name }}{% if it.price %} <span style="font-size:11px;opacity:.7;font-weight:normal;">${{ "%.2f"|format(it.price|float) }}</span>{% endif %}
{{ it.name }}{% if it.price or it.ck_price %} <span class="alt-prices">{% if it.price %}<span class="price-src-label">TCG</span> ${{ "%.2f"|format(it.price|float) }}{% endif %}{% if it.price and it.ck_price %} · {% endif %}{% if it.ck_price %}<span class="price-src-label">CK</span> ${{ "%.2f"|format(it.ck_price|float) }}{% endif %}</span>{% endif %}
</button>
</li>
{% endfor %}

View file

@ -55,7 +55,7 @@
{% if alt.price %}data-price="{{ alt.price }}"{% endif %}
title="{{ alt.shared_tags|join(', ') if alt.shared_tags else '' }}">
{{ alt.name }}
{% if alt.price %}<span class="alt-price">${{ '%.2f'|format(alt.price|float) }}</span>{% endif %}
{% if alt.price or alt.ck_price %}<span class="alt-price">{% if alt.price %}TCG ${{ '%.2f'|format(alt.price|float) }}{% endif %}{% if alt.price and alt.ck_price %} · {% endif %}{% if alt.ck_price %}CK ${{ '%.2f'|format(alt.ck_price|float) }}{% endif %}</span>{% endif %}
</button>
</form>
{% endfor %}

View file

@ -1,7 +1,7 @@
{% extends "base.html" %}
{% block banner_subtitle %}Budget Pickups{% endblock %}
{% block banner_subtitle %}Upgrade Suggestions{% endblock %}
{% block content %}
<h2>Pickups List</h2>
<h2>Upgrade Suggestions</h2>
{% if commander %}
<div class="muted" style="margin-bottom:.5rem;">Deck: <strong>{{ commander }}</strong>{% if name %} — <span class="muted text-xs">{{ name }}</span>{% endif %}</div>
{% endif %}
@ -30,13 +30,35 @@
{% if budget_report.pickups_list %}
<p class="muted text-sm" style="margin-bottom:.5rem;">
Cards you don't own yet that fit the deck's themes and budget. Sorted by theme match priority.
Cards that fit the deck's themes and budget. Owned cards are free upgrades — just swap one in. Sorted by theme match priority.
<span class="price-legend" style="display:block; margin-top:.2rem;">TCG = TCGPlayer &middot; CK = Card Kingdom</span>
</p>
{# Cart toolbar #}
<div class="cart-toolbar" id="cart-toolbar">
<label style="display:inline-flex;align-items:center;gap:.35rem;cursor:pointer;font-size:.85rem;">
<input type="checkbox" id="cart-select-all" checked aria-label="Select all cards">
<span>Select all</span>
</label>
<span id="cart-selected-count" class="cart-label"></span>
<button id="btn-copy-tcg" class="btn btn-sm" type="button" onclick="cartCopyTCG()">Open in TCGPlayer</button>
<button id="btn-copy-ck" class="btn btn-sm" type="button" onclick="cartCopyCK()">Open in Card Kingdom</button>
</div>
{# Fallback textarea (shown when Clipboard API is unavailable) #}
<div id="cart-fallback-wrap" class="cart-fallback-wrap" style="display:none;">
<p>Clipboard access unavailable. Select all and copy the text below:</p>
<textarea id="cart-fallback-text" class="cart-fallback-textarea" readonly aria-label="Card list for manual copy"></textarea>
<button type="button" class="btn btn-sm" style="margin-top:.4rem;" onclick="document.getElementById('cart-fallback-wrap').style.display='none';">Close</button>
</div>
<table class="pickups-table" style="width:100%; border-collapse:collapse;">
<thead>
<tr>
<th class="cart-cb-th" aria-label="Select"></th>
<th style="text-align:left; padding:.4rem .5rem; border-bottom:1px solid var(--border,#333);">Card</th>
<th style="text-align:right; padding:.4rem .5rem; border-bottom:1px solid var(--border,#333);">Price</th>
<th style="text-align:right; padding:.4rem .5rem; border-bottom:1px solid var(--border,#333);">TCG</th>
<th style="text-align:right; padding:.4rem .5rem; border-bottom:1px solid var(--border,#333);">CK</th>
<th style="text-align:center; padding:.4rem .5rem; border-bottom:1px solid var(--border,#333);">Owned</th>
<th style="text-align:center; padding:.4rem .5rem; border-bottom:1px solid var(--border,#333);">Tier</th>
<th style="text-align:right; padding:.4rem .5rem; border-bottom:1px solid var(--border,#333);">Priority</th>
</tr>
@ -44,16 +66,33 @@
<tbody>
{% for card in budget_report.pickups_list %}
<tr>
<td class="cart-cb-td">
<input type="checkbox" class="cart-cb" data-card-name="{{ card.card|e }}" checked aria-label="Select {{ card.card|e }}">
</td>
<td style="padding:.35rem .5rem; border-bottom:1px solid var(--border-subtle,#222);">
<span class="card-name-price-hover" data-card-name="{{ card.card|e }}">{{ card.card }}</span>
</td>
<td style="text-align:right; padding:.35rem .5rem; border-bottom:1px solid var(--border-subtle,#222);">
{% if card.price is not none %}
{% if owned_names is defined and card.card|lower in owned_names %}
<span class="muted text-sm">owned</span>
{% elif card.price is not none %}
${{ "%.2f"|format(card.price) }}{% if stale_prices is defined and card.card|lower in stale_prices %}<span class="stale-price-badge" title="Price may be outdated (>24h)">&#x23F1;</span>{% endif %}
{% else %}
<span class="muted"></span>
{% endif %}
</td>
<td style="text-align:right; padding:.35rem .5rem; border-bottom:1px solid var(--border-subtle,#222);">
{% if card.ck_price is not none %}
${{ "%.2f"|format(card.ck_price) }}
{% else %}
<span class="muted"></span>
{% endif %}
</td>
<td style="text-align:center; padding:.35rem .5rem; border-bottom:1px solid var(--border-subtle,#222);">
{% if owned_names is defined and card.card|lower in owned_names %}
<span class="owned-badge" title="You own this card">yes</span>
{% endif %}
</td>
<td style="text-align:center; padding:.35rem .5rem; border-bottom:1px solid var(--border-subtle,#222);">
<span class="tier-badge tier-badge--{{ card.tier|lower }}">{{ card.tier }}</span>
</td>
@ -64,8 +103,84 @@
{% endfor %}
</tbody>
</table>
<script>
(function () {
var allCb = document.getElementById('cart-select-all');
function getCheckedNames() {
return Array.from(document.querySelectorAll('.cart-cb:checked'))
.map(function (cb) { return cb.getAttribute('data-card-name'); });
}
function updateState() {
var all = document.querySelectorAll('.cart-cb');
var checked = document.querySelectorAll('.cart-cb:checked');
var n = checked.length, total = all.length;
var countEl = document.getElementById('cart-selected-count');
if (countEl) countEl.textContent = n + ' of ' + total + ' selected';
var btnTCG = document.getElementById('btn-copy-tcg');
var btnCK = document.getElementById('btn-copy-ck');
if (btnTCG) btnTCG.disabled = n === 0;
if (btnCK) btnCK.disabled = n === 0;
if (allCb) {
allCb.indeterminate = n > 0 && n < total;
allCb.checked = n === total;
}
}
if (allCb) {
allCb.addEventListener('change', function () {
document.querySelectorAll('.cart-cb').forEach(function (cb) { cb.checked = allCb.checked; });
updateState();
});
}
document.querySelectorAll('.cart-cb').forEach(function (cb) {
cb.addEventListener('change', updateState);
});
function stripDFC(n) { return n.split(' // ')[0].trim(); }
function showFallback(text) {
var wrap = document.getElementById('cart-fallback-wrap');
var ta = document.getElementById('cart-fallback-text');
if (!wrap || !ta) return;
ta.value = text;
wrap.style.display = 'block';
ta.focus();
ta.select();
}
function showCartToast(msg) {
var el = document.createElement('div');
el.className = 'cart-toast-top';
el.textContent = msg;
document.body.appendChild(el);
setTimeout(function () { el.classList.add('hide'); setTimeout(function () { el.remove(); }, 300); }, 6000);
}
function openAfterCopy(url, vendorName) {
var names = getCheckedNames();
if (!names.length) return;
var text = names.map(function (n) { return '1 ' + stripDFC(n); }).join('\n');
function doOpen() {
showCartToast('List copied — paste into ' + vendorName + ' with Ctrl+V');
setTimeout(function () { window.open(url, '_blank'); }, 400);
}
if (navigator.clipboard && navigator.clipboard.writeText) {
navigator.clipboard.writeText(text).then(doOpen).catch(function () { showFallback(text); window.open(url, '_blank'); });
} else { showFallback(text); window.open(url, '_blank'); }
}
window.cartCopyTCG = function () { openAfterCopy('https://www.tcgplayer.com/massentry', 'TCGPlayer'); };
window.cartCopyCK = function () { openAfterCopy('https://www.cardkingdom.com/builder', 'Card Kingdom'); };
updateState();
})();
</script>
{% else %}
<div class="panel muted">No pickups suggestions available — your deck may already fit the budget well.</div>
<div class="panel muted">No upgrade suggestions available — your deck may already fit the budget well.</div>
{% endif %}
{% if budget_report.over_budget_cards %}
@ -102,3 +217,4 @@
<a href="/decks" class="btn" role="button">All Decks</a>
</div>
{% endblock %}

View file

@ -45,6 +45,8 @@
{% if commander_overlap_tags %}data-overlaps="{{ commander_overlap_tags|join(', ') }}"{% endif %}
{% if commander_reason_text %}data-reasons="{{ commander_reason_text|e }}"{% endif %}
width="320" />
{# Price overlay — ensures commander price is loaded into window._priceNum for the hover panel #}
<div class="card-price-overlay" data-price-for="{{ commander_base }}" aria-hidden="true"></div>
</div>
<div class="muted" style="margin-top:.25rem;">Commander: <span data-card-name="{{ commander }}"
data-original-name="{{ commander }}"
@ -69,12 +71,74 @@
{% endif %}
<a href="/decks/compare?A={{ name|urlencode }}" class="btn" role="button" title="Compare this deck with another">Compare…</a>
{% if budget_report %}
<a href="/decks/pickups?name={{ name|urlencode }}" class="btn" role="button" title="View cards to acquire for this budget build">Pickups List</a>
<a href="/decks/pickups?name={{ name|urlencode }}" class="btn" role="button" title="View upgrade suggestions for this deck">Upgrade Suggestions</a>
{% endif %}
<form method="get" action="/decks" style="display:inline; margin:0;">
<button type="submit">Back to Finished Decks</button>
</form>
</div>
{# Buy This Deck: collect all cards, strip DFC names, open vendor + copy to clipboard #}
{%- set _buy_cards = [] -%}
{%- if commander_base -%}
{%- set _ = _buy_cards.append({'name': commander_base, 'count': 1}) -%}
{%- endif -%}
{%- if summary and summary.type_breakdown and summary.type_breakdown.cards -%}
{%- for _btype, _bclist in summary.type_breakdown.cards.items() -%}
{%- for _bc in _bclist -%}
{%- if _bc.name -%}
{%- set _ = _buy_cards.append({'name': _bc.name, 'count': (_bc.count if _bc.count and _bc.count > 1 else 1)}) -%}
{%- endif -%}
{%- endfor -%}
{%- endfor -%}
{%- endif -%}
{% if _buy_cards %}
<div class="cart-toolbar" style="margin-top:.6rem; flex-direction:column; align-items:flex-start; gap:.35rem;" id="buy-deck-toolbar">
<span class="cart-label" style="font-weight:600; color:var(--text,#e5e7eb);">Buy this deck:</span>
<div style="display:flex; gap:.4rem; flex-wrap:wrap;">
<button class="btn btn-sm" type="button" onclick="buyViaTCG()">Open in TCGPlayer</button>
<button class="btn btn-sm" type="button" onclick="buyViaCK()">Open in Card Kingdom</button>
</div>
</div>
<div id="buy-fallback-wrap" class="cart-fallback-wrap" style="display:none;">
<p>Clipboard access unavailable. Select all and copy the text below, then paste it at the vendor site:</p>
<textarea id="buy-fallback-text" class="cart-fallback-textarea" readonly aria-label="Deck list for manual copy"></textarea>
<button type="button" class="btn btn-sm" style="margin-top:.4rem;" onclick="document.getElementById('buy-fallback-wrap').style.display='none';">Close</button>
</div>
<script>
(function () {
var _buyCards = {{ _buy_cards | tojson }};
function stripDFC(n) { return n.split(' // ')[0].trim(); }
function buildList(cards) {
return cards.map(function (c) { return c.count + ' ' + stripDFC(c.name); }).join('\n');
}
function showFallback(text) {
var wrap = document.getElementById('buy-fallback-wrap');
var ta = document.getElementById('buy-fallback-text');
if (!wrap || !ta) return;
ta.value = text; wrap.style.display = 'block'; ta.focus(); ta.select();
}
function showCartToast(msg) {
var el = document.createElement('div');
el.className = 'cart-toast-top';
el.textContent = msg;
document.body.appendChild(el);
setTimeout(function () { el.classList.add('hide'); setTimeout(function () { el.remove(); }, 300); }, 6000);
}
function openAfterCopy(url, vendorName) {
var text = buildList(_buyCards);
function doOpen() {
showCartToast('List copied — paste into ' + vendorName + ' with Ctrl+V');
setTimeout(function () { window.open(url, '_blank'); }, 400);
}
if (navigator.clipboard && navigator.clipboard.writeText) {
navigator.clipboard.writeText(text).then(doOpen).catch(function () { showFallback(text); window.open(url, '_blank'); });
} else { showFallback(text); window.open(url, '_blank'); }
}
window.buyViaTCG = function () { openAfterCopy('https://www.tcgplayer.com/massentry', 'TCGPlayer'); };
window.buyViaCK = function () { openAfterCopy('https://www.cardkingdom.com/builder', 'Card Kingdom'); };
})();
</script>
{% endif %}
{% if budget_report %}
{% set bstatus = budget_report.budget_status %}
<div class="budget-badge budget-badge--{{ bstatus }}" style="margin-top:.6rem;">

View file

@ -8,6 +8,7 @@
<h5>Card Types</h5>
<div class="summary-view-controls">
<span class="muted">View:</span>
<span class="price-legend" style="margin-left:auto;">TCG = TCGPlayer &middot; CK = Card Kingdom</span>
<div class="seg" role="tablist" aria-label="Type view">
<button type="button" class="seg-btn" data-view="list" aria-selected="true" onclick="(function(btn){var list=document.getElementById('typeview-list');var thumbs=document.getElementById('typeview-thumbs');if(!list||!thumbs)return;list.classList.remove('hidden');thumbs.classList.add('hidden');btn.setAttribute('aria-selected','true');var other=btn.parentElement.querySelector('.seg-btn[data-view=thumbs]');if(other)other.setAttribute('aria-selected','false');try{localStorage.setItem('summaryTypeView','list');}catch(e){}})(this)">List</button>
<button type="button" class="seg-btn" data-view="thumbs" onclick="(function(btn){var list=document.getElementById('typeview-list');var thumbs=document.getElementById('typeview-thumbs');if(!list||!thumbs)return;list.classList.add('hidden');thumbs.classList.remove('hidden');btn.setAttribute('aria-selected','true');var other=btn.parentElement.querySelector('.seg-btn[data-view=list]');if(other)other.setAttribute('aria-selected','false');try{localStorage.setItem('summaryTypeView','thumbs');}catch(e){}; (function(){var tv=document.getElementById('typeview-thumbs'); if(!tv) return; tv.querySelectorAll('.stack-wrap').forEach(function(sw){var grid=sw.querySelector('.stack-grid'); if(!grid) return; var cs=getComputedStyle(sw); var cardW=parseFloat(cs.getPropertyValue('--card-w'))||160; var gap=10; var width=sw.clientWidth; if(!width||width<cardW){ sw.style.setProperty('--cols','1'); return;} var cols=Math.max(1,Math.floor((width+gap)/(cardW+gap))); sw.style.setProperty('--cols',String(cols));}); })();})(this)">Thumbnails</button>

View file

@ -184,8 +184,9 @@
{% if theme.example_cards %}
{% for c in theme.example_cards %}
{% set base_c = (c.split(' - Synergy (')[0] if ' - Synergy (' in c else c) %}
<div class="ex-card text-center" data-card-name="{{ base_c }}" data-role="example_card" data-tags="{{ theme.synergies|join(', ') }}" data-original-name="{{ c }}">
<div class="ex-card text-center" style="position:relative" data-card-name="{{ base_c }}" data-role="example_card" data-tags="{{ theme.synergies|join(', ') }}" data-original-name="{{ c }}">
<img class="card-thumb w-full h-auto border border-[var(--border)] rounded-[10px]" loading="lazy" decoding="async" alt="{{ c }} image" src="{{ base_c|card_image('small') }}" />
<div class="card-price-overlay" data-price-for="{{ base_c }}" aria-hidden="true"></div>
<div class="text-[11px] mt-1 whitespace-nowrap overflow-hidden text-ellipsis font-semibold card-ref" data-card-name="{{ base_c }}" data-tags="{{ theme.synergies|join(', ') }}" data-original-name="{{ c }}">{{ c }}</div>
</div>
{% endfor %}
@ -198,8 +199,9 @@
{% if theme.example_commanders %}
{% for c in theme.example_commanders %}
{% set base_c = (c.split(' - Synergy (')[0] if ' - Synergy (' in c else c) %}
<div class="ex-commander commander-cell text-center" data-card-name="{{ base_c }}" data-role="commander_example" data-tags="{{ theme.synergies|join(', ') }}" data-original-name="{{ c }}">
<div class="ex-commander commander-cell text-center" style="position:relative" data-card-name="{{ base_c }}" data-role="commander_example" data-tags="{{ theme.synergies|join(', ') }}" data-original-name="{{ c }}">
<img class="card-thumb w-full h-auto border border-[var(--border)] rounded-[10px]" loading="lazy" decoding="async" alt="{{ c }} image" src="{{ base_c|card_image('small') }}" />
<div class="card-price-overlay" data-price-for="{{ base_c }}" aria-hidden="true"></div>
<div class="text-[11px] mt-1 font-semibold whitespace-nowrap overflow-hidden text-ellipsis card-ref" data-card-name="{{ base_c }}" data-tags="{{ theme.synergies|join(', ') }}" data-original-name="{{ c }}">{{ c }}</div>
</div>
{% endfor %}