feat(api): implement inventory service with equipment system
Add InventoryService for managing character inventory, equipment, and consumable usage. Key features: - Add/remove items with inventory capacity checks - Equipment slot validation (weapon, off_hand, helmet, chest, gloves, boots, accessory_1, accessory_2) - Level and class requirement validation for equipment - Consumable usage with instant and duration-based effects - Combat-specific consumable method returning effects for combat system - Bulk operations (add_items, get_items_by_type, get_equippable_items) Design decision: Uses full Item object storage (not IDs) to support procedurally generated items with unique identifiers. Files added: - /api/app/services/inventory_service.py (560 lines) - /api/tests/test_inventory_service.py (51 tests passing) Task 2.3 of Phase 4 Combat Implementation complete.
This commit is contained in:
@@ -402,6 +402,111 @@ effects_applied:
|
||||
|
||||
---
|
||||
|
||||
## Procedural Item Generation
|
||||
|
||||
### Overview
|
||||
|
||||
Weapons and armor are procedurally generated using a Diablo-style affix system.
|
||||
Items are created by combining:
|
||||
1. **Base Template** - Defines item type, base stats, level requirement
|
||||
2. **Affixes** - Prefixes and suffixes that add stats and modify the name
|
||||
|
||||
### Generation Process
|
||||
|
||||
1. Select base template (filtered by level, rarity)
|
||||
2. Determine affix count based on rarity (0-3)
|
||||
3. Roll affix tier based on rarity weights
|
||||
4. Select random affixes avoiding duplicates
|
||||
5. Combine stats and generate name
|
||||
|
||||
### Rarity System
|
||||
|
||||
| Rarity | Affixes | Value Multiplier | Color |
|
||||
|--------|---------|------------------|-------|
|
||||
| COMMON | 0 | 1.0× | Gray |
|
||||
| UNCOMMON | 0 | 1.5× | Green |
|
||||
| RARE | 1 | 2.5× | Blue |
|
||||
| EPIC | 2 | 5.0× | Purple |
|
||||
| LEGENDARY | 3 | 10.0× | Orange |
|
||||
|
||||
### Affix Distribution
|
||||
|
||||
| Rarity | Affix Count | Distribution |
|
||||
|--------|-------------|--------------|
|
||||
| RARE | 1 | 50% prefix OR 50% suffix |
|
||||
| EPIC | 2 | 1 prefix AND 1 suffix |
|
||||
| LEGENDARY | 3 | Mix (2+1 or 1+2) |
|
||||
|
||||
### Affix Tiers
|
||||
|
||||
Higher rarity items have better chances at higher tier affixes:
|
||||
|
||||
| Rarity | MINOR | MAJOR | LEGENDARY |
|
||||
|--------|-------|-------|-----------|
|
||||
| RARE | 80% | 20% | 0% |
|
||||
| EPIC | 30% | 70% | 0% |
|
||||
| LEGENDARY | 10% | 40% | 50% |
|
||||
|
||||
### Name Generation Examples
|
||||
|
||||
- **COMMON:** "Dagger"
|
||||
- **RARE (prefix):** "Flaming Dagger"
|
||||
- **RARE (suffix):** "Dagger of Strength"
|
||||
- **EPIC:** "Flaming Dagger of Strength"
|
||||
- **LEGENDARY:** "Blazing Glacial Dagger of the Titan"
|
||||
|
||||
### Luck Influence
|
||||
|
||||
Player's LUK stat affects rarity rolls for loot drops:
|
||||
|
||||
**Base chances at LUK 8:**
|
||||
- COMMON: 50%
|
||||
- UNCOMMON: 30%
|
||||
- RARE: 15%
|
||||
- EPIC: 4%
|
||||
- LEGENDARY: 1%
|
||||
|
||||
**Luck Bonus:**
|
||||
Each point of LUK above 8 adds +0.5% to higher rarity chances.
|
||||
|
||||
**Examples:**
|
||||
- LUK 8 (baseline): 1% legendary chance
|
||||
- LUK 12: ~3% legendary chance
|
||||
- LUK 16: ~5% legendary chance
|
||||
|
||||
### Service Usage
|
||||
|
||||
```python
|
||||
from app.services.item_generator import get_item_generator
|
||||
from app.models.enums import ItemRarity
|
||||
|
||||
generator = get_item_generator()
|
||||
|
||||
# Generate item of specific rarity
|
||||
sword = generator.generate_item(
|
||||
item_type="weapon",
|
||||
rarity=ItemRarity.EPIC,
|
||||
character_level=5
|
||||
)
|
||||
|
||||
# Generate random loot with luck bonus
|
||||
loot = generator.generate_loot_drop(
|
||||
character_level=10,
|
||||
luck_stat=15
|
||||
)
|
||||
```
|
||||
|
||||
### Data Files
|
||||
|
||||
| File | Description |
|
||||
|------|-------------|
|
||||
| `/app/data/base_items/weapons.yaml` | 13 weapon templates |
|
||||
| `/app/data/base_items/armor.yaml` | 12 armor templates |
|
||||
| `/app/data/affixes/prefixes.yaml` | 18 prefix affixes |
|
||||
| `/app/data/affixes/suffixes.yaml` | 11 suffix affixes |
|
||||
|
||||
---
|
||||
|
||||
## Quest System (Future)
|
||||
|
||||
### Quest Types
|
||||
|
||||
Reference in New Issue
Block a user