Skip to content

Commit

Permalink
Merging PR #4056
Browse files Browse the repository at this point in the history
  • Loading branch information
tioui committed Oct 15, 2024
2 parents 43cc5ed + 618564c commit e1b1c27
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 9 deletions.
16 changes: 10 additions & 6 deletions MultiServer.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,11 +185,9 @@ class Context:
slot_info: typing.Dict[int, NetworkSlot]
generator_version = Version(0, 0, 0)
checksums: typing.Dict[str, str]
item_names: typing.Dict[str, typing.Dict[int, str]] = (
collections.defaultdict(lambda: Utils.KeyedDefaultDict(lambda code: f'Unknown item (ID:{code})')))
item_names: typing.Dict[str, typing.Dict[int, str]]
item_name_groups: typing.Dict[str, typing.Dict[str, typing.Set[str]]]
location_names: typing.Dict[str, typing.Dict[int, str]] = (
collections.defaultdict(lambda: Utils.KeyedDefaultDict(lambda code: f'Unknown location (ID:{code})')))
location_names: typing.Dict[str, typing.Dict[int, str]]
location_name_groups: typing.Dict[str, typing.Dict[str, typing.Set[str]]]
all_item_and_group_names: typing.Dict[str, typing.Set[str]]
all_location_and_group_names: typing.Dict[str, typing.Set[str]]
Expand All @@ -198,7 +196,6 @@ class Context:
""" each sphere is { player: { location_id, ... } } """
logger: logging.Logger


def __init__(self, host: str, port: int, server_password: str, password: str, location_check_points: int,
hint_cost: int, item_cheat: bool, release_mode: str = "disabled", collect_mode="disabled",
remaining_mode: str = "disabled", auto_shutdown: typing.SupportsFloat = 0, compatibility: int = 2,
Expand Down Expand Up @@ -269,6 +266,10 @@ def __init__(self, host: str, port: int, server_password: str, password: str, lo
self.location_name_groups = {}
self.all_item_and_group_names = {}
self.all_location_and_group_names = {}
self.item_names = collections.defaultdict(
lambda: Utils.KeyedDefaultDict(lambda code: f'Unknown item (ID:{code})'))
self.location_names = collections.defaultdict(
lambda: Utils.KeyedDefaultDict(lambda code: f'Unknown location (ID:{code})'))
self.non_hintable_names = collections.defaultdict(frozenset)

self._load_game_data()
Expand Down Expand Up @@ -1153,7 +1154,10 @@ def __call__(self, raw: str) -> typing.Optional[bool]:
if not raw:
return
try:
command = shlex.split(raw, comments=False)
try:
command = shlex.split(raw, comments=False)
except ValueError: # most likely: "ValueError: No closing quotation"
command = raw.split()
basecommand = command[0]
if basecommand[0] == self.marker:
method = self.commands.get(basecommand[1:].lower(), None)
Expand Down
1 change: 1 addition & 0 deletions docs/network protocol.md
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,7 @@ Additional arguments added to the [Set](#Set) package that triggered this [SetRe
These packets are sent purely from client to server. They are not accepted by clients.

* [Connect](#Connect)
* [ConnectUpdate](#ConnectUpdate)
* [Sync](#Sync)
* [LocationChecks](#LocationChecks)
* [LocationScouts](#LocationScouts)
Expand Down
4 changes: 3 additions & 1 deletion worlds/dark_souls_3/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ def __init__(self, multiworld: MultiWorld, player: int):
self.all_excluded_locations = set()

def generate_early(self) -> None:
self.created_regions = set()
self.all_excluded_locations.update(self.options.exclude_locations.value)

# Inform Universal Tracker where Yhorm is being randomized to.
Expand Down Expand Up @@ -294,6 +295,7 @@ def create_region(self, region_name, location_table) -> Region:
new_region.locations.append(new_location)

self.multiworld.regions.append(new_region)
self.created_regions.add(region_name)
return new_region

def create_items(self) -> None:
Expand Down Expand Up @@ -1305,7 +1307,7 @@ def _add_location_rule(self, location: Union[str, List[str]], rule: Union[Collec
def _add_entrance_rule(self, region: str, rule: Union[CollectionRule, str]) -> None:
"""Sets a rule for the entrance to the given region."""
assert region in location_tables
if not any(region == reg for reg in self.multiworld.regions.region_cache[self.player]): return
if region not in self.created_regions: return
if isinstance(rule, str):
if " -> " not in rule:
assert item_dictionary[rule].classification == ItemClassification.progression
Expand Down
2 changes: 2 additions & 0 deletions worlds/messenger/rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,8 @@ def __init__(self, world: "MessengerWorld") -> None:
}

self.location_rules = {
# hq
"Money Wrench": self.can_shop,
# ninja village
"Ninja Village Seal - Tree House":
self.has_dart,
Expand Down
13 changes: 13 additions & 0 deletions worlds/messenger/test/test_shop.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from typing import Dict

from BaseClasses import CollectionState
from . import MessengerTestBase
from ..shop import SHOP_ITEMS, FIGURINES

Expand Down Expand Up @@ -89,3 +90,15 @@ def test_costs(self) -> None:

self.assertTrue(loc in FIGURINES)
self.assertEqual(len(figures), len(FIGURINES))

max_cost_state = CollectionState(self.multiworld)
self.assertFalse(self.world.get_location("Money Wrench").can_reach(max_cost_state))
prog_shards = []
for item in self.multiworld.itempool:
if "Time Shard " in item.name:
value = int(item.name.strip("Time Shard ()"))
if value >= 100:
prog_shards.append(item)
for shard in prog_shards:
max_cost_state.collect(shard, True)
self.assertTrue(self.world.get_location("Money Wrench").can_reach(max_cost_state))
2 changes: 1 addition & 1 deletion worlds/minecraft/Structures.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def set_pair(exit, struct):

# Connect plando structures first
if self.options.plando_connections:
for conn in self.plando_connections:
for conn in self.options.plando_connections:
set_pair(conn.entrance, conn.exit)

# The algorithm tries to place the most restrictive structures first. This algorithm always works on the
Expand Down
4 changes: 4 additions & 0 deletions worlds/oot/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,10 @@ class OOTWorld(World):
"Small Key Ring (Spirit Temple)", "Small Key Ring (Thieves Hideout)", "Small Key Ring (Water Temple)",
"Boss Key (Fire Temple)", "Boss Key (Forest Temple)", "Boss Key (Ganons Castle)",
"Boss Key (Shadow Temple)", "Boss Key (Spirit Temple)", "Boss Key (Water Temple)"},

# aliases
"Longshot": {"Progressive Hookshot"}, # fuzzy hinting thought Longshot was Slingshot
"Hookshot": {"Progressive Hookshot"}, # for consistency, mostly
}

location_name_groups = build_location_name_groups()
Expand Down
2 changes: 1 addition & 1 deletion worlds/timespinner/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ def write_spoiler_header(self, spoiler_handle: TextIO) -> None:

if self.options.has_replaced_options:
warning = \
f"NOTICE: Timespinner options for player '{self.player_name}' where renamed from PasCalCase to snake_case, " \
f"NOTICE: Timespinner options for player '{self.player_name}' were renamed from PascalCase to snake_case, " \
"please update your yaml"

spoiler_handle.write("\n")
Expand Down

0 comments on commit e1b1c27

Please sign in to comment.