Skip to content

Commit

Permalink
Make the behavior option values actual behaviors (ArchipelagoMW#25)
Browse files Browse the repository at this point in the history
  • Loading branch information
nex3 authored Jul 8, 2024
1 parent d2ee8d2 commit 763fd0e
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 26 deletions.
26 changes: 13 additions & 13 deletions worlds/dark_souls_3/Options.py
Original file line number Diff line number Diff line change
Expand Up @@ -328,44 +328,44 @@ class DS3ExcludeLocations(ExcludeLocations):


class ExcludedLocationBehaviorOption(Choice):
"""Which items can be placed in excluded locations in DS3.
"""How to choose items for excluded locations in DS3.
- **Unnecessary:** Excluded locations can't have progression items, but they can have useful
- **Allow Useful:** Excluded locations can't have progression items, but they can have useful
items.
- **Unimportant:** Neither progression items nor useful items can be placed in excluded
- **Forbid Useful:** Neither progression items nor useful items can be placed in excluded
locations.
- **Unrandomized:** Excluded locations always contain the same item as in vanilla Dark Souls
- **Do Not Randomize:** Excluded locations always contain the same item as in vanilla Dark Souls
III.
A "progression item" is anything that's required to unlock another location in some game. A
"useful item" is something each game defines individually, usually items that are quite
desirable but not strictly necessary.
"""
display_name = "Excluded Locations Behavior"
option_unnecessary = 1
option_unimportant = 2
option_unrandomized = 3
option_allow_useful = 1
option_forbid_useful = 2
option_do_not_randomize = 3
default = 2


class MissableLocationBehaviorOption(Choice):
"""Which items can be placed in locations that can be permanently missed.
- **Unnecessary:** Missable locations can't have progression items, but they can have useful
- **Allow Useful:** Missable locations can't have progression items, but they can have useful
items.
- **Unimportant:** Neither progression items nor useful items can be placed in missable
- **Forbid Useful:** Neither progression items nor useful items can be placed in missable
locations.
- **Unrandomized:** Missable locations always contain the same item as in vanilla Dark Souls
- **Do Not Randomize:** Missable locations always contain the same item as in vanilla Dark Souls
III.
A "progression item" is anything that's required to unlock another location in some game. A
"useful item" is something each game defines individually, usually items that are quite
desirable but not strictly necessary.
"""
display_name = "Missable Locations Behavior"
option_unnecessary = 1
option_unimportant = 2
option_unrandomized = 3
option_allow_useful = 1
option_forbid_useful = 2
option_do_not_randomize = 3
default = 2


Expand Down
26 changes: 13 additions & 13 deletions worlds/dark_souls_3/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ class DarkSouls3World(World):

all_excluded_locations: Set[str] = set()
"""This is the same value as `self.options.exclude_locations.value` initially, but if
`options.exclude_locations` gets cleared due to `excluded_locations: unnecessary` this still
`options.exclude_locations` gets cleared due to `excluded_locations: allow_useful` this still
holds the old locations so we can ensure they don't get necessary items.
"""

Expand Down Expand Up @@ -250,8 +250,8 @@ def create_region(self, region_name, location_table) -> Region:
if self._is_location_available(location):
new_location = DarkSouls3Location(self.player, location, new_region)
if (
# Exclude missable, unimportant locations
location.missable and self.options.missable_location_behavior == "unimportant"
# Exclude missable locations that don't allow useful items
location.missable and self.options.missable_location_behavior == "forbid_useful"
and not (
# Unless they are excluded to a higher degree already
location.name in self.all_excluded_locations
Expand Down Expand Up @@ -529,7 +529,7 @@ def set_rules(self) -> None:
self._add_npc_rules()
self._add_transposition_rules()
self._add_crow_rules()
self._add_unnecessary_location_rules()
self._add_allow_useful_location_rules()
self._add_early_item_rules(randomized_items)

self._add_entrance_rule("Firelink Shrine Bell Tower", "Tower Key")
Expand Down Expand Up @@ -1211,7 +1211,7 @@ def _add_crow_rules(self) -> None:
and not item.data.is_upgraded
))

def _add_unnecessary_location_rules(self) -> None:
def _add_allow_useful_location_rules(self) -> None:
"""Adds rules for locations that can contain useful but not necessary items.
If we allow useful items in the excluded locations, we don't want Archipelago's fill
Expand All @@ -1221,7 +1221,7 @@ def _add_unnecessary_location_rules(self) -> None:

all_locations = self.multiworld.get_locations(self.player)

unnecessary_locations = (
allow_useful_locations = (
(
{
location.name
Expand All @@ -1232,7 +1232,7 @@ def _add_unnecessary_location_rules(self) -> None:
if self.options.excluded_location_behavior < self.options.missable_location_behavior
else self.all_excluded_locations
)
if self.options.excluded_location_behavior == "unnecessary"
if self.options.excluded_location_behavior == "allow_useful"
else set()
).union(
{
Expand All @@ -1245,16 +1245,16 @@ def _add_unnecessary_location_rules(self) -> None:
self.options.excluded_location_behavior
)
}
if self.options.missable_location_behavior == "unnecessary"
if self.options.missable_location_behavior == "allow_useful"
else set()
)
for location in unnecessary_locations:
for location in allow_useful_locations:
self._add_item_rule(
location,
lambda item: not item.advancement
)

if self.options.excluded_location_behavior == "unnecessary":
if self.options.excluded_location_behavior == "allow_useful":
self.options.exclude_locations.value.clear()

def _add_early_item_rules(self, randomized_items: Set[str]) -> None:
Expand Down Expand Up @@ -1343,11 +1343,11 @@ def _is_location_available(
and (not data.dlc or self.options.enable_dlc)
and (not data.ngp or self.options.enable_ngp)
and not (
self.options.excluded_location_behavior == "unrandomized"
self.options.excluded_location_behavior == "do_not_randomize"
and data.name in self.all_excluded_locations
)
and not (
self.options.missable_location_behavior == "unrandomized"
self.options.missable_location_behavior == "do_not_randomize"
and data.missable
)
)
Expand All @@ -1358,7 +1358,7 @@ def write_spoiler(self, spoiler_handle: TextIO) -> None:
if self.yhorm_location != default_yhorm_location:
text += f"\nYhorm takes the place of {self.yhorm_location.name} in {self.player_name}'s world\n"

if self.options.excluded_location_behavior == "unnecessary":
if self.options.excluded_location_behavior == "allow_useful":
text += f"\n{self.player_name}'s world excluded: {sorted(self.all_excluded_locations)}\n"

if text:
Expand Down

0 comments on commit 763fd0e

Please sign in to comment.