Skip to content

Commit

Permalink
Changed the output of PrimeOptions to be a class instead of a diction…
Browse files Browse the repository at this point in the history
…ary. Updated references to it in Regions and init accordingly.
  • Loading branch information
Electro1512 committed Mar 2, 2024
1 parent ca7d18f commit 165cc11
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 29 deletions.
20 changes: 11 additions & 9 deletions worlds/metroidprime/PrimeOptions.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import typing
from Options import Option, Toggle, Range, ItemDict, StartInventoryPool, Choice

from Options import Toggle, Range, ItemDict, StartInventoryPool, Choice, PerGameCommonOptions
from dataclasses import dataclass


class SpringBall(Toggle):
Expand Down Expand Up @@ -34,10 +35,11 @@ class FinalBosses(Choice):
default = 0


metroidprime_options: typing.Dict[str, type(Option)] = {
"start_inventory_from_pool": StartInventoryPool,
"spring_ball": SpringBall,
"required_artifacts": RequiredArtifacts,
"exclude_items": ExcludeItems,
"final_bosses": FinalBosses
}
@dataclass
class MetroidPrimeOptions(PerGameCommonOptions):
start_inventory_from_pool: StartInventoryPool
spring_ball: SpringBall
required_artifacts: RequiredArtifacts
exclude_items: ExcludeItems
final_bosses: FinalBosses

12 changes: 6 additions & 6 deletions worlds/metroidprime/Regions.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,21 +44,21 @@ def create_regions(self):
logic.prime_can_heat(state, self.multiworld, self.player)))
tallon_overworld.connect(phazon_mines, "East Mines Elevator", lambda state: (
logic.prime_frigate(state, self.multiworld, self.player)))
if (PrimeOptions.metroidprime_options['final_bosses'] == 0 or
PrimeOptions.metroidprime_options['final_bosses'] == 2):
if (PrimeOptions.MetroidPrimeOptions.final_bosses == 0 or
PrimeOptions.MetroidPrimeOptions.final_bosses == 2):
tallon_overworld.connect(impact_crater, "Crater Access", lambda state: (
logic.prime_has_missiles(state, self.multiworld, self.player) and
(logic.prime_artifact_count(state, self.multiworld, self.player) == 12) and
state.has({"Wave Beam", "Ice Beam", "Plasma Beam", "Thermal Visor", "X-Ray Visor", "Phazon Suit",
"Space Jump Boots"}, self.player) and
logic.prime_etank_count(state, self.multiworld, self.player) >= 8))
elif PrimeOptions.metroidprime_options['final_bosses'] == 1:
elif PrimeOptions.MetroidPrimeOptions.final_bosses == 1:
tallon_overworld.connect(mission_complete, "Mission Complete", lambda state: (
logic.prime_has_missiles(state, self.multiworld, self.player) and
(logic.prime_artifact_count(state, self.multiworld, self.player) == 12) and
(state.has({"Plasma Beam"}, self.player) or logic.prime_can_super(state, self.multiworld, self.player)) and
logic.prime_etank_count(state, self.multiworld, self.player) >= 8))
elif PrimeOptions.metroidprime_options['final_bosses'] == 3:
elif PrimeOptions.MetroidPrimeOptions.final_bosses == 3:
tallon_overworld.connect(mission_complete, "Mission Complete", lambda state: (
logic.prime_has_missiles(state, self.multiworld, self.player) and
(logic.prime_artifact_count(state, self.multiworld, self.player) == 12)))
Expand All @@ -74,6 +74,6 @@ def create_regions(self):
magmoor_caverns.connect(phazon_mines, "West Mines Elevator", lambda state: (
logic.prime_late_magmoor(state, self.multiworld, self.player) and state.has({"Ice Beam"}, self.player)))

if (PrimeOptions.metroidprime_options['final_bosses'] == 0 or
PrimeOptions.metroidprime_options['final_bosses'] == 2):
if (PrimeOptions.MetroidPrimeOptions.final_bosses == 0 or
PrimeOptions.MetroidPrimeOptions.final_bosses == 2):
impact_crater.connect(mission_complete)
21 changes: 7 additions & 14 deletions worlds/metroidprime/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from BaseClasses import Item
from .Items import MetroidPrimeItem, suit_upgrade_table, artifact_table, item_table
from .PrimeOptions import metroidprime_options
from .PrimeOptions import MetroidPrimeOptions
from .Locations import every_location
from .Regions import create_regions
from .Rules import set_rules
Expand All @@ -14,13 +14,14 @@ class MetroidPrimeWorld(World):
of the Space Pirates.
"""
game = "Metroid Prime"
option_definitions = metroidprime_options
options_dataclass = MetroidPrimeOptions
options: MetroidPrimeOptions
topology_present = True
item_name_to_id = {name: data.code for name, data in item_table.items()}
location_name_to_id = every_location

def generate_early(self):
reqarts = self.option_definitions['required_artifacts']
reqarts = int(self.options.required_artifacts)
# starting inventory
self.multiworld.precollected_items += [self.create_item("Power Beam")]
self.multiworld.precollected_items += [self.create_item("Scan Visor")]
Expand All @@ -41,14 +42,14 @@ def create_item(self, name: str) -> "Item":

def create_items(self) -> None:
# add remaining artifacts
reqarts = self.option_definitions['required_artifacts']
reqarts = int(self.options.required_artifacts)
artcount = 12
for i in artifact_table:
if artcount >= reqarts:
self.multiworld.itempool += [self.create_item(i)]
artcount -= 1
excluded = self.option_definitions['excluded_items']
spring = self.option_definitions['spring_ball']
excluded = self.options.exclude_items
spring = bool(self.options.spring_ball)
items_added = 0
for i in suit_upgrade_table:
if i == "Power Beam" or i == "Scan Visor" or i == "Power Suit" or i == "Combat Visor":
Expand Down Expand Up @@ -82,11 +83,3 @@ def create_items(self) -> None:

def set_rules(self) -> None:
set_rules(self.multiworld, self.player)








0 comments on commit 165cc11

Please sign in to comment.