Skip to content

Commit c38893a

Browse files
authored
Merge pull request #75 from ManualForArchipelago/skip-ids
Allow items to skip IDs
2 parents 5f19814 + 6200d9c commit c38893a

File tree

4 files changed

+24
-2
lines changed

4 files changed

+24
-2
lines changed

schemas/Manual.items.schema.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,10 @@
9494
"type": ["boolean", "integer"],
9595
"default": false
9696
},
97+
"id": {
98+
"description": "(Optional) Skips the item ID forward to the given value.\nThis can be used to provide buffer space for future items.",
99+
"type": "integer"
100+
},
97101
"_comment": {"$ref": "#/definitions/comment"}
98102
},
99103
"required": ["name"]
@@ -107,4 +111,4 @@
107111
}
108112
}
109113
}
110-
}
114+
}

schemas/Manual.locations.schema.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,10 @@
9292
"type": "boolean",
9393
"default": false
9494
},
95+
"id": {
96+
"description": "(Optional) Skips the item ID forward to the given value.\nThis can be used to provide buffer space for future items.",
97+
"type": "integer"
98+
},
9599
"_comment": {"$ref": "#/definitions/comment"}
96100
}
97101
},
@@ -118,4 +122,4 @@
118122
}
119123
}
120124
}
121-
}
125+
}

src/Items.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,13 @@
2323

2424
# add sequential generated ids to the lists
2525
for key, val in enumerate(item_table):
26+
if "id" in item_table[key]:
27+
item_id = item_table[key]["id"]
28+
if item_id >= count:
29+
count = item_id
30+
else:
31+
raise ValueError(f"{item_table[key]['name']} has an invalid ID. ID must be at least {count + 1}")
32+
2633
item_table[key]["id"] = count
2734
item_table[key]["progression"] = val["progression"] if "progression" in val else False
2835
count += 1

src/Locations.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,13 @@
1515
if "victory" in location_table[key] and location_table[key]["victory"]:
1616
victory_names.append(location_table[key]["name"])
1717

18+
if "id" in location_table[key]:
19+
item_id = location_table[key]["id"]
20+
if item_id >= count:
21+
count = item_id
22+
else:
23+
raise ValueError(f"{location_table[key]['name']} has an invalid ID. ID must be at least {count + 1}")
24+
1825
location_table[key]["id"] = count
1926

2027
if not "region" in location_table[key]:

0 commit comments

Comments
 (0)