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

Seperate the total Metroid count from the required amount #20

Merged
merged 1 commit into from
Jul 24, 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
4 changes: 4 additions & 0 deletions worlds/am2r/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import types
import logging
from typing import Dict
from .items import item_table
from .locations import get_location_datas, EventId
Expand All @@ -8,6 +9,7 @@
from worlds.AutoWorld import World, WebWorld
from worlds.LauncherComponents import Component, components, Type, launch_subprocess

logger = logging.getLogger("AM2R")

def launch_client():
from .Client import launch
Expand Down Expand Up @@ -55,6 +57,8 @@ def create_item(self, name: str) -> Item:
return items.create_item(self.player, name)

def create_items(self) -> None:
if self.options.MetroidsRequired > self.options.MetroidsInPool:
logger.warning(f"Metroid count raised to set requirement for {self.multiworld.get_player_name(self.player)} because the given count was too low for the requirement.")
if self.options.MetroidsAreChecks != MetroidsAreChecks.option_include_A6:
self.multiworld.get_location("Deep Caves: Lil\' Bro", self.player).place_locked_item(self.create_item("Metroid"))
self.multiworld.get_location("Deep Caves: Big Sis", self.player).place_locked_item(self.create_item("Metroid"))
Expand Down
12 changes: 7 additions & 5 deletions worlds/am2r/items.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from typing import Dict, List, NamedTuple, Set

from BaseClasses import Item, ItemClassification, MultiWorld
from .options import MetroidsAreChecks, MetroidsRequired, get_option_value, TrapFillPercentage, RemoveFloodTrap, RemoveTossTrap, RemoveShortBeam, RemoveEMPTrap, RemoveOHKOTrap, RemoveTouhouTrap
from .options import MetroidsAreChecks, MetroidsInPool, MetroidsRequired, get_option_value, TrapFillPercentage, RemoveFloodTrap, RemoveTossTrap, RemoveShortBeam, RemoveEMPTrap, RemoveOHKOTrap, RemoveTouhouTrap


class ItemData(NamedTuple):
Expand All @@ -28,12 +28,14 @@ def create_fixed_item_pool() -> List[str]:
return list(Counter(required_items).elements())


def create_metroid_items(MetroidsRequired: MetroidsRequired, MetroidsAreChecks: MetroidsAreChecks) -> List[str]:
def create_metroid_items(MetroidsRequired: MetroidsRequired, MetroidsInPool: MetroidsInPool, MetroidsAreChecks: MetroidsAreChecks) -> List[str]:
metroid_count = 0
if MetroidsRequired > MetroidsInPool:
MetroidsInPool = MetroidsRequired
if MetroidsAreChecks == MetroidsAreChecks.option_include_A6:
metroid_count = MetroidsRequired.value
metroid_count = MetroidsInPool.value
elif MetroidsAreChecks == MetroidsAreChecks.option_exclude_A6:
metroid_count += MetroidsRequired.value - 5
metroid_count = MetroidsInPool.value - 5
return ["Metroid" for _ in range(metroid_count)]


Expand Down Expand Up @@ -80,7 +82,7 @@ def create_all_items(multiworld: MultiWorld, player: int) -> None:

itempool = (
create_fixed_item_pool()
+ create_metroid_items(multiworld.MetroidsRequired[player], multiworld.MetroidsAreChecks[player])
+ create_metroid_items(multiworld.MetroidsRequired[player], multiworld.MetroidsInPool[player], multiworld.MetroidsAreChecks[player])
)

trap_percentage = get_option_value(multiworld, player, "TrapFillPercentage")
Expand Down
11 changes: 10 additions & 1 deletion worlds/am2r/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,21 @@


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


class MetroidsInPool(Range):
"""Chose how many Metroids will be in the pool, if Metroids are randomized. This will value will be ignored if smaller than the required amount"""
display_name = "Total Metroids in Pool"
range_start = 0
range_end = 46
default = 46


class MetroidsAreChecks(Choice):
"""Have each of the 46 non lab Metroids be treated as locations"""
display_name = "Metroids are Checks"
Expand Down Expand Up @@ -109,6 +117,7 @@ class RemoveOHKOTrap(Toggle):

AM2R_options: Dict[str, AssembleOptions] = {
"MetroidsRequired": MetroidsRequired,
"MetroidsInPool": MetroidsInPool,
"MetroidsAreChecks": MetroidsAreChecks,
"TrapFillPercentage": TrapFillPercentage,
"RemoveFloodTrap": RemoveFloodTrap,
Expand Down
Loading