diff options
author | B. Stack <bgstack15@gmail.com> | 2024-03-19 14:10:10 -0400 |
---|---|---|
committer | B. Stack <bgstack15@gmail.com> | 2024-03-19 14:10:10 -0400 |
commit | 88da6cab8739706a2da320d9980e169b85c63a10 (patch) | |
tree | e2758640725d165b55b472b04dfc7af14c1270e6 /srb_lib.py | |
parent | add set-level, set-level-balloons (diff) | |
download | srb_lib-88da6cab8739706a2da320d9980e169b85c63a10.tar.gz srb_lib-88da6cab8739706a2da320d9980e169b85c63a10.tar.bz2 srb_lib-88da6cab8739706a2da320d9980e169b85c63a10.zip |
set levelset available levels
Diffstat (limited to 'srb_lib.py')
-rw-r--r-- | srb_lib.py | 24 |
1 files changed, 23 insertions, 1 deletions
@@ -451,10 +451,32 @@ def get_levelset_status(data_object,profile_id,levelset): x += 1 completed_letters = ''.join(completed_letters) print(f"Debug: letters, uppercase is collected: {completed_letters}") - # it comes back as an int, but does it look better as a hex? return profile_levelset_status +def set_levelset_available_levels(data_object,profile_id,levelset,completed_count): + data = _get_data_from_data_object(data_object) + levelset_obj, message = get_levelset_info(levelset) + if message != "": + return -1, f"For set_levelset_available_levels unable to get levelset for {levelset}." + if completed_count == "all": + completed_count = 8 # no levelset has more than 6 levels so this is a safe maximum, and it will get checked farther below. + if completed_count == "none": + completed_count = 0 + # by this point, it better be an integer + try: + completed_count = int(completed_count) + except: + return -1, f"cannot set levelset available levels to {completed_count}" + if completed_count < 0: + completed_count = 0 + completed_count = min(levelset_obj["l"], completed_count) + pos_levelset_completed_mission_mask = PROFILE_START_POSITION[profile_id]+POS_LEVELSET_COMPLETED_MISSIONS_MASK+(INT_SIZE*levelset_obj["id"]) + completed_bitmask = pow(2,completed_count)-1 + #print(f"debug: need to set levelset {levelset} available count to {completed_count}, which stored as a bitmask should be {completed_bitmask:07b}") + data = srb_pack('<1i',data,pos_levelset_completed_mission_mask,completed_bitmask) + return data, "" + def get_collected_balloons_for_levelset(data_object,profile_id,levelset,silent=False): data = _get_data_from_data_object(data_object) levelset_obj, message = get_levelset_info(levelset) |