Phase 4b Abilities and skill trees is finished

This commit is contained in:
2025-11-28 22:02:57 -06:00
parent a8767b34e2
commit 8784fbaa88
3 changed files with 157 additions and 482 deletions

View File

@@ -1269,9 +1269,9 @@ class CombatService:
character = self.character_service.get_character(char_id, user_id)
# Add XP and check for level up
old_level = character.level
character.experience += xp_per_player
# TODO: Add level up logic based on XP thresholds
leveled_up = character.add_experience(xp_per_player)
if leveled_up:
rewards.level_ups.append(char_id)
# Add gold
character.gold += gold_per_player
@@ -1279,9 +1279,6 @@ class CombatService:
# Save character
self.character_service.update_character(character, user_id)
if character.level > old_level:
rewards.level_ups.append(char_id)
except Exception as e:
logger.error("Failed to distribute rewards to character",
char_id=char_id,

View File

@@ -365,17 +365,162 @@ effects_applied:
### Experience & Leveling
| Source | XP Gain |
|--------|---------|
| Combat victory | Based on enemy difficulty |
| Quest completion | Fixed quest reward |
| Story milestones | Major plot points |
| Exploration | Discovering new locations |
**XP Sources:**
| Source | XP Gain | Notes |
|--------|---------|-------|
| Combat victory | Based on enemy `experience_reward` field | Divided evenly among party members |
| Quest completion | Fixed quest reward | Defined in quest data |
| Story milestones | Major plot points | AI-driven narrative rewards |
| Exploration | Discovering new locations | Future enhancement |
**Level Progression:**
- XP required increases per level (exponential curve)
- Each level grants +1 skill point
- Stats may increase based on class
The XP requirement for each level follows an exponential curve using the formula:
```
XP Required = 100 × (current_level ^ 1.5)
```
| Level | XP Required | Cumulative XP |
|-------|-------------|---------------|
| 1→2 | 100 | 100 |
| 2→3 | 282 | 382 |
| 3→4 | 519 | 901 |
| 4→5 | 800 | 1,701 |
| 5→6 | 1,118 | 2,819 |
| 6→7 | 1,469 | 4,288 |
| 7→8 | 1,849 | 6,137 |
| 8→9 | 2,254 | 8,391 |
| 9→10 | 2,683 | 11,074 |
**Leveling Mechanics:**
- Each level grants **+1 skill point** to spend in skill trees
- Skill points calculated: `level - unlocked_skills.length`
- Overflow XP automatically carries to next level
- Level up triggers automatically when threshold reached
- Base stats remain constant (progression via skill trees & equipment)
**Implementation:**
- Leveling logic lives in `Character` model (`add_experience()`, `level_up()` methods)
- No separate service needed (OOP design pattern)
- See `api/app/models/character.py` lines 312-358
### Skill Trees
**Overview:**
Each character class has **2-3 skill trees** representing different specializations or playstyles. Players earn **1 skill point per level** to unlock skills, which provide permanent bonuses and unlock combat abilities.
**Skill Points:**
```
Available Skill Points = Character Level - Unlocked Skills Count
```
**Skill Tree Structure:**
Each skill tree contains **5 tiers** of increasing power:
| Tier | Description | Typical Effects |
|------|-------------|-----------------|
| **1** | Entry-level skills | Basic abilities, small stat bonuses (+3-5) |
| **2** | Intermediate skills | Enhanced abilities, moderate bonuses (+5-8) |
| **3** | Advanced skills | Powerful abilities, passive effects |
| **4** | Expert skills | Ability enhancements, large bonuses (+10-15) |
| **5** | Ultimate skills | Class-defining abilities, massive bonuses (+20+) |
**Prerequisites:**
Skills have prerequisites that create progression paths:
- Tier 1 skills have **no prerequisites** (open choices)
- Higher tier skills require **specific lower-tier skills**
- Cannot skip tiers (must unlock Tier 1 before Tier 2, etc.)
- Can mix between trees within same class
**Skill Effects:**
Skills provide multiple types of benefits:
1. **Stat Bonuses** - Permanent increases to stats
```yaml
effects:
stat_bonuses:
strength: 10
defense: 5
```
2. **Ability Unlocks** - Grant new combat abilities
```yaml
effects:
abilities:
- shield_bash
- riposte
```
3. **Passive Effects** - Special mechanics
```yaml
effects:
passive_effects:
- stun_resistance
- damage_reflection
```
4. **Ability Enhancements** - Modify existing abilities
```yaml
effects:
ability_enhancements:
fireball:
damage_bonus: 15
mana_cost_reduction: 5
```
5. **Combat Bonuses** - Crit chance, crit multiplier, etc.
```yaml
effects:
combat_bonuses:
crit_chance: 0.1 # +10%
crit_multiplier: 0.5 # +0.5x
```
**Example Progression Path:**
**Vanguard - Shield Bearer Tree:**
```
Level 1: No skills yet (0 points)
Level 2: Unlock "Shield Bash" (Tier 1) → Gain shield bash ability
Level 3: Unlock "Fortify" (Tier 1) → +5 defense bonus
Level 4: Unlock "Shield Wall" (Tier 2, requires Shield Bash) → Shield wall ability
Level 5: Unlock "Iron Skin" (Tier 2, requires Fortify) → +5 constitution
Level 6: Unlock "Guardian's Resolve" (Tier 3) → +10 defense + stun resistance
...
```
**Class Specializations:**
Each class offers distinct playstyles through their trees:
| Class | Tree 1 | Tree 2 | Tree 3 |
|-------|--------|--------|--------|
| **Vanguard** | Shield Bearer (Tank) | Weapon Master (DPS) | - |
| **Arcanist** | Pyromancy (Fire) | Cryomancy (Ice) | Electromancy (Lightning) |
| **Wildstrider** | Beast Mastery | Nature Magic | - |
| **Assassin** | Shadow Arts | Poison Master | - |
| **Luminary** | Holy Magic | Divine Protection | - |
| **Necromancer** | Death Magic | Corpse Summoning | - |
| **Lorekeeper** | Arcane Knowledge | Support Magic | - |
| **Oathkeeper** | Divine Wrath | Holy Shield | - |
**Design Notes:**
- Skill choices are **permanent** (no respec system currently)
- Players can mix skills from different trees within same class
- Some skills are **mutually exclusive** by design (different playstyles)
- Skill point allocation encourages specialization vs. generalization
**Implementation:**
- Skills defined in class YAML files at `api/app/data/classes/*.yaml`
- Character stores only `unlocked_skills: List[str]` (skill IDs)
- Bonuses calculated dynamically via `Character.get_effective_stats()`
- Full documentation: [SKILLS_AND_ABILITIES.md](SKILLS_AND_ABILITIES.md)
### Loot System