Skip to content

Commit

Permalink
Merge ExemptMedic PR
Browse files Browse the repository at this point in the history
  • Loading branch information
hesto2 committed Nov 26, 2024
2 parents 73a7f33 + 01b617d commit f6f50d4
Show file tree
Hide file tree
Showing 22 changed files with 241 additions and 281 deletions.
16 changes: 8 additions & 8 deletions worlds/metroidprime/ClientReceiveItems.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@


async def handle_receive_items(
ctx: "MetroidPrimeContext", current_items: dict[str, InventoryItemData]
ctx: "MetroidPrimeContext", current_items: Dict[str, InventoryItemData]
):
# Will be used when consumables are implemented
# current_index = ctx.game_interface.get_last_received_index()
Expand Down Expand Up @@ -90,15 +90,15 @@ def disable_item_if_owned(ctx: "MetroidPrimeContext", item_data: InventoryItemDa


async def handle_cosmetic_suit(
ctx: "MetroidPrimeContext", current_items: dict[str, InventoryItemData]
ctx: "MetroidPrimeContext", current_items: Dict[str, InventoryItemData]
):
if ctx.cosmetic_suit == None:
return
ctx.game_interface.set_current_suit(ctx.cosmetic_suit)


async def handle_disable_gravity_suit(
ctx: "MetroidPrimeContext", current_items: dict[str, InventoryItemData]
ctx: "MetroidPrimeContext", current_items: Dict[str, InventoryItemData]
):
if ctx.gravity_suit_enabled:
return
Expand All @@ -107,7 +107,7 @@ async def handle_disable_gravity_suit(


async def handle_receive_missiles(
ctx: "MetroidPrimeContext", current_items: dict[str, InventoryItemData]
ctx: "MetroidPrimeContext", current_items: Dict[str, InventoryItemData]
):
# Slot data is required for missiles + Power Bombs so we can check if launcher / main pb are enabled
if ctx.slot_data and "Missile Expansion" in current_items:
Expand Down Expand Up @@ -161,7 +161,7 @@ async def handle_receive_missiles(


async def handle_receive_power_bombs(
ctx: "MetroidPrimeContext", current_items: dict[str, InventoryItemData]
ctx: "MetroidPrimeContext", current_items: Dict[str, InventoryItemData]
):
# Handle Power Bomb Expansions
if ctx.slot_data and "Power Bomb Expansion" in current_items:
Expand Down Expand Up @@ -218,7 +218,7 @@ async def handle_receive_power_bombs(


async def handle_receive_energy_tanks(
ctx: "MetroidPrimeContext", current_items: dict[str, InventoryItemData]
ctx: "MetroidPrimeContext", current_items: Dict[str, InventoryItemData]
):
# Handle Energy Tanks
if "Energy Tank" in current_items:
Expand Down Expand Up @@ -258,7 +258,7 @@ async def handle_receive_energy_tanks(


async def handle_receive_progressive_items(
ctx: "MetroidPrimeContext", current_items: dict[str, InventoryItemData]
ctx: "MetroidPrimeContext", current_items: Dict[str, InventoryItemData]
):
counts = {upgrade.value: 0 for upgrade in PROGRESSIVE_ITEM_MAPPING}
network_items: Dict[str, List[NetworkItem]] = {
Expand Down Expand Up @@ -289,7 +289,7 @@ async def handle_receive_progressive_items(


def inventory_item_by_network_id(
network_id: int, current_inventory: dict[str, InventoryItemData]
network_id: int, current_inventory: Dict[str, InventoryItemData]
) -> InventoryItemData | None:
for item in current_inventory.values():
if item.code == network_id:
Expand Down
4 changes: 2 additions & 2 deletions worlds/metroidprime/Config.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def color_options_to_value(world: "MetroidPrimeWorld") -> List[float]:
]

# get the key in hudcolor enum that matches all caps color
color: str = str(world.options.hud_color.value)
color: str = world.options.hud_color.current_key
color = color.upper()
for key in HudColor.__members__.keys():
if key == color:
Expand Down Expand Up @@ -204,7 +204,7 @@ def make_config(world: "MetroidPrimeWorld") -> Dict[str, Any]:
"warpToStart": True,
"multiworldDolPatches": True,
"nonvariaHeatDamage": bool(options.non_varia_heat_damage.value),
"staggeredSuitDamage": options.staggered_suit_damage.value,
"staggeredSuitDamage": options.staggered_suit_damage.current_option_name,
"heatDamagePerSec": 10.0,
"poisonDamagePerSec": 0.11,
"phazonDamagePerSec": 0.964,
Expand Down
10 changes: 5 additions & 5 deletions worlds/metroidprime/Items.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ def get_item_for_options(
return item


suit_upgrade_table: dict[str, ItemData] = {
suit_upgrade_table: Dict[str, ItemData] = {
SuitUpgrade.Power_Beam.value: ItemData(
SuitUpgrade.Power_Beam.value, 0, ItemClassification.progression
),
Expand Down Expand Up @@ -244,7 +244,7 @@ def get_item_for_options(
),
}

misc_item_table: dict[str, ItemData] = {
misc_item_table: Dict[str, ItemData] = {
"UnknownItem1": ItemData("UnknownItem1", 25, ItemClassification.useful),
"HealthRefill": ItemData(
"HealthRefill", 26, ItemClassification.trap
Expand All @@ -253,7 +253,7 @@ def get_item_for_options(
}

# 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] = {
custom_suit_upgrade_table: Dict[str, ItemData] = {
SuitUpgrade.Missile_Launcher.value: ItemData(
SuitUpgrade.Missile_Launcher.value, 41, ItemClassification.progression
),
Expand Down Expand Up @@ -300,7 +300,7 @@ def get_item_for_options(
),
}

artifact_table: dict[str, ItemData] = {
artifact_table: Dict[str, ItemData] = {
"Artifact of Truth": ItemData(
"Artifact of Truth", 29, ItemClassification.progression_skip_balancing
),
Expand Down Expand Up @@ -339,7 +339,7 @@ def get_item_for_options(
),
}

item_table: dict[str, ItemData] = {
item_table: Dict[str, ItemData] = {
**suit_upgrade_table,
**artifact_table,
**custom_suit_upgrade_table,
Expand Down
2 changes: 1 addition & 1 deletion worlds/metroidprime/Locations.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class MetroidPrimeLocation(Location):
"Chozo Ruins: Transport Access North": 5031117,
"Chozo Ruins: Gathering Hall": 5031118,
"Chozo Ruins: Hive Totem": 5031119,
"Chozo Ruins: Sunchamber - Flaaghra": 5031120,
"Chozo Ruins: Sunchamber - Flaahgra": 5031120,
"Chozo Ruins: Sunchamber - Ghosts": 5031121,
"Chozo Ruins: Watery Hall Access": 5031122,
"Chozo Ruins: Watery Hall - Scan Puzzle": 5031123,
Expand Down
2 changes: 1 addition & 1 deletion worlds/metroidprime/LogicCombat.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def can_combat_omega_pirate(world: "MetroidPrimeWorld", state: CollectionState)
return _can_combat_generic(world, state, 6, 3) and can_xray(world, state, True)


def can_combat_flaaghra(world: "MetroidPrimeWorld", state: CollectionState) -> bool:
def can_combat_flaahgra(world: "MetroidPrimeWorld", state: CollectionState) -> bool:
return (
world.options.starting_room_name == RoomName.Sunchamber_Lobby.value
or _can_combat_generic(world, state, 2, 1, False)
Expand Down
64 changes: 28 additions & 36 deletions worlds/metroidprime/MetroidPrimeClient.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ class MetroidPrimeContext(CommonContext):
items_handling = 0b111
dolphin_sync_task: Optional[asyncio.Task[Any]] = None
connection_state = ConnectionState.DISCONNECTED
slot_data: dict[str, Utils.Any] = {}
slot_data: Dict[str, Utils.Any] = {}
death_link_enabled = False
gravity_suit_enabled: bool = True
previous_location_str: str = ""
Expand Down Expand Up @@ -298,41 +298,33 @@ def get_version_from_iso(path: str) -> str:
game_rev = f.read(1)[0]
if game_id[:3] != "GM8":
raise Exception("This is not Metroid Prime GC")
match game_id[3]:
case "E":
match game_rev:
case 0:
return "0-00"
case 1:
return "0-01"
case 2:
return "0-02"
case 48:
return "kor"
case _rev:
raise Exception(
f"Unknown revision of Metroid Prime GC US (game_rev : {_rev})"
)
case "J":
match game_rev:
case 0:
return "jpn"
case _rev:
raise Exception(
f"Unknown revision of Metroid Prime GC JPN (game_rev : {_rev})"
)
case "P":
match game_rev:
case 0:
return "pal"
case _rev:
raise Exception(
f"Unknown revision of Metroid Prime GC PAL (game_rev : {_rev})"
)
case _id:
raise Exception(
f"Unknown version of Metroid Prime GC (game_id : {game_id} | game_rev : {game_rev})"
)
if game_id[3] == "E":
if game_rev == 0:
return "0-00"
if game_rev == 1:
return "0-01"
if game_rev == 2:
return "0-02"
if game_rev == 48:
return "kor"
raise Exception(
f"Unknown revision of Metroid Prime GC US (game_rev : {game_rev})"
)
if game_id[3] == "J":
if game_rev == 0:
return "jpn"
raise Exception(
f"Unknown revision of Metroid Prime GC JPN (game_rev : {game_rev})"
)
if game_id[3] == "P":
if game_rev == 0:
return "pal"
raise Exception(
f"Unknown revision of Metroid Prime GC PAL (game_rev : {game_rev})"
)
raise Exception(
f"Unknown version of Metroid Prime GC (game_id : {game_id} | game_rev : {game_rev})"
)


def get_options_from_apmp1(apmp1_file: str) -> Dict[str, Any]:
Expand Down
30 changes: 14 additions & 16 deletions worlds/metroidprime/MetroidPrimeInterface.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from logging import Logger
import struct
from typing import Any, Dict, Optional
from typing import Any, Dict, Optional, Union

from .DolphinClient import GC_GAME_ID_ADDRESS, DolphinClient, DolphinException
from enum import Enum
Expand Down Expand Up @@ -253,7 +253,7 @@ def set_cosmetic_suit_by_id(self, item_id: int):
def check_for_new_locations(self):
pass

def get_item(self, item_data: ItemData | int) -> InventoryItemData | None:
def get_item(self, item_data: Union[ItemData, int]) -> Optional[InventoryItemData]:
if isinstance(item_data, int):
for item in item_table.values():
if item.id == item_data:
Expand All @@ -279,9 +279,9 @@ def get_item(self, item_data: ItemData | int) -> InventoryItemData | None:
return InventoryItemData(item_data, current_ammount, current_capacity)
return None

def get_current_inventory(self) -> dict[str, InventoryItemData]:
def get_current_inventory(self) -> Dict[str, InventoryItemData]:
MAX_VANILLA_ITEM_ID = 40
inventory: dict[str, InventoryItemData] = {}
inventory: Dict[str, InventoryItemData] = {}
for item in item_table.values():
i = self.get_item(item)
if i is not None:
Expand Down Expand Up @@ -474,18 +474,16 @@ def _save_message_to_memory(self, message: str):

def __progressive_beam_to_beam(
self, charge_beam: SuitUpgrade
) -> SuitUpgrade | None:
match charge_beam:
case SuitUpgrade.Power_Charge_Beam:
return SuitUpgrade.Power_Beam
case SuitUpgrade.Wave_Charge_Beam:
return SuitUpgrade.Wave_Beam
case SuitUpgrade.Ice_Charge_Beam:
return SuitUpgrade.Ice_Beam
case SuitUpgrade.Plasma_Charge_Beam:
return SuitUpgrade.Plasma_Beam
case _:
return None
) -> Optional[SuitUpgrade]:
if charge_beam == SuitUpgrade.Power_Charge_Beam:
return SuitUpgrade.Power_Beam
if charge_beam == SuitUpgrade.Wave_Charge_Beam:
return SuitUpgrade.Wave_Beam
if charge_beam == SuitUpgrade.Ice_Charge_Beam:
return SuitUpgrade.Ice_Beam
if charge_beam == SuitUpgrade.Plasma_Charge_Beam:
return SuitUpgrade.Plasma_Beam
return None

def set_progressive_beam_charge_state(self, charge_beam: SuitUpgrade, state: bool):
cplayer_state = self.__get_player_state_pointer()
Expand Down
Loading

0 comments on commit f6f50d4

Please sign in to comment.