Skip to content

Commit

Permalink
Add option to unlock all equipment
Browse files Browse the repository at this point in the history
  • Loading branch information
fatsbrown authored Sep 12, 2024
1 parent 364423f commit 23722e0
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 11 deletions.
12 changes: 10 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
<details><summary>Expand</summary>

* 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.
</details>

### Entitlements

To unlock entitlements (special equipment), create a file ``unlock_entitlements.txt`` in the ``storage`` directory.
<details><summary>Expand</summary>

* 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.
</details>

## Community Discord server and Strava club

Expand Down
21 changes: 12 additions & 9 deletions zwift_offline.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
Expand Down

0 comments on commit 23722e0

Please sign in to comment.