feat(api): implement Diablo-style item affix system
Add procedural item generation with affix naming system: - Items with RARE/EPIC/LEGENDARY rarity get dynamic names - Prefixes (e.g., "Flaming") add elemental damage, material bonuses - Suffixes (e.g., "of Strength") add stat bonuses - Affix count scales with rarity: RARE=1, EPIC=2, LEGENDARY=3 New files: - models/affixes.py: Affix and BaseItemTemplate dataclasses - services/affix_loader.py: YAML-based affix pool loading - services/base_item_loader.py: Base item template loading - services/item_generator.py: Main procedural generation service - data/affixes/prefixes.yaml: 14 prefix definitions - data/affixes/suffixes.yaml: 15 suffix definitions - data/base_items/weapons.yaml: 12 weapon templates - data/base_items/armor.yaml: 12 armor templates - tests/test_item_generator.py: 34 comprehensive tests Modified: - enums.py: Added AffixType and AffixTier enums - items.py: Added affix tracking fields (applied_affixes, generated_name) Example output: "Frozen Dagger of the Bear" (EPIC with ice damage + STR/CON)
This commit is contained in:
177
api/app/data/affixes/prefixes.yaml
Normal file
177
api/app/data/affixes/prefixes.yaml
Normal file
@@ -0,0 +1,177 @@
|
||||
# Item Prefix Affixes
|
||||
# Prefixes appear before the item name: "Flaming Dagger"
|
||||
#
|
||||
# Affix Structure:
|
||||
# affix_id: Unique identifier
|
||||
# name: Display name (what appears in the item name)
|
||||
# affix_type: "prefix"
|
||||
# tier: "minor" (RARE), "major" (EPIC), "legendary" (LEGENDARY only)
|
||||
# description: Flavor text describing the effect
|
||||
# stat_bonuses: Dict of stat_name -> bonus value
|
||||
# defense_bonus: Direct defense bonus
|
||||
# resistance_bonus: Direct resistance bonus
|
||||
# damage_bonus: Flat damage bonus (weapons)
|
||||
# damage_type: Elemental damage type
|
||||
# elemental_ratio: Portion converted to elemental (0.0-1.0)
|
||||
# crit_chance_bonus: Added to crit chance
|
||||
# crit_multiplier_bonus: Added to crit multiplier
|
||||
# allowed_item_types: [] = all types, or ["weapon", "armor"]
|
||||
# required_rarity: null = any, or "legendary"
|
||||
|
||||
prefixes:
|
||||
# ==================== ELEMENTAL PREFIXES (FIRE) ====================
|
||||
flaming:
|
||||
affix_id: "flaming"
|
||||
name: "Flaming"
|
||||
affix_type: "prefix"
|
||||
tier: "minor"
|
||||
description: "Imbued with fire magic, dealing bonus fire damage"
|
||||
damage_type: "fire"
|
||||
elemental_ratio: 0.25
|
||||
damage_bonus: 3
|
||||
allowed_item_types: ["weapon"]
|
||||
|
||||
blazing:
|
||||
affix_id: "blazing"
|
||||
name: "Blazing"
|
||||
affix_type: "prefix"
|
||||
tier: "major"
|
||||
description: "Wreathed in intense flames"
|
||||
damage_type: "fire"
|
||||
elemental_ratio: 0.35
|
||||
damage_bonus: 6
|
||||
allowed_item_types: ["weapon"]
|
||||
|
||||
# ==================== ELEMENTAL PREFIXES (ICE) ====================
|
||||
frozen:
|
||||
affix_id: "frozen"
|
||||
name: "Frozen"
|
||||
affix_type: "prefix"
|
||||
tier: "minor"
|
||||
description: "Enchanted with frost magic"
|
||||
damage_type: "ice"
|
||||
elemental_ratio: 0.25
|
||||
damage_bonus: 3
|
||||
allowed_item_types: ["weapon"]
|
||||
|
||||
glacial:
|
||||
affix_id: "glacial"
|
||||
name: "Glacial"
|
||||
affix_type: "prefix"
|
||||
tier: "major"
|
||||
description: "Encased in eternal ice"
|
||||
damage_type: "ice"
|
||||
elemental_ratio: 0.35
|
||||
damage_bonus: 6
|
||||
allowed_item_types: ["weapon"]
|
||||
|
||||
# ==================== ELEMENTAL PREFIXES (LIGHTNING) ====================
|
||||
shocking:
|
||||
affix_id: "shocking"
|
||||
name: "Shocking"
|
||||
affix_type: "prefix"
|
||||
tier: "minor"
|
||||
description: "Crackles with electrical energy"
|
||||
damage_type: "lightning"
|
||||
elemental_ratio: 0.25
|
||||
damage_bonus: 3
|
||||
allowed_item_types: ["weapon"]
|
||||
|
||||
thundering:
|
||||
affix_id: "thundering"
|
||||
name: "Thundering"
|
||||
affix_type: "prefix"
|
||||
tier: "major"
|
||||
description: "Charged with the power of storms"
|
||||
damage_type: "lightning"
|
||||
elemental_ratio: 0.35
|
||||
damage_bonus: 6
|
||||
allowed_item_types: ["weapon"]
|
||||
|
||||
# ==================== MATERIAL PREFIXES ====================
|
||||
iron:
|
||||
affix_id: "iron"
|
||||
name: "Iron"
|
||||
affix_type: "prefix"
|
||||
tier: "minor"
|
||||
description: "Reinforced with sturdy iron"
|
||||
stat_bonuses:
|
||||
constitution: 1
|
||||
defense_bonus: 2
|
||||
|
||||
steel:
|
||||
affix_id: "steel"
|
||||
name: "Steel"
|
||||
affix_type: "prefix"
|
||||
tier: "major"
|
||||
description: "Forged from fine steel"
|
||||
stat_bonuses:
|
||||
constitution: 2
|
||||
strength: 1
|
||||
defense_bonus: 4
|
||||
|
||||
# ==================== QUALITY PREFIXES ====================
|
||||
sharp:
|
||||
affix_id: "sharp"
|
||||
name: "Sharp"
|
||||
affix_type: "prefix"
|
||||
tier: "minor"
|
||||
description: "Honed to a fine edge"
|
||||
damage_bonus: 3
|
||||
crit_chance_bonus: 0.02
|
||||
allowed_item_types: ["weapon"]
|
||||
|
||||
keen:
|
||||
affix_id: "keen"
|
||||
name: "Keen"
|
||||
affix_type: "prefix"
|
||||
tier: "major"
|
||||
description: "Razor-sharp edge that finds weak points"
|
||||
damage_bonus: 5
|
||||
crit_chance_bonus: 0.04
|
||||
allowed_item_types: ["weapon"]
|
||||
|
||||
# ==================== DEFENSIVE PREFIXES ====================
|
||||
sturdy:
|
||||
affix_id: "sturdy"
|
||||
name: "Sturdy"
|
||||
affix_type: "prefix"
|
||||
tier: "minor"
|
||||
description: "Built to withstand punishment"
|
||||
defense_bonus: 3
|
||||
allowed_item_types: ["armor"]
|
||||
|
||||
reinforced:
|
||||
affix_id: "reinforced"
|
||||
name: "Reinforced"
|
||||
affix_type: "prefix"
|
||||
tier: "major"
|
||||
description: "Heavily reinforced for maximum protection"
|
||||
defense_bonus: 5
|
||||
resistance_bonus: 2
|
||||
allowed_item_types: ["armor"]
|
||||
|
||||
# ==================== LEGENDARY PREFIXES ====================
|
||||
infernal:
|
||||
affix_id: "infernal"
|
||||
name: "Infernal"
|
||||
affix_type: "prefix"
|
||||
tier: "legendary"
|
||||
description: "Burns with hellfire"
|
||||
damage_type: "fire"
|
||||
elemental_ratio: 0.45
|
||||
damage_bonus: 12
|
||||
allowed_item_types: ["weapon"]
|
||||
required_rarity: "legendary"
|
||||
|
||||
vorpal:
|
||||
affix_id: "vorpal"
|
||||
name: "Vorpal"
|
||||
affix_type: "prefix"
|
||||
tier: "legendary"
|
||||
description: "Cuts through anything with supernatural precision"
|
||||
damage_bonus: 10
|
||||
crit_chance_bonus: 0.08
|
||||
crit_multiplier_bonus: 0.5
|
||||
allowed_item_types: ["weapon"]
|
||||
required_rarity: "legendary"
|
||||
Reference in New Issue
Block a user