Files
Phillip Tarrant a38906b445 feat(api): integrate equipment stats into combat damage system
Equipment-Combat Integration:
- Update Stats damage formula from STR//2 to int(STR*0.75) for better scaling
- Add spell_power system for magical weapons (staves, wands)
- Add spell_power_bonus field to Stats model with spell_power property
- Add spell_power field to Item model with is_magical_weapon() method
- Update Character.get_effective_stats() to populate spell_power_bonus

Combatant Model Updates:
- Add weapon property fields (crit_chance, crit_multiplier, damage_type)
- Add elemental weapon support (elemental_damage_type, physical_ratio, elemental_ratio)
- Update serialization to handle new weapon properties

DamageCalculator Refactoring:
- Remove weapon_damage parameter from calculate_physical_damage()
- Use attacker_stats.damage directly (includes weapon bonus)
- Use attacker_stats.spell_power for magical damage calculations

Combat Service Updates:
- Extract weapon properties in _create_combatant_from_character()
- Use stats.damage_bonus for enemy combatants from templates
- Remove hardcoded _get_weapon_damage() method
- Handle elemental weapons with split damage in _execute_attack()

Item Generation Updates:
- Add base_spell_power to BaseItemTemplate dataclass
- Add ARCANE damage type to DamageType enum
- Add magical weapon templates (wizard_staff, arcane_staff, wand, crystal_wand)

Test Updates:
- Update test_stats.py for new damage formula (0.75 scaling)
- Update test_character.py for equipment bonus calculations
- Update test_damage_calculator.py for new API signatures
- Update test_combat_service.py mock fixture for equipped attribute

Tests: 174 passing
2025-11-26 19:54:58 -06:00

141 lines
4.7 KiB
Python

"""
Enumeration types for the Code of Conquest game system.
This module defines all enum types used throughout the data models to ensure
type safety and prevent invalid values.
"""
from enum import Enum
class EffectType(Enum):
"""Types of effects that can be applied to combatants."""
BUFF = "buff" # Temporarily increase stats
DEBUFF = "debuff" # Temporarily decrease stats
DOT = "dot" # Damage over time (poison, bleed, burn)
HOT = "hot" # Heal over time (regeneration)
STUN = "stun" # Prevent actions (skip turn)
SHIELD = "shield" # Absorb damage before HP loss
class DamageType(Enum):
"""Types of damage that can be dealt in combat."""
PHYSICAL = "physical" # Standard weapon damage
FIRE = "fire" # Fire-based magic damage
ICE = "ice" # Ice-based magic damage
LIGHTNING = "lightning" # Lightning-based magic damage
HOLY = "holy" # Holy/divine damage
SHADOW = "shadow" # Dark/shadow magic damage
POISON = "poison" # Poison damage (usually DoT)
ARCANE = "arcane" # Pure magical damage (staves, wands)
class ItemType(Enum):
"""Categories of items in the game."""
WEAPON = "weapon" # Adds damage, may have special effects
ARMOR = "armor" # Adds defense/resistance
CONSUMABLE = "consumable" # One-time use (potions, scrolls)
QUEST_ITEM = "quest_item" # Story-related, non-tradeable
class ItemRarity(Enum):
"""Item rarity tiers affecting drop rates, value, and visual styling."""
COMMON = "common" # White/gray - basic items
UNCOMMON = "uncommon" # Green - slightly better
RARE = "rare" # Blue - noticeably better
EPIC = "epic" # Purple - powerful items
LEGENDARY = "legendary" # Orange/gold - best items
class AffixType(Enum):
"""Types of item affixes for procedural item generation."""
PREFIX = "prefix" # Appears before item name: "Flaming Dagger"
SUFFIX = "suffix" # Appears after item name: "Dagger of Strength"
class AffixTier(Enum):
"""Affix power tiers determining bonus magnitudes."""
MINOR = "minor" # Weaker bonuses, rolls on RARE items
MAJOR = "major" # Medium bonuses, rolls on EPIC items
LEGENDARY = "legendary" # Strongest bonuses, LEGENDARY only
class StatType(Enum):
"""Character attribute types."""
STRENGTH = "strength" # Physical power
DEXTERITY = "dexterity" # Agility and precision
CONSTITUTION = "constitution" # Endurance and health
INTELLIGENCE = "intelligence" # Magical power
WISDOM = "wisdom" # Perception and insight
CHARISMA = "charisma" # Social influence
LUCK = "luck" # Fortune and fate
class AbilityType(Enum):
"""Categories of abilities that can be used in combat or exploration."""
ATTACK = "attack" # Basic physical attack
SPELL = "spell" # Magical spell
SKILL = "skill" # Special class ability
ITEM_USE = "item_use" # Using a consumable item
DEFEND = "defend" # Defensive action
class CombatStatus(Enum):
"""Status of a combat encounter."""
ACTIVE = "active" # Combat is ongoing
VICTORY = "victory" # Player(s) won
DEFEAT = "defeat" # Player(s) lost
FLED = "fled" # Player(s) escaped
class SessionStatus(Enum):
"""Status of a game session."""
ACTIVE = "active" # Session is ongoing
COMPLETED = "completed" # Session ended normally
TIMEOUT = "timeout" # Session ended due to inactivity
class ListingStatus(Enum):
"""Status of a marketplace listing."""
ACTIVE = "active" # Listing is live
SOLD = "sold" # Item has been sold
EXPIRED = "expired" # Listing time ran out
REMOVED = "removed" # Seller cancelled listing
class ListingType(Enum):
"""Type of marketplace listing."""
AUCTION = "auction" # Bidding system
FIXED_PRICE = "fixed_price" # Immediate purchase at set price
class SessionType(Enum):
"""Type of game session."""
SOLO = "solo" # Single-player session
MULTIPLAYER = "multiplayer" # Multi-player party session
class LocationType(Enum):
"""Types of locations in the game world."""
TOWN = "town" # Town or city
TAVERN = "tavern" # Tavern or inn
WILDERNESS = "wilderness" # Outdoor wilderness areas
DUNGEON = "dungeon" # Underground dungeons/caves
RUINS = "ruins" # Ancient ruins
LIBRARY = "library" # Library or archive
SAFE_AREA = "safe_area" # Safe rest areas