Add complete item collection system (v0.2.0)

🎒 Item Collection System:
- 16 unique items across 5 categories (healing, battle, rare, location, special)
- Rarity tiers: Common, Uncommon, Rare, Epic, Legendary with symbols
- 30% chance to find items during exploration
- Location-specific items (shells, mushrooms, crystals, runes)
- Inventory management with \!inventory and \!use commands
- Web interface integration showing player inventories
- Consumable items: healing potions, battle boosters, lucky charms

🔧 Technical Updates:
- Added items and player_inventory database tables
- New Inventory module for item management
- Updated game engine with item discovery system
- Enhanced web interface with inventory display
- Item initialization from config/items.json

🆕 New Commands:
- \!inventory / \!inv / \!items - View collected items by category
- \!use <item name> - Use consumable items on active pets

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
megaproxy 2025-07-14 00:19:57 +01:00
parent e0edcb391a
commit db144da24f
13 changed files with 952 additions and 22 deletions

View file

@ -928,10 +928,28 @@ class PetBotRequestHandler(BaseHTTPRequestHandler):
}
achievements.append(achievement_dict)
# Get player inventory
cursor = await db.execute("""
SELECT i.name, i.description, i.category, i.rarity, pi.quantity
FROM player_inventory pi
JOIN items i ON pi.item_id = i.id
WHERE pi.player_id = ?
ORDER BY i.rarity DESC, i.name ASC
""", (player_dict['id'],))
inventory_rows = await cursor.fetchall()
inventory = []
for row in inventory_rows:
item_dict = {
'name': row[0], 'description': row[1], 'category': row[2],
'rarity': row[3], 'quantity': row[4]
}
inventory.append(item_dict)
return {
'player': player_dict,
'pets': pets,
'achievements': achievements
'achievements': achievements,
'inventory': inventory
}
except Exception as e:
@ -1087,6 +1105,7 @@ class PetBotRequestHandler(BaseHTTPRequestHandler):
player = player_data['player']
pets = player_data['pets']
achievements = player_data['achievements']
inventory = player_data.get('inventory', [])
# Calculate stats
active_pets = [pet for pet in pets if pet['is_active']]
@ -1139,6 +1158,41 @@ class PetBotRequestHandler(BaseHTTPRequestHandler):
No achievements yet. Keep exploring and catching pets to earn achievements!
</div>"""
# Build inventory HTML
inventory_html = ""
if inventory:
rarity_symbols = {
"common": "",
"uncommon": "",
"rare": "",
"epic": "",
"legendary": ""
}
rarity_colors = {
"common": "#ffffff",
"uncommon": "#1eff00",
"rare": "#0070dd",
"epic": "#a335ee",
"legendary": "#ff8000"
}
for item in inventory:
symbol = rarity_symbols.get(item['rarity'], "")
color = rarity_colors.get(item['rarity'], "#ffffff")
quantity_str = f" x{item['quantity']}" if item['quantity'] > 1 else ""
inventory_html += f"""
<div style="background: var(--bg-tertiary); padding: 15px; border-radius: 8px; margin: 10px 0; border-left: 4px solid {color};">
<strong style="color: {color};">{symbol} {item['name']}{quantity_str}</strong><br>
<small>{item['description']}</small><br>
<em style="color: var(--text-secondary);">Category: {item['category'].replace('_', ' ').title()} | Rarity: {item['rarity'].title()}</em>
</div>"""
else:
inventory_html = """
<div style="text-align: center; padding: 40px; color: var(--text-secondary);">
No items yet. Try exploring to find useful items!
</div>"""
html = f"""<!DOCTYPE html>
<html lang="en">
<head>
@ -1359,6 +1413,13 @@ class PetBotRequestHandler(BaseHTTPRequestHandler):
{achievements_html}
</div>
</div>
<div class="section">
<div class="section-header">🎒 Inventory</div>
<div class="section-content">
{inventory_html}
</div>
</div>
</body>
</html>"""