Skip to content

Commit

Permalink
Merge pull request #337 from randovania/fix-starting-eparts
Browse files Browse the repository at this point in the history
Allow starting with any amount of eparts regardless of configuration
  • Loading branch information
henriquegemignani authored Jul 21, 2024
2 parents f8b0cd0 + 7e4c10b commit f491248
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
12 changes: 9 additions & 3 deletions src/open_dread_rando/dread_patcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,15 @@ def create_custom_init(editor: PatcherEditor, configuration: dict) -> str:
if "ITEM_ENERGY_TANKS" in inventory:
etanks = inventory.pop("ITEM_ENERGY_TANKS")
max_life += etanks * energy_per_tank
if "ITEM_LIFE_SHARDS" in inventory and configuration["immediate_energy_parts"]:
shards = inventory.pop("ITEM_LIFE_SHARDS")
max_life += shards * energy_per_part
if "ITEM_LIFE_SHARDS" in inventory and inventory["ITEM_LIFE_SHARDS"] > 0:
total_shards = inventory["ITEM_LIFE_SHARDS"]
leftover_shards = total_shards % 4
if configuration["immediate_energy_parts"] or leftover_shards == 0:
max_life += total_shards * energy_per_part
inventory.pop("ITEM_LIFE_SHARDS")
elif total_shards > leftover_shards:
max_life += (total_shards - leftover_shards) * energy_per_part
inventory["ITEM_LIFE_SHARDS"] = leftover_shards

inventory.update({
# TODO: expose shuffling these
Expand Down
3 changes: 0 additions & 3 deletions src/open_dread_rando/files/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -251,9 +251,6 @@
},
"starting_items": {
"type": "object",
"properties": {
"ITEM_LIFE_SHARDS": {"type": "number", "maximum": 3}
},
"propertyNames": {
"$ref": "#/$defs/item_id"
}
Expand Down
5 changes: 3 additions & 2 deletions tests/test_files/april_fools_patcher.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
"ITEM_RANDO_ARTIFACT_9": 1,
"ITEM_RANDO_ARTIFACT_10": 1,
"ITEM_RANDO_ARTIFACT_11": 1,
"ITEM_RANDO_ARTIFACT_12": 1
"ITEM_RANDO_ARTIFACT_12": 1,
"ITEM_LIFE_SHARDS": 7
},
"starting_text": [
[]
Expand Down Expand Up @@ -4057,7 +4058,7 @@
}
},
"energy_per_tank": 100,
"immediate_energy_parts": true,
"immediate_energy_parts": false,
"enable_remote_lua": true,
"constant_environment_damage": {
"heat": 20,
Expand Down

0 comments on commit f491248

Please sign in to comment.