From 23722e0227cb186553ca10e3513cb7090383e170 Mon Sep 17 00:00:00 2001 From: fatsbrown <123950591+fatsbrown@users.noreply.github.com> Date: Wed, 11 Sep 2024 23:24:03 -0300 Subject: [PATCH] Add option to unlock all equipment --- README.md | 12 ++++++++++-- zwift_offline.py | 21 ++++++++++++--------- 2 files changed, 22 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index fc707f7c..7e2de435 100644 --- a/README.md +++ b/README.md @@ -375,11 +375,19 @@ To enable support for multiple users perform the steps below: ### All-time leaderboards -To enable all-time leaderboards (override 60 minutes live results and 90 days personal records), create a file ``all_time_leaderboards.txt`` in the ``storage`` directory. +
Expand + +* To enable all-time leaderboards (override 60 minutes live results and 90 days personal records), create a file ``all_time_leaderboards.txt`` in the ``storage`` directory. +* Jerseys are still valid for 60 minutes but will be granted only when a new all-time record is set. +
### Entitlements -To unlock entitlements (special equipment), create a file ``unlock_entitlements.txt`` in the ``storage`` directory. +
Expand + +* To unlock entitlements (special equipment), create a file ``unlock_entitlements.txt`` in the ``storage`` directory. +* To unlock all equipment, create a file ``unlock_all_equipment.txt`` instead. +
## Community Discord server and Strava club diff --git a/zwift_offline.py b/zwift_offline.py index a22b8ff7..7991f037 100644 --- a/zwift_offline.py +++ b/zwift_offline.py @@ -1758,17 +1758,20 @@ def do_api_profiles(profile_id, is_json): for entitlement in list(profile.entitlements): if entitlement.type == profile_pb2.ProfileEntitlement.EntitlementType.RIDE: profile.entitlements.remove(entitlement) - if os.path.isfile('%s/unlock_entitlements.txt' % STORAGE_DIR): - with open('%s/data/entitlements.txt' % SCRIPT_DIR) as f: - entitlements = json.load(f) - for entitlement in entitlements: - if not any(e.id == entitlement['id'] for e in profile.entitlements): - e = profile.entitlements.add() - e.type = profile_pb2.ProfileEntitlement.EntitlementType.USE - e.id = entitlement['id'] - e.status = profile_pb2.ProfileEntitlement.ProfileEntitlementStatus.ACTIVE if not profile.mix_panel_distinct_id: profile.mix_panel_distinct_id = str(uuid.uuid4()) + if os.path.isfile('%s/unlock_entitlements.txt' % STORAGE_DIR) or os.path.isfile('%s/unlock_all_equipment.txt' % STORAGE_DIR): + with open('%s/data/entitlements.txt' % SCRIPT_DIR) as f: + entitlements = json.load(f) + if os.path.isfile('%s/unlock_all_equipment.txt' % STORAGE_DIR): + for i in range(1, min([e['id'] for e in entitlements])): + entitlements.append({'id': i}) + for entitlement in entitlements: + if not any(e.id == entitlement['id'] for e in profile.entitlements): + e = profile.entitlements.add() + e.type = profile_pb2.ProfileEntitlement.EntitlementType.USE + e.id = entitlement['id'] + e.status = profile_pb2.ProfileEntitlement.ProfileEntitlementStatus.ACTIVE if is_json: #todo: publicId, bodyType, totalRunCalories != total_watt_hours, totalRunTimeInMinutes != time_ridden_in_minutes etc if profile.dob != "": profile.age = age(datetime.datetime.strptime(profile.dob, "%m/%d/%Y"))