İlk commit: Stepstead backend (FastAPI)
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
commit
ea049b8ccd
45 changed files with 6751 additions and 0 deletions
30
game_logic.py
Normal file
30
game_logic.py
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
"""
|
||||
Oyun mantığı yardımcıları: XP eğrisi, level hesabı.
|
||||
"""
|
||||
from config import settings
|
||||
|
||||
# Her skill için XP eğrisi: level N → toplam XP eşiği
|
||||
# Basit kare: 100 * N^2 (level 50 = 250000 XP)
|
||||
def xp_threshold_for_level(level: int) -> int:
|
||||
return 100 * level * level
|
||||
|
||||
|
||||
def skill_level_from_xp(xp: int) -> int:
|
||||
lvl = 1
|
||||
while lvl < 50 and xp >= xp_threshold_for_level(lvl + 1):
|
||||
lvl += 1
|
||||
return lvl
|
||||
|
||||
|
||||
def character_level_from_total_xp(total_xp: int) -> int:
|
||||
# Karakter level: tüm skill XP toplamı eşiği — daha hızlı eğri
|
||||
# Level 1 → 0 XP, Level 50 → 10*250000 = 2.5M XP (zor)
|
||||
# Karakter eğrisi: 500 * N^2
|
||||
lvl = 1
|
||||
while lvl < 50 and total_xp >= 500 * (lvl + 1) * (lvl + 1):
|
||||
lvl += 1
|
||||
return lvl
|
||||
|
||||
|
||||
def is_valid_skill(name: str) -> bool:
|
||||
return name in settings.SKILL_NAMES
|
||||
Loading…
Add table
Add a link
Reference in a new issue