Player Stats Leveling - xopherdeep/do-it-for-the-xp GitHub Wiki
Player Stats & Leveling System
This document describes how player stats (HP, MP, XP) are calculated and how the leveling system works.
Overview
The leveling system uses a combination of:
- Base stats per job class - Each class has different starting HP/MP and growth rates
- Level-based growth - Stats increase with each level
- Special stats contribution - Endurance, Intelligence, and Wisdom affect HP/MP
Base Stats by Job Class
| Class | Base HP | Base MP | HP/Level | MP/Level | Primary Stat |
|---|---|---|---|---|---|
| Warrior | 50 | 10 | +8 | +2 | Endurance → HP |
| Mage | 25 | 40 | +3 | +8 | Intelligence → MP |
| Thief | 35 | 20 | +5 | +4 | Balanced |
| Monk | 45 | 25 | +7 | +5 | Endurance + Wisdom |
| Default | 30 | 20 | +5 | +4 | Balanced |
Stat Calculation Formulas
Max HP
MaxHP = BaseHP + (HPGrowth × (Level - 1)) + (Endurance × EnduranceMultiplier) + (Guts × 0.5)
Max MP
MaxMP = BaseMP + (MPGrowth × (Level - 1)) + (Intelligence × IntelligenceMultiplier) + (Wisdom × WisdomMultiplier)
XP Required Per Level
XP_for_Level = 100 × Level^1.5
Example XP requirements:
- Level 2: 283 XP
- Level 5: 1,118 XP
- Level 10: 3,162 XP
- Level 20: 8,944 XP
- Level 50: 35,355 XP
Special Stats Impact
Endurance
- Primary contributor to HP
- Warrior: 3× multiplier
- Monk: 2.5× multiplier
- Thief: 1.5× multiplier
- Mage: 1× multiplier
Intelligence
- Primary contributor to MP
- Mage: 3× multiplier
- Others: 0.5-1× multiplier
Wisdom
- Secondary contributor to MP
- Mage: 2× multiplier
- Monk: 1.5× multiplier
- Others: 0.5-1× multiplier
Guts
- Secondary contributor to HP
- All classes: 0.5× multiplier (universal)
Example Calculations
Level 1 Warrior with 5 Endurance
MaxHP = 50 + (8 × 0) + (5 × 3) + (0 × 0.5) = 50 + 0 + 15 + 0 = 65 HP
MaxMP = 10 + (2 × 0) + (0 × 0.5) + (0 × 0.5) = 10 + 0 + 0 + 0 = 10 MP
Level 5 Mage with 10 Intelligence, 5 Wisdom
MaxHP = 25 + (3 × 4) + (0 × 1) + (0 × 0.5) = 25 + 12 + 0 + 0 = 37 HP
MaxMP = 40 + (8 × 4) + (10 × 3) + (5 × 2) = 40 + 32 + 30 + 10 = 112 MP
Level 10 Monk with 8 Endurance, 5 Intelligence, 7 Wisdom
MaxHP = 45 + (7 × 9) + (8 × 2.5) + (0 × 0.5) = 45 + 63 + 20 + 0 = 128 HP
MaxMP = 25 + (5 × 9) + (5 × 1) + (7 × 1.5) = 25 + 45 + 5 + 10.5 = 85 MP
Implementation
The leveling system is implemented in:
src/lib/services/stats/PlayerStatsService.ts- Core calculationssrc/app/Console/BattleField/hooks/useBattlePlayer.ts- Battle HUD integration
Key Functions
// Calculate max HP for a player
calculateMaxHp(level, jobClass, specialStats)
// Calculate max MP for a player
calculateMaxMp(level, jobClass, specialStats)
// Get full stats object
calculatePlayerStats(level, jobClass, specialStats, currentHp?, currentMp?)
// XP calculations
getXpForLevel(level) // Total XP to reach level
getXpToNextLevel(level) // XP needed for next level
getLevelFromXp(totalXp) // What level for given XP
// Level up preview
calculateLevelUp(currentLevel, targetLevel, jobClass, specialStats)
Future Enhancements
- Equipment bonuses to stats
- Status effects (buffs/debuffs)
- Job class evolution (Tier 2/3 classes)
- Stat point allocation on level up
- Prestige system for level 99+