Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update config #4

Merged
merged 1 commit into from
May 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -198,3 +198,6 @@ minecraft_versions.json
.LSOverride
Thumbs.db
[Dd]esktop.ini

config.json
prime.iso
9 changes: 6 additions & 3 deletions worlds/metroidprime/Items.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class MetroidPrimeItem(Item):
"Plasma Beam": ItemData("Plasma Beam", 3, ItemClassification.progression),
"Missile Expansion": ItemData("Missile Expansion", 4, ItemClassification.useful, 999),
"Scan Visor": ItemData("Scan Visor", 5, ItemClassification.progression),
"Morph Ball Bombs": ItemData("Morph Ball Bombs", 6, ItemClassification.progression),
"Morph Ball Bomb": ItemData("Morph Ball Bomb", 6, ItemClassification.progression),
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

randomprime expects this to be singular 🤷

"Power Bomb Expansion": ItemData("Power Bomb Expansion", 7, ItemClassification.useful, 99),
"Flamethrower": ItemData("Flamethrower", 8, ItemClassification.filler),
"Thermal Visor": ItemData("Thermal Visor", 9, ItemClassification.progression),
Expand All @@ -48,12 +48,15 @@ class MetroidPrimeItem(Item):
"Varia Suit": ItemData("Varia Suit", 22, ItemClassification.progression),
"Phazon Suit": ItemData("Phazon Suit", 23, ItemClassification.progression),
"Energy Tank": ItemData("Energy Tank", 24, ItemClassification.useful, 14),
"UnknownItem1": ItemData("UnknownItem1", 25, ItemClassification.useful),
# item 026 is a health refill
"Ice Trap": ItemData("Ice Trap", 27, ItemClassification.trap),
"Wavebuster": ItemData("Wavebuster", 28, ItemClassification.filler),
}

misc_item_table: dict[str, ItemData] = {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved these out so they aren't included in the item pool for now (we'll obviously want to move ice traps back in eventually)

"UnknownItem1": ItemData("UnknownItem1", 25, ItemClassification.useful),
"Ice Trap": ItemData("Ice Trap", 27, ItemClassification.trap),
}

# These item ids are invalid in the player state, we'll need to exclude it from logic relying on that
custom_suit_upgrade_table: dict[str, ItemData] = {
"Main Missile": ItemData("Main Missile", 41, ItemClassification.progression),
Expand Down
4 changes: 2 additions & 2 deletions worlds/metroidprime/Logic.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def prime_etank_count(self, world: MultiWorld, player: int) -> int:
return count

def prime_can_bomb(self, world: MultiWorld, player: int) -> bool:
return self.has_all({'Morph Ball', 'Morph Ball Bombs'}, player)
return self.has_all({'Morph Ball', 'Morph Ball Bomb'}, player)

def prime_can_boost(self, world: MultiWorld, player: int) -> bool:
return self.has_all({'Morph Ball', 'Boost Ball'}, player)
Expand Down Expand Up @@ -125,5 +125,5 @@ def prime_upper_mines(self, world: MultiWorld, player: int) -> bool:
# should also cover reverse lower mines since upper mines can logically expect magmoor elevator
def prime_lower_mines(self, world: MultiWorld, player: int) -> bool:
return (self.prime_upper_mines(world, player) and self.prime_can_pb(world, player) and
self.has_all({'Morph Ball Bombs', 'Boost Ball', 'Spider Ball', 'Plasma Beam',
self.has_all({'Morph Ball Bomb', 'Boost Ball', 'Spider Ball', 'Plasma Beam',
'X-Ray Visor', 'Grapple Beam'}, player))
21 changes: 18 additions & 3 deletions worlds/metroidprime/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from pathlib import Path
from typing import Any, Dict, List
from BaseClasses import Item, Tutorial, ItemClassification
from .Items import MetroidPrimeItem, suit_upgrade_table, artifact_table, item_table, custom_suit_upgrade_table
Expand Down Expand Up @@ -45,6 +46,7 @@ class MetroidPrimeWorld(World):
topology_present = True
item_name_to_id = {name: data.code for name, data in item_table.items()}
location_name_to_id = every_location
settings: MetroidPrimeSettings
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Once I wired this up that settings class worked as expected and correctly asked me to put in an ISO 🎉


def create_regions(self) -> None:
boss_selection = int(self.options.final_bosses)
Expand Down Expand Up @@ -113,9 +115,22 @@ def set_rules(self) -> None:
self.multiworld.completion_condition[self.player] = lambda state: (
state.can_reach("Mission Complete", "Region", self.player))

def generate_output(self) -> None:
configjson = make_config(self, self.options)
py_randomprime.patch_iso(self.settings.rom_file, "prime_out.iso", configjson)
def generate_output(self, output_directory: str) -> None:
configjson = make_config(self)
# convert configjson to json
import json

configjsons = json.dumps(configjson, indent=4)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I left this in for now just to make debugging the config easier, I'm good to remove if you want or to flag it so it only does it if we have a debug argument passed in or something

# TODO: Remove this later
# write configjson to a file for review
with open("config.json", "w") as file:
file.write(configjsons)
notifier = py_randomprime.ProgressNotifier(lambda progress, message: print("Generating ISO: ", progress, message))

input_iso_path = Path(settings.get_settings().metroidprime_options.rom_file)
output_iso_path = Path(f"{output_directory}\prime_out.iso")

py_randomprime.patch_iso(input_iso_path, output_iso_path, configjson, notifier)

def fill_slot_data(self) -> Dict[str, Any]:

Expand Down
Loading
Loading