first commit
This commit is contained in:
51
api/data.py
Normal file
51
api/data.py
Normal file
@@ -0,0 +1,51 @@
|
||||
import random
|
||||
from typing import Dict
|
||||
|
||||
|
||||
def generate_skill_build() -> Dict[int, str]:
|
||||
"""
|
||||
Generate a random skill build for levels 1-25 following Dota 2 rules:
|
||||
- Ultimate (r) can only be skilled at levels 6, 12, 18
|
||||
- Talents can only be skilled at levels 10, 15, 20, 25
|
||||
- Basic abilities (q, w, e) can be skilled at other levels
|
||||
- Each basic ability maxes at 4 points
|
||||
- Ultimate maxes at 3 points
|
||||
- One talent per tier (left OR right)
|
||||
"""
|
||||
skill_build: Dict[int, str] = {}
|
||||
|
||||
# Track ability points spent
|
||||
ability_points = {"q": 0, "w": 0, "e": 0, "r": 0}
|
||||
max_points = {"q": 4, "w": 4, "e": 4, "r": 3}
|
||||
|
||||
# Talent levels and which side to pick
|
||||
talent_levels = [10, 15, 20, 25]
|
||||
|
||||
# Ultimate levels
|
||||
ult_levels = [6, 12, 18]
|
||||
|
||||
for level in range(1, 26):
|
||||
if level in talent_levels:
|
||||
# Pick random talent side
|
||||
skill_build[level] = random.choice(["left_talent", "right_talent"])
|
||||
elif level in ult_levels:
|
||||
# Must skill ultimate if not maxed
|
||||
if ability_points["r"] < max_points["r"]:
|
||||
skill_build[level] = "r"
|
||||
ability_points["r"] += 1
|
||||
else:
|
||||
# Ultimate maxed, pick a basic ability
|
||||
available = [a for a in ["q", "w", "e"] if ability_points[a] < max_points[a]]
|
||||
if available:
|
||||
choice = random.choice(available)
|
||||
skill_build[level] = choice
|
||||
ability_points[choice] += 1
|
||||
else:
|
||||
# Regular level - pick a basic ability
|
||||
available = [a for a in ["q", "w", "e"] if ability_points[a] < max_points[a]]
|
||||
if available:
|
||||
choice = random.choice(available)
|
||||
skill_build[level] = choice
|
||||
ability_points[choice] += 1
|
||||
|
||||
return skill_build
|
||||
Reference in New Issue
Block a user