Skip to content

Commit

Permalink
Add submit_high_stakes function and related checks
Browse files Browse the repository at this point in the history
  • Loading branch information
NicholasBottone committed Jul 14, 2024
1 parent f700dc3 commit cd53aea
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions highscores/lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,10 @@ def submit_crescendo(score_obj: Score) -> Union[str, None]:
return submit_score(score_obj, crescendo_clean_code_check)


def submit_high_stakes(score_obj: Score) -> Union[str, None]:
return submit_score(score_obj, high_stakes_clean_code_check)


def decode_time_data(in_string: str) -> str:
out_bytes = ""

Expand Down Expand Up @@ -276,6 +280,10 @@ def crescendo_clean_code_check(score_obj: Score) -> Union[str, None]:
return clean_code_check(score_obj, check_crescendo_game_settings, check_subtraction_score)


def high_stakes_clean_code_check(score_obj: Score) -> Union[str, None]:
return clean_code_check(score_obj, check_high_stakes_game_settings, check_score)


def extract_clean_code_info(score_obj: Score) -> tuple[str, list[str], str, str, str, str, str]:
""" Extracts the relevant information from the clean code.
:param score_obj: Score object to extract from
Expand Down Expand Up @@ -466,6 +474,20 @@ def check_crescendo_game_settings(game_options: list, restart_option: str, game_
return None # No error


def check_high_stakes_game_settings(game_options: list, restart_option: str, game_index: str) -> Union[str, None]:
""" Checks if the High Stakes game settings are valid.
:return: None if the settings are valid, or a response with an error message if they are not.
"""
if (game_index != '17'):
return 'Wrong game! This form is for High Stakes.'
if (restart_option != '2'):
return 'You must use restart option 2 (skills challenge) for High Stakes high score submissions.'
if (game_options[0] != '1'):
return 'You must have auto wall enabled for high score submissions.'

return None # No error


def check_robot_type(score_obj: Score, robot_model: str) -> Union[str, None]:
""" Checks if the robot model is valid.
:return: None if the robot model is valid, or a response with an error message if it is not.
Expand Down Expand Up @@ -631,6 +653,7 @@ def check_time_data(score_obj: Score) -> Union[str, None]:
"cs": submit_centerstage,
"ou": submit_over_under,
"cr": submit_crescendo,
"hs": submit_high_stakes,
}

game_to_submit_func = {
Expand All @@ -644,4 +667,5 @@ def check_time_data(score_obj: Score) -> Union[str, None]:
"CENTERSTAGE": submit_centerstage,
"Over Under": submit_over_under,
"Crescendo": submit_crescendo,
"High Stakes": submit_high_stakes,
}

0 comments on commit cd53aea

Please sign in to comment.