Combat Backend & Data Models

- Implement Combat Service
- Implement Damage Calculator
- Implement Effect Processor
- Implement Combat Actions
- Created Combat API Endpoints
This commit is contained in:
2025-11-26 15:43:20 -06:00
parent 30c3b800e6
commit 03ab783eeb
22 changed files with 9091 additions and 5 deletions

View File

@@ -196,3 +196,55 @@ def test_stats_repr():
assert "INT=10" in repr_str
assert "HP=" in repr_str
assert "MP=" in repr_str
# =============================================================================
# LUK Computed Properties (Combat System Integration)
# =============================================================================
def test_crit_bonus_calculation():
"""Test crit bonus calculation: luck * 0.5%."""
stats = Stats(luck=8)
assert stats.crit_bonus == pytest.approx(0.04, abs=0.001) # 4%
stats = Stats(luck=12)
assert stats.crit_bonus == pytest.approx(0.06, abs=0.001) # 6%
stats = Stats(luck=0)
assert stats.crit_bonus == pytest.approx(0.0, abs=0.001) # 0%
def test_hit_bonus_calculation():
"""Test hit bonus (miss reduction): luck * 0.5%."""
stats = Stats(luck=8)
assert stats.hit_bonus == pytest.approx(0.04, abs=0.001) # 4%
stats = Stats(luck=12)
assert stats.hit_bonus == pytest.approx(0.06, abs=0.001) # 6%
stats = Stats(luck=20)
assert stats.hit_bonus == pytest.approx(0.10, abs=0.001) # 10%
def test_lucky_roll_chance_calculation():
"""Test lucky roll chance: 5% + (luck * 0.25%)."""
stats = Stats(luck=8)
# 5% + (8 * 0.25%) = 5% + 2% = 7%
assert stats.lucky_roll_chance == pytest.approx(0.07, abs=0.001)
stats = Stats(luck=12)
# 5% + (12 * 0.25%) = 5% + 3% = 8%
assert stats.lucky_roll_chance == pytest.approx(0.08, abs=0.001)
stats = Stats(luck=0)
# 5% + (0 * 0.25%) = 5%
assert stats.lucky_roll_chance == pytest.approx(0.05, abs=0.001)
def test_repr_includes_combat_bonuses():
"""Test that repr includes LUK-based combat bonuses."""
stats = Stats(luck=10)
repr_str = repr(stats)
assert "CRIT_BONUS=" in repr_str
assert "HIT_BONUS=" in repr_str