{% extends "base.html" %}
{% block content %}
<section class="panel">
<h2>Inventory</h2>
<p class="muted">Equip weapons and armor, set an active home, use drugs and medical, or sell items to NPCs where allowed.</p>
</section>
{% if grouped_items %}
{% for category, items in grouped_items.items() %}
<section class="panel">
<h2>{{ category|replace('_', ' ')|title }}</h2>
<table>
<thead>
<tr>
<th>Item</th>
<th>Quantity</th>
<th>Details</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
{% for item in items %}
<tr>
<td>
<strong>{{ item.name }}</strong><br>
<span class="muted mini">{{ item.description }}</span>
</td>
<td>{{ item.quantity }}</td>
<td class="mini">
Buy ${{ item.buy_price }} / Sell ${{ item.sell_price }}<br>
{% if item.weapon_damage_max %}Damage {{ item.weapon_damage_min }}-{{ item.weapon_damage_max }}<br>{% endif %}
{% if item.armor_reduction %}Armor reduction {{ item.armor_reduction }}<br>{% endif %}
{% if item.energy_gain or item.nerve_gain or item.life_gain or item.happy_gain %}
Use gains:
{% if item.energy_gain %}+{{ item.energy_gain }} energy {% endif %}
{% if item.nerve_gain %}+{{ item.nerve_gain }} nerve {% endif %}
{% if item.life_gain %}+{{ item.life_gain }} life {% endif %}
{% if item.happy_gain %}+{{ item.happy_gain }} happy{% endif %}
{% endif %}
</td>
<td class="stack">
{% if item.category in ["weapons", "armor", "homes"] %}
<form method="post" class="inline-form">
<input type="hidden" name="action" value="equip">
<input type="hidden" name="item_id" value="{{ item.id }}">
<button type="submit" class="primary">
{% if item.category == "homes" %}
{% if item.is_active_home %}Active Home{% else %}Set Active Home{% endif %}
{% else %}
{% if item.is_equipped_weapon or item.is_equipped_armor %}Equipped{% else %}Equip{% endif %}
{% endif %}
</button>
</form>
{% endif %}
{% if item.consumable %}
<form method="post" class="inline-form">
<input type="hidden" name="action" value="use">
<input type="hidden" name="item_id" value="{{ item.id }}">
<button type="submit" class="subtle">Use 1</button>
</form>
{% endif %}
{% if item.sell_price > 0 %}
<form method="post" class="inline-form">
<input type="hidden" name="action" value="sell">
<input type="hidden" name="item_id" value="{{ item.id }}">
<input type="number" name="quantity" min="1" max="{{ item.quantity }}" value="1">
<button type="submit" class="subtle">Sell to NPC</button>
</form>
{% endif %}
</td>
</tr>
{% endfor %}
</tbody>
</table>
</section>
{% endfor %}
{% else %}
<section class="panel">
<p class="muted">Inventory is empty. Start with jobs, crimes, or shops.</p>
</section>
{% endif %}
{% endblock %}