Skip to content

Commit

Permalink
Changed formating
Browse files Browse the repository at this point in the history
Changed some formatting to better suit functions in init.py
  • Loading branch information
Ehseezed committed Mar 16, 2023
1 parent 909ac0b commit 35b76a8
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 110 deletions.
20 changes: 7 additions & 13 deletions worlds/AM2R/items.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ class ItemData(typing.NamedTuple):


class AM2RItem(Item):
game = str = "AM2R"
game: str = "AM2R"


item_table = {
"Missile": ItemData(1, ItemClassification.progression),
"Super_Missile": ItemData(1, ItemClassification.progression),
"Power_Bomb": ItemData(1, ItemClassification.progression),
"Energy_Tank": ItemData(1, ItemClassification.useful),
"Missile": ItemData(1, ItemClassification.filler),
"Super_Missile": ItemData(1, ItemClassification.filler),
"Power_Bomb": ItemData(1, ItemClassification.filler),
"Energy_Tank": ItemData(1, ItemClassification.filler),
# "Morph_ball": ItemData(1, ItemClassification.progression)
# "Power_Grip": ItemData(1, ItemClassification.progression)
"Bombs": ItemData(1, ItemClassification.progression),
Expand All @@ -37,12 +37,6 @@ class AM2RItem(Item):
"Short_Beam": ItemData(1, ItemClassification.trap),
"EMP_Trap": ItemData(1, ItemClassification.trap),
"Metroid": ItemData(1, ItemClassification.progression),
"Victory": ItemData(1, ItemClassification.progression)
"The Galaxy is at Peace": ItemData(1, ItemClassification.progression)
}
item_frequencies = {
"Missile": 44,
"Super_Missile": 10,
"Power_Bomb": 10,
"Energy Tank": 10,
"Metroid": 41
}

10 changes: 8 additions & 2 deletions worlds/AM2R/locations.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
from BaseClasses import Location
import typing

from BaseClasses import Location

class LocationData(typing.NamedTuple):
id: typing.Optional[int]
region: str


class AM2RLocation(Location):
Expand Down Expand Up @@ -111,4 +115,6 @@ def __int__(self, player: int, name: str, address: typing.Optional[int], parent)
"Deep Caves: Ball Spark": LocationData(2, "Deep Caves"),
"Deep Caves: Behind the Bomb Block": LocationData(2, "Deep Caves"),
"Deep Caves: After Omega": LocationData(2, "Deep Caves"),
}

"The Last Metroid is in Captivity": LocationData(None, "Research Station")
}
115 changes: 29 additions & 86 deletions worlds/AM2R/options.py
Original file line number Diff line number Diff line change
@@ -1,82 +1,36 @@
from dataclasses import dataclass
from typing import Dict, Union, Protocol, runtime_checkable

from Options import Option, Range, DeathLink, SpecialRange, Toggle, Choice


@runtime_checkable
class AM2ROption(Protocol):
internal_name: str


@dataclass
class AM2ROptions:
options: Dict[str, Union[bool, int]]

def __getitem__(self, item: Union[str, AM2ROption]) -> Union[bool, int]:
if isinstance(item, AM2ROption):
item = item.internal_name

return self.options.get(item, None)
from typing import Dict, Union, List
from BaseClasses import MultiWorld
from Options import Option, Range, DeathLink, SpecialRange, Toggle, Choice, OptionList


class MetroidsRequired(Range):
"""Chose how many Metroids need to be killed or obtained to go through to the omega nest"""
display_name = "Metroids Required"
internal_name = "metroids_required"
range_start = 0
range_end = 41
default = 41


class MetroidsAreChecks(Toggle):
"""Have each of the 46 non lab Metroids be treated as checks"""
"""Have each of the 46 non lab Metroids be treated as locations"""
display_name = "Metroids are Checks"
internal_name = "metroids_are_checks"


class TrapFillPrecentage(Range):
"""Adds in Slightly inconvenient Traps into the item pool Equipment Traps disable 1 random item for up to 3 minutes
depending on the disabled item (more critical items will be disabled for less time). Ice Traps seem rather
self-explanatory, but they will freeze you upon receiving them with a full fanfare and an actual player freeze"""
display_name = "Trap Fill Percentage"
internal_name = "trap_fill_percentage"
range_start = 0
range_end = 100
default = 50


class BaseTrapWeight(Choice):
"""Base Class for Trap Weights"""
option_none = 0
option_low = 1
option_medium = 2
option_high = 4
default = 1
default = 0


class EquipmentTrap(BaseTrapWeight):
"""Disables 1 of your items for a period of time depending on the item type"""
display_name = "Equipment Trap"
internal_name = "equipment_trap"


class IceTrap(BaseTrapWeight):
"""Play the full item fanfare and then freezes the player"""
display_name = "Ice Trap"
internal_name = "ice_trap"


class ShortBeam(BaseTrapWeight):
"""Makes your beam shots expire rapidly lasts 10 minutes"""
display_name = "Short Beam"
internal_name = "short_beam"


class EMPTrap(BaseTrapWeight):
"""Activates an EMP effect on you for 30 secconds"""
display_name = "EMP Trap"
internal_name = "emp_trap"
class Traps(OptionList):
"""List of traps that can be found in the pool"""
display_name = "Trap Types"
valid_keys = {"Equipment Trap", "Ice Trap", "Short Beam", "EMP Trap"}
default = {"Equipment Trap", "Ice Trap", "Short Beam", "EMP Trap"}


# class AreaRando(Choice):
Expand All @@ -86,7 +40,7 @@ class EMPTrap(BaseTrapWeight):
# Temple Guardian, Tester and Serris
# Both activates Both independently on their own"""
# display_name = "Area Randomizer"
# internal_name = "area_rando"

# default = 0
# option_disabled = 0
# option_area = 1
Expand All @@ -99,43 +53,32 @@ class EMPTrap(BaseTrapWeight):
# """Activates Boss Randomization randomizes Arachnus, Torizo Ascended, and Genesis with each other.
# then also randomizes Temple Guardian, Tester abd Serris"""
# display_name = "Boss Randomizer"
# internal_name = "boss_rando"


class IceMissiles(Toggle):
"""Changes missiles to have Ice properties """
display_name = "Ice Missiles"
internal_name = "ice_missiles"
# class IceMissiles(Toggle):
# """Changes missiles to have Ice properties """
# display_name = "Ice Missiles"


AM2R_options: Dict[str, type(Option)] = {
option.internal_name: option
for option in [
MetroidsRequired,
MetroidsAreChecks,
TrapFillPrecentage,
IceTrap,
EquipmentTrap,
ShortBeam,
EMPTrap,
# AreaRando,
# BossRando,
IceMissiles,
]
"metroids_required": MetroidsRequired,
"metroids_are_checks": MetroidsAreChecks,
"trap_fill_precentage": TrapFillPrecentage,
"traps": Traps,
# "area_rando": AreaRando,
# "boss_rando": BossRando,
# "ice_missiles": IceMissiles,
# "DeathLink": DeathLink,
}
default_options = {option.internal_name: option.default for option in AM2R_options.values()}
AM2R_options["death_link"] = DeathLink


def fetch_options(world, player: int) -> AM2ROptions:
return AM2ROptions({option: get_option_value(world, player, option) for option in AM2R_options})

def is_option_enabled(world: MultiWorld, player: int, name: str) -> bool:
return get_option_value(world, player, name) > 0

def get_option_value(world, player: int, name: str) -> Union[bool, int]:
assert name in AM2R_options, f"{name} is not a valid option for AM2R."

value = getattr(world, name)
def get_option_value(world: MultiWorld, player: int, name: str) -> Union[int, Dict, List]:
option = getattr(world, name, None)
if option == None:
return 0

if issubclass(AM2R_options[name], Toggle):
return bool(value[player].value)
return value[player].value
return option[player].value
20 changes: 11 additions & 9 deletions worlds/AM2R/regions.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,41 +63,43 @@ def __post_init__(self):
RegionData('Pipe Hell', ['Grav Win Pipe', 'BL-BR Pipe', 'TL-TR Pipe']),
RegionData('Gravity', ['Reach Outside Hell']),
RegionData('EMP', ['Reach Pipe Hell Lose']),
RegionData('GFS Thoth'),
RegionData('GFS Thoth' ['Fight Genesis']),
RegionData('Genesis'),
RegionData('Deep Caves', ['reach Omega Nest']),
RegionData('Omega Nest')
]

mandatory_connections = [
ConnectionData('New Game', 'Main Caves'),
ConnectionData('To Alpha', 'First Alpha', flag=RandomizationFlag.AREA_RANDO),
ConnectionData('Fight Guardian', 'Guardian', flag=RandomizationFlag.BOSS_RANDO),
ConnectionData('Fight Guardian', 'Guardian', flag=RandomizationFlag.BOSS_RANDO_2),
ConnectionData('Reach A1', 'Golden Temple', flag=RandomizationFlag.BOSS_RANDO_2),
ConnectionData('Reach A2', 'Hydro Station', flag=RandomizationFlag.AREA_RANDO),
ConnectionData('Reach Mines', 'Mines', flag=RandomizationFlag.AREA_RANDO),
ConnectionData('Reach A3 Nest', 'Industrial Complex Nest', flag=RandomizationFlag.AREA_RANDO),
ConnectionData('Reach GFS', 'GFS Thoth', flag=RandomizationFlag.AREA_RANDO),
ConnectionData('Fight Genesis', 'Genesis', flag=RandomizationFlag.BOSS_RANDO_1),
ConnectionData('Reach A4', 'The Tower', flag=RandomizationFlag.AREA_RANDO),
ConnectionData('Reach A5', 'Distribution Center', flag=RandomizationFlag.AREA_RANDO),
ConnectionData('Reach A6', 'Deep Caves', flag=RandomizationFlag.AREA_RANDO),
ConnectionData('Reach A1', 'Golden Temple', flag=RandomizationFlag.BOSS_RANDO),
ConnectionData('Reach A1 Nest', 'Golden Temple Nest', flag=RandomizationFlag.AREA_RANDO),
ConnectionData('A1-Pipe Hell Pipe', 'Pipe Hell', flag=RandomizationFlag.PIPE_RANDO),
ConnectionData('Reach A2 Nest', 'Hydro Station Nest', flag=RandomizationFlag.AREA_RANDO),
ConnectionData('A2-A4 Pipe', 'The Tower', flag=RandomizationFlag.PIPE_RANDO),
ConnectionData('A2-Lab Pipe', 'Omega Nest', flag=RandomizationFlag.PIPE_RANDO),
ConnectionData('Fight Arachnus', 'Arachnus', flag=RandomizationFlag.BOSS_RANDO),
ConnectionData('Fight Arachnus', 'Arachnus', flag=RandomizationFlag.BOSS_RANDO_1),
ConnectionData('Reach A3', 'Pre Industrial Complex', flag=RandomizationFlag.AREA_RANDO),
ConnectionData('I find it quite simple', 'Industrial Complex', flag=RandomizationFlag.AREA_RANDO),
ConnectionData('Fight Torizo Ascended', 'Torizo Ascended', flag=RandomizationFlag.BOSS_RANDO),
ConnectionData('Fight Torizo Ascended', 'Torizo Ascended', flag=RandomizationFlag.BOSS_RANDO_1),
ConnectionData('Reach Basement', 'Geothermal', flag=RandomizationFlag.AREA_RANDO),
ConnectionData('Fight Tester', 'Tester', flag=RandomizationFlag.BOSS_RANDO),
ConnectionData('Leave Tester', 'The Tower', flag=RandomizationFlag.BOSS_RANDO),
ConnectionData('Fight Tester', 'Tester', flag=RandomizationFlag.BOSS_RANDO_2),
ConnectionData('Leave Tester', 'The Tower', flag=RandomizationFlag.BOSS_RANDO_2),
ConnectionData('Reach EMP Win', 'EMP', flag=RandomizationFlag.AREA_RANDO),
ConnectionData('Reach Pipe Hell Lose', 'Pipe Hell', flag=RandomizationFlag.AREA_RANDO),
ConnectionData('Reach Bottom Hell', 'Pipe Hell', flag=RandomizationFlag.AREA_RANDO),
ConnectionData('Reach Top Hell', 'Pipe Hell', flag=RandomizationFlag.AREA_RANDO),
ConnectionData('Fight Serris', 'Serris', flag=RandomizationFlag.BOSS_RANDO),
ConnectionData('Exit Stage Left', 'Distribution Center', flag=RandomizationFlag.BOSS_RANDO),
ConnectionData('Fight Serris', 'Serris', flag=RandomizationFlag.BOSS_RANDO_2),
ConnectionData('Exit Stage Left', 'Distribution Center', flag=RandomizationFlag.BOSS_RANDO_2),
ConnectionData('Grav Win Pipe', 'Gravity', flag=RandomizationFlag.PIPE_RANDO),
ConnectionData('BL-BR Pipe', 'Pipe Hell', flag=RandomizationFlag.PIPE_RANDO),
ConnectionData('TL-TR Pipe', 'Pipe Hell', flag=RandomizationFlag.PIPE_RANDO),
Expand Down

0 comments on commit 35b76a8

Please sign in to comment.