Skip to content

Commit 8955f03

Browse files
authored
Add REBUILT game, bump minimum game version to 19.0 (#57)
1 parent 369ea59 commit 8955f03

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

highscores/lib.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,10 @@ def submit_decode(score_obj: Score) -> Union[str, None, tuple[None, str]]:
291291
return submit_score(score_obj, decode_clean_code_check)
292292

293293

294+
def submit_rebuilt(score_obj: Score) -> Union[str, None, tuple[None, str]]:
295+
return submit_score(score_obj, rebuilt_clean_code_check)
296+
297+
294298
def decode_time_data(in_string: str) -> str:
295299
out_bytes = ""
296300

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

533537

538+
def rebuilt_clean_code_check(score_obj: Score) -> Union[str, None, tuple[None, str]]:
539+
return clean_code_check(score_obj, check_rebuilt_game_settings, check_subtraction_score)
540+
541+
534542
def extract_clean_code_info(score_obj: Score) -> tuple[str, list[str], str, str, str, str, str, str]:
535543
""" Extracts the relevant information from the clean code.
536544
:param score_obj: Score object to extract from
@@ -826,6 +834,16 @@ def check_decode_game_settings(game_options: list, restart_option: str, game_ind
826834
return None # No error
827835

828836

837+
def check_rebuilt_game_settings(game_options: list, restart_option: str, game_index: str) -> Union[str, None]:
838+
""" Checks if the REBUILT game settings are valid.
839+
:return: None if the settings are valid, or a response with an error message if they are not.
840+
"""
841+
if (game_index != '22'):
842+
return 'Wrong game! This form is for REBUILT.'
843+
844+
return None # No error
845+
846+
829847
def check_robot_type(score_obj: Score, robot_model: str) -> Union[str, None]:
830848
""" Checks if the robot model is valid.
831849
:return: None if the robot model is valid, or a response with an error message if it is not.
@@ -1018,6 +1036,7 @@ def get_game_length(game_index: str):
10181036
"rs": submit_reefscape,
10191037
"pb": submit_push_back,
10201038
"dc": submit_decode,
1039+
"rb": submit_rebuilt,
10211040
}
10221041

10231042
game_to_submit_func = {
@@ -1039,4 +1058,5 @@ def get_game_length(game_index: str):
10391058
"REEFSCAPE": submit_reefscape,
10401059
"Push Back": submit_push_back,
10411060
"DECODE": submit_decode,
1061+
"REBUILT": submit_rebuilt,
10421062
}

0 commit comments

Comments
 (0)