Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions highscores/lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,10 @@ def submit_decode(score_obj: Score) -> Union[str, None, tuple[None, str]]:
return submit_score(score_obj, decode_clean_code_check)


def submit_rebuilt(score_obj: Score) -> Union[str, None, tuple[None, str]]:
return submit_score(score_obj, rebuilt_clean_code_check)


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

Expand Down Expand Up @@ -531,6 +535,10 @@ def decode_clean_code_check(score_obj: Score) -> Union[str, None, tuple[None, st
return clean_code_check(score_obj, check_decode_game_settings, check_subtraction_score)


def rebuilt_clean_code_check(score_obj: Score) -> Union[str, None, tuple[None, str]]:
return clean_code_check(score_obj, check_rebuilt_game_settings, check_subtraction_score)


def extract_clean_code_info(score_obj: Score) -> tuple[str, list[str], 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 @@ -826,6 +834,16 @@ def check_decode_game_settings(game_options: list, restart_option: str, game_ind
return None # No error


def check_rebuilt_game_settings(game_options: list, restart_option: str, game_index: str) -> Union[str, None]:
""" Checks if the REBUILT 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 != '22'):
return 'Wrong game! This form is for REBUILT.'

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 @@ -1018,6 +1036,7 @@ def get_game_length(game_index: str):
"rs": submit_reefscape,
"pb": submit_push_back,
"dc": submit_decode,
"rb": submit_rebuilt,
}

game_to_submit_func = {
Expand All @@ -1039,4 +1058,5 @@ def get_game_length(game_index: str):
"REEFSCAPE": submit_reefscape,
"Push Back": submit_push_back,
"DECODE": submit_decode,
"REBUILT": submit_rebuilt,
}