Correct score submission value. Parse times correctly.
This commit is contained in:
+12
-2
@@ -315,7 +315,7 @@ async def send_highscore_message(channel: nextcord.TextChannel, group: CategoryG
|
||||
|
||||
|
||||
async def submit_score(
|
||||
interaction: nextcord.Interaction, group_id: int, category_id: int, username: str, score: float
|
||||
interaction: nextcord.Interaction, group_id: int, category_id: int, username: str, score: str
|
||||
) -> None:
|
||||
"""
|
||||
Adds passed score to group. Then updates group message by calling send_highscore_message.
|
||||
@@ -326,9 +326,19 @@ async def submit_score(
|
||||
group (CategoryGroup): group to submit score to.
|
||||
category_id (Category): Category to submit score to.
|
||||
username (str): The user who submitted the score.
|
||||
score (float): Score to submit.
|
||||
score (str): Score to submit. Need to convert to correct type.
|
||||
"""
|
||||
|
||||
stmt = select(Category.IsTimeRecord).where(Category.CategoryId == category_id)
|
||||
is_time_record = session.scalar(stmt)
|
||||
|
||||
if is_time_record:
|
||||
minutes = float(score.split(":", maxsplit=1)[0])
|
||||
seconds = float(score.split(":", maxsplit=1)[1])
|
||||
score = (minutes * 60) + seconds
|
||||
else:
|
||||
score = float(score)
|
||||
|
||||
score_obj = Score(UserName=username, Score=score, CategoryId=category_id)
|
||||
session.add(score_obj)
|
||||
session.commit()
|
||||
|
||||
Reference in New Issue
Block a user