Skip to content

Commit

Permalink
Merge pull request #75 from ManualForArchipelago/skip-ids
Browse files Browse the repository at this point in the history
Allow items to skip IDs
  • Loading branch information
FuzzyGamesOn authored Sep 24, 2024
2 parents 5f19814 + 6200d9c commit c38893a
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 2 deletions.
6 changes: 5 additions & 1 deletion schemas/Manual.items.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,10 @@
"type": ["boolean", "integer"],
"default": false
},
"id": {
"description": "(Optional) Skips the item ID forward to the given value.\nThis can be used to provide buffer space for future items.",
"type": "integer"
},
"_comment": {"$ref": "#/definitions/comment"}
},
"required": ["name"]
Expand All @@ -107,4 +111,4 @@
}
}
}
}
}
6 changes: 5 additions & 1 deletion schemas/Manual.locations.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,10 @@
"type": "boolean",
"default": false
},
"id": {
"description": "(Optional) Skips the item ID forward to the given value.\nThis can be used to provide buffer space for future items.",
"type": "integer"
},
"_comment": {"$ref": "#/definitions/comment"}
}
},
Expand All @@ -118,4 +122,4 @@
}
}
}
}
}
7 changes: 7 additions & 0 deletions src/Items.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,13 @@

# add sequential generated ids to the lists
for key, val in enumerate(item_table):
if "id" in item_table[key]:
item_id = item_table[key]["id"]
if item_id >= count:
count = item_id
else:
raise ValueError(f"{item_table[key]['name']} has an invalid ID. ID must be at least {count + 1}")

item_table[key]["id"] = count
item_table[key]["progression"] = val["progression"] if "progression" in val else False
count += 1
Expand Down
7 changes: 7 additions & 0 deletions src/Locations.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@
if "victory" in location_table[key] and location_table[key]["victory"]:
victory_names.append(location_table[key]["name"])

if "id" in location_table[key]:
item_id = location_table[key]["id"]
if item_id >= count:
count = item_id
else:
raise ValueError(f"{location_table[key]['name']} has an invalid ID. ID must be at least {count + 1}")

location_table[key]["id"] = count

if not "region" in location_table[key]:
Expand Down

0 comments on commit c38893a

Please sign in to comment.