aboutsummaryrefslogtreecommitdiff
path: root/srb.py
diff options
context:
space:
mode:
authorB. Stack <bgstack15@gmail.com>2024-03-19 13:12:15 -0400
committerB. Stack <bgstack15@gmail.com>2024-03-19 13:12:15 -0400
commit5d403bec9273db6b5b5afdd1730f6bcd96766243 (patch)
tree1fda5a12b7ffb2bb2955e70a01172eeca6f5d300 /srb.py
parentadd get/add/remove purchased planes (diff)
downloadsrb_lib-5d403bec9273db6b5b5afdd1730f6bcd96766243.tar.gz
srb_lib-5d403bec9273db6b5b5afdd1730f6bcd96766243.tar.bz2
srb_lib-5d403bec9273db6b5b5afdd1730f6bcd96766243.zip
add set-level, set-level-balloons
Diffstat (limited to 'srb.py')
-rwxr-xr-xsrb.py39
1 files changed, 38 insertions, 1 deletions
diff --git a/srb.py b/srb.py
index 81c8b5f..9674a66 100755
--- a/srb.py
+++ b/srb.py
@@ -46,6 +46,8 @@ parser.add_argument("--get-purchased-planes",action="store_true",help="Print cur
parser.add_argument("--add-purchased-planes",action="append",help="For profile, add these purchased planes. Can be used multiple times.")
parser.add_argument("--remove-purchased-planes",action="append",help="For profile, remove (un-buy) these purchased planes. Can be used multiple times.")
parser.add_argument("--get-level",help="Print status for this level for profile.")
+parser.add_argument("--set-level",action="append",help="Set completion status for this level for profile. Example value to pass: \"0,general\"")
+parser.add_argument("--set-level-balloons",action="append",help="Set balloon status for this level for profile. Example value to pass: \"0,all\" or \"0,none\"")
parser.add_argument("--get-levelset",help="Print status for this levelset for profile.")
parser.add_argument("--get-name",action="store_true",help="Print name for profile.")
parser.add_argument("--set-name",help="Set name for profile.")
@@ -76,7 +78,7 @@ profile_id = args.profile
#print(f"profile_id={profile_id}")
# WORKHERE: new actions that need --profile must be added here.
-if not profile_id and (args.get_money or args.set_money or args.get_weapon or args.set_weapon or args.get_level or args.get_name or args.set_name or args.get_profile_in_use or args.get_purchased_weapons or args.get_tutorial_completed or args.add_purchased_weapons or args.remove_purchased_weapons or args.get_health or args.get_stunt or args.get_gun or args.set_health or args.set_stunt or args.set_gun or args.get_levelset or args.get_purchased_planes or args.add_purchased_planes or args.remove_purchased_planes):
+if not profile_id and (args.get_money or args.set_money or args.get_weapon or args.set_weapon or args.get_level or args.get_name or args.set_name or args.get_profile_in_use or args.get_purchased_weapons or args.get_tutorial_completed or args.add_purchased_weapons or args.remove_purchased_weapons or args.get_health or args.get_stunt or args.get_gun or args.set_health or args.set_stunt or args.set_gun or args.get_levelset or args.get_purchased_planes or args.add_purchased_planes or args.remove_purchased_planes or args.set_level or args.set_level_balloons):
ferror("Warning: Cannot perform most actions without --profile. Not all tasks may run.")
else:
if args.get_money:
@@ -103,6 +105,41 @@ else:
srb_lib.write_file(args.file,0,data)
if args.get_level:
print(f"Profile {profile_id} has level {args.get_level} status {srb_lib.get_level_status(args.file,profile_id,args.get_level)}")
+ if args.set_level:
+ for l in args.set_level:
+ level_num = -1
+ try:
+ level_num, completion = l.split(",")
+ except:
+ ferror(f"Warning! Skipping un-parseable level completion spec {l}. Please use \"0,general\" format.")
+ if level_num != -1:
+ completion_names = [i["name"] for i in srb_lib.LEVEL_STATUSES]
+ if completion not in completion_names:
+ ferror(f"Warning! Skipping invalid level completion spec {l}; for completion, use one of {completion_names}")
+ else:
+ # so we have a valid level completion spec.
+ data, new_status, message = srb_lib.set_level_status(args.file,profile_id,level_num, completion)
+ if (type(data) == int and data == -1) or message != "":
+ ferror(f"Failed to set profile {profile_id} level {level_num} status to {completion} because {message}")
+ else:
+ srb_lib.write_file(args.file,0,data)
+ if args.set_level_balloons:
+ for l in args.set_level_balloons:
+ level_num = -1
+ try:
+ level_num, balloons = l.split(",")
+ except:
+ ferror(f"Warning! Skipping un-parseable level completion spec {l}. Please use \"0,general\" format.")
+ if level_num != -1:
+ if balloons not in ["none","all"]:
+ ferror(f"Warning! Skipping invalid balloons for level {l}; options are all or none.")
+ else:
+ data, message = srb_lib.set_level_balloons(args.file,profile_id,level_num,balloons)
+ if (type(data) == int and data == -1) or message != "":
+ ferror(f"Failed to set profile {profile_id} level {level_num} balloons to {balloons} because {message}")
+ else:
+ srb_lib.write_file(args.file,0,data)
+
if args.get_levelset:
print(f"Profile {profile_id} has levelset {args.get_levelset} status {srb_lib.get_levelset_status(args.file,profile_id,args.get_levelset)}")
if args.get_name:
bgstack15