Add: armor plates support with new database tables and loadout functionality
fix: only required mods are applied to guns for weight management.
This commit is contained in:
@@ -197,106 +197,75 @@
|
||||
<div class="total-bar">
|
||||
<span class="lbl">Lightest possible build:</span>
|
||||
<span class="big">{{ "%.3f"|format(lightest_total) }} kg</span>
|
||||
<span class="breakdown">base {{ "%.3f"|format(gun.weight_kg or 0) }} kg + lightest mod per slot</span>
|
||||
<span class="breakdown">base {{ "%.3f"|format(gun.weight_kg or 0) }} kg + lightest mod per required slot</span>
|
||||
</div>
|
||||
|
||||
{% if key_slots %}
|
||||
<div class="slot-section">
|
||||
<div class="section-hdr">Key slots</div>
|
||||
{% for slot in key_slots %}
|
||||
{% set lightest = slot.mods[0] if slot.mods else none %}
|
||||
<div class="slot-card key-slot {% if loop.first %}open{% endif %}" id="slot-{{ slot.slot_id }}">
|
||||
<div class="slot-header" onclick="toggleSlot('slot-{{ slot.slot_id }}')">
|
||||
<span class="slot-name">{{ slot.slot_name }}</span>
|
||||
<span class="key-badge">key slot</span>
|
||||
{% if slot.required %}<span class="required-badge">required</span>{% endif %}
|
||||
<span class="slot-count">{{ slot.mods | length }} mods</span>
|
||||
<span class="slot-lightest">
|
||||
{% if lightest and lightest.weight_kg is not none %}
|
||||
lightest {{ "%.3f"|format(lightest.weight_kg) }} kg
|
||||
{% else %}—{% endif %}
|
||||
</span>
|
||||
<span class="chevron">▶</span>
|
||||
</div>
|
||||
<div class="mod-list">
|
||||
{% if slot.mods %}
|
||||
{% for mod in slot.mods %}
|
||||
<div class="mod-row">
|
||||
{% if mod.grid_image_url %}
|
||||
<img src="{{ mod.grid_image_url }}" loading="lazy" alt="">
|
||||
{% else %}
|
||||
<div style="width:36px;height:36px;background:#222;border-radius:4px;flex-shrink:0"></div>
|
||||
{% endif %}
|
||||
<div class="mod-name">
|
||||
{{ mod.mod_name }}
|
||||
{% if mod.mod_short and mod.mod_short != mod.mod_name %}
|
||||
<small>{{ mod.mod_short }}</small>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% if mod.wiki_url %}
|
||||
<a class="mod-wiki" href="{{ mod.wiki_url }}" target="_blank">wiki</a>
|
||||
{% endif %}
|
||||
<span class="mod-weight {% if loop.first %}lightest{% endif %}">
|
||||
{% if mod.weight_kg is not none %}{{ "%.3f"|format(mod.weight_kg) }} kg{% else %}—{% endif %}
|
||||
</span>
|
||||
</div>
|
||||
{% endfor %}
|
||||
{% else %}
|
||||
<div class="no-mods">No compatible mods found in database.</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
{# ---- Macro to render a slot card ---- #}
|
||||
{% macro slot_card(slot, extra_class='', open=False) %}
|
||||
{% set lightest = slot.mods[0] if slot.mods else none %}
|
||||
<div class="slot-card {{ extra_class }} {% if open %}open{% endif %}" id="slot-{{ slot.slot_id }}">
|
||||
<div class="slot-header" onclick="toggleSlot('slot-{{ slot.slot_id }}')">
|
||||
<span class="slot-name">{{ slot.slot_name }}</span>
|
||||
{% if extra_class == 'key-slot' %}<span class="key-badge">key slot</span>{% endif %}
|
||||
<span class="slot-count">{{ slot.mods | length }} mods</span>
|
||||
<span class="slot-lightest">
|
||||
{% if lightest and lightest.weight_kg is not none %}
|
||||
lightest {{ "%.3f"|format(lightest.weight_kg) }} kg
|
||||
{% else %}—{% endif %}
|
||||
</span>
|
||||
<span class="chevron">▶</span>
|
||||
</div>
|
||||
<div class="mod-list">
|
||||
{% if slot.mods %}
|
||||
{% for mod in slot.mods %}
|
||||
<div class="mod-row">
|
||||
{% if mod.grid_image_url %}
|
||||
<img src="{{ mod.grid_image_url }}" loading="lazy" alt="">
|
||||
{% else %}
|
||||
<div style="width:36px;height:36px;background:#222;border-radius:4px;flex-shrink:0"></div>
|
||||
{% endif %}
|
||||
<div class="mod-name">
|
||||
{{ mod.mod_name }}
|
||||
{% if mod.mod_short and mod.mod_short != mod.mod_name %}
|
||||
<small>{{ mod.mod_short }}</small>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% if mod.wiki_url %}
|
||||
<a class="mod-wiki" href="{{ mod.wiki_url }}" target="_blank">wiki</a>
|
||||
{% endif %}
|
||||
<span class="mod-weight {% if loop.first %}lightest{% endif %}">
|
||||
{% if mod.weight_kg is not none %}{{ "%.3f"|format(mod.weight_kg) }} kg{% else %}—{% endif %}
|
||||
</span>
|
||||
</div>
|
||||
{% endfor %}
|
||||
{% else %}
|
||||
<div class="no-mods">No compatible mods found in database.</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
{% endmacro %}
|
||||
|
||||
{# ---- Required slots (key slots highlighted, open by default) ---- #}
|
||||
{% if key_slots or req_slots %}
|
||||
<div class="slot-section">
|
||||
<div class="section-hdr">Required slots <span style="font-weight:normal;color:#666">(counted in lightest build weight)</span></div>
|
||||
{% for slot in key_slots %}
|
||||
{{ slot_card(slot, 'key-slot', open=True) }}
|
||||
{% endfor %}
|
||||
{% for slot in req_slots %}
|
||||
{{ slot_card(slot, '', open=False) }}
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% if other_slots %}
|
||||
<button class="toggle-other" onclick="toggleOther(this)">Show {{ other_slots | length }} other slots ▼</button>
|
||||
{# ---- Optional slots (collapsed behind toggle) ---- #}
|
||||
{% if optional_slots %}
|
||||
<button class="toggle-other" onclick="toggleOther(this)">Show {{ optional_slots | length }} optional slots ▼</button>
|
||||
<div id="other-slots">
|
||||
<div class="slot-section">
|
||||
<div class="section-hdr">All other slots</div>
|
||||
{% for slot in other_slots %}
|
||||
{% set lightest = slot.mods[0] if slot.mods else none %}
|
||||
<div class="slot-card" id="slot-{{ slot.slot_id }}">
|
||||
<div class="slot-header" onclick="toggleSlot('slot-{{ slot.slot_id }}')">
|
||||
<span class="slot-name">{{ slot.slot_name }}</span>
|
||||
{% if slot.required %}<span class="required-badge">required</span>{% endif %}
|
||||
<span class="slot-count">{{ slot.mods | length }} mods</span>
|
||||
<span class="slot-lightest">
|
||||
{% if lightest and lightest.weight_kg is not none %}
|
||||
lightest {{ "%.3f"|format(lightest.weight_kg) }} kg
|
||||
{% else %}—{% endif %}
|
||||
</span>
|
||||
<span class="chevron">▶</span>
|
||||
</div>
|
||||
<div class="mod-list">
|
||||
{% if slot.mods %}
|
||||
{% for mod in slot.mods %}
|
||||
<div class="mod-row">
|
||||
{% if mod.grid_image_url %}
|
||||
<img src="{{ mod.grid_image_url }}" loading="lazy" alt="">
|
||||
{% else %}
|
||||
<div style="width:36px;height:36px;background:#222;border-radius:4px;flex-shrink:0"></div>
|
||||
{% endif %}
|
||||
<div class="mod-name">
|
||||
{{ mod.mod_name }}
|
||||
{% if mod.mod_short and mod.mod_short != mod.mod_name %}
|
||||
<small>{{ mod.mod_short }}</small>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% if mod.wiki_url %}
|
||||
<a class="mod-wiki" href="{{ mod.wiki_url }}" target="_blank">wiki</a>
|
||||
{% endif %}
|
||||
<span class="mod-weight {% if loop.first %}lightest{% endif %}">
|
||||
{% if mod.weight_kg is not none %}{{ "%.3f"|format(mod.weight_kg) }} kg{% else %}—{% endif %}
|
||||
</span>
|
||||
</div>
|
||||
{% endfor %}
|
||||
{% else %}
|
||||
<div class="no-mods">No compatible mods found in database.</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
<div class="section-hdr">Optional slots <span style="font-weight:normal;color:#666">(not counted in lightest build weight)</span></div>
|
||||
{% for slot in optional_slots %}
|
||||
{{ slot_card(slot) }}
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
@@ -311,8 +280,8 @@
|
||||
const div = document.getElementById('other-slots');
|
||||
div.classList.toggle('visible');
|
||||
btn.textContent = div.classList.contains('visible')
|
||||
? 'Hide other slots ▲'
|
||||
: 'Show {{ other_slots | length }} other slots ▼';
|
||||
? 'Hide optional slots ▲'
|
||||
: 'Show {{ optional_slots | length }} optional slots ▼';
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
|
||||
Reference in New Issue
Block a user