Fix weapon icon mapping and local SVG assets
This commit is contained in:
@@ -622,12 +622,18 @@ function renderNamedCountSection(title, items) {
|
||||
return `
|
||||
<article class="historical-player-stats-panel__section">
|
||||
<h5>${escapeHtml(title)}</h5>
|
||||
<ol>
|
||||
<ol class="historical-weapon-stat-list">
|
||||
${items
|
||||
.map((stat) => {
|
||||
const name = stat.name || stat.label || "Sin nombre";
|
||||
const count = stat.count ?? stat.total ?? 0;
|
||||
return `<li><span>${escapeHtml(name)}</span><strong>${escapeHtml(formatNumber(count))}</strong></li>`;
|
||||
return `
|
||||
<li>
|
||||
${renderHistoricalWeaponIcon(name)}
|
||||
<span>${escapeHtml(name)}</span>
|
||||
<strong>${escapeHtml(formatNumber(count))}</strong>
|
||||
</li>
|
||||
`;
|
||||
})
|
||||
.join("")}
|
||||
</ol>
|
||||
@@ -635,6 +641,47 @@ function renderNamedCountSection(title, items) {
|
||||
`;
|
||||
}
|
||||
|
||||
function renderHistoricalWeaponIcon(name) {
|
||||
const weapon = resolveHistoricalWeapon(name);
|
||||
if (!weapon.icon) {
|
||||
return `
|
||||
<span class="historical-weapon-stat-list__icon-frame" aria-hidden="true">
|
||||
<span class="historical-weapon-stat-list__fallback">?</span>
|
||||
</span>
|
||||
`;
|
||||
}
|
||||
return `
|
||||
<span class="historical-weapon-stat-list__icon-frame" aria-hidden="true">
|
||||
<img
|
||||
class="historical-weapon-stat-list__icon"
|
||||
src="${escapeHtml(weapon.icon)}"
|
||||
alt=""
|
||||
width="72"
|
||||
height="26"
|
||||
loading="lazy"
|
||||
decoding="async"
|
||||
onerror="this.hidden = true; this.nextElementSibling.hidden = false;"
|
||||
/>
|
||||
<span class="historical-weapon-stat-list__fallback" hidden>?</span>
|
||||
</span>
|
||||
`;
|
||||
}
|
||||
|
||||
function resolveHistoricalWeapon(value) {
|
||||
const runtimeWeaponIcons = globalThis.HLL_VIETNAM_CURRENT_MATCH_WEAPON_ICONS;
|
||||
if (runtimeWeaponIcons?.lookup) {
|
||||
const runtimeKey = runtimeWeaponIcons.normalize(value);
|
||||
return runtimeWeaponIcons.lookup[runtimeKey] || {
|
||||
label: String(value || runtimeWeaponIcons.unknown.label),
|
||||
icon: runtimeWeaponIcons.unknown.icon,
|
||||
};
|
||||
}
|
||||
return {
|
||||
label: String(value || "Arma desconocida"),
|
||||
icon: "",
|
||||
};
|
||||
}
|
||||
|
||||
function renderDirectMatchupsSection(matchups) {
|
||||
if (!matchups.length) {
|
||||
return `
|
||||
|
||||
Reference in New Issue
Block a user