modified: bot.py
This commit is contained in:
12
bot.py
12
bot.py
@@ -475,8 +475,12 @@ def read_background_data(filename):
|
|||||||
def get_current_datetime():
|
def get_current_datetime():
|
||||||
return datetime.now().strftime("%Y-%m-%d %H:%M:%S")
|
return datetime.now().strftime("%Y-%m-%d %H:%M:%S")
|
||||||
|
|
||||||
def calculate_xp_for_level(level):
|
def calculate_level(xp):
|
||||||
return 5 * (level ** 2) + 50 * level + 100
|
if xp is None:
|
||||||
|
xp = 0 # Setze XP auf 0, wenn es None ist
|
||||||
|
# Hier die Berechnung für das Level basierend auf der XP
|
||||||
|
level = 5 * (xp ** 2) + 50 * xp + 100
|
||||||
|
return level
|
||||||
|
|
||||||
async def add_xp_to_user(user_id, xp_gained):
|
async def add_xp_to_user(user_id, xp_gained):
|
||||||
user_data = load_user_data(user_id)
|
user_data = load_user_data(user_id)
|
||||||
@@ -485,13 +489,13 @@ async def add_xp_to_user(user_id, xp_gained):
|
|||||||
|
|
||||||
# Füge die neu verdiente XP hinzu
|
# Füge die neu verdiente XP hinzu
|
||||||
new_xp = current_xp + xp_gained
|
new_xp = current_xp + xp_gained
|
||||||
next_level_xp = calculate_xp_for_level(current_level)
|
next_level_xp = calculate_level(current_level)
|
||||||
|
|
||||||
# Level-Up-Logik
|
# Level-Up-Logik
|
||||||
while new_xp >= next_level_xp:
|
while new_xp >= next_level_xp:
|
||||||
new_xp -= next_level_xp
|
new_xp -= next_level_xp
|
||||||
current_level += 1
|
current_level += 1
|
||||||
next_level_xp = calculate_xp_for_level(current_level)
|
next_level_xp = calculate_level(current_level)
|
||||||
await notify_level_up(user_id, current_level) # Funktion für Level-Up-Benachrichtigung
|
await notify_level_up(user_id, current_level) # Funktion für Level-Up-Benachrichtigung
|
||||||
|
|
||||||
# Speichern der neuen XP und des Levels
|
# Speichern der neuen XP und des Levels
|
||||||
|
|||||||
Reference in New Issue
Block a user