aboutsummaryrefslogtreecommitdiff
path: root/srb_lib.py
diff options
context:
space:
mode:
Diffstat (limited to 'srb_lib.py')
-rw-r--r--srb_lib.py24
1 files changed, 23 insertions, 1 deletions
diff --git a/srb_lib.py b/srb_lib.py
index b659028..64d323e 100644
--- a/srb_lib.py
+++ b/srb_lib.py
@@ -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)
bgstack15