stepstead-backend/game_logic.py
jts ea049b8ccd İlk commit: Stepstead backend (FastAPI)
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-11 11:30:24 +03:00

30 lines
852 B
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

"""
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