Skip to content

Commit

Permalink
resolve todos
Browse files Browse the repository at this point in the history
  • Loading branch information
hesto2 committed Nov 18, 2024
1 parent 4b62248 commit 711fa48
Show file tree
Hide file tree
Showing 12 changed files with 2,483 additions and 42 deletions.
4 changes: 2 additions & 2 deletions ClientReceiveItems.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,12 +276,12 @@ async def handle_receive_progressive_items(
if count > 0:
for i in range(count):
mapping = PROGRESSIVE_ITEM_MAPPING[
ProgressiveUpgrade.get_by_value(progressive_upgrade)
ProgressiveUpgrade(progressive_upgrade)
]
if i >= len(mapping):
continue
item = PROGRESSIVE_ITEM_MAPPING[
ProgressiveUpgrade.get_by_value(progressive_upgrade)
ProgressiveUpgrade(progressive_upgrade)
][i]
inventory_item = current_items[item.value]
network_item = network_items[progressive_upgrade][i]
Expand Down
16 changes: 0 additions & 16 deletions Items.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,29 +66,13 @@ class SuitUpgrade(Enum):
def __str__(self):
return self.value

# TODO: pretty sure I can remove this and just do SuitUpgrade(value)
@staticmethod
def get_by_value(value: str) -> "SuitUpgrade":
for suit in SuitUpgrade:
if suit.value == value:
return suit
raise ValueError(f"Invalid suit upgrade value: {value}")


class ProgressiveUpgrade(Enum):
Progressive_Power_Beam = "Progressive Power Beam"
Progressive_Ice_Beam = "Progressive Ice Beam"
Progressive_Wave_Beam = "Progressive Wave Beam"
Progressive_Plasma_Beam = "Progressive Plasma Beam"

# TODO: Same as above
@staticmethod
def get_by_value(value: str) -> "ProgressiveUpgrade":
for upgrade in ProgressiveUpgrade:
if upgrade.value == value:
return upgrade
raise ValueError(f"Invalid progressive upgrade value: {value}")

def __str__(self):
return self.value

Expand Down
2 changes: 1 addition & 1 deletion LogicCombat.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def can_combat_thardus(world: "MetroidPrimeWorld", state: CollectionState) -> bo


def can_combat_omega_pirate(world: "MetroidPrimeWorld", state: CollectionState) -> bool:
return _can_combat_generic(world, state, 6, 3)
return _can_combat_generic(world, state, 6, 3) and can_xray(world, state, True)


def can_combat_flaaghra(world: "MetroidPrimeWorld", state: CollectionState) -> bool:
Expand Down
2 changes: 1 addition & 1 deletion __init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ def create_items(self) -> None:
if (
self.options.progressive_beam_upgrades.value
and get_progressive_upgrade_for_item(
SuitUpgrade.get_by_value(suit_upgrade)
SuitUpgrade(suit_upgrade)
)
is not None
):
Expand Down
13 changes: 3 additions & 10 deletions data/DoorData.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ class DoorData:
defaultLock: DoorLockType = DoorLockType.Blue
blast_shield: Optional["BlastShieldType"] = None
lock: Optional[DoorLockType] = None
# TODO: Remove destination, not going to pursue room rando
destination: Optional[RoomName] = None
destination_area: Optional[MetroidPrimeArea] = (
None # Used for rooms that have the same name in different areas like Transport Tunnel A
)
Expand All @@ -34,16 +32,11 @@ class DoorData:
Callable[["MetroidPrimeWorld", CollectionState], bool]
] = None # Used to override the access check for reaching this door, if necessary when connecting it to a sub region

def get_destination_region_name(self):
def get_destination_region_name(self) -> str:
assert self.default_destination is not None
destination = (
self.destination.value
if self.destination is not None
else self.default_destination.value
)
if self.destination_area is not None:
return f"{self.destination_area.value}: {destination}"
return destination
return f"{self.destination_area.value}: { self.default_destination.value}"
return self.default_destination.value


def get_door_data_by_room_names(
Expand Down
4 changes: 0 additions & 4 deletions data/PhazonMines.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,22 +164,19 @@ def __init__(self):
),
RoomName.Elite_Quarters: RoomData(
doors={
# TODO: Move xray requirements to omega pirate reqs
0: DoorData(
RoomName.Elite_Quarters_Access,
defaultLock=DoorLockType.Plasma,
rule_func=lambda world, state: can_combat_omega_pirate(
world, state
)
and can_xray(world, state, hard_required=True),
),
1: DoorData(
RoomName.Processing_Center_Access,
defaultLock=DoorLockType.Plasma,
rule_func=lambda world, state: can_combat_omega_pirate(
world, state
)
and can_xray(world, state, hard_required=True)
and can_scan(world, state),
),
},
Expand All @@ -189,7 +186,6 @@ def __init__(self):
rule_func=lambda world, state: can_combat_omega_pirate(
world, state
)
and can_xray(world, state, hard_required=True),
),
],
),
Expand Down
5 changes: 1 addition & 4 deletions data/RoomData.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,8 +217,6 @@ def create_world_region(self, world: "MetroidPrimeWorld"):
if pickup.exclude_from_logic:
continue

# TODO: Remove the generator

region.add_locations(
{pickup.name: every_location[pickup.name]}, MetroidPrimeLocation
)
Expand All @@ -240,7 +238,7 @@ def create_world_region(self, world: "MetroidPrimeWorld"):
name = room_data.get_region_name(room_name.value)
region = world.multiworld.get_region(name, world.player)
for door_data in room_data.doors.values():
destination = door_data.destination or door_data.default_destination
destination = door_data.default_destination
if destination is None:
continue

Expand All @@ -257,7 +255,6 @@ def apply_blast_shield_to_both_sides_of_door(
door_data: DoorData, target_room_data: RoomData = room_data
):
paired_door = target_room_data.get_matching_door(door_data, world)
# TODO: Handle pairing door mappings in the apply shield logic, also handle locked doors there
shield_applied = False
if (
paired_door
Expand Down
2 changes: 1 addition & 1 deletion data/StartRoomData.py
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,7 @@ def replace_starting_beam(new_beam: SuitUpgrade):
world.options.starting_beam.value
and world.options.starting_beam.value != "none"
):
new_beam = SuitUpgrade.get_by_value(str(world.options.starting_beam.value))
new_beam = SuitUpgrade(str(world.options.starting_beam.value))
if new_beam:
replace_starting_beam(new_beam)

Expand Down
1 change: 0 additions & 1 deletion test/TestDoorRando.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,6 @@ def test_starting_beam_is_not_wave(self):


class TestDoorPlando(MetroidPrimeTestBase):
# TODO: rework the data structure here so you don't have to do area and type_mapping
options = {
"door_color_randomization": "regional",
"door_color_mapping": {
Expand Down
23 changes: 23 additions & 0 deletions test/TestOutputGeneration.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,29 @@ def test_output_generates_correctly_with_main_pb_and_missile_launcher(self) -> N
dump_output_if_test_fails(self, output, expected_output)


class TestAllRandomizedOutput(MetroidPrimeTestBase):
auto_construct = False
options = {
"elevator_randomization": True,
"door_randomization": "regional",
"blast_shield_randomization": "mix_it_up",
}

def test_output_generates_correctly_with_all_randomized(self) -> None:
self.world_setup() # type: ignore
distribute_items_restrictive(self.multiworld)
output = make_config(self.world)
expected_output = {}
path = os.path.join(
os.path.dirname(__file__), "data", "all_randomized.json"
)
with open(path, "r") as f:
expected_output = json.load(f)

dict_diff(expected_output, output)
dump_output_if_test_fails(self, output, expected_output)


def dump_output_if_test_fails(
test: MetroidPrimeTestBase, output: Dict[str, Any], expected_output: Dict[str, Any]
):
Expand Down
4 changes: 2 additions & 2 deletions test/TestUniversalTracker.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ def test_starting_room_info_is_preserved(self):
world.starting_room_data.name, self.options["starting_room_name"]
)
self.assertEqual(
SuitUpgrade.get_by_value(self.options["starting_beam"]),
SuitUpgrade(self.options["starting_beam"]),
world.starting_room_data.selected_loadout.starting_beam,
)

Expand All @@ -136,7 +136,7 @@ def test_starting_room_info_is_preserved_with_progressive_beams(self):
world.starting_room_data.name, self.options["starting_room_name"]
)
self.assertEqual(
SuitUpgrade.get_by_value(self.options["starting_beam"]),
SuitUpgrade(self.options["starting_beam"]),
world.starting_room_data.selected_loadout.starting_beam,
)

Expand Down
Loading

0 comments on commit 711fa48

Please sign in to comment.