Skip to content

Commit 119eeeb

Browse files
committed
Update XP calculation
1 parent 6f57400 commit 119eeeb

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

app.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,13 @@ def check_level_up(self): # check if user has leveled up
4343
self.xp >= self.xp_required
4444
): # if user XP is greater than or equal to XP required
4545
self.xp -= self.xp_required
46-
self.xp_required = round(
47-
self.xp_required + self.xp_required * 1 / math.sqrt(self.level)
48-
) # increase XP required exponentially with slower growth at higher levels
46+
self.xp_required = max(
47+
1.0,
48+
round(
49+
self.xp_required
50+
+ max(1.0, self.xp_required * 1.0 / math.sqrt(self.level))
51+
),
52+
)
4953
self.level += 1 # increase level
5054

5155
def get_xp_required(self): # get required XP to next level

0 commit comments

Comments
 (0)