Compare commits

..

1 Commits

Author SHA1 Message Date
NewSoupVi
8b819aa0a4 Please merge my unit tests 2024-07-03 00:21:14 +02:00
323 changed files with 12202 additions and 14282 deletions

2
.gitignore vendored
View File

@@ -150,7 +150,7 @@ venv/
ENV/
env.bak/
venv.bak/
*.code-workspace
.code-workspace
shell.nix
# Spyder project settings

View File

@@ -61,7 +61,6 @@ class ClientCommandProcessor(CommandProcessor):
if address:
self.ctx.server_address = None
self.ctx.username = None
self.ctx.password = None
elif not self.ctx.server_address:
self.output("Please specify an address.")
return False
@@ -515,7 +514,6 @@ class CommonContext:
async def shutdown(self):
self.server_address = ""
self.username = None
self.password = None
self.cancel_autoreconnect()
if self.server and not self.server.socket.closed:
await self.server.socket.close()

13
Main.py
View File

@@ -124,19 +124,14 @@ def main(args, seed=None, baked_server_options: Optional[Dict[str, object]] = No
for player in multiworld.player_ids:
exclusion_rules(multiworld, player, multiworld.worlds[player].options.exclude_locations.value)
multiworld.worlds[player].options.priority_locations.value -= multiworld.worlds[player].options.exclude_locations.value
world_excluded_locations = set()
for location_name in multiworld.worlds[player].options.priority_locations.value:
try:
location = multiworld.get_location(location_name, player)
except KeyError:
continue
if location.progress_type != LocationProgressType.EXCLUDED:
location.progress_type = LocationProgressType.PRIORITY
except KeyError as e: # failed to find the given location. Check if it's a legitimate location
if location_name not in multiworld.worlds[player].location_name_to_id:
raise Exception(f"Unable to prioritize location {location_name} in player {player}'s world.") from e
else:
logger.warning(f"Unable to prioritize location \"{location_name}\" in player {player}'s world because the world excluded it.")
world_excluded_locations.add(location_name)
multiworld.worlds[player].options.priority_locations.value -= world_excluded_locations
location.progress_type = LocationProgressType.PRIORITY
# Set local and non-local item rules.
if multiworld.players > 1:

View File

@@ -1352,7 +1352,7 @@ class ClientMessageProcessor(CommonCommandProcessor):
if self.ctx.remaining_mode == "enabled":
remaining_item_ids = get_remaining(self.ctx, self.client.team, self.client.slot)
if remaining_item_ids:
self.output("Remaining items: " + ", ".join(self.ctx.item_names[self.ctx.games[self.client.slot]][item_id]
self.output("Remaining items: " + ", ".join(self.ctx.item_names[self.client.slot.game][item_id]
for item_id in remaining_item_ids))
else:
self.output("No remaining items found.")
@@ -1365,7 +1365,7 @@ class ClientMessageProcessor(CommonCommandProcessor):
if self.ctx.client_game_state[self.client.team, self.client.slot] == ClientStatus.CLIENT_GOAL:
remaining_item_ids = get_remaining(self.ctx, self.client.team, self.client.slot)
if remaining_item_ids:
self.output("Remaining items: " + ", ".join(self.ctx.item_names[self.ctx.games[self.client.slot]][item_id]
self.output("Remaining items: " + ", ".join(self.ctx.item_names[self.client.slot.game][item_id]
for item_id in remaining_item_ids))
else:
self.output("No remaining items found.")

View File

@@ -29,7 +29,7 @@ class UndertaleCommandProcessor(ClientCommandProcessor):
def _cmd_patch(self):
"""Patch the game. Only use this command if /auto_patch fails."""
if isinstance(self.ctx, UndertaleContext):
os.makedirs(name=Utils.user_path("Undertale"), exist_ok=True)
os.makedirs(name=os.path.join(os.getcwd(), "Undertale"), exist_ok=True)
self.ctx.patch_game()
self.output("Patched.")
@@ -43,7 +43,7 @@ class UndertaleCommandProcessor(ClientCommandProcessor):
def _cmd_auto_patch(self, steaminstall: typing.Optional[str] = None):
"""Patch the game automatically."""
if isinstance(self.ctx, UndertaleContext):
os.makedirs(name=Utils.user_path("Undertale"), exist_ok=True)
os.makedirs(name=os.path.join(os.getcwd(), "Undertale"), exist_ok=True)
tempInstall = steaminstall
if not os.path.isfile(os.path.join(tempInstall, "data.win")):
tempInstall = None
@@ -62,7 +62,7 @@ class UndertaleCommandProcessor(ClientCommandProcessor):
for file_name in os.listdir(tempInstall):
if file_name != "steam_api.dll":
shutil.copy(os.path.join(tempInstall, file_name),
Utils.user_path("Undertale", file_name))
os.path.join(os.getcwd(), "Undertale", file_name))
self.ctx.patch_game()
self.output("Patching successful!")
@@ -111,12 +111,12 @@ class UndertaleContext(CommonContext):
self.save_game_folder = os.path.expandvars(r"%localappdata%/UNDERTALE")
def patch_game(self):
with open(Utils.user_path("Undertale", "data.win"), "rb") as f:
with open(os.path.join(os.getcwd(), "Undertale", "data.win"), "rb") as f:
patchedFile = bsdiff4.patch(f.read(), undertale.data_path("patch.bsdiff"))
with open(Utils.user_path("Undertale", "data.win"), "wb") as f:
with open(os.path.join(os.getcwd(), "Undertale", "data.win"), "wb") as f:
f.write(patchedFile)
os.makedirs(name=Utils.user_path("Undertale", "Custom Sprites"), exist_ok=True)
with open(os.path.expandvars(Utils.user_path("Undertale", "Custom Sprites",
os.makedirs(name=os.path.join(os.getcwd(), "Undertale", "Custom Sprites"), exist_ok=True)
with open(os.path.expandvars(os.path.join(os.getcwd(), "Undertale", "Custom Sprites",
"Which Character.txt")), "w") as f:
f.writelines(["// Put the folder name of the sprites you want to play as, make sure it is the only "
"line other than this one.\n", "frisk"])

View File

@@ -325,12 +325,10 @@ def run_server_process(name: str, ponyconfig: dict, static_server_data: dict,
def run(self):
while 1:
next_room = rooms_to_run.get(block=True, timeout=None)
gc.collect(0)
task = asyncio.run_coroutine_threadsafe(start_room(next_room), loop)
self._tasks.append(task)
task.add_done_callback(self._done)
logging.info(f"Starting room {next_room} on {name}.")
del task # delete reference to task object
starter = Starter()
starter.daemon = True

View File

@@ -1,8 +1,8 @@
# Archipelago World Code Owners / Maintainers Document
#
# This file is used to notate the current "owners" or "maintainers" of any currently merged world folder as well as
# certain documentation. For any pull requests that modify these worlds/docs, a code owner must approve the PR in
# addition to a core maintainer. All other files and folders are owned and maintained by core maintainers directly.
# This file is used to notate the current "owners" or "maintainers" of any currently merged world folder. For any pull
# requests that modify these worlds, a code owner must approve the PR in addition to a core maintainer. This is not to
# be used for files/folders outside the /worlds folder, those will always need sign off from a core maintainer.
#
# All usernames must be GitHub usernames (and are case sensitive).
@@ -226,11 +226,3 @@
# Ori and the Blind Forest
# /worlds_disabled/oribf/
###################
## Documentation ##
###################
# Apworld Dev Faq
/docs/apworld_dev_faq.md @qwint @ScipioWright

View File

@@ -1,68 +0,0 @@
# APWorld Dev FAQ
This document is meant as a reference tool to show solutions to common problems when developing an apworld.
It is not intended to answer every question about Archipelago and it assumes you have read the other docs,
including [Contributing](contributing.md), [Adding Games](<adding games.md>), and [World API](<world api.md>).
---
### My game has a restrictive start that leads to fill errors
Hint to the Generator that an item needs to be in sphere one with local_early_items. Here, `1` represents the number of "Sword" items to attempt to place in sphere one.
```py
early_item_name = "Sword"
self.multiworld.local_early_items[self.player][early_item_name] = 1
```
Some alternative ways to try to fix this problem are:
* Add more locations to sphere one of your world, potentially only when there would be a restrictive start
* Pre-place items yourself, such as during `create_items`
* Put items into the player's starting inventory using `push_precollected`
* Raise an exception, such as an `OptionError` during `generate_early`, to disallow options that would lead to a restrictive start
---
### I have multiple settings that change the item/location pool counts and need to balance them out
In an ideal situation your system for producing locations and items wouldn't leave any opportunity for them to be unbalanced. But in real, complex situations, that might be unfeasible.
If that's the case, you can create extra filler based on the difference between your unfilled locations and your itempool by comparing [get_unfilled_locations](https://github.com/ArchipelagoMW/Archipelago/blob/main/BaseClasses.py#:~:text=get_unfilled_locations) to your list of items to submit
Note: to use self.create_filler(), self.get_filler_item_name() should be defined to only return valid filler item names
```py
total_locations = len(self.multiworld.get_unfilled_locations(self.player))
item_pool = self.create_non_filler_items()
for _ in range(total_locations - len(item_pool)):
item_pool.append(self.create_filler())
self.multiworld.itempool += item_pool
```
A faster alternative to the `for` loop would be to use a [list comprehension](https://docs.python.org/3/tutorial/datastructures.html#list-comprehensions):
```py
item_pool += [self.create_filler() for _ in range(total_locations - len(item_pool))]
```
---
### I learned about indirect conditions in the world API document, but I want to know more. What are they and why are they necessary?
The world API document mentions indirect conditions and **when** you should use them, but not *how* they work and *why* they are necessary. This is because the explanation is quite complicated.
Region sweep (the algorithm that determines which regions are reachable) is a Breadth-First Search of the region graph from the origin region, checking entrances one by one and adding newly reached nodes (regions) and their entrances to the queue until there is nothing more to check.
For performance reasons, AP only checks every entrance once. However, if an entrance's access condition depends on regions, then it is possible for this to happen:
1. An entrance that depends on a region is checked and determined to be nontraversable because the region hasn't been reached yet during the graph search.
2. After that, the region is reached by the graph search.
The entrance *would* now be determined to be traversable if it were rechecked, but it is not.
To account for this case, AP would have to recheck all entrances every time a new region is reached until no new regions are reached.
However, there is a way to **manually** define that a *specific* entrance needs to be rechecked during region sweep if a *specific* region is reached during it. This is what an indirect condition is.
This keeps almost all of the performance upsides. Even a game making heavy use of indirect conditions (See: The Witness) is still significantly faster than if it just blanket "rechecked all entrances until nothing new is found".
The reason entrance access rules using `location.can_reach` and `entrance.can_reach` are also affected is simple: They call `region.can_reach` on their respective parent/source region.
We recognize it can feel like a trap since it will not alert you when you are missing an indirect condition, and that some games have very complex access rules.
As of [PR #3682 (Core: Region handling customization)](https://github.com/ArchipelagoMW/Archipelago/pull/3682) being merged, it is also possible for a world to opt out of indirect conditions entirely, although it does come at a flat performance cost.
It should only be used by games that *really* need it. For most games, it should be reasonable to know all entrance &rarr; region dependencies, and in this case, indirect conditions are still preferred because they are faster.

View File

@@ -595,9 +595,8 @@ class GameManager(App):
"!help for server commands.")
def connect_button_action(self, button):
self.ctx.username = None
self.ctx.password = None
if self.ctx.server:
self.ctx.username = None
async_start(self.ctx.disconnect())
else:
async_start(self.ctx.connect(self.server_connect_bar.text.replace("/connect ", "")))
@@ -837,10 +836,6 @@ class KivyJSONtoTextParser(JSONtoTextParser):
return self._handle_text(node)
def _handle_text(self, node: JSONMessagePart):
# All other text goes through _handle_color, and we don't want to escape markup twice,
# or mess up text that already has intentional markup applied to it
if node.get("type", "text") == "text":
node["text"] = escape_markup(node["text"])
for ref in node.get("refs", []):
node["text"] = f"[ref={self.ref_count}|{ref}]{node['text']}[/ref]"
self.ref_count += 1

View File

@@ -3,7 +3,6 @@ Application settings / host.yaml interface using type hints.
This is different from player options.
"""
import os
import os.path
import shutil
import sys
@@ -12,6 +11,7 @@ import warnings
from enum import IntEnum
from threading import Lock
from typing import cast, Any, BinaryIO, ClassVar, Dict, Iterator, List, Optional, TextIO, Tuple, Union, TypeVar
import os
__all__ = [
"get_settings", "fmt_doc", "no_gui",
@@ -798,7 +798,6 @@ class Settings(Group):
atexit.register(autosave)
def save(self, location: Optional[str] = None) -> None: # as above
from Utils import parse_yaml
location = location or self._filename
assert location, "No file specified"
temp_location = location + ".tmp" # not using tempfile to test expected file access
@@ -808,18 +807,10 @@ class Settings(Group):
# can't use utf-8-sig because it breaks backward compat: pyyaml on Windows with bytes does not strip the BOM
with open(temp_location, "w", encoding="utf-8") as f:
self.dump(f)
f.flush()
if hasattr(os, "fsync"):
os.fsync(f.fileno())
# validate new file is valid yaml
with open(temp_location, encoding="utf-8") as f:
parse_yaml(f.read())
# replace old with new, try atomic operation first
try:
os.rename(temp_location, location)
except (OSError, FileExistsError):
# replace old with new
if os.path.exists(location):
os.unlink(location)
os.rename(temp_location, location)
os.rename(temp_location, location)
self._filename = location
def dump(self, f: TextIO, level: int = 0) -> None:
@@ -841,6 +832,7 @@ def get_settings() -> Settings:
with _lock: # make sure we only have one instance
res = getattr(get_settings, "_cache", None)
if not res:
import os
from Utils import user_path, local_path
filenames = ("options.yaml", "host.yaml")
locations: List[str] = []

View File

@@ -21,7 +21,7 @@ from pathlib import Path
# This is a bit jank. We need cx-Freeze to be able to run anything from this script, so install it
try:
requirement = 'cx-Freeze==7.2.0'
requirement = 'cx-Freeze==7.0.0'
import pkg_resources
try:
pkg_resources.require(requirement)

View File

@@ -1,12 +1,11 @@
import os
import os.path
import unittest
from io import StringIO
from tempfile import TemporaryDirectory, TemporaryFile
from tempfile import TemporaryFile
from typing import Any, Dict, List, cast
import Utils
from settings import Group, Settings, ServerOptions
from settings import Settings, Group
class TestIDs(unittest.TestCase):
@@ -81,27 +80,3 @@ class TestSettingsDumper(unittest.TestCase):
self.assertEqual(value_spaces[2], value_spaces[0]) # start of sub-list
self.assertGreater(value_spaces[3], value_spaces[0],
f"{value_lines[3]} should have more indentation than {value_lines[0]} in {lines}")
class TestSettingsSave(unittest.TestCase):
def test_save(self) -> None:
"""Test that saving and updating works"""
with TemporaryDirectory() as d:
filename = os.path.join(d, "host.yaml")
new_release_mode = ServerOptions.ReleaseMode("enabled")
# create default host.yaml
settings = Settings(None)
settings.save(filename)
self.assertTrue(os.path.exists(filename),
"Default settings could not be saved")
self.assertNotEqual(settings.server_options.release_mode, new_release_mode,
"Unexpected default release mode")
# update host.yaml
settings.server_options.release_mode = new_release_mode
settings.save(filename)
self.assertFalse(os.path.exists(filename + ".tmp"),
"Temp file was not removed during save")
# read back host.yaml
settings = Settings(filename)
self.assertEqual(settings.server_options.release_mode, new_release_mode,
"Settings were not overwritten")

View File

@@ -1,36 +0,0 @@
import unittest
import typing
from uuid import uuid4
from flask import Flask
from flask.testing import FlaskClient
class TestBase(unittest.TestCase):
app: typing.ClassVar[Flask]
client: FlaskClient
@classmethod
def setUpClass(cls) -> None:
from WebHostLib import app as raw_app
from WebHost import get_app
raw_app.config["PONY"] = {
"provider": "sqlite",
"filename": ":memory:",
"create_db": True,
}
raw_app.config.update({
"TESTING": True,
"DEBUG": True,
})
try:
cls.app = get_app()
except AssertionError as e:
# since we only have 1 global app object, this might fail, but luckily all tests use the same config
if "register_blueprint" not in e.args[0]:
raise
cls.app = raw_app
def setUp(self) -> None:
self.client = self.app.test_client()

View File

@@ -1,16 +1,31 @@
import io
import unittest
import json
import yaml
from . import TestBase
class TestDocs(unittest.TestCase):
@classmethod
def setUpClass(cls) -> None:
from WebHostLib import app as raw_app
from WebHost import get_app
raw_app.config["PONY"] = {
"provider": "sqlite",
"filename": ":memory:",
"create_db": True,
}
raw_app.config.update({
"TESTING": True,
})
app = get_app()
class TestAPIGenerate(TestBase):
def test_correct_error_empty_request(self) -> None:
cls.client = app.test_client()
def test_correct_error_empty_request(self):
response = self.client.post("/api/generate")
self.assertIn("No options found. Expected file attachment or json weights.", response.text)
def test_generation_queued_weights(self) -> None:
def test_generation_queued_weights(self):
options = {
"Tester1":
{
@@ -28,7 +43,7 @@ class TestAPIGenerate(TestBase):
self.assertTrue(json_data["text"].startswith("Generation of seed "))
self.assertTrue(json_data["text"].endswith(" started successfully."))
def test_generation_queued_file(self) -> None:
def test_generation_queued_file(self):
options = {
"game": "Archipelago",
"name": "Tester",

View File

@@ -1,192 +0,0 @@
import os
from uuid import UUID, uuid4, uuid5
from flask import url_for
from . import TestBase
class TestHostFakeRoom(TestBase):
room_id: UUID
log_filename: str
def setUp(self) -> None:
from pony.orm import db_session
from Utils import user_path
from WebHostLib.models import Room, Seed
super().setUp()
with self.client.session_transaction() as session:
session["_id"] = uuid4()
with db_session:
# create an empty seed and a room from it
seed = Seed(multidata=b"", owner=session["_id"])
room = Room(seed=seed, owner=session["_id"], tracker=uuid4())
self.room_id = room.id
self.log_filename = user_path("logs", f"{self.room_id}.txt")
def tearDown(self) -> None:
from pony.orm import db_session, select
from WebHostLib.models import Command, Room
with db_session:
for command in select(command for command in Command if command.room.id == self.room_id): # type: ignore
command.delete()
room: Room = Room.get(id=self.room_id)
room.seed.delete()
room.delete()
try:
os.unlink(self.log_filename)
except FileNotFoundError:
pass
def test_display_log_missing_full(self) -> None:
"""
Verify that we get a 200 response even if log is missing.
This is required to not get an error for fetch.
"""
with self.app.app_context(), self.app.test_request_context():
response = self.client.get(url_for("display_log", room=self.room_id))
self.assertEqual(response.status_code, 200)
def test_display_log_missing_range(self) -> None:
"""
Verify that we get a full response for missing log even if we asked for range.
This is required for the JS logic to differentiate between log update and log error message.
"""
with self.app.app_context(), self.app.test_request_context():
response = self.client.get(url_for("display_log", room=self.room_id), headers={
"Range": "bytes=100-"
})
self.assertEqual(response.status_code, 200)
def test_display_log_denied(self) -> None:
"""Verify that only the owner can see the log."""
other_client = self.app.test_client()
with self.app.app_context(), self.app.test_request_context():
response = other_client.get(url_for("display_log", room=self.room_id))
self.assertEqual(response.status_code, 403)
def test_display_log_missing_room(self) -> None:
"""Verify log for missing room gives an error as opposed to missing log for existing room."""
missing_room_id = uuid5(uuid4(), "") # rooms are always uuid4, so this can't exist
other_client = self.app.test_client()
with self.app.app_context(), self.app.test_request_context():
response = other_client.get(url_for("display_log", room=missing_room_id))
self.assertEqual(response.status_code, 404)
def test_display_log_full(self) -> None:
"""Verify full log response."""
with open(self.log_filename, "w", encoding="utf-8") as f:
text = "x" * 200
f.write(text)
with self.app.app_context(), self.app.test_request_context():
response = self.client.get(url_for("display_log", room=self.room_id))
self.assertEqual(response.status_code, 200)
self.assertEqual(response.get_data(True), text)
def test_display_log_range(self) -> None:
"""Verify that Range header in request gives a range in response."""
with open(self.log_filename, "w", encoding="utf-8") as f:
f.write(" " * 100)
text = "x" * 100
f.write(text)
with self.app.app_context(), self.app.test_request_context():
response = self.client.get(url_for("display_log", room=self.room_id), headers={
"Range": "bytes=100-"
})
self.assertEqual(response.status_code, 206)
self.assertEqual(response.get_data(True), text)
def test_display_log_range_bom(self) -> None:
"""Verify that a BOM in the log file is skipped for range."""
with open(self.log_filename, "w", encoding="utf-8-sig") as f:
f.write(" " * 100)
text = "x" * 100
f.write(text)
self.assertEqual(f.tell(), 203) # including BOM
with self.app.app_context(), self.app.test_request_context():
response = self.client.get(url_for("display_log", room=self.room_id), headers={
"Range": "bytes=100-"
})
self.assertEqual(response.status_code, 206)
self.assertEqual(response.get_data(True), text)
def test_host_room_missing(self) -> None:
"""Verify that missing room gives a 404 response."""
missing_room_id = uuid5(uuid4(), "") # rooms are always uuid4, so this can't exist
with self.app.app_context(), self.app.test_request_context():
response = self.client.get(url_for("host_room", room=missing_room_id))
self.assertEqual(response.status_code, 404)
def test_host_room_own(self) -> None:
"""Verify that own room gives the full output."""
with open(self.log_filename, "w", encoding="utf-8-sig") as f:
text = "* should be visible *"
f.write(text)
with self.app.app_context(), self.app.test_request_context():
response = self.client.get(url_for("host_room", room=self.room_id))
response_text = response.get_data(True)
self.assertEqual(response.status_code, 200)
self.assertIn("href=\"/seed/", response_text)
self.assertIn(text, response_text)
def test_host_room_other(self) -> None:
"""Verify that non-own room gives the reduced output."""
from pony.orm import db_session
from WebHostLib.models import Room
with db_session:
room: Room = Room.get(id=self.room_id)
room.last_port = 12345
with open(self.log_filename, "w", encoding="utf-8-sig") as f:
text = "* should not be visible *"
f.write(text)
other_client = self.app.test_client()
with self.app.app_context(), self.app.test_request_context():
response = other_client.get(url_for("host_room", room=self.room_id))
response_text = response.get_data(True)
self.assertEqual(response.status_code, 200)
self.assertNotIn("href=\"/seed/", response_text)
self.assertNotIn(text, response_text)
self.assertIn("/connect ", response_text)
self.assertIn(":12345", response_text)
def test_host_room_own_post(self) -> None:
"""Verify command from owner gets queued for the server and response is redirect."""
from pony.orm import db_session, select
from WebHostLib.models import Command
with self.app.app_context(), self.app.test_request_context():
response = self.client.post(url_for("host_room", room=self.room_id), data={
"cmd": "/help"
})
self.assertEqual(response.status_code, 302, response.text)\
with db_session:
commands = select(command for command in Command if command.room.id == self.room_id) # type: ignore
self.assertIn("/help", (command.commandtext for command in commands))
def test_host_room_other_post(self) -> None:
"""Verify command from non-owner does not get queued for the server."""
from pony.orm import db_session, select
from WebHostLib.models import Command
other_client = self.app.test_client()
with self.app.app_context(), self.app.test_request_context():
response = other_client.post(url_for("host_room", room=self.room_id), data={
"cmd": "/help"
})
self.assertLess(response.status_code, 500)
with db_session:
commands = select(command for command in Command if command.room.id == self.room_id) # type: ignore
self.assertNotIn("/help", (command.commandtext for command in commands))

View File

@@ -292,9 +292,6 @@ blacklisted_combos = {
# See above comment
"Time Rift - Deep Sea": ["Alpine Free Roam", "Nyakuza Free Roam", "Contractual Obligations",
"Murder on the Owl Express"],
# was causing test failures
"Time Rift - Balcony": ["Alpine Free Roam"],
}

View File

@@ -863,8 +863,6 @@ def set_rift_rules(world: "HatInTimeWorld", regions: Dict[str, Region]):
if world.is_dlc1():
for entrance in regions["Time Rift - Balcony"].entrances:
add_rule(entrance, lambda state: can_clear_required_act(state, world, "The Arctic Cruise - Finale"))
reg_act_connection(world, world.multiworld.get_entrance("The Arctic Cruise - Finale",
world.player).connected_region, entrance)
for entrance in regions["Time Rift - Deep Sea"].entrances:
add_rule(entrance, lambda state: has_relic_combo(state, world, "Cake"))
@@ -941,7 +939,6 @@ def set_default_rift_rules(world: "HatInTimeWorld"):
if world.is_dlc1():
for entrance in world.multiworld.get_region("Time Rift - Balcony", world.player).entrances:
add_rule(entrance, lambda state: can_clear_required_act(state, world, "The Arctic Cruise - Finale"))
reg_act_connection(world, "Rock the Boat", entrance.name)
for entrance in world.multiworld.get_region("Time Rift - Deep Sea", world.player).entrances:
add_rule(entrance, lambda state: has_relic_combo(state, world, "Cake"))

View File

@@ -12,29 +12,41 @@
## Instructions
1. **BACK UP YOUR SAVE FILES IN YOUR MAIN INSTALL IF YOU CARE ABOUT THEM!!!**
Go to `steamapps/common/HatinTime/HatinTimeGame/SaveData/` and copy everything inside that folder over to a safe place.
**This is important! Changing the game version CAN and WILL break your existing save files!!!**
1. Have Steam running. Open the Steam console with this link: [steam://open/console](steam://open/console)
This may not work for some browsers. If that's the case, and you're on Windows, open the Run dialog using Win+R,
paste the link into the box, and hit Enter.
2. In your Steam library, right-click on **A Hat in Time** in the list of games and click on **Properties**.
2. In the Steam console, enter the following command:
`download_depot 253230 253232 7770543545116491859`. ***Wait for the console to say the download is finished!***
This can take a while to finish (30+ minutes) depending on your connection speed, so please be patient. Additionally,
**try to prevent your connection from being interrupted or slowed while Steam is downloading the depot,**
or else the download may potentially become corrupted (see first FAQ issue below).
3. Click the **Betas** tab. In the **Beta Participation** dropdown, select `tcplink`.
While it downloads, you can subscribe to the [Archipelago workshop mod.]((https://steamcommunity.com/sharedfiles/filedetails/?id=3026842601))
3. Once the download finishes, go to `steamapps/content/app_253230` in Steam's program folder.
4. Once the game finishes downloading, start it up.
In Game Settings, make sure **Enable Developer Console** is checked.
4. There should be a folder named `depot_253232`. Rename it to HatinTime_AP and move it to your `steamapps/common` folder.
5. You should now be good to go. See below for more details on how to use the mod and connect to an Archipelago game.
5. In the HatinTime_AP folder, navigate to `Binaries/Win64` and create a new file: `steam_appid.txt`.
In this new text file, input the number **253230** on the first line.
6. Create a shortcut of `HatinTimeGame.exe` from that folder and move it to wherever you'd like.
You will use this shortcut to open the Archipelago-compatible version of A Hat in Time.
7. Start up the game using your new shortcut. To confirm if you are on the correct version,
go to Settings -> Game Settings. If you don't see an option labelled ***Live Game Events*** you should be running
the correct version of the game. In Game Settings, make sure ***Enable Developer Console*** is checked.
## Connecting to the Archipelago server
To connect to the multiworld server, simply run the **Archipelago AHIT Client** from the Launcher
and connect it to the Archipelago server.
To connect to the multiworld server, simply run the **ArchipelagoAHITClient**
(or run it from the Launcher if you have the apworld installed) and connect it to the Archipelago server.
The game will connect to the client automatically when you create a new save file.
@@ -49,8 +61,33 @@ make sure ***Enable Developer Console*** is checked in Game Settings and press t
## FAQ/Common Issues
### I followed the setup, but I receive an odd error message upon starting the game or creating a save file!
If you receive an error message such as
**"Failed to find default engine .ini to retrieve My Documents subdirectory to use. Force quitting."** or
**"Failed to load map "hub_spaceship"** after booting up the game or creating a save file respectively, then the depot
download was likely corrupted. The only way to fix this is to start the entire download all over again.
Unfortunately, this appears to be an underlying issue with Steam's depot downloader. The only way to really prevent this
from happening is to ensure that your connection is not interrupted or slowed while downloading.
### The game is not connecting when starting a new save!
### The game keeps crashing on startup after the splash screen!
This issue is unfortunately very hard to fix, and the underlying cause is not known. If it does happen however,
try the following:
- Close Steam **entirely**.
- Open the downpatched version of the game (with Steam closed) and allow it to load to the titlescreen.
- Close the game, and then open Steam again.
- After launching the game, the issue should hopefully disappear. If not, repeat the above steps until it does.
### I followed the setup, but "Live Game Events" still shows up in the options menu!
The most common cause of this is the `steam_appid.txt` file. If you're on Windows 10, file extensions are hidden by
default (thanks Microsoft). You likely made the mistake of still naming the file `steam_appid.txt`, which, since file
extensions are hidden, would result in the file being named `steam_appid.txt.txt`, which is incorrect.
To show file extensions in Windows 10, open any folder, click the View tab at the top, and check
"File name extensions". Then you can correct the name of the file. If the name of the file is correct,
and you're still running into the issue, re-read the setup guide again in case you missed a step.
If you still can't get it to work, ask for help in the Discord thread.
### The game is running on the older version, but it's not connecting when starting a new save!
For unknown reasons, the mod will randomly disable itself in the mod menu. To fix this, go to the Mods menu
(rocket icon) in-game, and re-enable the mod.

View File

@@ -488,7 +488,7 @@ def global_rules(multiworld: MultiWorld, player: int):
set_rule(multiworld.get_location('Turtle Rock - Roller Room - Right', player), lambda state: state.has('Cane of Somaria', player) and state.has('Fire Rod', player))
set_rule(multiworld.get_location('Turtle Rock - Big Chest', player), lambda state: state.has('Big Key (Turtle Rock)', player) and (state.has('Cane of Somaria', player) or state.has('Hookshot', player)))
set_rule(multiworld.get_entrance('Turtle Rock (Big Chest) (North)', player), lambda state: state.has('Cane of Somaria', player) or state.has('Hookshot', player))
set_rule(multiworld.get_entrance('Turtle Rock Big Key Door', player), lambda state: state.has('Big Key (Turtle Rock)', player) and can_kill_most_things(state, player, 10) and can_bomb_or_bonk(state, player))
set_rule(multiworld.get_entrance('Turtle Rock Big Key Door', player), lambda state: state.has('Big Key (Turtle Rock)', player) and can_kill_most_things(state, player, 10))
set_rule(multiworld.get_location('Turtle Rock - Chain Chomps', player), lambda state: can_use_bombs(state, player) or can_shoot_arrows(state, player)
or has_beam_sword(state, player) or state.has_any(["Blue Boomerang", "Red Boomerang", "Hookshot", "Cane of Somaria", "Fire Rod", "Ice Rod"], player))
set_rule(multiworld.get_entrance('Turtle Rock (Dark Room) (North)', player), lambda state: state.has('Cane of Somaria', player))

View File

@@ -30,7 +30,7 @@ class AquariaLocations:
locations_verse_cave_r = {
"Verse Cave, bulb in the skeleton room": 698107,
"Verse Cave, bulb in the path right of the skeleton room": 698108,
"Verse Cave, bulb in the path left of the skeleton room": 698108,
"Verse Cave right area, Big Seed": 698175,
}
@@ -122,7 +122,6 @@ class AquariaLocations:
"Open Water top right area, second urn in the Mithalas exit": 698149,
"Open Water top right area, third urn in the Mithalas exit": 698150,
}
locations_openwater_tr_turtle = {
"Open Water top right area, bulb in the turtle room": 698009,
"Open Water top right area, Transturtle": 698211,
@@ -196,7 +195,7 @@ class AquariaLocations:
locations_cathedral_l = {
"Mithalas City Castle, bulb in the flesh hole": 698042,
"Mithalas City Castle, Blue Banner": 698165,
"Mithalas City Castle, Blue banner": 698165,
"Mithalas City Castle, urn in the bedroom": 698130,
"Mithalas City Castle, first urn of the single lamp path": 698131,
"Mithalas City Castle, second urn of the single lamp path": 698132,
@@ -227,7 +226,7 @@ class AquariaLocations:
"Mithalas Cathedral, third urn in the path behind the flesh vein": 698146,
"Mithalas Cathedral, fourth urn in the top right room": 698147,
"Mithalas Cathedral, Mithalan Dress": 698189,
"Mithalas Cathedral, urn below the left entrance": 698198,
"Mithalas Cathedral right area, urn below the left entrance": 698198,
}
locations_cathedral_underground = {
@@ -240,7 +239,7 @@ class AquariaLocations:
}
locations_cathedral_boss = {
"Mithalas boss area, beating Mithalan God": 698202,
"Cathedral boss area, beating Mithalan God": 698202,
}
locations_forest_tl = {
@@ -270,7 +269,7 @@ class AquariaLocations:
locations_forest_bl = {
"Kelp Forest bottom left area, bulb close to the spirit crystals": 698054,
"Kelp Forest bottom left area, Walker Baby": 698186,
"Kelp Forest bottom left area, Walker baby": 698186,
"Kelp Forest bottom left area, Transturtle": 698212,
}
@@ -452,7 +451,7 @@ class AquariaLocations:
locations_body_c = {
"The Body center area, breaking Li's cage": 698201,
"The Body center area, bulb on the main path blocking tube": 698097,
"The Body main area, bulb on the main path blocking tube": 698097,
}
locations_body_l = {

View File

@@ -5,7 +5,7 @@ Description: Manage options in the Aquaria game multiworld randomizer
"""
from dataclasses import dataclass
from Options import Toggle, Choice, Range, PerGameCommonOptions, DefaultOnToggle, StartInventoryPool
from Options import Toggle, Choice, Range, DeathLink, PerGameCommonOptions, DefaultOnToggle, StartInventoryPool
class IngredientRandomizer(Choice):
@@ -111,14 +111,6 @@ class BindSongNeededToGetUnderRockBulb(Toggle):
display_name = "Bind song needed to get sing bulbs under rocks"
class BlindGoal(Toggle):
"""
Hide the goal's requirements from the help page so that you have to go to the last boss door to know
what is needed to access the boss.
"""
display_name = "Hide the goal's requirements"
class UnconfineHomeWater(Choice):
"""
Open the way out of the Home Water area so that Naija can go to open water and beyond without the bind song.
@@ -150,4 +142,4 @@ class AquariaOptions(PerGameCommonOptions):
dish_randomizer: DishRandomizer
aquarian_translation: AquarianTranslation
skip_first_vision: SkipFirstVision
blind_goal: BlindGoal
death_link: DeathLink

View File

@@ -300,7 +300,7 @@ class AquariaRegions:
AquariaLocations.locations_cathedral_l_sc)
self.cathedral_r = self.__add_region("Mithalas Cathedral",
AquariaLocations.locations_cathedral_r)
self.cathedral_underground = self.__add_region("Mithalas Cathedral underground",
self.cathedral_underground = self.__add_region("Mithalas Cathedral Underground area",
AquariaLocations.locations_cathedral_underground)
self.cathedral_boss_r = self.__add_region("Mithalas Cathedral, Mithalan God room",
AquariaLocations.locations_cathedral_boss)
@@ -597,22 +597,22 @@ class AquariaRegions:
lambda state: _has_beast_form(state, self.player) and
_has_energy_form(state, self.player) and
_has_bind_song(state, self.player))
self.__connect_regions("Mithalas castle", "Mithalas Cathedral underground",
self.__connect_regions("Mithalas castle", "Cathedral underground",
self.cathedral_l, self.cathedral_underground,
lambda state: _has_beast_form(state, self.player) and
_has_bind_song(state, self.player))
self.__connect_regions("Mithalas castle", "Mithalas Cathedral",
self.__connect_regions("Mithalas castle", "Cathedral right area",
self.cathedral_l, self.cathedral_r,
lambda state: _has_bind_song(state, self.player) and
_has_energy_form(state, self.player))
self.__connect_regions("Mithalas Cathedral", "Mithalas Cathedral underground",
self.__connect_regions("Cathedral right area", "Cathedral underground",
self.cathedral_r, self.cathedral_underground,
lambda state: _has_energy_form(state, self.player))
self.__connect_one_way_regions("Mithalas Cathedral underground", "Cathedral boss left area",
self.__connect_one_way_regions("Cathedral underground", "Cathedral boss left area",
self.cathedral_underground, self.cathedral_boss_r,
lambda state: _has_energy_form(state, self.player) and
_has_bind_song(state, self.player))
self.__connect_one_way_regions("Cathedral boss left area", "Mithalas Cathedral underground",
self.__connect_one_way_regions("Cathedral boss left area", "Cathedral underground",
self.cathedral_boss_r, self.cathedral_underground,
lambda state: _has_beast_form(state, self.player))
self.__connect_regions("Cathedral boss right area", "Cathedral boss left area",
@@ -1099,7 +1099,7 @@ class AquariaRegions:
lambda state: _has_beast_form(state, self.player))
add_rule(self.multiworld.get_location("Open Water bottom left area, bulb inside the lowest fish pass", self.player),
lambda state: _has_fish_form(state, self.player))
add_rule(self.multiworld.get_location("Kelp Forest bottom left area, Walker Baby", self.player),
add_rule(self.multiworld.get_location("Kelp Forest bottom left area, Walker baby", self.player),
lambda state: _has_spirit_form(state, self.player))
add_rule(self.multiworld.get_location("The Veil top left area, bulb hidden behind the blocking rock", self.player),
lambda state: _has_bind_song(state, self.player))
@@ -1134,7 +1134,7 @@ class AquariaRegions:
self.multiworld.get_location("Energy Temple boss area, Fallen God Tooth",
self.player).item_rule =\
lambda item: item.classification != ItemClassification.progression
self.multiworld.get_location("Mithalas boss area, beating Mithalan God",
self.multiworld.get_location("Cathedral boss area, beating Mithalan God",
self.player).item_rule =\
lambda item: item.classification != ItemClassification.progression
self.multiworld.get_location("Kelp Forest boss area, beating Drunian God",
@@ -1191,7 +1191,7 @@ class AquariaRegions:
self.multiworld.get_location("Kelp Forest bottom left area, bulb close to the spirit crystals",
self.player).item_rule =\
lambda item: item.classification != ItemClassification.progression
self.multiworld.get_location("Kelp Forest bottom left area, Walker Baby",
self.multiworld.get_location("Kelp Forest bottom left area, Walker baby",
self.player).item_rule =\
lambda item: item.classification != ItemClassification.progression
self.multiworld.get_location("Sun Temple, Sun Key",

View File

@@ -204,8 +204,7 @@ class AquariaWorld(World):
def fill_slot_data(self) -> Dict[str, Any]:
return {"ingredientReplacement": self.ingredients_substitution,
"aquarian_translate": bool(self.options.aquarian_translation.value),
"blind_goal": bool(self.options.blind_goal.value),
"aquarianTranslate": bool(self.options.aquarian_translation.value),
"secret_needed": self.options.objective.value > 0,
"minibosses_to_kill": self.options.mini_bosses_to_beat.value,
"bigbosses_to_kill": self.options.big_bosses_to_beat.value,

View File

@@ -60,7 +60,7 @@ after_home_water_locations = [
"Mithalas City, Doll",
"Mithalas City, urn inside a home fish pass",
"Mithalas City Castle, bulb in the flesh hole",
"Mithalas City Castle, Blue Banner",
"Mithalas City Castle, Blue banner",
"Mithalas City Castle, urn in the bedroom",
"Mithalas City Castle, first urn of the single lamp path",
"Mithalas City Castle, second urn of the single lamp path",
@@ -82,14 +82,14 @@ after_home_water_locations = [
"Mithalas Cathedral, third urn in the path behind the flesh vein",
"Mithalas Cathedral, fourth urn in the top right room",
"Mithalas Cathedral, Mithalan Dress",
"Mithalas Cathedral, urn below the left entrance",
"Mithalas Cathedral right area, urn below the left entrance",
"Cathedral Underground, bulb in the center part",
"Cathedral Underground, first bulb in the top left part",
"Cathedral Underground, second bulb in the top left part",
"Cathedral Underground, third bulb in the top left part",
"Cathedral Underground, bulb close to the save crystal",
"Cathedral Underground, bulb in the bottom right path",
"Mithalas boss area, beating Mithalan God",
"Cathedral boss area, beating Mithalan God",
"Kelp Forest top left area, bulb in the bottom left clearing",
"Kelp Forest top left area, bulb in the path down from the top left clearing",
"Kelp Forest top left area, bulb in the top left clearing",
@@ -104,7 +104,7 @@ after_home_water_locations = [
"Kelp Forest top right area, Black Pearl",
"Kelp Forest top right area, bulb in the top fish pass",
"Kelp Forest bottom left area, bulb close to the spirit crystals",
"Kelp Forest bottom left area, Walker Baby",
"Kelp Forest bottom left area, Walker baby",
"Kelp Forest bottom left area, Transturtle",
"Kelp Forest bottom right area, Odd Container",
"Kelp Forest boss area, beating Drunian God",
@@ -175,7 +175,7 @@ after_home_water_locations = [
"Sunken City left area, Girl Costume",
"Sunken City, bulb on top of the boss area",
"The Body center area, breaking Li's cage",
"The Body center area, bulb on the main path blocking tube",
"The Body main area, bulb on the main path blocking tube",
"The Body left area, first bulb in the top face room",
"The Body left area, second bulb in the top face room",
"The Body left area, bulb below the water stream",

View File

@@ -39,8 +39,8 @@ class EnergyFormAccessTest(AquariaTestBase):
"Mithalas Cathedral, third urn in the path behind the flesh vein",
"Mithalas Cathedral, fourth urn in the top right room",
"Mithalas Cathedral, Mithalan Dress",
"Mithalas Cathedral, urn below the left entrance",
"Mithalas boss area, beating Mithalan God",
"Mithalas Cathedral right area, urn below the left entrance",
"Cathedral boss area, beating Mithalan God",
"Kelp Forest top left area, bulb close to the Verse Egg",
"Kelp Forest top left area, Verse Egg",
"Kelp Forest boss area, beating Drunian God",

View File

@@ -24,7 +24,7 @@ class LiAccessTest(AquariaTestBase):
"Sunken City left area, Girl Costume",
"Sunken City, bulb on top of the boss area",
"The Body center area, breaking Li's cage",
"The Body center area, bulb on the main path blocking tube",
"The Body main area, bulb on the main path blocking tube",
"The Body left area, first bulb in the top face room",
"The Body left area, second bulb in the top face room",
"The Body left area, bulb below the water stream",

View File

@@ -38,7 +38,7 @@ class NatureFormAccessTest(AquariaTestBase):
"Beating the Golem",
"Sunken City cleared",
"The Body center area, breaking Li's cage",
"The Body center area, bulb on the main path blocking tube",
"The Body main area, bulb on the main path blocking tube",
"The Body left area, first bulb in the top face room",
"The Body left area, second bulb in the top face room",
"The Body left area, bulb below the water stream",

View File

@@ -16,7 +16,7 @@ class UNoProgressionHardHiddenTest(AquariaTestBase):
unfillable_locations = [
"Energy Temple boss area, Fallen God Tooth",
"Mithalas boss area, beating Mithalan God",
"Cathedral boss area, beating Mithalan God",
"Kelp Forest boss area, beating Drunian God",
"Sun Temple boss area, beating Sun God",
"Sunken City, bulb on top of the boss area",
@@ -35,7 +35,7 @@ class UNoProgressionHardHiddenTest(AquariaTestBase):
"Bubble Cave, bulb in the right cave wall (behind the ice crystal)",
"Bubble Cave, Verse Egg",
"Kelp Forest bottom left area, bulb close to the spirit crystals",
"Kelp Forest bottom left area, Walker Baby",
"Kelp Forest bottom left area, Walker baby",
"Sun Temple, Sun Key",
"The Body bottom area, Mutant Costume",
"Sun Temple, bulb in the hidden room of the right part",

View File

@@ -15,7 +15,7 @@ class UNoProgressionHardHiddenTest(AquariaTestBase):
unfillable_locations = [
"Energy Temple boss area, Fallen God Tooth",
"Mithalas boss area, beating Mithalan God",
"Cathedral boss area, beating Mithalan God",
"Kelp Forest boss area, beating Drunian God",
"Sun Temple boss area, beating Sun God",
"Sunken City, bulb on top of the boss area",
@@ -34,7 +34,7 @@ class UNoProgressionHardHiddenTest(AquariaTestBase):
"Bubble Cave, bulb in the right cave wall (behind the ice crystal)",
"Bubble Cave, Verse Egg",
"Kelp Forest bottom left area, bulb close to the spirit crystals",
"Kelp Forest bottom left area, Walker Baby",
"Kelp Forest bottom left area, Walker baby",
"Sun Temple, Sun Key",
"The Body bottom area, Mutant Costume",
"Sun Temple, bulb in the hidden room of the right part",

View File

@@ -16,7 +16,7 @@ class SpiritFormAccessTest(AquariaTestBase):
"The Veil bottom area, bulb in the spirit path",
"Mithalas City Castle, Trident Head",
"Open Water skeleton path, King Skull",
"Kelp Forest bottom left area, Walker Baby",
"Kelp Forest bottom left area, Walker baby",
"Abyss right area, bulb behind the rock in the whale room",
"The Whale, Verse Egg",
"Ice Cave, bulb in the room to the right",

View File

@@ -762,7 +762,7 @@ location_table: List[LocationDict] = [
'game_id': "graf385"},
{'name': "Tagged 389 Graffiti Spots",
'stage': Stages.Misc,
'game_id': "graf389"},
'game_id': "graf379"},
]

View File

@@ -8,15 +8,11 @@ from .Locations import DLCQuestLocation, location_table
from .Options import DLCQuestOptions
from .Regions import create_regions
from .Rules import set_rules
from .presets import dlcq_options_presets
from .option_groups import dlcq_option_groups
client_version = 0
class DLCqwebworld(WebWorld):
options_presets = dlcq_options_presets
option_groups = dlcq_option_groups
setup_en = Tutorial(
"Multiworld Setup Guide",
"A guide to setting up the Archipelago DLCQuest game on your computer.",

View File

@@ -1,27 +0,0 @@
from typing import List
from Options import ProgressionBalancing, Accessibility, OptionGroup
from .Options import (Campaign, ItemShuffle, TimeIsMoney, EndingChoice, PermanentCoins, DoubleJumpGlitch, CoinSanity,
CoinSanityRange, DeathLink)
dlcq_option_groups: List[OptionGroup] = [
OptionGroup("General", [
Campaign,
ItemShuffle,
CoinSanity,
]),
OptionGroup("Customization", [
EndingChoice,
PermanentCoins,
CoinSanityRange,
]),
OptionGroup("Tedious and Grind", [
TimeIsMoney,
DoubleJumpGlitch,
]),
OptionGroup("Advanced Options", [
DeathLink,
ProgressionBalancing,
Accessibility,
]),
]

View File

@@ -1,68 +0,0 @@
from typing import Any, Dict
from .Options import DoubleJumpGlitch, CoinSanity, CoinSanityRange, PermanentCoins, TimeIsMoney, EndingChoice, Campaign, ItemShuffle
all_random_settings = {
DoubleJumpGlitch.internal_name: "random",
CoinSanity.internal_name: "random",
CoinSanityRange.internal_name: "random",
PermanentCoins.internal_name: "random",
TimeIsMoney.internal_name: "random",
EndingChoice.internal_name: "random",
Campaign.internal_name: "random",
ItemShuffle.internal_name: "random",
"death_link": "random",
}
main_campaign_settings = {
DoubleJumpGlitch.internal_name: DoubleJumpGlitch.option_none,
CoinSanity.internal_name: CoinSanity.option_coin,
CoinSanityRange.internal_name: 30,
PermanentCoins.internal_name: PermanentCoins.option_false,
TimeIsMoney.internal_name: TimeIsMoney.option_required,
EndingChoice.internal_name: EndingChoice.option_true,
Campaign.internal_name: Campaign.option_basic,
ItemShuffle.internal_name: ItemShuffle.option_shuffled,
}
lfod_campaign_settings = {
DoubleJumpGlitch.internal_name: DoubleJumpGlitch.option_none,
CoinSanity.internal_name: CoinSanity.option_coin,
CoinSanityRange.internal_name: 30,
PermanentCoins.internal_name: PermanentCoins.option_false,
TimeIsMoney.internal_name: TimeIsMoney.option_required,
EndingChoice.internal_name: EndingChoice.option_true,
Campaign.internal_name: Campaign.option_live_freemium_or_die,
ItemShuffle.internal_name: ItemShuffle.option_shuffled,
}
easy_settings = {
DoubleJumpGlitch.internal_name: DoubleJumpGlitch.option_none,
CoinSanity.internal_name: CoinSanity.option_none,
CoinSanityRange.internal_name: 40,
PermanentCoins.internal_name: PermanentCoins.option_true,
TimeIsMoney.internal_name: TimeIsMoney.option_required,
EndingChoice.internal_name: EndingChoice.option_true,
Campaign.internal_name: Campaign.option_both,
ItemShuffle.internal_name: ItemShuffle.option_shuffled,
}
hard_settings = {
DoubleJumpGlitch.internal_name: DoubleJumpGlitch.option_simple,
CoinSanity.internal_name: CoinSanity.option_coin,
CoinSanityRange.internal_name: 30,
PermanentCoins.internal_name: PermanentCoins.option_false,
TimeIsMoney.internal_name: TimeIsMoney.option_optional,
EndingChoice.internal_name: EndingChoice.option_true,
Campaign.internal_name: Campaign.option_both,
ItemShuffle.internal_name: ItemShuffle.option_shuffled,
}
dlcq_options_presets: Dict[str, Dict[str, Any]] = {
"All random": all_random_settings,
"Main campaign": main_campaign_settings,
"LFOD campaign": lfod_campaign_settings,
"Both easy": easy_settings,
"Both hard": hard_settings,
}

View File

@@ -71,7 +71,7 @@ class FFMQClient(SNIClient):
received = await snes_read(ctx, RECEIVED_DATA[0], RECEIVED_DATA[1])
data = await snes_read(ctx, READ_DATA_START, READ_DATA_END - READ_DATA_START)
check_2 = await snes_read(ctx, 0xF53749, 1)
if check_1 != b'01' or check_2 != b'01':
if check_1 in (b'\x00', b'\x55') or check_2 in (b'\x00', b'\x55'):
return
def get_range(data_range):

View File

@@ -222,10 +222,10 @@ for item, data in item_table.items():
def create_items(self) -> None:
items = []
starting_weapon = self.options.starting_weapon.current_key.title().replace("_", " ")
starting_weapon = self.multiworld.starting_weapon[self.player].current_key.title().replace("_", " ")
self.multiworld.push_precollected(self.create_item(starting_weapon))
self.multiworld.push_precollected(self.create_item("Steel Armor"))
if self.options.sky_coin_mode == "start_with":
if self.multiworld.sky_coin_mode[self.player] == "start_with":
self.multiworld.push_precollected(self.create_item("Sky Coin"))
precollected_item_names = {item.name for item in self.multiworld.precollected_items[self.player]}
@@ -233,28 +233,28 @@ def create_items(self) -> None:
def add_item(item_name):
if item_name in ["Steel Armor", "Sky Fragment"] or "Progressive" in item_name:
return
if item_name.lower().replace(" ", "_") == self.options.starting_weapon.current_key:
if item_name.lower().replace(" ", "_") == self.multiworld.starting_weapon[self.player].current_key:
return
if self.options.progressive_gear:
if self.multiworld.progressive_gear[self.player]:
for item_group in prog_map:
if item_name in self.item_name_groups[item_group]:
item_name = prog_map[item_group]
break
if item_name == "Sky Coin":
if self.options.sky_coin_mode == "shattered_sky_coin":
if self.multiworld.sky_coin_mode[self.player] == "shattered_sky_coin":
for _ in range(40):
items.append(self.create_item("Sky Fragment"))
return
elif self.options.sky_coin_mode == "save_the_crystals":
elif self.multiworld.sky_coin_mode[self.player] == "save_the_crystals":
items.append(self.create_filler())
return
if item_name in precollected_item_names:
items.append(self.create_filler())
return
i = self.create_item(item_name)
if self.options.logic != "friendly" and item_name in ("Magic Mirror", "Mask"):
if self.multiworld.logic[self.player] != "friendly" and item_name in ("Magic Mirror", "Mask"):
i.classification = ItemClassification.useful
if (self.options.logic == "expert" and self.options.map_shuffle == "none" and
if (self.multiworld.logic[self.player] == "expert" and self.multiworld.map_shuffle[self.player] == "none" and
item_name == "Exit Book"):
i.classification = ItemClassification.progression
items.append(i)
@@ -263,11 +263,11 @@ def create_items(self) -> None:
for item in self.item_name_groups[item_group]:
add_item(item)
if self.options.brown_boxes == "include":
if self.multiworld.brown_boxes[self.player] == "include":
filler_items = []
for item, count in fillers.items():
filler_items += [self.create_item(item) for _ in range(count)]
if self.options.sky_coin_mode == "shattered_sky_coin":
if self.multiworld.sky_coin_mode[self.player] == "shattered_sky_coin":
self.multiworld.random.shuffle(filler_items)
filler_items = filler_items[39:]
items += filler_items

View File

@@ -1,5 +1,4 @@
from Options import Choice, FreeText, Toggle, Range, PerGameCommonOptions
from dataclasses import dataclass
from Options import Choice, FreeText, Toggle, Range
class Logic(Choice):
@@ -322,36 +321,36 @@ class KaelisMomFightsMinotaur(Toggle):
default = 0
@dataclass
class FFMQOptions(PerGameCommonOptions):
logic: Logic
brown_boxes: BrownBoxes
sky_coin_mode: SkyCoinMode
shattered_sky_coin_quantity: ShatteredSkyCoinQuantity
starting_weapon: StartingWeapon
progressive_gear: ProgressiveGear
leveling_curve: LevelingCurve
starting_companion: StartingCompanion
available_companions: AvailableCompanions
companions_locations: CompanionsLocations
kaelis_mom_fight_minotaur: KaelisMomFightsMinotaur
companion_leveling_type: CompanionLevelingType
companion_spellbook_type: CompanionSpellbookType
enemies_density: EnemiesDensity
enemies_scaling_lower: EnemiesScalingLower
enemies_scaling_upper: EnemiesScalingUpper
bosses_scaling_lower: BossesScalingLower
bosses_scaling_upper: BossesScalingUpper
enemizer_attacks: EnemizerAttacks
enemizer_groups: EnemizerGroups
shuffle_res_weak_types: ShuffleResWeakType
shuffle_enemies_position: ShuffleEnemiesPositions
progressive_formations: ProgressiveFormations
doom_castle_mode: DoomCastle
doom_castle_shortcut: DoomCastleShortcut
tweak_frustrating_dungeons: TweakFrustratingDungeons
map_shuffle: MapShuffle
crest_shuffle: CrestShuffle
shuffle_battlefield_rewards: ShuffleBattlefieldRewards
map_shuffle_seed: MapShuffleSeed
battlefields_battles_quantities: BattlefieldsBattlesQuantities
option_definitions = {
"logic": Logic,
"brown_boxes": BrownBoxes,
"sky_coin_mode": SkyCoinMode,
"shattered_sky_coin_quantity": ShatteredSkyCoinQuantity,
"starting_weapon": StartingWeapon,
"progressive_gear": ProgressiveGear,
"leveling_curve": LevelingCurve,
"starting_companion": StartingCompanion,
"available_companions": AvailableCompanions,
"companions_locations": CompanionsLocations,
"kaelis_mom_fight_minotaur": KaelisMomFightsMinotaur,
"companion_leveling_type": CompanionLevelingType,
"companion_spellbook_type": CompanionSpellbookType,
"enemies_density": EnemiesDensity,
"enemies_scaling_lower": EnemiesScalingLower,
"enemies_scaling_upper": EnemiesScalingUpper,
"bosses_scaling_lower": BossesScalingLower,
"bosses_scaling_upper": BossesScalingUpper,
"enemizer_attacks": EnemizerAttacks,
"enemizer_groups": EnemizerGroups,
"shuffle_res_weak_types": ShuffleResWeakType,
"shuffle_enemies_position": ShuffleEnemiesPositions,
"progressive_formations": ProgressiveFormations,
"doom_castle_mode": DoomCastle,
"doom_castle_shortcut": DoomCastleShortcut,
"tweak_frustrating_dungeons": TweakFrustratingDungeons,
"map_shuffle": MapShuffle,
"crest_shuffle": CrestShuffle,
"shuffle_battlefield_rewards": ShuffleBattlefieldRewards,
"map_shuffle_seed": MapShuffleSeed,
"battlefields_battles_quantities": BattlefieldsBattlesQuantities,
}

View File

@@ -1,13 +1,13 @@
import yaml
import os
import zipfile
import Utils
from copy import deepcopy
from .Regions import object_id_table
from Utils import __version__
from worlds.Files import APPatch
import pkgutil
settings_template = Utils.parse_yaml(pkgutil.get_data(__name__, "data/settings.yaml"))
settings_template = yaml.load(pkgutil.get_data(__name__, "data/settings.yaml"), yaml.Loader)
def generate_output(self, output_directory):
@@ -21,7 +21,7 @@ def generate_output(self, output_directory):
item_name = "".join(item_name.split(" "))
else:
if item.advancement or item.useful or (item.trap and
self.random.randint(0, 1)):
self.multiworld.per_slot_randoms[self.player].randint(0, 1)):
item_name = "APItem"
else:
item_name = "APItemFiller"
@@ -46,60 +46,60 @@ def generate_output(self, output_directory):
options = deepcopy(settings_template)
options["name"] = self.multiworld.player_name[self.player]
option_writes = {
"enemies_density": cc(self.options.enemies_density),
"enemies_density": cc(self.multiworld.enemies_density[self.player]),
"chests_shuffle": "Include",
"shuffle_boxes_content": self.options.brown_boxes == "shuffle",
"shuffle_boxes_content": self.multiworld.brown_boxes[self.player] == "shuffle",
"npcs_shuffle": "Include",
"battlefields_shuffle": "Include",
"logic_options": cc(self.options.logic),
"shuffle_enemies_position": tf(self.options.shuffle_enemies_position),
"enemies_scaling_lower": cc(self.options.enemies_scaling_lower),
"enemies_scaling_upper": cc(self.options.enemies_scaling_upper),
"bosses_scaling_lower": cc(self.options.bosses_scaling_lower),
"bosses_scaling_upper": cc(self.options.bosses_scaling_upper),
"enemizer_attacks": cc(self.options.enemizer_attacks),
"leveling_curve": cc(self.options.leveling_curve),
"battles_quantity": cc(self.options.battlefields_battles_quantities) if
self.options.battlefields_battles_quantities.value < 5 else
"logic_options": cc(self.multiworld.logic[self.player]),
"shuffle_enemies_position": tf(self.multiworld.shuffle_enemies_position[self.player]),
"enemies_scaling_lower": cc(self.multiworld.enemies_scaling_lower[self.player]),
"enemies_scaling_upper": cc(self.multiworld.enemies_scaling_upper[self.player]),
"bosses_scaling_lower": cc(self.multiworld.bosses_scaling_lower[self.player]),
"bosses_scaling_upper": cc(self.multiworld.bosses_scaling_upper[self.player]),
"enemizer_attacks": cc(self.multiworld.enemizer_attacks[self.player]),
"leveling_curve": cc(self.multiworld.leveling_curve[self.player]),
"battles_quantity": cc(self.multiworld.battlefields_battles_quantities[self.player]) if
self.multiworld.battlefields_battles_quantities[self.player].value < 5 else
"RandomLow" if
self.options.battlefields_battles_quantities.value == 5 else
self.multiworld.battlefields_battles_quantities[self.player].value == 5 else
"RandomHigh",
"shuffle_battlefield_rewards": tf(self.options.shuffle_battlefield_rewards),
"shuffle_battlefield_rewards": tf(self.multiworld.shuffle_battlefield_rewards[self.player]),
"random_starting_weapon": True,
"progressive_gear": tf(self.options.progressive_gear),
"tweaked_dungeons": tf(self.options.tweak_frustrating_dungeons),
"doom_castle_mode": cc(self.options.doom_castle_mode),
"doom_castle_shortcut": tf(self.options.doom_castle_shortcut),
"sky_coin_mode": cc(self.options.sky_coin_mode),
"sky_coin_fragments_qty": cc(self.options.shattered_sky_coin_quantity),
"progressive_gear": tf(self.multiworld.progressive_gear[self.player]),
"tweaked_dungeons": tf(self.multiworld.tweak_frustrating_dungeons[self.player]),
"doom_castle_mode": cc(self.multiworld.doom_castle_mode[self.player]),
"doom_castle_shortcut": tf(self.multiworld.doom_castle_shortcut[self.player]),
"sky_coin_mode": cc(self.multiworld.sky_coin_mode[self.player]),
"sky_coin_fragments_qty": cc(self.multiworld.shattered_sky_coin_quantity[self.player]),
"enable_spoilers": False,
"progressive_formations": cc(self.options.progressive_formations),
"map_shuffling": cc(self.options.map_shuffle),
"crest_shuffle": tf(self.options.crest_shuffle),
"enemizer_groups": cc(self.options.enemizer_groups),
"shuffle_res_weak_type": tf(self.options.shuffle_res_weak_types),
"companion_leveling_type": cc(self.options.companion_leveling_type),
"companion_spellbook_type": cc(self.options.companion_spellbook_type),
"starting_companion": cc(self.options.starting_companion),
"progressive_formations": cc(self.multiworld.progressive_formations[self.player]),
"map_shuffling": cc(self.multiworld.map_shuffle[self.player]),
"crest_shuffle": tf(self.multiworld.crest_shuffle[self.player]),
"enemizer_groups": cc(self.multiworld.enemizer_groups[self.player]),
"shuffle_res_weak_type": tf(self.multiworld.shuffle_res_weak_types[self.player]),
"companion_leveling_type": cc(self.multiworld.companion_leveling_type[self.player]),
"companion_spellbook_type": cc(self.multiworld.companion_spellbook_type[self.player]),
"starting_companion": cc(self.multiworld.starting_companion[self.player]),
"available_companions": ["Zero", "One", "Two",
"Three", "Four"][self.options.available_companions.value],
"companions_locations": cc(self.options.companions_locations),
"kaelis_mom_fight_minotaur": tf(self.options.kaelis_mom_fight_minotaur),
"Three", "Four"][self.multiworld.available_companions[self.player].value],
"companions_locations": cc(self.multiworld.companions_locations[self.player]),
"kaelis_mom_fight_minotaur": tf(self.multiworld.kaelis_mom_fight_minotaur[self.player]),
}
for option, data in option_writes.items():
options["Final Fantasy Mystic Quest"][option][data] = 1
rom_name = f'MQ{Utils.__version__.replace(".", "")[0:3]}_{self.player}_{self.multiworld.seed_name:11}'[:21]
rom_name = f'MQ{__version__.replace(".", "")[0:3]}_{self.player}_{self.multiworld.seed_name:11}'[:21]
self.rom_name = bytearray(rom_name,
'utf8')
self.rom_name_available_event.set()
setup = {"version": "1.5", "name": self.multiworld.player_name[self.player], "romname": rom_name, "seed":
hex(self.random.randint(0, 0xFFFFFFFF)).split("0x")[1].upper()}
hex(self.multiworld.per_slot_randoms[self.player].randint(0, 0xFFFFFFFF)).split("0x")[1].upper()}
starting_items = [output_item_name(item) for item in self.multiworld.precollected_items[self.player]]
if self.options.sky_coin_mode == "shattered_sky_coin":
if self.multiworld.sky_coin_mode[self.player] == "shattered_sky_coin":
starting_items.append("SkyCoin")
file_path = os.path.join(output_directory, f"{self.multiworld.get_out_file_name_base(self.player)}.apmq")

View File

@@ -1,9 +1,11 @@
from BaseClasses import Region, MultiWorld, Entrance, Location, LocationProgressType, ItemClassification
from worlds.generic.Rules import add_rule
from .data.rooms import rooms, entrances
from .Items import item_groups, yaml_item
import pkgutil
import yaml
entrance_names = {entrance["id"]: entrance["name"] for entrance in entrances}
rooms = yaml.load(pkgutil.get_data(__name__, "data/rooms.yaml"), yaml.Loader)
entrance_names = {entrance["id"]: entrance["name"] for entrance in yaml.load(pkgutil.get_data(__name__, "data/entrances.yaml"), yaml.Loader)}
object_id_table = {}
object_type_table = {}
@@ -67,7 +69,7 @@ def create_regions(self):
location_table else None, object["type"], object["access"],
self.create_item(yaml_item(object["on_trigger"][0])) if object["type"] == "Trigger" else None) for object in
room["game_objects"] if "Hero Chest" not in object["name"] and object["type"] not in ("BattlefieldGp",
"BattlefieldXp") and (object["type"] != "Box" or self.options.brown_boxes == "include") and
"BattlefieldXp") and (object["type"] != "Box" or self.multiworld.brown_boxes[self.player] == "include") and
not (object["name"] == "Kaeli Companion" and not object["on_trigger"])], room["links"]))
dark_king_room = self.multiworld.get_region("Doom Castle Dark King Room", self.player)
@@ -89,13 +91,15 @@ def create_regions(self):
if "entrance" in link and link["entrance"] != -1:
spoiler = False
if link["entrance"] in crest_warps:
if self.options.crest_shuffle:
if self.multiworld.crest_shuffle[self.player]:
spoiler = True
elif self.options.map_shuffle == "everything":
elif self.multiworld.map_shuffle[self.player] == "everything":
spoiler = True
elif "Subregion" in region.name and self.options.map_shuffle not in ("dungeons", "none"):
elif "Subregion" in region.name and self.multiworld.map_shuffle[self.player] not in ("dungeons",
"none"):
spoiler = True
elif "Subregion" not in region.name and self.options.map_shuffle not in ("none", "overworld"):
elif "Subregion" not in region.name and self.multiworld.map_shuffle[self.player] not in ("none",
"overworld"):
spoiler = True
if spoiler:
@@ -107,7 +111,6 @@ def create_regions(self):
connection.connect(connect_room)
break
non_dead_end_crest_rooms = [
'Libra Temple', 'Aquaria Gemini Room', "GrenadeMan's Mobius Room", 'Fireburg Gemini Room',
'Sealed Temple', 'Alive Forest', 'Kaidge Temple Upper Ledge',
@@ -137,7 +140,7 @@ def set_rules(self) -> None:
add_rule(self.multiworld.get_location("Gidrah", self.player), hard_boss_logic)
add_rule(self.multiworld.get_location("Dullahan", self.player), hard_boss_logic)
if self.options.map_shuffle:
if self.multiworld.map_shuffle[self.player]:
for boss in ("Freezer Crab", "Ice Golem", "Jinn", "Medusa", "Dualhead Hydra"):
loc = self.multiworld.get_location(boss, self.player)
checked_regions = {loc.parent_region}
@@ -155,12 +158,12 @@ def set_rules(self) -> None:
return True
check_foresta(loc.parent_region)
if self.options.logic == "friendly":
if self.multiworld.logic[self.player] == "friendly":
process_rules(self.multiworld.get_entrance("Overworld - Ice Pyramid", self.player),
["MagicMirror"])
process_rules(self.multiworld.get_entrance("Overworld - Volcano", self.player),
["Mask"])
if self.options.map_shuffle in ("none", "overworld"):
if self.multiworld.map_shuffle[self.player] in ("none", "overworld"):
process_rules(self.multiworld.get_entrance("Overworld - Bone Dungeon", self.player),
["Bomb"])
process_rules(self.multiworld.get_entrance("Overworld - Wintry Cave", self.player),
@@ -182,8 +185,8 @@ def set_rules(self) -> None:
process_rules(self.multiworld.get_entrance("Overworld - Mac Ship Doom", self.player),
["DragonClaw", "CaptainCap"])
if self.options.logic == "expert":
if self.options.map_shuffle == "none" and not self.options.crest_shuffle:
if self.multiworld.logic[self.player] == "expert":
if self.multiworld.map_shuffle[self.player] == "none" and not self.multiworld.crest_shuffle[self.player]:
inner_room = self.multiworld.get_region("Wintry Temple Inner Room", self.player)
connection = Entrance(self.player, "Sealed Temple Exit Trick", inner_room)
connection.connect(self.multiworld.get_region("Wintry Temple Outer Room", self.player))
@@ -195,14 +198,14 @@ def set_rules(self) -> None:
if entrance.connected_region.name in non_dead_end_crest_rooms:
entrance.access_rule = lambda state: False
if self.options.sky_coin_mode == "shattered_sky_coin":
logic_coins = [16, 24, 32, 32, 38][self.options.shattered_sky_coin_quantity.value]
if self.multiworld.sky_coin_mode[self.player] == "shattered_sky_coin":
logic_coins = [16, 24, 32, 32, 38][self.multiworld.shattered_sky_coin_quantity[self.player].value]
self.multiworld.get_entrance("Focus Tower 1F - Sky Door", self.player).access_rule = \
lambda state: state.has("Sky Fragment", self.player, logic_coins)
elif self.options.sky_coin_mode == "save_the_crystals":
elif self.multiworld.sky_coin_mode[self.player] == "save_the_crystals":
self.multiworld.get_entrance("Focus Tower 1F - Sky Door", self.player).access_rule = \
lambda state: state.has_all(["Flamerus Rex", "Dualhead Hydra", "Ice Golem", "Pazuzu"], self.player)
elif self.options.sky_coin_mode in ("standard", "start_with"):
elif self.multiworld.sky_coin_mode[self.player] in ("standard", "start_with"):
self.multiworld.get_entrance("Focus Tower 1F - Sky Door", self.player).access_rule = \
lambda state: state.has("Sky Coin", self.player)
@@ -210,24 +213,26 @@ def set_rules(self) -> None:
def stage_set_rules(multiworld):
# If there's no enemies, there's no repeatable income sources
no_enemies_players = [player for player in multiworld.get_game_players("Final Fantasy Mystic Quest")
if multiworld.worlds[player].options.enemies_density == "none"]
if multiworld.enemies_density[player] == "none"]
if (len([item for item in multiworld.itempool if item.classification in (ItemClassification.filler,
ItemClassification.trap)]) > len([player for player in no_enemies_players if
multiworld.worlds[player].options.accessibility == "minimal"]) * 3):
multiworld.accessibility[player] == "minimal"]) * 3):
for player in no_enemies_players:
for location in vendor_locations:
if multiworld.worlds[player].options.accessibility == "locations":
if multiworld.accessibility[player] == "locations":
multiworld.get_location(location, player).progress_type = LocationProgressType.EXCLUDED
else:
multiworld.get_location(location, player).access_rule = lambda state: False
else:
# There are not enough junk items to fill non-minimal players' vendors. Just set an item rule not allowing
# advancement items so that useful items can be placed.
# advancement items so that useful items can be placed
for player in no_enemies_players:
for location in vendor_locations:
multiworld.get_location(location, player).item_rule = lambda item: not item.advancement
class FFMQLocation(Location):
game = "Final Fantasy Mystic Quest"

View File

@@ -10,7 +10,7 @@ from .Regions import create_regions, location_table, set_rules, stage_set_rules,
non_dead_end_crest_warps
from .Items import item_table, item_groups, create_items, FFMQItem, fillers
from .Output import generate_output
from .Options import FFMQOptions
from .Options import option_definitions
from .Client import FFMQClient
@@ -45,8 +45,7 @@ class FFMQWorld(World):
item_name_to_id = {name: data.id for name, data in item_table.items() if data.id is not None}
location_name_to_id = location_table
options_dataclass = FFMQOptions
options: FFMQOptions
option_definitions = option_definitions
topology_present = True
@@ -68,14 +67,20 @@ class FFMQWorld(World):
super().__init__(world, player)
def generate_early(self):
if self.options.sky_coin_mode == "shattered_sky_coin":
self.options.brown_boxes.value = 1
if self.options.enemies_scaling_lower.value > self.options.enemies_scaling_upper.value:
self.options.enemies_scaling_lower.value, self.options.enemies_scaling_upper.value = \
self.options.enemies_scaling_upper.value, self.options.enemies_scaling_lower.value
if self.options.bosses_scaling_lower.value > self.options.bosses_scaling_upper.value:
self.options.bosses_scaling_lower.value, self.options.bosses_scaling_upper.value = \
self.options.bosses_scaling_upper.value, self.options.bosses_scaling_lower.value
if self.multiworld.sky_coin_mode[self.player] == "shattered_sky_coin":
self.multiworld.brown_boxes[self.player].value = 1
if self.multiworld.enemies_scaling_lower[self.player].value > \
self.multiworld.enemies_scaling_upper[self.player].value:
(self.multiworld.enemies_scaling_lower[self.player].value,
self.multiworld.enemies_scaling_upper[self.player].value) =\
(self.multiworld.enemies_scaling_upper[self.player].value,
self.multiworld.enemies_scaling_lower[self.player].value)
if self.multiworld.bosses_scaling_lower[self.player].value > \
self.multiworld.bosses_scaling_upper[self.player].value:
(self.multiworld.bosses_scaling_lower[self.player].value,
self.multiworld.bosses_scaling_upper[self.player].value) =\
(self.multiworld.bosses_scaling_upper[self.player].value,
self.multiworld.bosses_scaling_lower[self.player].value)
@classmethod
def stage_generate_early(cls, multiworld):
@@ -89,20 +94,20 @@ class FFMQWorld(World):
rooms_data = {}
for world in multiworld.get_game_worlds("Final Fantasy Mystic Quest"):
if (world.options.map_shuffle or world.options.crest_shuffle or world.options.shuffle_battlefield_rewards
or world.options.companions_locations):
if world.options.map_shuffle_seed.value.isdigit():
multiworld.random.seed(int(world.options.map_shuffle_seed.value))
elif world.options.map_shuffle_seed.value != "random":
multiworld.random.seed(int(hash(world.options.map_shuffle_seed.value))
+ int(world.multiworld.seed))
if (world.multiworld.map_shuffle[world.player] or world.multiworld.crest_shuffle[world.player] or
world.multiworld.crest_shuffle[world.player]):
if world.multiworld.map_shuffle_seed[world.player].value.isdigit():
multiworld.random.seed(int(world.multiworld.map_shuffle_seed[world.player].value))
elif world.multiworld.map_shuffle_seed[world.player].value != "random":
multiworld.random.seed(int(hash(world.multiworld.map_shuffle_seed[world.player].value))
+ int(world.multiworld.seed))
seed = hex(multiworld.random.randint(0, 0xFFFFFFFF)).split("0x")[1].upper()
map_shuffle = world.options.map_shuffle.value
crest_shuffle = world.options.crest_shuffle.current_key
battlefield_shuffle = world.options.shuffle_battlefield_rewards.current_key
companion_shuffle = world.options.companions_locations.value
kaeli_mom = world.options.kaelis_mom_fight_minotaur.current_key
map_shuffle = multiworld.map_shuffle[world.player].value
crest_shuffle = multiworld.crest_shuffle[world.player].current_key
battlefield_shuffle = multiworld.shuffle_battlefield_rewards[world.player].current_key
companion_shuffle = multiworld.companions_locations[world.player].value
kaeli_mom = multiworld.kaelis_mom_fight_minotaur[world.player].current_key
query = f"s={seed}&m={map_shuffle}&c={crest_shuffle}&b={battlefield_shuffle}&cs={companion_shuffle}&km={kaeli_mom}"
@@ -170,14 +175,14 @@ class FFMQWorld(World):
def extend_hint_information(self, hint_data):
hint_data[self.player] = {}
if self.options.map_shuffle:
if self.multiworld.map_shuffle[self.player]:
single_location_regions = ["Subregion Volcano Battlefield", "Subregion Mac's Ship", "Subregion Doom Castle"]
for subregion in ["Subregion Foresta", "Subregion Aquaria", "Subregion Frozen Fields", "Subregion Fireburg",
"Subregion Volcano Battlefield", "Subregion Windia", "Subregion Mac's Ship",
"Subregion Doom Castle"]:
region = self.multiworld.get_region(subregion, self.player)
for location in region.locations:
if location.address and self.options.map_shuffle != "dungeons":
if location.address and self.multiworld.map_shuffle[self.player] != "dungeons":
hint_data[self.player][location.address] = (subregion.split("Subregion ")[-1]
+ (" Region" if subregion not in
single_location_regions else ""))
@@ -197,13 +202,14 @@ class FFMQWorld(World):
for location in exit_check.connected_region.locations:
if location.address:
hint = []
if self.options.map_shuffle != "dungeons":
if self.multiworld.map_shuffle[self.player] != "dungeons":
hint.append((subregion.split("Subregion ")[-1] + (" Region" if subregion not
in single_location_regions else "")))
if self.options.map_shuffle != "overworld":
if self.multiworld.map_shuffle[self.player] != "overworld" and subregion not in \
("Subregion Mac's Ship", "Subregion Doom Castle"):
hint.append(overworld_spot.name.split("Overworld - ")[-1].replace("Pazuzu",
"Pazuzu's"))
hint = " - ".join(hint).replace(" - Mac Ship", "")
hint = " - ".join(hint)
if location.address in hint_data[self.player]:
hint_data[self.player][location.address] += f"/{hint}"
else:

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

4026
worlds/ffmq/data/rooms.yaml Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -12,7 +12,7 @@ Some steps also assume use of Windows, so may vary with your OS.
## Installing the Archipelago software
The most recent public release of Archipelago can be found on GitHub:
[Archipelago Latest Release](https://github.com/ArchipelagoMW/Archipelago/releases/latest).
[Archipelago Lastest Release](https://github.com/ArchipelagoMW/Archipelago/releases/latest).
Run the exe file, and after accepting the license agreement you will be asked which components you would like to
install.

View File

@@ -554,8 +554,7 @@ class HKWorld(World):
for effect_name, effect_value in item_effects.get(item.name, {}).items():
if state.prog_items[item.player][effect_name] == effect_value:
del state.prog_items[item.player][effect_name]
else:
state.prog_items[item.player][effect_name] -= effect_value
state.prog_items[item.player][effect_name] -= effect_value
return change

View File

@@ -116,19 +116,12 @@ class KH2Context(CommonContext):
# self.inBattle = 0x2A0EAC4 + 0x40
# self.onDeath = 0xAB9078
# PC Address anchors
# self.Now = 0x0714DB8 old address
# epic addresses
self.Now = 0x0716DF8
self.Save = 0x09A92F0
self.Journal = 0x743260
self.Shop = 0x743350
self.Slot1 = 0x2A22FD8
self.Now = 0x0714DB8
self.Save = 0x09A70B0
# self.Sys3 = 0x2A59DF0
# self.Bt10 = 0x2A74880
# self.BtlEnd = 0x2A0D3E0
# self.Slot1 = 0x2A20C98 old address
self.kh2_game_version = None # can be egs or steam
self.Slot1 = 0x2A20C98
self.chest_set = set(exclusion_table["Chests"])
self.keyblade_set = set(CheckDupingItems["Weapons"]["Keyblades"])
@@ -235,9 +228,6 @@ class KH2Context(CommonContext):
def kh2_write_int(self, address, value):
self.kh2.write_int(self.kh2.base_address + address, value)
def kh2_read_string(self, address, length):
return self.kh2.read_string(self.kh2.base_address + address, length)
def on_package(self, cmd: str, args: dict):
if cmd in {"RoomInfo"}:
self.kh2seedname = args['seed_name']
@@ -377,26 +367,10 @@ class KH2Context(CommonContext):
for weapon_location in all_weapon_slot:
all_weapon_location_id.append(self.kh2_loc_name_to_id[weapon_location])
self.all_weapon_location_id = set(all_weapon_location_id)
try:
self.kh2 = pymem.Pymem(process_name="KINGDOM HEARTS II FINAL MIX")
if self.kh2_game_version is None:
if self.kh2_read_string(0x09A9830, 4) == "KH2J":
self.kh2_game_version = "STEAM"
self.Now = 0x0717008
self.Save = 0x09A9830
self.Slot1 = 0x2A23518
self.Journal = 0x7434E0
self.Shop = 0x7435D0
elif self.kh2_read_string(0x09A92F0, 4) == "KH2J":
self.kh2_game_version = "EGS"
else:
self.kh2_game_version = None
logger.info("Your game version is out of date. Please update your game via The Epic Games Store or Steam.")
if self.kh2_game_version is not None:
logger.info(f"You are now auto-tracking. {self.kh2_game_version}")
self.kh2connected = True
logger.info("You are now auto-tracking")
self.kh2connected = True
except Exception as e:
if self.kh2connected:
@@ -615,8 +589,8 @@ class KH2Context(CommonContext):
# if journal=-1 and shop = 5 then in shop
# if journal !=-1 and shop = 10 then journal
journal = self.kh2_read_short(self.Journal)
shop = self.kh2_read_short(self.Shop)
journal = self.kh2_read_short(0x741230)
shop = self.kh2_read_short(0x741320)
if (journal == -1 and shop == 5) or (journal != -1 and shop == 10):
# print("your in the shop")
sellable_dict = {}
@@ -625,8 +599,8 @@ class KH2Context(CommonContext):
amount = self.kh2_read_byte(self.Save + itemdata.memaddr)
sellable_dict[itemName] = amount
while (journal == -1 and shop == 5) or (journal != -1 and shop == 10):
journal = self.kh2_read_short(self.Journal)
shop = self.kh2_read_short(self.Shop)
journal = self.kh2_read_short(0x741230)
shop = self.kh2_read_short(0x741320)
await asyncio.sleep(0.5)
for item, amount in sellable_dict.items():
itemdata = self.item_name_to_data[item]
@@ -776,7 +750,7 @@ class KH2Context(CommonContext):
item_data = self.item_name_to_data[item_name]
amount_of_items = 0
amount_of_items += self.kh2_seed_save_cache["AmountInvo"]["Magic"][item_name]
if self.kh2_read_byte(self.Save + item_data.memaddr) != amount_of_items and self.kh2_read_byte(self.Shop) in {10, 8}:
if self.kh2_read_byte(self.Save + item_data.memaddr) != amount_of_items and self.kh2_read_byte(0x741320) in {10, 8}:
self.kh2_write_byte(self.Save + item_data.memaddr, amount_of_items)
for item_name in master_stat:
@@ -828,7 +802,7 @@ class KH2Context(CommonContext):
self.kh2_write_byte(self.Save + 0x2502, current_item_slots + 1)
elif self.base_item_slots + amount_of_items < 8:
self.kh2_write_byte(self.Save + 0x2502, self.base_item_slots + amount_of_items)
# if self.kh2_read_byte(self.Save + item_data.memaddr) != amount_of_items \
# and self.kh2_read_byte(self.Slot1 + 0x1B2) >= 5 and \
# self.kh2_read_byte(self.Save + 0x23DF) & 0x1 << 3 > 0 and self.kh2_read_byte(0x741320) in {10, 8}:
@@ -931,23 +905,8 @@ async def kh2_watcher(ctx: KH2Context):
await asyncio.sleep(15)
ctx.kh2 = pymem.Pymem(process_name="KINGDOM HEARTS II FINAL MIX")
if ctx.kh2 is not None:
if ctx.kh2_game_version is None:
if ctx.kh2_read_string(0x09A9830, 4) == "KH2J":
ctx.kh2_game_version = "STEAM"
ctx.Now = 0x0717008
ctx.Save = 0x09A9830
ctx.Slot1 = 0x2A23518
ctx.Journal = 0x7434E0
ctx.Shop = 0x7435D0
elif ctx.kh2_read_string(0x09A92F0, 4) == "KH2J":
ctx.kh2_game_version = "EGS"
else:
ctx.kh2_game_version = None
logger.info("Your game version is out of date. Please update your game via The Epic Games Store or Steam.")
if ctx.kh2_game_version is not None:
logger.info(f"You are now auto-tracking {ctx.kh2_game_version}")
ctx.kh2connected = True
logger.info("You are now auto-tracking")
ctx.kh2connected = True
except Exception as e:
if ctx.kh2connected:
ctx.kh2connected = False

View File

@@ -98,12 +98,9 @@ class LinksAwakeningWorld(World):
# Items can be grouped using their names to allow easy checking if any item
# from that group has been collected. Group names can also be used for !hint
item_name_groups = {
"Instruments": {
"Full Moon Cello", "Conch Horn", "Sea Lily's Bell", "Surf Harp",
"Wind Marimba", "Coral Triangle", "Organ of Evening Calm", "Thunder Drum"
},
}
#item_name_groups = {
# "weapons": {"sword", "lance"}
#}
prefill_dungeon_items = None

View File

@@ -3,13 +3,13 @@ Archipelago init file for Lingo
"""
from logging import warning
from BaseClasses import CollectionState, Item, ItemClassification, Tutorial
from BaseClasses import Item, ItemClassification, Tutorial
from Options import OptionError
from worlds.AutoWorld import WebWorld, World
from .datatypes import Room, RoomEntrance
from .items import ALL_ITEM_TABLE, ITEMS_BY_GROUP, TRAP_ITEMS, LingoItem
from .locations import ALL_LOCATION_TABLE, LOCATIONS_BY_GROUP
from .options import LingoOptions, lingo_option_groups, SunwarpAccess, VictoryCondition
from .options import LingoOptions, lingo_option_groups
from .player_logic import LingoPlayerLogic
from .regions import create_regions
@@ -54,54 +54,20 @@ class LingoWorld(World):
player_logic: LingoPlayerLogic
def generate_early(self):
if not (self.options.shuffle_doors or self.options.shuffle_colors or
(self.options.sunwarp_access >= SunwarpAccess.option_unlock and
self.options.victory_condition == VictoryCondition.option_pilgrimage)):
if not (self.options.shuffle_doors or self.options.shuffle_colors or self.options.shuffle_sunwarps):
if self.multiworld.players == 1:
warning(f"{self.player_name}'s Lingo world doesn't have any progression items. Please turn on Door"
f" Shuffle or Color Shuffle, or use item-blocked sunwarps with the Pilgrimage victory condition"
f" if that doesn't seem right.")
warning(f"{self.multiworld.get_player_name(self.player)}'s Lingo world doesn't have any progression"
f" items. Please turn on Door Shuffle, Color Shuffle, or Sunwarp Shuffle if that doesn't seem"
f" right.")
else:
raise OptionError(f"{self.player_name}'s Lingo world doesn't have any progression items. Please turn on"
f" Door Shuffle or Color Shuffle, or use item-blocked sunwarps with the Pilgrimage"
f" victory condition.")
raise OptionError(f"{self.multiworld.get_player_name(self.player)}'s Lingo world doesn't have any"
f" progression items. Please turn on Door Shuffle, Color Shuffle or Sunwarp Shuffle.")
self.player_logic = LingoPlayerLogic(self)
def create_regions(self):
create_regions(self)
if not self.options.shuffle_postgame:
state = CollectionState(self.multiworld)
state.collect(LingoItem("Prevent Victory", ItemClassification.progression, None, self.player), True)
# Note: relies on the assumption that real_items is a definitive list of real progression items in this
# world, and is not modified after being created.
for item in self.player_logic.real_items:
state.collect(self.create_item(item), True)
# Exception to the above: a forced good item is not considered a "real item", but needs to be here anyway.
if self.player_logic.forced_good_item != "":
state.collect(self.create_item(self.player_logic.forced_good_item), True)
all_locations = self.multiworld.get_locations(self.player)
state.sweep_for_events(locations=all_locations)
unreachable_locations = [location for location in all_locations
if not state.can_reach_location(location.name, self.player)]
for location in unreachable_locations:
if location.name in self.player_logic.event_loc_to_item.keys():
continue
self.player_logic.real_locations.remove(location.name)
location.parent_region.locations.remove(location)
if len(self.player_logic.real_items) > len(self.player_logic.real_locations):
raise OptionError(f"{self.player_name}'s Lingo world does not have enough locations to fit the number"
f" of required items without shuffling the postgame. Either enable postgame"
f" shuffling, or choose different options.")
def create_items(self):
pool = [self.create_item(name) for name in self.player_logic.real_items]
@@ -170,8 +136,7 @@ class LingoWorld(World):
slot_options = [
"death_link", "victory_condition", "shuffle_colors", "shuffle_doors", "shuffle_paintings", "shuffle_panels",
"enable_pilgrimage", "sunwarp_access", "mastery_achievements", "level_2_requirement", "location_checks",
"early_color_hallways", "pilgrimage_allows_roof_access", "pilgrimage_allows_paintings", "shuffle_sunwarps",
"group_doors"
"early_color_hallways", "pilgrimage_allows_roof_access", "pilgrimage_allows_paintings", "shuffle_sunwarps"
]
slot_data = {

File diff suppressed because it is too large Load Diff

Binary file not shown.

View File

@@ -272,9 +272,8 @@ panels:
PAINTING (4): 445081
PAINTING (5): 445082
ROOM: 445083
Ending Area:
THE END: 444620
Orange Tower Seventh Floor:
THE END: 444620
THE MASTER: 444621
MASTERY: 444622
Behind A Smile:
@@ -1478,145 +1477,3 @@ progression:
Progressive Art Gallery: 444563
Progressive Colorful: 444580
Progressive Pilgrimage: 444583
Progressive Suits Area: 444602
Progressive Symmetry Room: 444608
Progressive Number Hunt: 444654
panel_doors:
Starting Room:
HIDDEN: 444589
Hidden Room:
OPEN: 444590
Hub Room:
ORDER: 444591
SLAUGHTER: 444592
TRACE: 444594
RAT: 444595
OPEN: 444596
Crossroads:
DECAY: 444597
NOPE: 444598
WE ROT: 444599
WORDS SWORD: 444600
BEND HI: 444601
Lost Area:
LOST: 444603
Amen Name Area:
AMEN NAME: 444604
The Tenacious:
Black Palindromes: 444605
Near Far Area:
NEAR FAR: 444606
Warts Straw Area:
WARTS STRAW: 444609
Leaf Feel Area:
LEAF FEEL: 444610
Outside The Agreeable:
MASSACRED: 444611
BLACK: 444612
CLOSE: 444613
RIGHT: 444614
Compass Room:
Lookout: 444615
Hedge Maze:
DOWN: 444617
The Perceptive:
GAZE: 444618
The Observant:
BACKSIDE: 444619
STAIRS: 444621
The Incomparable:
Giant Sevens: 444622
Orange Tower:
Access: 444623
Orange Tower First Floor:
SECRET: 444624
Orange Tower Fourth Floor:
HOT CRUSTS: 444625
Orange Tower Fifth Floor:
SIZE: 444626
First Second Third Fourth:
FIRST SECOND THIRD FOURTH: 444627
The Colorful (White):
BEGIN: 444628
The Colorful (Black):
FOUND: 444630
The Colorful (Red):
LOAF: 444631
The Colorful (Yellow):
CREAM: 444632
The Colorful (Blue):
SUN: 444633
The Colorful (Purple):
SPOON: 444634
The Colorful (Orange):
LETTERS: 444635
The Colorful (Green):
WALLS: 444636
The Colorful (Brown):
IRON: 444637
The Colorful (Gray):
OBSTACLE: 444638
Owl Hallway:
STRAYS: 444639
Outside The Initiated:
UNCOVER: 444640
OXEN: 444641
Outside The Bold:
UNOPEN: 444642
BEGIN: 444643
Outside The Undeterred:
ZERO: 444644
PEN: 444645
TWO: 444646
THREE: 444647
FOUR: 444648
Number Hunt:
FIVE: 444649
SIX: 444650
SEVEN: 444651
EIGHT: 444652
NINE: 444653
Color Hunt:
EXIT: 444655
RED: 444656
BLUE: 444658
YELLOW: 444659
ORANGE: 444660
PURPLE: 444661
GREEN: 444662
The Bearer:
FARTHER: 444663
MIDDLE: 444664
Knight Night (Final):
TRUSTED: 444665
Outside The Wondrous:
SHRINK: 444666
Hallway Room (1):
CASTLE: 444667
Hallway Room (2):
COUNTERCLOCKWISE: 444669
Hallway Room (3):
TRANSFORMATION: 444670
Hallway Room (4):
WHEELBARROW: 444671
Outside The Wanderer:
WANDERLUST: 444672
Art Gallery:
ORDER: 444673
Room Room:
STAIRS: 444674
Colors: 444676
Outside The Wise:
KITTEN CAT: 444677
Outside The Scientific:
OPEN: 444678
Directional Gallery:
TURN LEARN: 444679
panel_groups:
Tenacious Entrance Panels: 444593
Symmetry Room Panels: 444607
Backside Entrance Panels: 444620
Colorful Panels: 444629
Color Hunt Panels: 444657
Hallway Room Panels: 444668
Room Room Panels: 444675

View File

@@ -12,11 +12,6 @@ class RoomAndPanel(NamedTuple):
panel: str
class RoomAndPanelDoor(NamedTuple):
room: Optional[str]
panel_door: str
class EntranceType(Flag):
NORMAL = auto()
PAINTING = auto()
@@ -68,15 +63,9 @@ class Panel(NamedTuple):
exclude_reduce: bool
achievement: bool
non_counting: bool
panel_door: Optional[RoomAndPanelDoor] # This will always be fully specified.
location_name: Optional[str]
class PanelDoor(NamedTuple):
item_name: str
panel_group: Optional[str]
class Painting(NamedTuple):
id: str
room: str

View File

@@ -3,7 +3,7 @@ from typing import Dict, List, NamedTuple, Set
from BaseClasses import Item, ItemClassification
from .static_logic import DOORS_BY_ROOM, PROGRESSIVE_ITEMS, get_door_group_item_id, get_door_item_id, \
get_progressive_item_id, get_special_item_id, PANEL_DOORS_BY_ROOM, get_panel_door_item_id, get_panel_group_item_id
get_progressive_item_id, get_special_item_id
class ItemType(Enum):
@@ -65,21 +65,6 @@ def load_item_data():
ItemClassification.progression, ItemType.NORMAL, True, [])
ITEMS_BY_GROUP.setdefault("Doors", []).append(group)
panel_groups: Set[str] = set()
for room_name, panel_doors in PANEL_DOORS_BY_ROOM.items():
for panel_door_name, panel_door in panel_doors.items():
if panel_door.panel_group is not None:
panel_groups.add(panel_door.panel_group)
ALL_ITEM_TABLE[panel_door.item_name] = ItemData(get_panel_door_item_id(room_name, panel_door_name),
ItemClassification.progression, ItemType.NORMAL, False, [])
ITEMS_BY_GROUP.setdefault("Panels", []).append(panel_door.item_name)
for group in panel_groups:
ALL_ITEM_TABLE[group] = ItemData(get_panel_group_item_id(group), ItemClassification.progression,
ItemType.NORMAL, False, [])
ITEMS_BY_GROUP.setdefault("Panels", []).append(group)
special_items: Dict[str, ItemClassification] = {
":)": ItemClassification.filler,
"The Feeling of Being Lost": ItemClassification.filler,

View File

@@ -8,31 +8,21 @@ from .items import TRAP_ITEMS
class ShuffleDoors(Choice):
"""This option specifies how doors open.
"""If on, opening doors will require their respective "keys".
- **None:** Doors in the game will open the way they do in vanilla.
- **Panels:** Doors still open as in vanilla, but the panels that open the
doors will be locked, and an item will be required to unlock the panels.
- **Doors:** the doors themselves are locked behind items, and will open
automatically without needing to solve a panel once the key is obtained.
- **Simple:** Doors are sorted into logical groups, which are all opened by
receiving an item.
- **Complex:** The items are much more granular, and will usually only open
a single door each.
"""
display_name = "Shuffle Doors"
option_none = 0
option_panels = 1
option_doors = 2
alias_simple = 2
alias_complex = 2
class GroupDoors(Toggle):
"""By default, door shuffle in either panels or doors mode will create individual keys for every panel or door to be locked.
When group doors is on, some panels and doors are sorted into logical groups, which are opened together by receiving an item."""
display_name = "Group Doors"
option_simple = 1
option_complex = 2
class ProgressiveOrangeTower(DefaultOnToggle):
"""When "Shuffle Doors" is on doors mode, this setting governs the manner in which the Orange Tower floors open up.
"""When "Shuffle Doors" is on, this setting governs the manner in which the Orange Tower floors open up.
- **Off:** There is an item for each floor of the tower, and each floor's
item is the only one needed to access that floor.
@@ -43,7 +33,7 @@ class ProgressiveOrangeTower(DefaultOnToggle):
class ProgressiveColorful(DefaultOnToggle):
"""When "Shuffle Doors" is on either panels or doors mode and "Group Doors" is off, this setting governs the manner in which The Colorful opens up.
"""When "Shuffle Doors" is on "complex", this setting governs the manner in which The Colorful opens up.
- **Off:** There is an item for each room of The Colorful, meaning that
random rooms in the middle of the sequence can open up without giving you
@@ -204,11 +194,6 @@ class EarlyColorHallways(Toggle):
display_name = "Early Color Hallways"
class ShufflePostgame(Toggle):
"""When off, locations that could not be reached without also reaching your victory condition are removed."""
display_name = "Shuffle Postgame"
class TrapPercentage(Range):
"""Replaces junk items with traps, at the specified rate."""
display_name = "Trap Percentage"
@@ -263,7 +248,6 @@ lingo_option_groups = [
@dataclass
class LingoOptions(PerGameCommonOptions):
shuffle_doors: ShuffleDoors
group_doors: GroupDoors
progressive_orange_tower: ProgressiveOrangeTower
progressive_colorful: ProgressiveColorful
location_checks: LocationChecks
@@ -279,7 +263,6 @@ class LingoOptions(PerGameCommonOptions):
mastery_achievements: MasteryAchievements
level_2_requirement: Level2Requirement
early_color_hallways: EarlyColorHallways
shuffle_postgame: ShufflePostgame
trap_percentage: TrapPercentage
trap_weights: TrapWeights
puzzle_skip_percentage: PuzzleSkipPercentage

View File

@@ -7,8 +7,8 @@ from .items import ALL_ITEM_TABLE, ItemType
from .locations import ALL_LOCATION_TABLE, LocationClassification
from .options import LocationChecks, ShuffleDoors, SunwarpAccess, VictoryCondition
from .static_logic import DOORS_BY_ROOM, PAINTINGS, PAINTING_ENTRANCES, PAINTING_EXITS, \
PANELS_BY_ROOM, REQUIRED_PAINTING_ROOMS, REQUIRED_PAINTING_WHEN_NO_DOORS_ROOMS, PROGRESSIVE_DOORS_BY_ROOM, \
PANEL_DOORS_BY_ROOM, PROGRESSIVE_PANELS_BY_ROOM, SUNWARP_ENTRANCES, SUNWARP_EXITS
PANELS_BY_ROOM, PROGRESSION_BY_ROOM, REQUIRED_PAINTING_ROOMS, REQUIRED_PAINTING_WHEN_NO_DOORS_ROOMS, \
SUNWARP_ENTRANCES, SUNWARP_EXITS
if TYPE_CHECKING:
from . import LingoWorld
@@ -18,35 +18,23 @@ class AccessRequirements:
rooms: Set[str]
doors: Set[RoomAndDoor]
colors: Set[str]
items: Set[str]
progression: Dict[str, int]
the_master: bool
postgame: bool
def __init__(self):
self.rooms = set()
self.doors = set()
self.colors = set()
self.items = set()
self.progression = dict()
self.the_master = False
self.postgame = False
def merge(self, other: "AccessRequirements"):
self.rooms |= other.rooms
self.doors |= other.doors
self.colors |= other.colors
self.items |= other.items
self.the_master |= other.the_master
self.postgame |= other.postgame
for progression, index in other.progression.items():
if progression not in self.progression or index > self.progression[progression]:
self.progression[progression] = index
def __str__(self):
return f"AccessRequirements(rooms={self.rooms}, doors={self.doors}, colors={self.colors}, items={self.items}," \
f" progression={self.progression}), the_master={self.the_master}, postgame={self.postgame}"
return f"AccessRequirements(rooms={self.rooms}, doors={self.doors}, colors={self.colors})," \
f" the_master={self.the_master}"
class PlayerLocation(NamedTuple):
@@ -126,15 +114,15 @@ class LingoPlayerLogic:
self.item_by_door.setdefault(room, {})[door] = item
def handle_non_grouped_door(self, room_name: str, door_data: Door, world: "LingoWorld"):
if room_name in PROGRESSIVE_DOORS_BY_ROOM and door_data.name in PROGRESSIVE_DOORS_BY_ROOM[room_name]:
progression_name = PROGRESSIVE_DOORS_BY_ROOM[room_name][door_data.name].item_name
if room_name in PROGRESSION_BY_ROOM and door_data.name in PROGRESSION_BY_ROOM[room_name]:
progression_name = PROGRESSION_BY_ROOM[room_name][door_data.name].item_name
progression_handling = should_split_progression(progression_name, world)
if progression_handling == ProgressiveItemBehavior.SPLIT:
self.set_door_item(room_name, door_data.name, door_data.item_name)
self.real_items.append(door_data.item_name)
elif progression_handling == ProgressiveItemBehavior.PROGRESSIVE:
progressive_item_name = PROGRESSIVE_DOORS_BY_ROOM[room_name][door_data.name].item_name
progressive_item_name = PROGRESSION_BY_ROOM[room_name][door_data.name].item_name
self.set_door_item(room_name, door_data.name, progressive_item_name)
self.real_items.append(progressive_item_name)
else:
@@ -165,31 +153,17 @@ class LingoPlayerLogic:
victory_condition = world.options.victory_condition
early_color_hallways = world.options.early_color_hallways
if location_checks == LocationChecks.option_reduced:
if door_shuffle == ShuffleDoors.option_doors:
raise OptionError(f"Slot \"{world.player_name}\" cannot have reduced location checks when door shuffle"
f" is on, because there would not be enough locations for all of the door items.")
if door_shuffle == ShuffleDoors.option_panels:
if not world.options.group_doors:
raise OptionError(f"Slot \"{world.player_name}\" cannot have reduced location checks when ungrouped"
f" panels mode door shuffle is on, because there would not be enough locations for"
f" all of the panel items.")
if color_shuffle:
raise OptionError(f"Slot \"{world.player_name}\" cannot have reduced location checks with both"
f" panels mode door shuffle and color shuffle because there would not be enough"
f" locations for all of the items.")
if world.options.sunwarp_access >= SunwarpAccess.option_individual:
raise OptionError(f"Slot \"{world.player_name}\" cannot have reduced location checks with both"
f" panels mode door shuffle and individual or progressive sunwarp access because"
f" there would not be enough locations for all of the items.")
if location_checks == LocationChecks.option_reduced and door_shuffle != ShuffleDoors.option_none:
raise OptionError("You cannot have reduced location checks when door shuffle is on, because there would not"
" be enough locations for all of the door items.")
# Create door items, where needed.
door_groups: Set[str] = set()
for room_name, room_data in DOORS_BY_ROOM.items():
for door_name, door_data in room_data.items():
if door_data.skip_item is False and door_data.event is False:
if door_data.type == DoorType.NORMAL and door_shuffle == ShuffleDoors.option_doors:
if door_data.door_group is not None and world.options.group_doors:
if door_data.type == DoorType.NORMAL and door_shuffle != ShuffleDoors.option_none:
if door_data.door_group is not None and door_shuffle == ShuffleDoors.option_simple:
# Grouped doors are handled differently if shuffle doors is on simple.
self.set_door_item(room_name, door_name, door_data.door_group)
door_groups.add(door_data.door_group)
@@ -211,33 +185,21 @@ class LingoPlayerLogic:
self.real_items.append(door_data.item_name)
self.real_items += door_groups
# Create panel items, where needed.
if world.options.shuffle_doors == ShuffleDoors.option_panels:
panel_groups: Set[str] = set()
for room_name, room_data in PANEL_DOORS_BY_ROOM.items():
for panel_door_name, panel_door_data in room_data.items():
if panel_door_data.panel_group is not None and world.options.group_doors:
panel_groups.add(panel_door_data.panel_group)
elif room_name in PROGRESSIVE_PANELS_BY_ROOM \
and panel_door_name in PROGRESSIVE_PANELS_BY_ROOM[room_name]:
progression_obj = PROGRESSIVE_PANELS_BY_ROOM[room_name][panel_door_name]
progression_handling = should_split_progression(progression_obj.item_name, world)
if progression_handling == ProgressiveItemBehavior.SPLIT:
self.real_items.append(panel_door_data.item_name)
elif progression_handling == ProgressiveItemBehavior.PROGRESSIVE:
self.real_items.append(progression_obj.item_name)
else:
self.real_items.append(panel_door_data.item_name)
self.real_items += panel_groups
# Create color items, if needed.
if color_shuffle:
self.real_items += [name for name, item in ALL_ITEM_TABLE.items() if item.type == ItemType.COLOR]
# Create events for each achievement panel, so that we can determine when THE MASTER is accessible.
for room_name, room_data in PANELS_BY_ROOM.items():
for panel_name, panel_data in room_data.items():
if panel_data.achievement:
access_req = AccessRequirements()
access_req.merge(self.calculate_panel_requirements(room_name, panel_name, world))
access_req.rooms.add(room_name)
self.mastery_reqs.append(access_req)
# Handle the victory condition. Victory conditions other than the chosen one become regular checks, so we need
# to prevent the actual victory condition from becoming a check.
self.mastery_location = "Orange Tower Seventh Floor - THE MASTER"
@@ -245,7 +207,7 @@ class LingoPlayerLogic:
if victory_condition == VictoryCondition.option_the_end:
self.victory_condition = "Orange Tower Seventh Floor - THE END"
self.add_location("Ending Area", "The End (Solved)", None, [], world)
self.add_location("Orange Tower Seventh Floor", "The End (Solved)", None, [], world)
self.event_loc_to_item["The End (Solved)"] = "Victory"
elif victory_condition == VictoryCondition.option_the_master:
self.victory_condition = "Orange Tower Seventh Floor - THE MASTER"
@@ -269,16 +231,6 @@ class LingoPlayerLogic:
[RoomAndPanel("Pilgrim Antechamber", "PILGRIM")], world)
self.event_loc_to_item["PILGRIM (Solved)"] = "Victory"
# Create events for each achievement panel, so that we can determine when THE MASTER is accessible.
for room_name, room_data in PANELS_BY_ROOM.items():
for panel_name, panel_data in room_data.items():
if panel_data.achievement:
access_req = AccessRequirements()
access_req.merge(self.calculate_panel_requirements(room_name, panel_name, world))
access_req.rooms.add(room_name)
self.mastery_reqs.append(access_req)
# Create groups of counting panel access requirements for the LEVEL 2 check.
self.create_panel_hunt_events(world)
@@ -289,7 +241,7 @@ class LingoPlayerLogic:
elif location_checks == LocationChecks.option_insanity:
location_classification = LocationClassification.insanity
if door_shuffle == ShuffleDoors.option_doors and not early_color_hallways:
if door_shuffle != ShuffleDoors.option_none and not early_color_hallways:
location_classification |= LocationClassification.small_sphere_one
for location_name, location_data in ALL_LOCATION_TABLE.items():
@@ -331,7 +283,7 @@ class LingoPlayerLogic:
"iterations. This is very unlikely to happen on its own, and probably indicates some "
"kind of logic error.")
if door_shuffle == ShuffleDoors.option_doors and location_checks != LocationChecks.option_insanity \
if door_shuffle != ShuffleDoors.option_none and location_checks != LocationChecks.option_insanity \
and not early_color_hallways and world.multiworld.players > 1:
# Under the combination of door shuffle, normal location checks, and no early color hallways, sphere 1 is
# only three checks. In a multiplayer situation, this can be frustrating for the player because they are
@@ -346,19 +298,19 @@ class LingoPlayerLogic:
# Starting Room - Exit Door gives access to OPEN and TRACE.
good_item_options: List[str] = ["Starting Room - Back Right Door", "Second Room - Exit Door"]
if not color_shuffle:
if not world.options.enable_pilgrimage:
# HOT CRUST and THIS.
good_item_options.append("Pilgrim Room - Sun Painting")
if not color_shuffle and not world.options.enable_pilgrimage:
# HOT CRUST and THIS.
good_item_options.append("Pilgrim Room - Sun Painting")
if world.options.group_doors:
if not color_shuffle:
if door_shuffle == ShuffleDoors.option_simple:
# WELCOME BACK, CLOCKWISE, and DRAWL + RUNS.
good_item_options.append("Welcome Back Doors")
else:
# WELCOME BACK and CLOCKWISE.
good_item_options.append("Welcome Back Area - Shortcut to Starting Room")
if world.options.group_doors:
if door_shuffle == ShuffleDoors.option_simple:
# Color hallways access (NOTE: reconsider when sunwarp shuffling exists).
good_item_options.append("Rhyme Room Doors")
@@ -404,11 +356,13 @@ class LingoPlayerLogic:
def randomize_paintings(self, world: "LingoWorld") -> bool:
self.painting_mapping.clear()
door_shuffle = world.options.shuffle_doors
# First, assign mappings to the required-exit paintings. We ensure that req-blocked paintings do not lead to
# required paintings.
req_exits = []
required_painting_rooms = REQUIRED_PAINTING_ROOMS
if world.options.shuffle_doors != ShuffleDoors.option_doors:
if door_shuffle == ShuffleDoors.option_none:
required_painting_rooms += REQUIRED_PAINTING_WHEN_NO_DOORS_ROOMS
req_exits = [painting_id for painting_id, painting in PAINTINGS.items() if painting.required_when_no_doors]
@@ -475,7 +429,7 @@ class LingoPlayerLogic:
for painting_id, painting in PAINTINGS.items():
if painting_id not in self.painting_mapping.values() \
and (painting.required or (painting.required_when_no_doors and
world.options.shuffle_doors != ShuffleDoors.option_doors)):
door_shuffle == ShuffleDoors.option_none)):
return False
return True
@@ -490,31 +444,12 @@ class LingoPlayerLogic:
access_reqs = AccessRequirements()
panel_object = PANELS_BY_ROOM[room][panel]
if world.options.shuffle_doors == ShuffleDoors.option_panels and panel_object.panel_door is not None:
panel_door_room = panel_object.panel_door.room
panel_door_name = panel_object.panel_door.panel_door
panel_door = PANEL_DOORS_BY_ROOM[panel_door_room][panel_door_name]
if panel_door.panel_group is not None and world.options.group_doors:
access_reqs.items.add(panel_door.panel_group)
elif panel_door_room in PROGRESSIVE_PANELS_BY_ROOM\
and panel_door_name in PROGRESSIVE_PANELS_BY_ROOM[panel_door_room]:
progression_obj = PROGRESSIVE_PANELS_BY_ROOM[panel_door_room][panel_door_name]
progression_handling = should_split_progression(progression_obj.item_name, world)
if progression_handling == ProgressiveItemBehavior.SPLIT:
access_reqs.items.add(panel_door.item_name)
elif progression_handling == ProgressiveItemBehavior.PROGRESSIVE:
access_reqs.progression[progression_obj.item_name] = progression_obj.index
else:
access_reqs.items.add(panel_door.item_name)
for req_room in panel_object.required_rooms:
access_reqs.rooms.add(req_room)
for req_door in panel_object.required_doors:
door_object = DOORS_BY_ROOM[room if req_door.room is None else req_door.room][req_door.door]
if door_object.event or world.options.shuffle_doors != ShuffleDoors.option_doors:
if door_object.event or world.options.shuffle_doors == ShuffleDoors.option_none:
sub_access_reqs = self.calculate_door_requirements(
room if req_door.room is None else req_door.room, req_door.door, world)
access_reqs.merge(sub_access_reqs)
@@ -535,11 +470,6 @@ class LingoPlayerLogic:
if panel == "THE MASTER":
access_reqs.the_master = True
# Evil python magic (so sayeth NewSoupVi): this checks victory_condition against the panel's location name
# override if it exists, or the auto-generated location name if it's None.
if self.victory_condition == (panel_object.location_name or f"{room} - {panel}"):
access_reqs.postgame = True
self.panel_reqs[room][panel] = access_reqs
return self.panel_reqs[room][panel]
@@ -584,14 +514,11 @@ class LingoPlayerLogic:
continue
# We won't coalesce any panels that have requirements beyond colors. To simplify things for now, we will
# only coalesce single-color panels. Chains/stacks/combo puzzles will be separate. Panel door locked
# puzzles will be separate if panels mode is on. THE MASTER has special access rules and is handled
# separately.
# only coalesce single-color panels. Chains/stacks/combo puzzles will be separate. THE MASTER has
# special access rules and is handled separately.
if len(panel_data.required_panels) > 0 or len(panel_data.required_doors) > 0\
or len(panel_data.required_rooms) > 0\
or (world.options.shuffle_colors and len(panel_data.colors) > 1)\
or (world.options.shuffle_doors == ShuffleDoors.option_panels
and panel_data.panel_door is not None)\
or panel_name == "THE MASTER":
self.counting_panel_reqs.setdefault(room_name, []).append(
(self.calculate_panel_requirements(room_name, panel_name, world), 1))

View File

@@ -159,7 +159,7 @@ def create_regions(world: "LingoWorld") -> None:
RoomAndDoor("Pilgrim Antechamber", "Sun Painting"), EntranceType.PAINTING, False, world)
if early_color_hallways:
connect_entrance(regions, regions["Starting Room"], regions["Color Hallways"], "Early Color Hallways",
connect_entrance(regions, regions["Starting Room"], regions["Outside The Undeterred"], "Early Color Hallways",
None, EntranceType.PAINTING, False, world)
if painting_shuffle:

View File

@@ -3,7 +3,7 @@ from typing import TYPE_CHECKING
from BaseClasses import CollectionState
from .datatypes import RoomAndDoor
from .player_logic import AccessRequirements, PlayerLocation
from .static_logic import PROGRESSIVE_DOORS_BY_ROOM, PROGRESSIVE_ITEMS
from .static_logic import PROGRESSION_BY_ROOM, PROGRESSIVE_ITEMS
if TYPE_CHECKING:
from . import LingoWorld
@@ -59,18 +59,9 @@ def _lingo_can_satisfy_requirements(state: CollectionState, access: AccessRequir
if not state.has(color.capitalize(), world.player):
return False
if not all(state.has(item, world.player) for item in access.items):
return False
if not all(state.has(item, world.player, index) for item, index in access.progression.items()):
return False
if access.the_master and not lingo_can_use_mastery_location(state, world):
return False
if access.postgame and state.has("Prevent Victory", world.player):
return False
return True
@@ -83,7 +74,7 @@ def _lingo_can_open_door(state: CollectionState, room: str, door: str, world: "L
item_name = world.player_logic.item_by_door[room][door]
if item_name in PROGRESSIVE_ITEMS:
progression = PROGRESSIVE_DOORS_BY_ROOM[room][door]
progression = PROGRESSION_BY_ROOM[room][door]
return state.has(item_name, world.player, progression.index)
return state.has(item_name, world.player)

View File

@@ -4,17 +4,15 @@ import pickle
from io import BytesIO
from typing import Dict, List, Set
from .datatypes import Door, Painting, Panel, PanelDoor, Progression, Room
from .datatypes import Door, Painting, Panel, Progression, Room
ALL_ROOMS: List[Room] = []
DOORS_BY_ROOM: Dict[str, Dict[str, Door]] = {}
PANELS_BY_ROOM: Dict[str, Dict[str, Panel]] = {}
PANEL_DOORS_BY_ROOM: Dict[str, Dict[str, PanelDoor]] = {}
PAINTINGS: Dict[str, Painting] = {}
PROGRESSIVE_ITEMS: Set[str] = set()
PROGRESSIVE_DOORS_BY_ROOM: Dict[str, Dict[str, Progression]] = {}
PROGRESSIVE_PANELS_BY_ROOM: Dict[str, Dict[str, Progression]] = {}
PROGRESSIVE_ITEMS: List[str] = []
PROGRESSION_BY_ROOM: Dict[str, Dict[str, Progression]] = {}
PAINTING_ENTRANCES: int = 0
PAINTING_EXIT_ROOMS: Set[str] = set()
@@ -30,8 +28,6 @@ PANEL_LOCATION_IDS: Dict[str, Dict[str, int]] = {}
DOOR_LOCATION_IDS: Dict[str, Dict[str, int]] = {}
DOOR_ITEM_IDS: Dict[str, Dict[str, int]] = {}
DOOR_GROUP_ITEM_IDS: Dict[str, int] = {}
PANEL_DOOR_ITEM_IDS: Dict[str, Dict[str, int]] = {}
PANEL_GROUP_ITEM_IDS: Dict[str, int] = {}
PROGRESSIVE_ITEM_IDS: Dict[str, int] = {}
HASHES: Dict[str, str] = {}
@@ -72,20 +68,6 @@ def get_door_group_item_id(name: str):
return DOOR_GROUP_ITEM_IDS[name]
def get_panel_door_item_id(room: str, name: str):
if room not in PANEL_DOOR_ITEM_IDS or name not in PANEL_DOOR_ITEM_IDS[room]:
raise Exception(f"Item ID for panel door {room} - {name} not found in ids.yaml.")
return PANEL_DOOR_ITEM_IDS[room][name]
def get_panel_group_item_id(name: str):
if name not in PANEL_GROUP_ITEM_IDS:
raise Exception(f"Item ID for panel group {name} not found in ids.yaml.")
return PANEL_GROUP_ITEM_IDS[name]
def get_progressive_item_id(name: str):
if name not in PROGRESSIVE_ITEM_IDS:
raise Exception(f"Item ID for progressive item {name} not found in ids.yaml.")
@@ -115,10 +97,8 @@ def load_static_data_from_file():
ALL_ROOMS.extend(pickdata["ALL_ROOMS"])
DOORS_BY_ROOM.update(pickdata["DOORS_BY_ROOM"])
PANELS_BY_ROOM.update(pickdata["PANELS_BY_ROOM"])
PANEL_DOORS_BY_ROOM.update(pickdata["PANEL_DOORS_BY_ROOM"])
PROGRESSIVE_ITEMS.update(pickdata["PROGRESSIVE_ITEMS"])
PROGRESSIVE_DOORS_BY_ROOM.update(pickdata["PROGRESSIVE_DOORS_BY_ROOM"])
PROGRESSIVE_PANELS_BY_ROOM.update(pickdata["PROGRESSIVE_PANELS_BY_ROOM"])
PROGRESSIVE_ITEMS.extend(pickdata["PROGRESSIVE_ITEMS"])
PROGRESSION_BY_ROOM.update(pickdata["PROGRESSION_BY_ROOM"])
PAINTING_ENTRANCES = pickdata["PAINTING_ENTRANCES"]
PAINTING_EXIT_ROOMS.update(pickdata["PAINTING_EXIT_ROOMS"])
PAINTING_EXITS = pickdata["PAINTING_EXITS"]
@@ -131,8 +111,6 @@ def load_static_data_from_file():
DOOR_LOCATION_IDS.update(pickdata["DOOR_LOCATION_IDS"])
DOOR_ITEM_IDS.update(pickdata["DOOR_ITEM_IDS"])
DOOR_GROUP_ITEM_IDS.update(pickdata["DOOR_GROUP_ITEM_IDS"])
PANEL_DOOR_ITEM_IDS.update(pickdata["PANEL_DOOR_ITEM_IDS"])
PANEL_GROUP_ITEM_IDS.update(pickdata["PANEL_GROUP_ITEM_IDS"])
PROGRESSIVE_ITEM_IDS.update(pickdata["PROGRESSIVE_ITEM_IDS"])

View File

@@ -3,7 +3,7 @@ from . import LingoTestBase
class TestRequiredRoomLogic(LingoTestBase):
options = {
"shuffle_doors": "doors",
"shuffle_doors": "complex",
"shuffle_colors": "false",
}
@@ -50,7 +50,7 @@ class TestRequiredRoomLogic(LingoTestBase):
class TestRequiredDoorLogic(LingoTestBase):
options = {
"shuffle_doors": "doors",
"shuffle_doors": "complex",
"shuffle_colors": "false",
}
@@ -78,8 +78,7 @@ class TestRequiredDoorLogic(LingoTestBase):
class TestSimpleDoors(LingoTestBase):
options = {
"shuffle_doors": "doors",
"group_doors": "true",
"shuffle_doors": "simple",
"shuffle_colors": "false",
}
@@ -91,52 +90,3 @@ class TestSimpleDoors(LingoTestBase):
self.assertTrue(self.multiworld.state.can_reach("Outside The Wanderer", "Region", self.player))
self.assertTrue(self.multiworld.state.can_reach("Orange Tower Third Floor", "Region", self.player))
class TestPanels(LingoTestBase):
options = {
"shuffle_doors": "panels"
}
def test_requirement(self):
self.assertFalse(self.can_reach_location("Starting Room - HIDDEN"))
self.assertFalse(self.can_reach_location("Hidden Room - OPEN"))
self.assertFalse(self.can_reach_location("The Seeker - Achievement"))
self.collect_by_name("Starting Room - HIDDEN (Panel)")
self.assertTrue(self.can_reach_location("Starting Room - HIDDEN"))
self.assertFalse(self.can_reach_location("Hidden Room - OPEN"))
self.assertFalse(self.can_reach_location("The Seeker - Achievement"))
self.collect_by_name("Hidden Room - OPEN (Panel)")
self.assertTrue(self.can_reach_location("Starting Room - HIDDEN"))
self.assertTrue(self.can_reach_location("Hidden Room - OPEN"))
self.assertTrue(self.can_reach_location("The Seeker - Achievement"))
class TestGroupedPanels(LingoTestBase):
options = {
"shuffle_doors": "panels",
"group_doors": "true",
"shuffle_colors": "false",
}
def test_requirement(self):
self.assertFalse(self.can_reach_location("Hub Room - SLAUGHTER"))
self.assertFalse(self.can_reach_location("Dread Hallway - DREAD"))
self.assertFalse(self.can_reach_location("The Tenacious - Achievement"))
self.collect_by_name("Tenacious Entrance Panels")
self.assertTrue(self.can_reach_location("Hub Room - SLAUGHTER"))
self.assertFalse(self.can_reach_location("Dread Hallway - DREAD"))
self.assertFalse(self.can_reach_location("The Tenacious - Achievement"))
self.collect_by_name("Outside The Agreeable - BLACK (Panel)")
self.assertTrue(self.can_reach_location("Hub Room - SLAUGHTER"))
self.assertTrue(self.can_reach_location("Dread Hallway - DREAD"))
self.assertFalse(self.can_reach_location("The Tenacious - Achievement"))
self.collect_by_name("The Tenacious - Black Palindromes (Panels)")
self.assertTrue(self.can_reach_location("Hub Room - SLAUGHTER"))
self.assertTrue(self.can_reach_location("Dread Hallway - DREAD"))
self.assertTrue(self.can_reach_location("The Tenacious - Achievement"))

View File

@@ -5,8 +5,7 @@ class TestMasteryWhenVictoryIsTheEnd(LingoTestBase):
options = {
"mastery_achievements": "22",
"victory_condition": "the_end",
"shuffle_colors": "true",
"shuffle_postgame": "true",
"shuffle_colors": "true"
}
def test_requirement(self):
@@ -44,8 +43,7 @@ class TestMasteryBlocksDependents(LingoTestBase):
options = {
"mastery_achievements": "24",
"shuffle_colors": "true",
"location_checks": "insanity",
"victory_condition": "level_2",
"location_checks": "insanity"
}
def test_requirement(self):

View File

@@ -3,7 +3,7 @@ from . import LingoTestBase
class TestMultiShuffleOptions(LingoTestBase):
options = {
"shuffle_doors": "doors",
"shuffle_doors": "complex",
"progressive_orange_tower": "true",
"shuffle_colors": "true",
"shuffle_paintings": "true",
@@ -13,7 +13,7 @@ class TestMultiShuffleOptions(LingoTestBase):
class TestPanelsanity(LingoTestBase):
options = {
"shuffle_doors": "doors",
"shuffle_doors": "complex",
"progressive_orange_tower": "true",
"location_checks": "insanity",
"shuffle_colors": "true"
@@ -22,18 +22,7 @@ class TestPanelsanity(LingoTestBase):
class TestAllPanelHunt(LingoTestBase):
options = {
"shuffle_doors": "doors",
"progressive_orange_tower": "true",
"shuffle_colors": "true",
"victory_condition": "level_2",
"level_2_requirement": "800",
"early_color_hallways": "true"
}
class TestAllPanelHuntPanelsMode(LingoTestBase):
options = {
"shuffle_doors": "panels",
"shuffle_doors": "complex",
"progressive_orange_tower": "true",
"shuffle_colors": "true",
"victory_condition": "level_2",

View File

@@ -3,7 +3,7 @@ from . import LingoTestBase
class TestProgressiveOrangeTower(LingoTestBase):
options = {
"shuffle_doors": "doors",
"shuffle_doors": "complex",
"progressive_orange_tower": "true"
}

View File

@@ -3,7 +3,7 @@ from . import LingoTestBase
class TestPanelHunt(LingoTestBase):
options = {
"shuffle_doors": "doors",
"shuffle_doors": "complex",
"location_checks": "insanity",
"victory_condition": "level_2",
"level_2_requirement": "15"

View File

@@ -18,7 +18,7 @@ class TestPilgrimageWithRoofAndPaintings(LingoTestBase):
options = {
"enable_pilgrimage": "true",
"shuffle_colors": "false",
"shuffle_doors": "doors",
"shuffle_doors": "complex",
"pilgrimage_allows_roof_access": "true",
"pilgrimage_allows_paintings": "true",
"early_color_hallways": "false"
@@ -29,6 +29,7 @@ class TestPilgrimageWithRoofAndPaintings(LingoTestBase):
"Outside The Undeterred - Green Painting"]
for door in doors:
print(door)
self.assertFalse(self.can_reach_location("Pilgrim Antechamber - PILGRIM"))
self.collect_by_name(door)
@@ -39,7 +40,7 @@ class TestPilgrimageNoRoofYesPaintings(LingoTestBase):
options = {
"enable_pilgrimage": "true",
"shuffle_colors": "false",
"shuffle_doors": "doors",
"shuffle_doors": "complex",
"pilgrimage_allows_roof_access": "false",
"pilgrimage_allows_paintings": "true",
"early_color_hallways": "false"
@@ -52,6 +53,7 @@ class TestPilgrimageNoRoofYesPaintings(LingoTestBase):
"Starting Room - Street Painting"]
for door in doors:
print(door)
self.assertFalse(self.can_reach_location("Pilgrim Antechamber - PILGRIM"))
self.collect_by_name(door)
@@ -62,7 +64,7 @@ class TestPilgrimageNoRoofNoPaintings(LingoTestBase):
options = {
"enable_pilgrimage": "true",
"shuffle_colors": "false",
"shuffle_doors": "doors",
"shuffle_doors": "complex",
"pilgrimage_allows_roof_access": "false",
"pilgrimage_allows_paintings": "false",
"early_color_hallways": "false"
@@ -79,45 +81,18 @@ class TestPilgrimageNoRoofNoPaintings(LingoTestBase):
"Orange Tower Fourth Floor - Hot Crusts Door"]
for door in doors:
print(door)
self.assertFalse(self.can_reach_location("Pilgrim Antechamber - PILGRIM"))
self.collect_by_name(door)
self.assertTrue(self.can_reach_location("Pilgrim Antechamber - PILGRIM"))
class TestPilgrimageRequireStartingRoom(LingoTestBase):
options = {
"enable_pilgrimage": "true",
"shuffle_colors": "false",
"shuffle_doors": "complex",
"pilgrimage_allows_roof_access": "false",
"pilgrimage_allows_paintings": "false",
"early_color_hallways": "false"
}
def test_access(self):
doors = ["Second Room - Exit Door", "Crossroads - Roof Access", "Hub Room - Crossroads Entrance",
"Outside The Undeterred - Green Painting", "Outside The Undeterred - Number Hunt",
"Starting Room - Street Painting", "Outside The Initiated - Shortcut to Hub Room",
"Directional Gallery - Shortcut to The Undeterred", "Orange Tower First Floor - Salt Pepper Door",
"Color Hunt - Shortcut to The Steady", "The Bearer - Entrance",
"Orange Tower Fifth Floor - Quadruple Intersection", "The Tenacious - Shortcut to Hub Room",
"Outside The Agreeable - Tenacious Entrance", "Crossroads - Tower Entrance",
"Orange Tower Fourth Floor - Hot Crusts Door", "Challenge Room - Welcome Door",
"Number Hunt - Challenge Entrance", "Welcome Back Area - Shortcut to Starting Room"]
for door in doors:
self.assertFalse(self.can_reach_location("Pilgrim Antechamber - PILGRIM"))
self.collect_by_name(door)
self.assertTrue(self.can_reach_location("Pilgrim Antechamber - PILGRIM"))
class TestPilgrimageYesRoofNoPaintings(LingoTestBase):
options = {
"enable_pilgrimage": "true",
"shuffle_colors": "false",
"shuffle_doors": "doors",
"shuffle_doors": "complex",
"pilgrimage_allows_roof_access": "true",
"pilgrimage_allows_paintings": "false",
"early_color_hallways": "false"
@@ -132,6 +107,7 @@ class TestPilgrimageYesRoofNoPaintings(LingoTestBase):
"Orange Tower Fifth Floor - Quadruple Intersection"]
for door in doors:
print(door)
self.assertFalse(self.can_reach_location("Pilgrim Antechamber - PILGRIM"))
self.collect_by_name(door)

View File

@@ -1,62 +0,0 @@
from . import LingoTestBase
class TestPostgameVanillaTheEnd(LingoTestBase):
options = {
"shuffle_doors": "none",
"victory_condition": "the_end",
"shuffle_postgame": "false",
}
def test_requirement(self):
location_names = [location.name for location in self.multiworld.get_locations(self.player)]
self.assertTrue("The End (Solved)" in location_names)
self.assertTrue("Champion's Rest - YOU" in location_names)
self.assertFalse("Orange Tower Seventh Floor - THE MASTER" in location_names)
self.assertFalse("The Red - Achievement" in location_names)
class TestPostgameComplexDoorsTheEnd(LingoTestBase):
options = {
"shuffle_doors": "complex",
"victory_condition": "the_end",
"shuffle_postgame": "false",
}
def test_requirement(self):
location_names = [location.name for location in self.multiworld.get_locations(self.player)]
self.assertTrue("The End (Solved)" in location_names)
self.assertFalse("Orange Tower Seventh Floor - THE MASTER" in location_names)
self.assertTrue("The Red - Achievement" in location_names)
class TestPostgameLateColorHunt(LingoTestBase):
options = {
"shuffle_doors": "none",
"victory_condition": "the_end",
"sunwarp_access": "disabled",
"shuffle_postgame": "false",
}
def test_requirement(self):
location_names = [location.name for location in self.multiworld.get_locations(self.player)]
self.assertFalse("Champion's Rest - YOU" in location_names)
class TestPostgameVanillaTheMaster(LingoTestBase):
options = {
"shuffle_doors": "none",
"victory_condition": "the_master",
"shuffle_postgame": "false",
}
def test_requirement(self):
location_names = [location.name for location in self.multiworld.get_locations(self.player)]
self.assertTrue("Orange Tower Seventh Floor - THE END" in location_names)
self.assertTrue("Orange Tower Seventh Floor - Mastery Achievements" in location_names)
self.assertTrue("The Red - Achievement" in location_names)
self.assertFalse("Mastery Panels" in location_names)

View File

@@ -3,7 +3,7 @@ from . import LingoTestBase
class TestComplexProgressiveHallwayRoom(LingoTestBase):
options = {
"shuffle_doors": "doors"
"shuffle_doors": "complex"
}
def test_item(self):
@@ -54,8 +54,7 @@ class TestComplexProgressiveHallwayRoom(LingoTestBase):
class TestSimpleHallwayRoom(LingoTestBase):
options = {
"shuffle_doors": "doors",
"group_doors": "true",
"shuffle_doors": "simple"
}
def test_item(self):
@@ -82,7 +81,7 @@ class TestSimpleHallwayRoom(LingoTestBase):
class TestProgressiveArtGallery(LingoTestBase):
options = {
"shuffle_doors": "doors",
"shuffle_doors": "complex",
"shuffle_colors": "false",
}

View File

@@ -19,8 +19,7 @@ class TestVanillaDoorsNormalSunwarps(LingoTestBase):
class TestSimpleDoorsNormalSunwarps(LingoTestBase):
options = {
"shuffle_doors": "doors",
"group_doors": "true",
"shuffle_doors": "simple",
"sunwarp_access": "normal"
}
@@ -38,8 +37,7 @@ class TestSimpleDoorsNormalSunwarps(LingoTestBase):
class TestSimpleDoorsDisabledSunwarps(LingoTestBase):
options = {
"shuffle_doors": "doors",
"group_doors": "true",
"shuffle_doors": "simple",
"sunwarp_access": "disabled"
}
@@ -58,8 +56,7 @@ class TestSimpleDoorsDisabledSunwarps(LingoTestBase):
class TestSimpleDoorsUnlockSunwarps(LingoTestBase):
options = {
"shuffle_doors": "doors",
"group_doors": "true",
"shuffle_doors": "simple",
"sunwarp_access": "unlock"
}
@@ -81,8 +78,7 @@ class TestSimpleDoorsUnlockSunwarps(LingoTestBase):
class TestComplexDoorsNormalSunwarps(LingoTestBase):
options = {
"shuffle_doors": "doors",
"group_doors": "false",
"shuffle_doors": "complex",
"sunwarp_access": "normal"
}
@@ -100,8 +96,7 @@ class TestComplexDoorsNormalSunwarps(LingoTestBase):
class TestComplexDoorsDisabledSunwarps(LingoTestBase):
options = {
"shuffle_doors": "doors",
"group_doors": "false",
"shuffle_doors": "complex",
"sunwarp_access": "disabled"
}
@@ -120,8 +115,7 @@ class TestComplexDoorsDisabledSunwarps(LingoTestBase):
class TestComplexDoorsIndividualSunwarps(LingoTestBase):
options = {
"shuffle_doors": "doors",
"group_doors": "false",
"shuffle_doors": "complex",
"sunwarp_access": "individual"
}
@@ -148,8 +142,7 @@ class TestComplexDoorsIndividualSunwarps(LingoTestBase):
class TestComplexDoorsProgressiveSunwarps(LingoTestBase):
options = {
"shuffle_doors": "doors",
"group_doors": "false",
"shuffle_doors": "complex",
"sunwarp_access": "progressive"
}

View File

@@ -73,22 +73,6 @@ if old_generated.include? "door_groups" then
end
end
end
if old_generated.include? "panel_doors" then
old_generated["panel_doors"].each do |room, panel_doors|
panel_doors.each do |name, id|
if id >= next_item_id then
next_item_id = id + 1
end
end
end
end
if old_generated.include? "panel_groups" then
old_generated["panel_groups"].each do |name, id|
if id >= next_item_id then
next_item_id = id + 1
end
end
end
if old_generated.include? "progression" then
old_generated["progression"].each do |name, id|
if id >= next_item_id then
@@ -98,7 +82,6 @@ if old_generated.include? "progression" then
end
door_groups = Set[]
panel_groups = Set[]
config = YAML.load_file(configpath)
config.each do |room_name, room_data|
@@ -180,29 +163,6 @@ config.each do |room_name, room_data|
end
end
if room_data.include? "panel_doors"
room_data["panel_doors"].each do |panel_door_name, panel_door|
unless old_generated.include? "panel_doors" and old_generated["panel_doors"].include? room_name and old_generated["panel_doors"][room_name].include? panel_door_name then
old_generated["panel_doors"] ||= {}
old_generated["panel_doors"][room_name] ||= {}
old_generated["panel_doors"][room_name][panel_door_name] = next_item_id
next_item_id += 1
end
if panel_door.include? "panel_group" and not panel_groups.include? panel_door["panel_group"] then
panel_groups.add(panel_door["panel_group"])
unless old_generated.include? "panel_groups" and old_generated["panel_groups"].include? panel_door["panel_group"] then
old_generated["panel_groups"] ||= {}
old_generated["panel_groups"][panel_door["panel_group"]] = next_item_id
next_item_id += 1
end
end
end
end
if room_data.include? "progression"
room_data["progression"].each do |progression_name, pdata|
unless old_generated.include? "progression" and old_generated["progression"].include? progression_name then

View File

@@ -6,8 +6,8 @@ import sys
sys.path.append(os.path.join("worlds", "lingo"))
sys.path.append(".")
sys.path.append("..")
from datatypes import Door, DoorType, EntranceType, Painting, Panel, PanelDoor, Progression, Room, RoomAndDoor,\
RoomAndPanel, RoomAndPanelDoor, RoomEntrance
from datatypes import Door, DoorType, EntranceType, Painting, Panel, Progression, Room, RoomAndDoor, RoomAndPanel,\
RoomEntrance
import hashlib
import pickle
@@ -18,12 +18,10 @@ import Utils
ALL_ROOMS: List[Room] = []
DOORS_BY_ROOM: Dict[str, Dict[str, Door]] = {}
PANELS_BY_ROOM: Dict[str, Dict[str, Panel]] = {}
PANEL_DOORS_BY_ROOM: Dict[str, Dict[str, PanelDoor]] = {}
PAINTINGS: Dict[str, Painting] = {}
PROGRESSIVE_ITEMS: Set[str] = set()
PROGRESSIVE_DOORS_BY_ROOM: Dict[str, Dict[str, Progression]] = {}
PROGRESSIVE_PANELS_BY_ROOM: Dict[str, Dict[str, Progression]] = {}
PROGRESSIVE_ITEMS: List[str] = []
PROGRESSION_BY_ROOM: Dict[str, Dict[str, Progression]] = {}
PAINTING_ENTRANCES: int = 0
PAINTING_EXIT_ROOMS: Set[str] = set()
@@ -39,13 +37,8 @@ PANEL_LOCATION_IDS: Dict[str, Dict[str, int]] = {}
DOOR_LOCATION_IDS: Dict[str, Dict[str, int]] = {}
DOOR_ITEM_IDS: Dict[str, Dict[str, int]] = {}
DOOR_GROUP_ITEM_IDS: Dict[str, int] = {}
PANEL_DOOR_ITEM_IDS: Dict[str, Dict[str, int]] = {}
PANEL_GROUP_ITEM_IDS: Dict[str, int] = {}
PROGRESSIVE_ITEM_IDS: Dict[str, int] = {}
# This doesn't need to be stored in the datafile.
PANEL_DOOR_BY_PANEL_BY_ROOM: Dict[str, Dict[str, str]] = {}
def hash_file(path):
md5 = hashlib.md5()
@@ -60,7 +53,7 @@ def hash_file(path):
def load_static_data(ll1_path, ids_path):
global PAINTING_EXITS, SPECIAL_ITEM_IDS, PANEL_LOCATION_IDS, DOOR_LOCATION_IDS, DOOR_ITEM_IDS, \
DOOR_GROUP_ITEM_IDS, PROGRESSIVE_ITEM_IDS, PANEL_DOOR_ITEM_IDS, PANEL_GROUP_ITEM_IDS
DOOR_GROUP_ITEM_IDS, PROGRESSIVE_ITEM_IDS
# Load in all item and location IDs. These are broken up into groups based on the type of item/location.
with open(ids_path, "r") as file:
@@ -93,17 +86,6 @@ def load_static_data(ll1_path, ids_path):
for item_name, item_id in config["door_groups"].items():
DOOR_GROUP_ITEM_IDS[item_name] = item_id
if "panel_doors" in config:
for room_name, panel_doors in config["panel_doors"].items():
PANEL_DOOR_ITEM_IDS[room_name] = {}
for panel_door, item_id in panel_doors.items():
PANEL_DOOR_ITEM_IDS[room_name][panel_door] = item_id
if "panel_groups" in config:
for item_name, item_id in config["panel_groups"].items():
PANEL_GROUP_ITEM_IDS[item_name] = item_id
if "progression" in config:
for item_name, item_id in config["progression"].items():
PROGRESSIVE_ITEM_IDS[item_name] = item_id
@@ -165,46 +147,6 @@ def process_entrance(source_room, doors, room_obj):
room_obj.entrances.append(RoomEntrance(source_room, door, entrance_type))
def process_panel_door(room_name, panel_door_name, panel_door_data):
global PANEL_DOORS_BY_ROOM, PANEL_DOOR_BY_PANEL_BY_ROOM
panels: List[RoomAndPanel] = list()
for panel in panel_door_data["panels"]:
if isinstance(panel, dict):
panels.append(RoomAndPanel(panel["room"], panel["panel"]))
else:
panels.append(RoomAndPanel(room_name, panel))
for panel in panels:
PANEL_DOOR_BY_PANEL_BY_ROOM.setdefault(panel.room, {})[panel.panel] = RoomAndPanelDoor(room_name,
panel_door_name)
if "item_name" in panel_door_data:
item_name = panel_door_data["item_name"]
else:
panel_per_room = dict()
for panel in panels:
panel_room_name = room_name if panel.room is None else panel.room
panel_per_room.setdefault(panel_room_name, []).append(panel.panel)
room_strs = list()
for door_room_str, door_panels_str in panel_per_room.items():
room_strs.append(door_room_str + " - " + ", ".join(door_panels_str))
if len(panels) == 1:
item_name = f"{room_strs[0]} (Panel)"
else:
item_name = " and ".join(room_strs) + " (Panels)"
if "panel_group" in panel_door_data:
panel_group = panel_door_data["panel_group"]
else:
panel_group = None
panel_door_obj = PanelDoor(item_name, panel_group)
PANEL_DOORS_BY_ROOM[room_name][panel_door_name] = panel_door_obj
def process_panel(room_name, panel_name, panel_data):
global PANELS_BY_ROOM
@@ -285,18 +227,13 @@ def process_panel(room_name, panel_name, panel_data):
else:
non_counting = False
if room_name in PANEL_DOOR_BY_PANEL_BY_ROOM and panel_name in PANEL_DOOR_BY_PANEL_BY_ROOM[room_name]:
panel_door = PANEL_DOOR_BY_PANEL_BY_ROOM[room_name][panel_name]
else:
panel_door = None
if "location_name" in panel_data:
location_name = panel_data["location_name"]
else:
location_name = None
panel_obj = Panel(required_rooms, required_doors, required_panels, colors, check, event, exclude_reduce,
achievement, non_counting, panel_door, location_name)
achievement, non_counting, location_name)
PANELS_BY_ROOM[room_name][panel_name] = panel_obj
@@ -388,7 +325,7 @@ def process_door(room_name, door_name, door_data):
painting_ids = []
door_type = DoorType.NORMAL
if room_name == "Sunwarps":
if door_name.endswith(" Sunwarp"):
door_type = DoorType.SUNWARP
elif room_name == "Pilgrim Antechamber" and door_name == "Sun Painting":
door_type = DoorType.SUN_PAINTING
@@ -467,11 +404,11 @@ def process_sunwarp(room_name, sunwarp_data):
SUNWARP_EXITS[sunwarp_data["dots"] - 1] = room_name
def process_progressive_door(room_name, progression_name, progression_doors):
global PROGRESSIVE_ITEMS, PROGRESSIVE_DOORS_BY_ROOM
def process_progression(room_name, progression_name, progression_doors):
global PROGRESSIVE_ITEMS, PROGRESSION_BY_ROOM
# Progressive items are configured as a list of doors.
PROGRESSIVE_ITEMS.add(progression_name)
PROGRESSIVE_ITEMS.append(progression_name)
progression_index = 1
for door in progression_doors:
@@ -482,31 +419,11 @@ def process_progressive_door(room_name, progression_name, progression_doors):
door_room = room_name
door_door = door
room_progressions = PROGRESSIVE_DOORS_BY_ROOM.setdefault(door_room, {})
room_progressions = PROGRESSION_BY_ROOM.setdefault(door_room, {})
room_progressions[door_door] = Progression(progression_name, progression_index)
progression_index += 1
def process_progressive_panel(room_name, progression_name, progression_panel_doors):
global PROGRESSIVE_ITEMS, PROGRESSIVE_PANELS_BY_ROOM
# Progressive items are configured as a list of panel doors.
PROGRESSIVE_ITEMS.add(progression_name)
progression_index = 1
for panel_door in progression_panel_doors:
if isinstance(panel_door, Dict):
panel_door_room = panel_door["room"]
panel_door_door = panel_door["panel_door"]
else:
panel_door_room = room_name
panel_door_door = panel_door
room_progressions = PROGRESSIVE_PANELS_BY_ROOM.setdefault(panel_door_room, {})
room_progressions[panel_door_door] = Progression(progression_name, progression_index)
progression_index += 1
def process_room(room_name, room_data):
global ALL_ROOMS
@@ -516,12 +433,6 @@ def process_room(room_name, room_data):
for source_room, doors in room_data["entrances"].items():
process_entrance(source_room, doors, room_obj)
if "panel_doors" in room_data:
PANEL_DOORS_BY_ROOM[room_name] = dict()
for panel_door_name, panel_door_data in room_data["panel_doors"].items():
process_panel_door(room_name, panel_door_name, panel_door_data)
if "panels" in room_data:
PANELS_BY_ROOM[room_name] = dict()
@@ -543,11 +454,8 @@ def process_room(room_name, room_data):
process_sunwarp(room_name, sunwarp_data)
if "progression" in room_data:
for progression_name, pdata in room_data["progression"].items():
if "doors" in pdata:
process_progressive_door(room_name, progression_name, pdata["doors"])
if "panel_doors" in pdata:
process_progressive_panel(room_name, progression_name, pdata["panel_doors"])
for progression_name, progression_doors in room_data["progression"].items():
process_progression(room_name, progression_name, progression_doors)
ALL_ROOMS.append(room_obj)
@@ -584,10 +492,8 @@ if __name__ == '__main__':
"ALL_ROOMS": ALL_ROOMS,
"DOORS_BY_ROOM": DOORS_BY_ROOM,
"PANELS_BY_ROOM": PANELS_BY_ROOM,
"PANEL_DOORS_BY_ROOM": PANEL_DOORS_BY_ROOM,
"PROGRESSIVE_ITEMS": PROGRESSIVE_ITEMS,
"PROGRESSIVE_DOORS_BY_ROOM": PROGRESSIVE_DOORS_BY_ROOM,
"PROGRESSIVE_PANELS_BY_ROOM": PROGRESSIVE_PANELS_BY_ROOM,
"PROGRESSION_BY_ROOM": PROGRESSION_BY_ROOM,
"PAINTING_ENTRANCES": PAINTING_ENTRANCES,
"PAINTING_EXIT_ROOMS": PAINTING_EXIT_ROOMS,
"PAINTING_EXITS": PAINTING_EXITS,
@@ -600,8 +506,6 @@ if __name__ == '__main__':
"DOOR_LOCATION_IDS": DOOR_LOCATION_IDS,
"DOOR_ITEM_IDS": DOOR_ITEM_IDS,
"DOOR_GROUP_ITEM_IDS": DOOR_GROUP_ITEM_IDS,
"PANEL_DOOR_ITEM_IDS": PANEL_DOOR_ITEM_IDS,
"PANEL_GROUP_ITEM_IDS": PANEL_GROUP_ITEM_IDS,
"PROGRESSIVE_ITEM_IDS": PROGRESSIVE_ITEM_IDS,
}

View File

@@ -33,23 +33,19 @@ end
configured_rooms = Set["Menu"]
configured_doors = Set[]
configured_panels = Set[]
configured_panel_doors = Set[]
mentioned_rooms = Set[]
mentioned_doors = Set[]
mentioned_panels = Set[]
mentioned_panel_doors = Set[]
mentioned_sunwarp_entrances = Set[]
mentioned_sunwarp_exits = Set[]
mentioned_paintings = Set[]
door_groups = {}
panel_groups = {}
directives = Set["entrances", "panels", "doors", "panel_doors", "paintings", "sunwarps", "progression"]
directives = Set["entrances", "panels", "doors", "paintings", "sunwarps", "progression"]
panel_directives = Set["id", "required_room", "required_door", "required_panel", "colors", "check", "exclude_reduce", "tag", "link", "subtag", "achievement", "copy_to_sign", "non_counting", "hunt", "location_name"]
door_directives = Set["id", "painting_id", "panels", "item_name", "item_group", "location_name", "skip_location", "skip_item", "door_group", "include_reduce", "event", "warp_id"]
panel_door_directives = Set["panels", "item_name", "panel_group"]
painting_directives = Set["id", "enter_only", "exit_only", "orientation", "required_door", "required", "required_when_no_doors", "move", "req_blocked", "req_blocked_when_no_doors"]
non_counting = 0
@@ -257,43 +253,6 @@ config.each do |room_name, room|
end
end
(room["panel_doors"] || {}).each do |panel_door_name, panel_door|
configured_panel_doors.add("#{room_name} - #{panel_door_name}")
if panel_door.include?("panels")
panel_door["panels"].each do |panel|
if panel.kind_of? Hash then
other_room = panel.include?("room") ? panel["room"] : room_name
mentioned_panels.add("#{other_room} - #{panel["panel"]}")
else
other_room = panel.include?("room") ? panel["room"] : room_name
mentioned_panels.add("#{room_name} - #{panel}")
end
end
else
puts "#{room_name} - #{panel_door_name} :::: Missing panels field"
end
if panel_door.include?("panel_group")
panel_groups[panel_door["panel_group"]] ||= 0
panel_groups[panel_door["panel_group"]] += 1
end
bad_subdirectives = []
panel_door.keys.each do |key|
unless panel_door_directives.include?(key) then
bad_subdirectives << key
end
end
unless bad_subdirectives.empty? then
puts "#{room_name} - #{panel_door_name} :::: Panel door has the following invalid subdirectives: #{bad_subdirectives.join(", ")}"
end
unless ids.include?("panel_doors") and ids["panel_doors"].include?(room_name) and ids["panel_doors"][room_name].include?(panel_door_name)
puts "#{room_name} - #{panel_door_name} :::: Panel door is missing an item ID"
end
end
(room["paintings"] || []).each do |painting|
if painting.include?("id") and painting["id"].kind_of? String then
unless paintings.include? painting["id"] then
@@ -368,24 +327,12 @@ config.each do |room_name, room|
end
end
(room["progression"] || {}).each do |progression_name, pdata|
if pdata.include? "doors" then
pdata["doors"].each do |door|
if door.kind_of? Hash then
mentioned_doors.add("#{door["room"]} - #{door["door"]}")
else
mentioned_doors.add("#{room_name} - #{door}")
end
end
end
if pdata.include? "panel_doors" then
pdata["panel_doors"].each do |panel_door|
if panel_door.kind_of? Hash then
mentioned_panel_doors.add("#{panel_door["room"]} - #{panel_door["panel_door"]}")
else
mentioned_panel_doors.add("#{room_name} - #{panel_door}")
end
(room["progression"] || {}).each do |progression_name, door_list|
door_list.each do |door|
if door.kind_of? Hash then
mentioned_doors.add("#{door["room"]} - #{door["door"]}")
else
mentioned_doors.add("#{room_name} - #{door}")
end
end
@@ -397,22 +344,17 @@ end
errored_rooms = mentioned_rooms - configured_rooms
unless errored_rooms.empty? then
puts "The following rooms are mentioned but do not exist: " + errored_rooms.to_s
puts "The folloring rooms are mentioned but do not exist: " + errored_rooms.to_s
end
errored_panels = mentioned_panels - configured_panels
unless errored_panels.empty? then
puts "The following panels are mentioned but do not exist: " + errored_panels.to_s
puts "The folloring panels are mentioned but do not exist: " + errored_panels.to_s
end
errored_doors = mentioned_doors - configured_doors
unless errored_doors.empty? then
puts "The following doors are mentioned but do not exist: " + errored_doors.to_s
end
errored_panel_doors = mentioned_panel_doors - configured_panel_doors
unless errored_panel_doors.empty? then
puts "The following panel doors are mentioned but do not exist: " + errored_panel_doors.to_s
puts "The folloring doors are mentioned but do not exist: " + errored_doors.to_s
end
door_groups.each do |group,num|
@@ -425,16 +367,6 @@ door_groups.each do |group,num|
end
end
panel_groups.each do |group,num|
if num == 1 then
puts "Panel group \"#{group}\" only has one panel in it"
end
unless ids.include?("panel_groups") and ids["panel_groups"].include?(group)
puts "#{group} :::: Panel group is missing an item ID"
end
end
slashed_rooms = configured_rooms.select do |room|
room.include? "/"
end

Binary file not shown.

View File

@@ -52,17 +52,8 @@ class PokemonEmeraldWebWorld(WebWorld):
"setup/es",
["nachocua"]
)
setup_sv = Tutorial(
"Multivärld Installations Guide",
"En guide för att kunna spela Pokémon Emerald med Archipelago.",
"Svenska",
"setup_sv.md",
"setup/sv",
["Tsukino"]
)
tutorials = [setup_en, setup_es, setup_sv]
tutorials = [setup_en, setup_es]
class PokemonEmeraldSettings(settings.Group):

View File

@@ -1,78 +0,0 @@
# Pokémon Emerald Installationsguide
## Programvara som behövs
- [Archipelago](https://github.com/ArchipelagoMW/Archipelago/releases)
- Ett engelskt Pokémon Emerald ROM, Archipelago kan inte hjälpa dig med detta.
- [BizHawk](https://tasvideos.org/BizHawk/ReleaseHistory) 2.7 eller senare
### Konfigurera BizHawk
När du har installerat BizHawk, öppna `EmuHawk.exe` och ändra följande inställningar:
- Om du använder BizHawk 2.7 eller 2.8, gå till `Config > Customize`. På "Advanced Tab", byt Lua core från
`NLua+KopiLua` till `Lua+LuaInterface`, starta om EmuHawk efteråt. (Använder du BizHawk 2.9, kan du skippa detta steg.)
- Gå till `Config > Customize`. Markera "Run in background" inställningen för att förhindra bortkoppling från
klienten om du alt-tabbar bort från EmuHawk.
- Öppna en `.gba` fil i EmuHawk och gå till `Config > Controllers…` för att konfigurera dina inputs.
Om du inte hittar `Controllers…`, starta ett valfritt `.gba` ROM först.
- Överväg att rensa keybinds i `Config > Hotkeys…` som du inte tänkt använda. Välj en keybind och tryck på ESC
för att rensa bort den.
## Extra programvara
- [Pokémon Emerald AP Tracker](https://github.com/seto10987/Archipelago-Emerald-AP-Tracker/releases/latest),
används tillsammans med
[PopTracker](https://github.com/black-sliver/PopTracker/releases)
## Generera och patcha ett spel
1. Skapa din konfigurationsfil (YAML). Du kan göra en via att använda
[Pokémon Emerald options hemsida](../../../games/Pokemon%20Emerald/player-options).
2. Följ de allmänna Archipelago instruktionerna för att
[Generera ett spel](../../Archipelago/setup/en#generating-a-game).
Detta kommer generera en fil för dig. Din patchfil kommer ha `.apemerald` som sitt filnamnstillägg.
3. Öppna `ArchipelagoLauncher.exe`
4. Välj "Open Patch" på vänstra sidan, och välj din patchfil.
5. Om detta är första gången du patchar, så kommer du behöva välja var ditt ursprungliga ROM är.
6. En patchad `.gba` fil kommer skapas på samma plats som patchfilen.
7. Första gången du öppnar en patch med BizHawk-klienten, kommer du också behöva bekräfta var `EmuHawk.exe` filen är
installerad i din BizHawk-mapp.
Om du bara tänkt spela själv och du inte bryr dig om automatisk spårning eller ledtrådar, så kan du stanna här, stänga
av klienten, och starta ditt patchade ROM med valfri emulator. Dock, för multvärldsfunktionen eller andra
Archipelago-funktioner, fortsätt nedanför med BizHawk.
## Anslut till en server
Om du vanligtsvis öppnar en patchad fil så görs steg 1-5 automatiskt åt dig. Även om det är så, kom ihåg dessa steg
ifall du till exempel behöver stänga ner och starta om något medans du spelar.
1. Pokemon Emerald använder Archipelagos BizHawk-klient. Om klienten inte startat efter att du patchat ditt spel,
så kan du bara öppna den igen från launchern.
2. Dubbelkolla att EmuHawk faktiskt startat med den patchade ROM-filen.
3. I EmuHawk, gå till `Tools > Lua Console`. Luakonsolen måste vara igång medans du spelar.
4. I Luakonsolen, Tryck på `Script > Open Script…`.
5. Leta reda på din Archipelago-mapp och i den öppna `data/lua/connector_bizhawk_generic.lua`.
6. Emulatorn och klienten kommer så småningom ansluta till varandra. I BizHawk-klienten kommer du kunna see om allt är
anslutet och att Pokemon Emerald är igenkänt.
7. För att ansluta klienten till en server, skriv in din lobbyadress och port i textfältet t.ex.
`archipelago.gg:38281`
längst upp i din klient och tryck sen på "Connect".
Du borde nu kunna ta emot och skicka föremål. Du behöver göra dom här stegen varje gång du vill ansluta igen. Det är
helt okej att göra saker offline utan att behöva oroa sig; allt kommer att synkronisera när du ansluter till servern
igen.
## Automatisk Spårning
Pokémon Emerald har en fullt fungerande spårare med stöd för automatisk spårning.
1. Ladda ner [Pokémon Emerald AP Tracker](https://github.com/seto10987/Archipelago-Emerald-AP-Tracker/releases/latest)
och
[PopTracker](https://github.com/black-sliver/PopTracker/releases).
2. Placera tracker pack zip-filen i packs/ där du har PopTracker installerat.
3. Öppna PopTracker, och välj Pokemon Emerald.
4. För att automatiskt spåra, tryck på "AP" symbolen längst upp.
5. Skriv in Archipelago-serverns uppgifter (Samma som du använde för att ansluta med klienten), "Slot"-namn samt
lösenord.

View File

@@ -558,10 +558,6 @@ def set_rules(world: "PokemonEmeraldWorld") -> None:
get_location("NPC_GIFT_GOT_BASEMENT_KEY_FROM_WATTSON"),
lambda state: state.has("EVENT_DEFEAT_NORMAN", world.player)
)
set_rule(
get_location("NPC_GIFT_RECEIVED_COIN_CASE"),
lambda state: state.has("EVENT_BUY_HARBOR_MAIL", world.player)
)
# Route 117
set_rule(
@@ -1642,6 +1638,10 @@ def set_rules(world: "PokemonEmeraldWorld") -> None:
get_location("NPC_GIFT_GOT_TM_THUNDERBOLT_FROM_WATTSON"),
lambda state: state.has("EVENT_DEFEAT_NORMAN", world.player) and state.has("EVENT_TURN_OFF_GENERATOR", world.player)
)
set_rule(
get_location("NPC_GIFT_RECEIVED_COIN_CASE"),
lambda state: state.has("EVENT_BUY_HARBOR_MAIL", world.player)
)
# Fallarbor Town
set_rule(

View File

@@ -427,7 +427,7 @@ location_data = [
LocationData("Seafoam Islands B3F", "Hidden Item Rock", "Max Elixir", rom_addresses['Hidden_Item_Seafoam_Islands_B3F'], Hidden(50), inclusion=hidden_items),
LocationData("Vermilion City", "Hidden Item In Water Near Fan Club", "Max Ether", rom_addresses['Hidden_Item_Vermilion_City'], Hidden(51), inclusion=hidden_items),
LocationData("Cerulean City-Badge House Backyard", "Hidden Item Gym Badge Guy's Backyard", "Rare Candy", rom_addresses['Hidden_Item_Cerulean_City'], Hidden(52), inclusion=hidden_items),
LocationData("Route 4-C", "Hidden Item Plateau East Of Mt Moon", "Great Ball", rom_addresses['Hidden_Item_Route_4'], Hidden(53), inclusion=hidden_items),
LocationData("Route 4-E", "Hidden Item Plateau East Of Mt Moon", "Great Ball", rom_addresses['Hidden_Item_Route_4'], Hidden(53), inclusion=hidden_items),
LocationData("Oak's Lab", "Oak's Parcel Reward", "Pokedex", rom_addresses["Event_Pokedex"], EventFlag(0x38)),

View File

@@ -1,5 +1,4 @@
from dataclasses import dataclass
from Options import Range, Toggle, DefaultOnToggle, Choice, DeathLink, PerGameCommonOptions
from Options import Range, Toggle, DefaultOnToggle, Choice, DeathLink
class MinimumResourcePackAmount(Range):
"""The minimum amount of resources available in a resource pack"""
@@ -48,8 +47,6 @@ class IslandFrequencyLocations(Choice):
option_progressive = 4
option_anywhere = 5
default = 2
def is_filling_frequencies_in_world(self):
return self.value <= self.option_random_on_island_random_order
class IslandGenerationDistance(Choice):
"""Sets how far away islands spawn from you when you input their coordinates into the Receiver."""
@@ -79,16 +76,16 @@ class PaddleboardMode(Toggle):
"""Sets later story islands to be in logic without an Engine or Steering Wheel. May require lots of paddling."""
display_name = "Paddleboard Mode"
@dataclass
class RaftOptions(PerGameCommonOptions):
minimum_resource_pack_amount: MinimumResourcePackAmount
maximum_resource_pack_amount: MaximumResourcePackAmount
duplicate_items: DuplicateItems
filler_item_types: FillerItemTypes
island_frequency_locations: IslandFrequencyLocations
island_generation_distance: IslandGenerationDistance
expensive_research: ExpensiveResearch
progressive_items: ProgressiveItems
big_island_early_crafting: BigIslandEarlyCrafting
paddleboard_mode: PaddleboardMode
death_link: DeathLink
raft_options = {
"minimum_resource_pack_amount": MinimumResourcePackAmount,
"maximum_resource_pack_amount": MaximumResourcePackAmount,
"duplicate_items": DuplicateItems,
"filler_item_types": FillerItemTypes,
"island_frequency_locations": IslandFrequencyLocations,
"island_generation_distance": IslandGenerationDistance,
"expensive_research": ExpensiveResearch,
"progressive_items": ProgressiveItems,
"big_island_early_crafting": BigIslandEarlyCrafting,
"paddleboard_mode": PaddleboardMode,
"death_link": DeathLink
}

View File

@@ -5,10 +5,10 @@ from ..AutoWorld import LogicMixin
class RaftLogic(LogicMixin):
def raft_paddleboard_mode_enabled(self, player):
return bool(self.multiworld.worlds[player].options.paddleboard_mode)
return self.multiworld.paddleboard_mode[player].value
def raft_big_islands_available(self, player):
return bool(self.multiworld.worlds[player].options.big_island_early_crafting) or self.raft_can_access_radio_tower(player)
return self.multiworld.big_island_early_crafting[player].value or self.raft_can_access_radio_tower(player)
def raft_can_smelt_items(self, player):
return self.has("Smelter", player)

View File

@@ -6,7 +6,7 @@ from .Items import (createResourcePackName, item_table, progressive_table, progr
from .Regions import create_regions, getConnectionName
from .Rules import set_rules
from .Options import RaftOptions
from .Options import raft_options
from BaseClasses import Region, Entrance, Location, MultiWorld, Item, ItemClassification, Tutorial
from ..AutoWorld import World, WebWorld
@@ -37,17 +37,16 @@ class RaftWorld(World):
lastItemId = max(filter(lambda val: val is not None, item_name_to_id.values()))
location_name_to_id = locations_lookup_name_to_id
options_dataclass = RaftOptions
options: RaftOptions
option_definitions = raft_options
required_client_version = (0, 3, 4)
def create_items(self):
minRPSpecified = self.options.minimum_resource_pack_amount.value
maxRPSpecified = self.options.maximum_resource_pack_amount.value
minRPSpecified = self.multiworld.minimum_resource_pack_amount[self.player].value
maxRPSpecified = self.multiworld.maximum_resource_pack_amount[self.player].value
minimumResourcePackAmount = min(minRPSpecified, maxRPSpecified)
maximumResourcePackAmount = max(minRPSpecified, maxRPSpecified)
isFillingFrequencies = self.options.island_frequency_locations.is_filling_frequencies_in_world()
isFillingFrequencies = self.multiworld.island_frequency_locations[self.player].value <= 3
# Generate item pool
pool = []
frequencyItems = []
@@ -65,20 +64,20 @@ class RaftWorld(World):
extraItemNamePool = []
extras = len(location_table) - len(item_table) - 1 # Victory takes up 1 unaccounted-for slot
if extras > 0:
if (self.options.filler_item_types != self.options.filler_item_types.option_duplicates): # Use resource packs
if (self.multiworld.filler_item_types[self.player].value != 1): # Use resource packs
for packItem in resourcePackItems:
for i in range(minimumResourcePackAmount, maximumResourcePackAmount + 1):
extraItemNamePool.append(createResourcePackName(i, packItem))
if self.options.filler_item_types != self.options.filler_item_types.option_resource_packs: # Use duplicate items
if self.multiworld.filler_item_types[self.player].value != 0: # Use duplicate items
dupeItemPool = item_table.copy()
# Remove frequencies if necessary
if self.options.island_frequency_locations != self.options.island_frequency_locations.option_anywhere: # Not completely random locations
if self.multiworld.island_frequency_locations[self.player].value != 5: # Not completely random locations
# If we let frequencies stay in with progressive-frequencies, the progressive-frequency item
# will be included 7 times. This is a massive flood of progressive-frequency items, so we
# instead add progressive-frequency as its own item a smaller amount of times to prevent
# flooding the duplicate item pool with them.
if self.options.island_frequency_locations == self.options.island_frequency_locations.option_progressive:
if self.multiworld.island_frequency_locations[self.player].value == 4:
for _ in range(2):
# Progressives are not in item_pool, need to create faux item for duplicate item pool
# This can still be filtered out later by duplicate_items setting
@@ -87,9 +86,9 @@ class RaftWorld(World):
dupeItemPool = (itm for itm in dupeItemPool if "Frequency" not in itm["name"])
# Remove progression or non-progression items if necessary
if (self.options.duplicate_items == self.options.duplicate_items.option_progression): # Progression only
if (self.multiworld.duplicate_items[self.player].value == 0): # Progression only
dupeItemPool = (itm for itm in dupeItemPool if itm["progression"] == True)
elif (self.options.duplicate_items == self.options.duplicate_items.option_non_progression): # Non-progression only
elif (self.multiworld.duplicate_items[self.player].value == 1): # Non-progression only
dupeItemPool = (itm for itm in dupeItemPool if itm["progression"] == False)
dupeItemPool = list(dupeItemPool)
@@ -116,14 +115,14 @@ class RaftWorld(World):
create_regions(self.multiworld, self.player)
def get_pre_fill_items(self):
if self.options.island_frequency_locations.is_filling_frequencies_in_world():
if self.multiworld.island_frequency_locations[self.player] in [0, 1, 2, 3]:
return [loc.item for loc in self.multiworld.get_filled_locations()]
return []
def create_item_replaceAsNecessary(self, name: str) -> Item:
isFrequency = "Frequency" in name
shouldUseProgressive = bool((isFrequency and self.options.island_frequency_locations == self.options.island_frequency_locations.option_progressive)
or (not isFrequency and self.options.progressive_items))
shouldUseProgressive = ((isFrequency and self.multiworld.island_frequency_locations[self.player].value == 4)
or (not isFrequency and self.multiworld.progressive_items[self.player].value))
if shouldUseProgressive and name in progressive_table:
name = progressive_table[name]
return self.create_item(name)
@@ -153,7 +152,7 @@ class RaftWorld(World):
return super(RaftWorld, self).collect_item(state, item, remove)
def pre_fill(self):
if self.options.island_frequency_locations == self.options.island_frequency_locations.option_vanilla:
if self.multiworld.island_frequency_locations[self.player] == 0: # Vanilla
self.setLocationItem("Radio Tower Frequency to Vasagatan", "Vasagatan Frequency")
self.setLocationItem("Vasagatan Frequency to Balboa", "Balboa Island Frequency")
self.setLocationItem("Relay Station quest", "Caravan Island Frequency")
@@ -161,7 +160,7 @@ class RaftWorld(World):
self.setLocationItem("Tangaroa Frequency to Varuna Point", "Varuna Point Frequency")
self.setLocationItem("Varuna Point Frequency to Temperance", "Temperance Frequency")
self.setLocationItem("Temperance Frequency to Utopia", "Utopia Frequency")
elif self.options.island_frequency_locations == self.options.island_frequency_locations.option_random_on_island:
elif self.multiworld.island_frequency_locations[self.player] == 1: # Random on island
self.setLocationItemFromRegion("RadioTower", "Vasagatan Frequency")
self.setLocationItemFromRegion("Vasagatan", "Balboa Island Frequency")
self.setLocationItemFromRegion("BalboaIsland", "Caravan Island Frequency")
@@ -169,10 +168,7 @@ class RaftWorld(World):
self.setLocationItemFromRegion("Tangaroa", "Varuna Point Frequency")
self.setLocationItemFromRegion("Varuna Point", "Temperance Frequency")
self.setLocationItemFromRegion("Temperance", "Utopia Frequency")
elif self.options.island_frequency_locations in [
self.options.island_frequency_locations.option_random_island_order,
self.options.island_frequency_locations.option_random_on_island_random_order
]:
elif self.multiworld.island_frequency_locations[self.player] in [2, 3]:
locationToFrequencyItemMap = {
"Vasagatan": "Vasagatan Frequency",
"BalboaIsland": "Balboa Island Frequency",
@@ -200,9 +196,9 @@ class RaftWorld(World):
else:
currentLocation = availableLocationList[0] # Utopia (only one left in list)
availableLocationList.remove(currentLocation)
if self.options.island_frequency_locations == self.options.island_frequency_locations.option_random_island_order:
if self.multiworld.island_frequency_locations[self.player] == 2: # Random island order
self.setLocationItem(locationToVanillaFrequencyLocationMap[previousLocation], locationToFrequencyItemMap[currentLocation])
elif self.options.island_frequency_locations == self.options.island_frequency_locations.option_random_on_island_random_order:
elif self.multiworld.island_frequency_locations[self.player] == 3: # Random on island random order
self.setLocationItemFromRegion(previousLocation, locationToFrequencyItemMap[currentLocation])
previousLocation = currentLocation
@@ -219,9 +215,9 @@ class RaftWorld(World):
def fill_slot_data(self):
return {
"IslandGenerationDistance": self.options.island_generation_distance.value,
"ExpensiveResearch": bool(self.options.expensive_research),
"DeathLink": bool(self.options.death_link)
"IslandGenerationDistance": self.multiworld.island_generation_distance[self.player].value,
"ExpensiveResearch": bool(self.multiworld.expensive_research[self.player].value),
"DeathLink": bool(self.multiworld.death_link[self.player].value)
}
def create_region(world: MultiWorld, player: int, name: str, locations=None, exits=None):

View File

@@ -51,7 +51,7 @@ for item, data in Items.get_full_item_list().items():
item_name_groups.setdefault(data.type, []).append(item)
# Numbered flaggroups get sorted into an unnumbered group
# Currently supports numbers of one or two digits
if data.type[-2:].strip().isnumeric():
if data.type[-2:].strip().isnumeric:
type_group = data.type[:-2].strip()
item_name_groups.setdefault(type_group, []).append(item)
# Flaggroups with numbers are unlisted

View File

@@ -328,7 +328,7 @@ location_table: List[LocationInfo] = [
{"name": "Boat Rental",
"id": base_id + 55,
"inGameId": "DadDeer[0]",
"needsShovel": False, "purchase": 100,
"needsShovel": False, "purchase": True,
"minGoldenFeathers": 0, "minGoldenFeathersEasy": 0, "minGoldenFeathersBucket": 0},
{"name": "Boat Challenge Reward",
"id": base_id + 56,

View File

@@ -1,14 +1,12 @@
import logging
from random import Random
from typing import Dict, Any, Iterable, Optional, Union, List, TextIO
from BaseClasses import Region, Entrance, Location, Item, Tutorial, ItemClassification, MultiWorld, CollectionState
from BaseClasses import Region, Entrance, Location, Item, Tutorial, ItemClassification, MultiWorld
from Options import PerGameCommonOptions
from worlds.AutoWorld import World, WebWorld
from . import rules
from .bundles.bundle_room import BundleRoom
from .bundles.bundles import get_all_bundles
from .content import content_packs, StardewContent, unpack_content, create_content
from .early_items import setup_early_items
from .items import item_table, create_items, ItemData, Group, items_by_group, get_all_filler_items, remove_limited_amount_packs
from .locations import location_table, create_locations, LocationData, locations_by_tag
@@ -16,32 +14,26 @@ from .logic.bundle_logic import BundleLogic
from .logic.logic import StardewLogic
from .logic.time_logic import MAX_MONTHS
from .option_groups import sv_option_groups
from .options import StardewValleyOptions, SeasonRandomization, Goal, BundleRandomization, BundlePrice, EnabledFillerBuffs, NumberOfMovementBuffs, \
BackpackProgression, BuildingProgression, ExcludeGingerIsland, TrapItems, EntranceRandomization, FarmType, Walnutsanity
from .options import StardewValleyOptions, SeasonRandomization, Goal, BundleRandomization, BundlePrice, NumberOfLuckBuffs, NumberOfMovementBuffs, \
BackpackProgression, BuildingProgression, ExcludeGingerIsland, TrapItems, EntranceRandomization
from .presets import sv_options_presets
from .regions import create_regions
from .rules import set_rules
from .stardew_rule import True_, StardewRule, HasProgressionPercent, true_
from .stardew_rule import True_, StardewRule, HasProgressionPercent
from .strings.ap_names.event_names import Event
from .strings.entrance_names import Entrance as EntranceName
from .strings.goal_names import Goal as GoalName
from .strings.metal_names import Ore
from .strings.region_names import Region as RegionName, LogicRegion
logger = logging.getLogger(__name__)
STARDEW_VALLEY = "Stardew Valley"
UNIVERSAL_TRACKER_SEED_PROPERTY = "ut_seed"
from .strings.region_names import Region as RegionName
client_version = 0
class StardewLocation(Location):
game: str = STARDEW_VALLEY
game: str = "Stardew Valley"
class StardewItem(Item):
game: str = STARDEW_VALLEY
game: str = "Stardew Valley"
class StardewWebWorld(WebWorld):
@@ -66,7 +58,7 @@ class StardewValleyWorld(World):
Stardew Valley is an open-ended country-life RPG. You can farm, fish, mine, fight, complete quests,
befriend villagers, and uncover dark secrets.
"""
game = STARDEW_VALLEY
game = "Stardew Valley"
topology_present = False
item_name_to_id = {name: data.code for name, data in item_table.items()}
@@ -85,7 +77,6 @@ class StardewValleyWorld(World):
options_dataclass = StardewValleyOptions
options: StardewValleyOptions
content: StardewContent
logic: StardewLogic
web = StardewWebWorld()
@@ -101,20 +92,8 @@ class StardewValleyWorld(World):
self.total_progression_items = 0
# self.all_progression_items = dict()
# Taking the seed specified in slot data for UT, otherwise just generating the seed.
self.seed = getattr(multiworld, "re_gen_passthrough", {}).get(STARDEW_VALLEY, self.random.getrandbits(64))
self.random = Random(self.seed)
def interpret_slot_data(self, slot_data: Dict[str, Any]) -> Optional[int]:
# If the seed is not specified in the slot data, this mean the world was generated before Universal Tracker support.
seed = slot_data.get(UNIVERSAL_TRACKER_SEED_PROPERTY)
if seed is None:
logger.warning(f"World was generated before Universal Tracker support. Tracker might not be accurate.")
return seed
def generate_early(self):
self.force_change_options_if_incompatible()
self.content = create_content(self.options)
def force_change_options_if_incompatible(self):
goal_is_walnut_hunter = self.options.goal == Goal.option_greatest_walnut_hunter
@@ -125,13 +104,8 @@ class StardewValleyWorld(World):
self.options.exclude_ginger_island.value = ExcludeGingerIsland.option_false
goal_name = self.options.goal.current_key
player_name = self.multiworld.player_name[self.player]
logger.warning(
logging.warning(
f"Goal '{goal_name}' requires Ginger Island. Exclude Ginger Island setting forced to 'False' for player {self.player} ({player_name})")
if exclude_ginger_island and self.options.walnutsanity != Walnutsanity.preset_none:
self.options.walnutsanity.value = Walnutsanity.preset_none
player_name = self.multiworld.player_name[self.player]
logger.warning(
f"Walnutsanity requires Ginger Island. Ginger Island was excluded from {self.player} ({player_name})'s world, so walnutsanity was force disabled")
def create_regions(self):
def create_region(name: str, exits: Iterable[str]) -> Region:
@@ -141,10 +115,9 @@ class StardewValleyWorld(World):
world_regions, world_entrances, self.randomized_entrances = create_regions(create_region, self.random, self.options)
self.logic = StardewLogic(self.player, self.options, self.content, world_regions.keys())
self.logic = StardewLogic(self.player, self.options, world_regions.keys())
self.modified_bundles = get_all_bundles(self.random,
self.logic,
self.content,
self.options)
def add_location(name: str, code: Optional[int], region: str):
@@ -152,12 +125,11 @@ class StardewValleyWorld(World):
location = StardewLocation(self.player, name, code, region)
region.locations.append(location)
create_locations(add_location, self.modified_bundles, self.options, self.content, self.random)
create_locations(add_location, self.modified_bundles, self.options, self.random)
self.multiworld.regions.extend(world_regions.values())
def create_items(self):
self.precollect_starting_season()
self.precollect_farm_type_items()
items_to_exclude = [excluded_items
for excluded_items in self.multiworld.precollected_items[self.player]
if not item_table[excluded_items.name].has_any_group(Group.RESOURCE_PACK,
@@ -171,7 +143,7 @@ class StardewValleyWorld(World):
for location in self.multiworld.get_locations(self.player)
if location.address is not None])
created_items = create_items(self.create_item, self.delete_item, locations_count, items_to_exclude, self.options, self.content,
created_items = create_items(self.create_item, self.delete_item, locations_count, items_to_exclude, self.options,
self.random)
self.multiworld.itempool += created_items
@@ -201,15 +173,10 @@ class StardewValleyWorld(World):
starting_season = self.create_starting_item(self.random.choice(season_pool))
self.multiworld.push_precollected(starting_season)
def precollect_farm_type_items(self):
if self.options.farm_type == FarmType.option_meadowlands and self.options.building_progression & BuildingProgression.option_progressive:
self.multiworld.push_precollected(self.create_starting_item("Progressive Coop"))
def setup_player_events(self):
self.setup_construction_events()
self.setup_quest_events()
self.setup_action_events()
self.setup_logic_events()
def setup_construction_events(self):
can_construct_buildings = LocationData(None, RegionName.carpenter, Event.can_construct_buildings)
@@ -220,26 +187,10 @@ class StardewValleyWorld(World):
self.create_event_location(start_dark_talisman_quest, self.logic.wallet.has_rusty_key(), Event.start_dark_talisman_quest)
def setup_action_events(self):
can_ship_event = LocationData(None, LogicRegion.shipping, Event.can_ship_items)
self.create_event_location(can_ship_event, true_, Event.can_ship_items)
can_ship_event = LocationData(None, RegionName.shipping, Event.can_ship_items)
self.create_event_location(can_ship_event, True_(), Event.can_ship_items)
can_shop_pierre_event = LocationData(None, RegionName.pierre_store, Event.can_shop_at_pierre)
self.create_event_location(can_shop_pierre_event, true_, Event.can_shop_at_pierre)
spring_farming = LocationData(None, LogicRegion.spring_farming, Event.spring_farming)
self.create_event_location(spring_farming, true_, Event.spring_farming)
summer_farming = LocationData(None, LogicRegion.summer_farming, Event.summer_farming)
self.create_event_location(summer_farming, true_, Event.summer_farming)
fall_farming = LocationData(None, LogicRegion.fall_farming, Event.fall_farming)
self.create_event_location(fall_farming, true_, Event.fall_farming)
winter_farming = LocationData(None, LogicRegion.winter_farming, Event.winter_farming)
self.create_event_location(winter_farming, true_, Event.winter_farming)
def setup_logic_events(self):
def register_event(name: str, region: str, rule: StardewRule):
event_location = LocationData(None, region, name)
self.create_event_location(event_location, rule, name)
self.logic.setup_events(register_event)
self.create_event_location(can_shop_pierre_event, True_(), Event.can_shop_at_pierre)
def setup_victory(self):
if self.options.goal == Goal.option_community_center:
@@ -260,7 +211,7 @@ class StardewValleyWorld(World):
Event.victory)
elif self.options.goal == Goal.option_master_angler:
self.create_event_location(location_table[GoalName.master_angler],
self.logic.fishing.can_catch_every_fish_for_fishsanity(),
self.logic.fishing.can_catch_every_fish_in_slot(self.get_all_location_names()),
Event.victory)
elif self.options.goal == Goal.option_complete_collection:
self.create_event_location(location_table[GoalName.complete_museum],
@@ -272,7 +223,7 @@ class StardewValleyWorld(World):
Event.victory)
elif self.options.goal == Goal.option_greatest_walnut_hunter:
self.create_event_location(location_table[GoalName.greatest_walnut_hunter],
self.logic.walnut.has_walnut(130),
self.logic.has_walnut(130),
Event.victory)
elif self.options.goal == Goal.option_protector_of_the_valley:
self.create_event_location(location_table[GoalName.protector_of_the_valley],
@@ -319,13 +270,18 @@ class StardewValleyWorld(World):
if override_classification is None:
override_classification = item.classification
if override_classification == ItemClassification.progression:
if override_classification == ItemClassification.progression and item.name != Event.victory:
self.total_progression_items += 1
# if item.name not in self.all_progression_items:
# self.all_progression_items[item.name] = 0
# self.all_progression_items[item.name] += 1
return StardewItem(item.name, override_classification, item.code, self.player)
def delete_item(self, item: Item):
if item.classification & ItemClassification.progression:
self.total_progression_items -= 1
# if item.name in self.all_progression_items:
# self.all_progression_items[item.name] -= 1
def create_starting_item(self, item: Union[str, ItemData]) -> StardewItem:
if isinstance(item, str):
@@ -343,11 +299,7 @@ class StardewValleyWorld(World):
location = StardewLocation(self.player, location_data.name, None, region)
location.access_rule = rule
region.locations.append(location)
location.place_locked_item(StardewItem(item, ItemClassification.progression, None, self.player))
# This is not ideal, but the rule count them so...
if item != Event.victory:
self.total_progression_items += 1
location.place_locked_item(self.create_item(item))
def set_rules(self):
set_rules(self)
@@ -406,7 +358,7 @@ class StardewValleyWorld(World):
quality = ""
else:
quality = f" ({item.quality.split(' ')[0]})"
spoiler_handle.write(f"\t\t{item.amount}x {item.get_item()}{quality}\n")
spoiler_handle.write(f"\t\t{item.amount}x {item.item_name}{quality}\n")
def add_entrances_to_spoiler_log(self):
if self.options.entrance_randomization == EntranceRandomization.option_disabled:
@@ -421,42 +373,19 @@ class StardewValleyWorld(World):
for bundle in room.bundles:
bundles[room.name][bundle.name] = {"number_required": bundle.number_required}
for i, item in enumerate(bundle.items):
bundles[room.name][bundle.name][i] = f"{item.get_item()}|{item.amount}|{item.quality}"
bundles[room.name][bundle.name][i] = f"{item.item_name}|{item.amount}|{item.quality}"
excluded_options = [BundleRandomization, NumberOfMovementBuffs, EnabledFillerBuffs]
excluded_options = [BundleRandomization, NumberOfMovementBuffs, NumberOfLuckBuffs]
excluded_option_names = [option.internal_name for option in excluded_options]
generic_option_names = [option_name for option_name in PerGameCommonOptions.type_hints]
excluded_option_names.extend(generic_option_names)
included_option_names: List[str] = [option_name for option_name in self.options_dataclass.type_hints if option_name not in excluded_option_names]
slot_data = self.options.as_dict(*included_option_names)
slot_data.update({
UNIVERSAL_TRACKER_SEED_PROPERTY: self.seed,
"seed": self.random.randrange(1000000000), # Seed should be max 9 digits
"randomized_entrances": self.randomized_entrances,
"modified_bundles": bundles,
"client_version": "6.0.0",
"client_version": "5.0.0",
})
return slot_data
def collect(self, state: CollectionState, item: StardewItem) -> bool:
change = super().collect(state, item)
if change:
state.prog_items[self.player][Event.received_walnuts] += self.get_walnut_amount(item.name)
return change
def remove(self, state: CollectionState, item: StardewItem) -> bool:
change = super().remove(state, item)
if change:
state.prog_items[self.player][Event.received_walnuts] -= self.get_walnut_amount(item.name)
return change
@staticmethod
def get_walnut_amount(item_name: str) -> int:
if item_name == "Golden Walnut":
return 1
if item_name == "3 Golden Walnuts":
return 3
if item_name == "5 Golden Walnuts":
return 5
return 0

View File

@@ -1,10 +1,8 @@
import math
from dataclasses import dataclass
from random import Random
from typing import List, Tuple
from typing import List
from .bundle_item import BundleItem
from ..content import StardewContent
from ..options import BundlePrice, StardewValleyOptions, ExcludeGingerIsland, FestivalLocations
from ..strings.currency_names import Currency
@@ -28,8 +26,7 @@ class BundleTemplate:
number_possible_items: int
number_required_items: int
def __init__(self, room: str, name: str, items: List[BundleItem], number_possible_items: int,
number_required_items: int):
def __init__(self, room: str, name: str, items: List[BundleItem], number_possible_items: int, number_required_items: int):
self.room = room
self.name = name
self.items = items
@@ -38,12 +35,17 @@ class BundleTemplate:
@staticmethod
def extend_from(template, items: List[BundleItem]):
return BundleTemplate(template.room, template.name, items, template.number_possible_items,
template.number_required_items)
return BundleTemplate(template.room, template.name, items, template.number_possible_items, template.number_required_items)
def create_bundle(self, random: Random, content: StardewContent, options: StardewValleyOptions) -> Bundle:
number_required, price_multiplier = get_bundle_final_prices(options.bundle_price, self.number_required_items, False)
filtered_items = [item for item in self.items if item.can_appear(content, options)]
def create_bundle(self, bundle_price_option: BundlePrice, random: Random, options: StardewValleyOptions) -> Bundle:
if bundle_price_option == BundlePrice.option_minimum:
number_required = 1
elif bundle_price_option == BundlePrice.option_maximum:
number_required = 8
else:
number_required = self.number_required_items + bundle_price_option.value
number_required = max(1, number_required)
filtered_items = [item for item in self.items if item.can_appear(options)]
number_items = len(filtered_items)
number_chosen_items = self.number_possible_items
if number_chosen_items < number_required:
@@ -53,7 +55,6 @@ class BundleTemplate:
chosen_items = filtered_items + random.choices(filtered_items, k=number_chosen_items - number_items)
else:
chosen_items = random.sample(filtered_items, number_chosen_items)
chosen_items = [item.as_amount(max(1, math.floor(item.amount * price_multiplier))) for item in chosen_items]
return Bundle(self.room, self.name, chosen_items, number_required)
def can_appear(self, options: StardewValleyOptions) -> bool:
@@ -67,13 +68,19 @@ class CurrencyBundleTemplate(BundleTemplate):
super().__init__(room, name, [item], 1, 1)
self.item = item
def create_bundle(self, random: Random, content: StardewContent, options: StardewValleyOptions) -> Bundle:
currency_amount = self.get_currency_amount(options.bundle_price)
def create_bundle(self, bundle_price_option: BundlePrice, random: Random, options: StardewValleyOptions) -> Bundle:
currency_amount = self.get_currency_amount(bundle_price_option)
return Bundle(self.room, self.name, [BundleItem(self.item.item_name, currency_amount)], 1)
def get_currency_amount(self, bundle_price_option: BundlePrice):
_, price_multiplier = get_bundle_final_prices(bundle_price_option, self.number_required_items, True)
currency_amount = max(1, int(self.item.amount * price_multiplier))
if bundle_price_option == BundlePrice.option_minimum:
price_multiplier = 0.1
elif bundle_price_option == BundlePrice.option_maximum:
price_multiplier = 4
else:
price_multiplier = round(1 + (bundle_price_option.value * 0.4), 2)
currency_amount = int(self.item.amount * price_multiplier)
return currency_amount
def can_appear(self, options: StardewValleyOptions) -> bool:
@@ -88,11 +95,11 @@ class CurrencyBundleTemplate(BundleTemplate):
class MoneyBundleTemplate(CurrencyBundleTemplate):
def __init__(self, room: str, default_name: str, item: BundleItem):
super().__init__(room, default_name, item)
def __init__(self, room: str, item: BundleItem):
super().__init__(room, "", item)
def create_bundle(self, random: Random, content: StardewContent, options: StardewValleyOptions) -> Bundle:
currency_amount = self.get_currency_amount(options.bundle_price)
def create_bundle(self, bundle_price_option: BundlePrice, random: Random, options: StardewValleyOptions) -> Bundle:
currency_amount = self.get_currency_amount(bundle_price_option)
currency_name = "g"
if currency_amount >= 1000:
unit_amount = currency_amount % 1000
@@ -104,8 +111,13 @@ class MoneyBundleTemplate(CurrencyBundleTemplate):
return Bundle(self.room, name, [BundleItem(self.item.item_name, currency_amount)], 1)
def get_currency_amount(self, bundle_price_option: BundlePrice):
_, price_multiplier = get_bundle_final_prices(bundle_price_option, self.number_required_items, True)
currency_amount = max(1, int(self.item.amount * price_multiplier))
if bundle_price_option == BundlePrice.option_minimum:
price_multiplier = 0.1
elif bundle_price_option == BundlePrice.option_maximum:
price_multiplier = 4
else:
price_multiplier = round(1 + (bundle_price_option.value * 0.4), 2)
currency_amount = int(self.item.amount * price_multiplier)
return currency_amount
@@ -122,54 +134,30 @@ class FestivalBundleTemplate(BundleTemplate):
class DeepBundleTemplate(BundleTemplate):
categories: List[List[BundleItem]]
def __init__(self, room: str, name: str, categories: List[List[BundleItem]], number_possible_items: int,
number_required_items: int):
def __init__(self, room: str, name: str, categories: List[List[BundleItem]], number_possible_items: int, number_required_items: int):
super().__init__(room, name, [], number_possible_items, number_required_items)
self.categories = categories
def create_bundle(self, random: Random, content: StardewContent, options: StardewValleyOptions) -> Bundle:
number_required, price_multiplier = get_bundle_final_prices(options.bundle_price, self.number_required_items, False)
def create_bundle(self, bundle_price_option: BundlePrice, random: Random, options: StardewValleyOptions) -> Bundle:
if bundle_price_option == BundlePrice.option_minimum:
number_required = 1
elif bundle_price_option == BundlePrice.option_maximum:
number_required = 8
else:
number_required = self.number_required_items + bundle_price_option.value
number_categories = len(self.categories)
number_chosen_categories = self.number_possible_items
if number_chosen_categories < number_required:
number_chosen_categories = number_required
if number_chosen_categories > number_categories:
chosen_categories = self.categories + random.choices(self.categories,
k=number_chosen_categories - number_categories)
chosen_categories = self.categories + random.choices(self.categories, k=number_chosen_categories - number_categories)
else:
chosen_categories = random.sample(self.categories, number_chosen_categories)
chosen_items = []
for category in chosen_categories:
filtered_items = [item for item in category if item.can_appear(content, options)]
filtered_items = [item for item in category if item.can_appear(options)]
chosen_items.append(random.choice(filtered_items))
chosen_items = [item.as_amount(max(1, math.floor(item.amount * price_multiplier))) for item in chosen_items]
return Bundle(self.room, self.name, chosen_items, number_required)
def get_bundle_final_prices(bundle_price_option: BundlePrice, default_required_items: int, is_currency: bool) -> Tuple[int, float]:
number_required_items = get_number_required_items(bundle_price_option, default_required_items)
price_multiplier = get_price_multiplier(bundle_price_option, is_currency)
return number_required_items, price_multiplier
def get_number_required_items(bundle_price_option: BundlePrice, default_required_items: int) -> int:
if bundle_price_option == BundlePrice.option_minimum:
return 1
if bundle_price_option == BundlePrice.option_maximum:
return 8
number_required = default_required_items + bundle_price_option.value
return min(8, max(1, number_required))
def get_price_multiplier(bundle_price_option: BundlePrice, is_currency: bool) -> float:
if bundle_price_option == BundlePrice.option_minimum:
return 0.1 if is_currency else 0.2
if bundle_price_option == BundlePrice.option_maximum:
return 4 if is_currency else 1.4
price_factor = 0.4 if is_currency else (0.2 if bundle_price_option.value <= 0 else 0.1)
price_multiplier_difference = bundle_price_option.value * price_factor
price_multiplier = 1 + price_multiplier_difference
return round(price_multiplier, 2)

View File

@@ -3,8 +3,7 @@ from __future__ import annotations
from abc import ABC, abstractmethod
from dataclasses import dataclass
from ..content import StardewContent
from ..options import StardewValleyOptions, ExcludeGingerIsland, FestivalLocations, SkillProgression
from ..options import StardewValleyOptions, ExcludeGingerIsland, FestivalLocations
from ..strings.crop_names import Fruit
from ..strings.currency_names import Currency
from ..strings.quality_names import CropQuality, FishQuality, ForageQuality
@@ -31,50 +30,27 @@ class FestivalItemSource(BundleItemSource):
return options.festival_locations != FestivalLocations.option_disabled
class MasteryItemSource(BundleItemSource):
def can_appear(self, options: StardewValleyOptions) -> bool:
return options.skill_progression == SkillProgression.option_progressive_with_masteries
class ContentItemSource(BundleItemSource):
"""This is meant to be used for items that are managed by the content packs."""
def can_appear(self, options: StardewValleyOptions) -> bool:
raise ValueError("This should not be called, check if the item is in the content instead.")
@dataclass(frozen=True, order=True)
class BundleItem:
class Sources:
vanilla = VanillaItemSource()
island = IslandItemSource()
festival = FestivalItemSource()
masteries = MasteryItemSource()
content = ContentItemSource()
item_name: str
amount: int = 1
quality: str = CropQuality.basic
source: BundleItemSource = Sources.vanilla
flavor: str = None
can_have_quality: bool = True
@staticmethod
def money_bundle(amount: int) -> BundleItem:
return BundleItem(Currency.money, amount)
def get_item(self) -> str:
if self.flavor is None:
return self.item_name
return f"{self.item_name} [{self.flavor}]"
def as_amount(self, amount: int) -> BundleItem:
return BundleItem(self.item_name, amount, self.quality, self.source, self.flavor)
return BundleItem(self.item_name, amount, self.quality, self.source)
def as_quality(self, quality: str) -> BundleItem:
if self.can_have_quality:
return BundleItem(self.item_name, self.amount, quality, self.source, self.flavor)
return BundleItem(self.item_name, self.amount, self.quality, self.source, self.flavor)
return BundleItem(self.item_name, self.amount, quality, self.source)
def as_quality_crop(self) -> BundleItem:
amount = 5
@@ -91,11 +67,7 @@ class BundleItem:
def __repr__(self):
quality = "" if self.quality == CropQuality.basic else self.quality
return f"{self.amount} {quality} {self.get_item()}"
def can_appear(self, content: StardewContent, options: StardewValleyOptions) -> bool:
if isinstance(self.source, ContentItemSource):
return self.get_item() in content.game_items
return f"{self.amount} {quality} {self.item_name}"
def can_appear(self, options: StardewValleyOptions) -> bool:
return self.source.can_appear(options)

View File

@@ -3,7 +3,6 @@ from random import Random
from typing import List
from .bundle import Bundle, BundleTemplate
from ..content import StardewContent
from ..options import BundlePrice, StardewValleyOptions
@@ -19,25 +18,7 @@ class BundleRoomTemplate:
bundles: List[BundleTemplate]
number_bundles: int
def create_bundle_room(self, random: Random, content: StardewContent, options: StardewValleyOptions):
def create_bundle_room(self, bundle_price_option: BundlePrice, random: Random, options: StardewValleyOptions):
filtered_bundles = [bundle for bundle in self.bundles if bundle.can_appear(options)]
priority_bundles = []
unpriority_bundles = []
for bundle in filtered_bundles:
if bundle.name in options.bundle_plando:
priority_bundles.append(bundle)
else:
unpriority_bundles.append(bundle)
if self.number_bundles <= len(priority_bundles):
chosen_bundles = random.sample(priority_bundles, self.number_bundles)
else:
chosen_bundles = priority_bundles
num_remaining_bundles = self.number_bundles - len(priority_bundles)
if num_remaining_bundles > len(unpriority_bundles):
chosen_bundles.extend(random.choices(unpriority_bundles, k=num_remaining_bundles))
else:
chosen_bundles.extend(random.sample(unpriority_bundles, num_remaining_bundles))
return BundleRoom(self.name, [bundle.create_bundle(random, content, options) for bundle in chosen_bundles])
chosen_bundles = random.sample(filtered_bundles, self.number_bundles)
return BundleRoom(self.name, [bundle.create_bundle(bundle_price_option, random, options) for bundle in chosen_bundles])

View File

@@ -1,102 +1,65 @@
from random import Random
from typing import List, Tuple
from typing import List
from .bundle import Bundle
from .bundle_room import BundleRoom, BundleRoomTemplate
from ..content import StardewContent
from .bundle_room import BundleRoom
from ..data.bundle_data import pantry_vanilla, crafts_room_vanilla, fish_tank_vanilla, boiler_room_vanilla, bulletin_board_vanilla, vault_vanilla, \
pantry_thematic, crafts_room_thematic, fish_tank_thematic, boiler_room_thematic, bulletin_board_thematic, vault_thematic, pantry_remixed, \
crafts_room_remixed, fish_tank_remixed, boiler_room_remixed, bulletin_board_remixed, vault_remixed, all_bundle_items_except_money, \
abandoned_joja_mart_thematic, abandoned_joja_mart_vanilla, abandoned_joja_mart_remixed, raccoon_vanilla, raccoon_thematic, raccoon_remixed, \
community_center_remixed_anywhere
abandoned_joja_mart_thematic, abandoned_joja_mart_vanilla, abandoned_joja_mart_remixed
from ..logic.logic import StardewLogic
from ..options import BundleRandomization, StardewValleyOptions
from ..options import BundleRandomization, StardewValleyOptions, ExcludeGingerIsland
def get_all_bundles(random: Random, logic: StardewLogic, content: StardewContent, options: StardewValleyOptions) -> List[BundleRoom]:
def get_all_bundles(random: Random, logic: StardewLogic, options: StardewValleyOptions) -> List[BundleRoom]:
if options.bundle_randomization == BundleRandomization.option_vanilla:
return get_vanilla_bundles(random, content, options)
return get_vanilla_bundles(random, options)
elif options.bundle_randomization == BundleRandomization.option_thematic:
return get_thematic_bundles(random, content, options)
return get_thematic_bundles(random, options)
elif options.bundle_randomization == BundleRandomization.option_remixed:
return get_remixed_bundles(random, content, options)
elif options.bundle_randomization == BundleRandomization.option_remixed_anywhere:
return get_remixed_bundles_anywhere(random, content, options)
return get_remixed_bundles(random, options)
elif options.bundle_randomization == BundleRandomization.option_shuffled:
return get_shuffled_bundles(random, logic, content, options)
return get_shuffled_bundles(random, logic, options)
raise NotImplementedError
def get_vanilla_bundles(random: Random, content: StardewContent, options: StardewValleyOptions) -> List[BundleRoom]:
pantry = pantry_vanilla.create_bundle_room(random, content, options)
crafts_room = crafts_room_vanilla.create_bundle_room(random, content, options)
fish_tank = fish_tank_vanilla.create_bundle_room(random, content, options)
boiler_room = boiler_room_vanilla.create_bundle_room(random, content, options)
bulletin_board = bulletin_board_vanilla.create_bundle_room(random, content, options)
vault = vault_vanilla.create_bundle_room(random, content, options)
abandoned_joja_mart = abandoned_joja_mart_vanilla.create_bundle_room(random, content, options)
raccoon = raccoon_vanilla.create_bundle_room(random, content, options)
fix_raccoon_bundle_names(raccoon)
return [pantry, crafts_room, fish_tank, boiler_room, bulletin_board, vault, abandoned_joja_mart, raccoon]
def get_vanilla_bundles(random: Random, options: StardewValleyOptions) -> List[BundleRoom]:
pantry = pantry_vanilla.create_bundle_room(options.bundle_price, random, options)
crafts_room = crafts_room_vanilla.create_bundle_room(options.bundle_price, random, options)
fish_tank = fish_tank_vanilla.create_bundle_room(options.bundle_price, random, options)
boiler_room = boiler_room_vanilla.create_bundle_room(options.bundle_price, random, options)
bulletin_board = bulletin_board_vanilla.create_bundle_room(options.bundle_price, random, options)
vault = vault_vanilla.create_bundle_room(options.bundle_price, random, options)
abandoned_joja_mart = abandoned_joja_mart_vanilla.create_bundle_room(options.bundle_price, random, options)
return [pantry, crafts_room, fish_tank, boiler_room, bulletin_board, vault, abandoned_joja_mart]
def get_thematic_bundles(random: Random, content: StardewContent, options: StardewValleyOptions) -> List[BundleRoom]:
pantry = pantry_thematic.create_bundle_room(random, content, options)
crafts_room = crafts_room_thematic.create_bundle_room(random, content, options)
fish_tank = fish_tank_thematic.create_bundle_room(random, content, options)
boiler_room = boiler_room_thematic.create_bundle_room(random, content, options)
bulletin_board = bulletin_board_thematic.create_bundle_room(random, content, options)
vault = vault_thematic.create_bundle_room(random, content, options)
abandoned_joja_mart = abandoned_joja_mart_thematic.create_bundle_room(random, content, options)
raccoon = raccoon_thematic.create_bundle_room(random, content, options)
fix_raccoon_bundle_names(raccoon)
return [pantry, crafts_room, fish_tank, boiler_room, bulletin_board, vault, abandoned_joja_mart, raccoon]
def get_thematic_bundles(random: Random, options: StardewValleyOptions) -> List[BundleRoom]:
pantry = pantry_thematic.create_bundle_room(options.bundle_price, random, options)
crafts_room = crafts_room_thematic.create_bundle_room(options.bundle_price, random, options)
fish_tank = fish_tank_thematic.create_bundle_room(options.bundle_price, random, options)
boiler_room = boiler_room_thematic.create_bundle_room(options.bundle_price, random, options)
bulletin_board = bulletin_board_thematic.create_bundle_room(options.bundle_price, random, options)
vault = vault_thematic.create_bundle_room(options.bundle_price, random, options)
abandoned_joja_mart = abandoned_joja_mart_thematic.create_bundle_room(options.bundle_price, random, options)
return [pantry, crafts_room, fish_tank, boiler_room, bulletin_board, vault, abandoned_joja_mart]
def get_remixed_bundles(random: Random, content: StardewContent, options: StardewValleyOptions) -> List[BundleRoom]:
pantry = pantry_remixed.create_bundle_room(random, content, options)
crafts_room = crafts_room_remixed.create_bundle_room(random, content, options)
fish_tank = fish_tank_remixed.create_bundle_room(random, content, options)
boiler_room = boiler_room_remixed.create_bundle_room(random, content, options)
bulletin_board = bulletin_board_remixed.create_bundle_room(random, content, options)
vault = vault_remixed.create_bundle_room(random, content, options)
abandoned_joja_mart = abandoned_joja_mart_remixed.create_bundle_room(random, content, options)
raccoon = raccoon_remixed.create_bundle_room(random, content, options)
fix_raccoon_bundle_names(raccoon)
return [pantry, crafts_room, fish_tank, boiler_room, bulletin_board, vault, abandoned_joja_mart, raccoon]
def get_remixed_bundles(random: Random, options: StardewValleyOptions) -> List[BundleRoom]:
pantry = pantry_remixed.create_bundle_room(options.bundle_price, random, options)
crafts_room = crafts_room_remixed.create_bundle_room(options.bundle_price, random, options)
fish_tank = fish_tank_remixed.create_bundle_room(options.bundle_price, random, options)
boiler_room = boiler_room_remixed.create_bundle_room(options.bundle_price, random, options)
bulletin_board = bulletin_board_remixed.create_bundle_room(options.bundle_price, random, options)
vault = vault_remixed.create_bundle_room(options.bundle_price, random, options)
abandoned_joja_mart = abandoned_joja_mart_remixed.create_bundle_room(options.bundle_price, random, options)
return [pantry, crafts_room, fish_tank, boiler_room, bulletin_board, vault, abandoned_joja_mart]
def get_remixed_bundles_anywhere(random: Random, content: StardewContent, options: StardewValleyOptions) -> List[BundleRoom]:
big_room = community_center_remixed_anywhere.create_bundle_room(random, content, options)
all_chosen_bundles = big_room.bundles
random.shuffle(all_chosen_bundles)
def get_shuffled_bundles(random: Random, logic: StardewLogic, options: StardewValleyOptions) -> List[BundleRoom]:
valid_bundle_items = [bundle_item for bundle_item in all_bundle_items_except_money if bundle_item.can_appear(options)]
end_index = 0
pantry, end_index = create_room_from_bundles(pantry_remixed, all_chosen_bundles, end_index)
crafts_room, end_index = create_room_from_bundles(crafts_room_remixed, all_chosen_bundles, end_index)
fish_tank, end_index = create_room_from_bundles(fish_tank_remixed, all_chosen_bundles, end_index)
boiler_room, end_index = create_room_from_bundles(boiler_room_remixed, all_chosen_bundles, end_index)
bulletin_board, end_index = create_room_from_bundles(bulletin_board_remixed, all_chosen_bundles, end_index)
vault = vault_remixed.create_bundle_room(random, content, options)
abandoned_joja_mart = abandoned_joja_mart_remixed.create_bundle_room(random, content, options)
raccoon = raccoon_remixed.create_bundle_room(random, content, options)
fix_raccoon_bundle_names(raccoon)
return [pantry, crafts_room, fish_tank, boiler_room, bulletin_board, vault, abandoned_joja_mart, raccoon]
def create_room_from_bundles(template: BundleRoomTemplate, all_bundles: List[Bundle], end_index: int) -> Tuple[BundleRoom, int]:
start_index = end_index
end_index += template.number_bundles
return BundleRoom(template.name, all_bundles[start_index:end_index]), end_index
def get_shuffled_bundles(random: Random, logic: StardewLogic, content: StardewContent, options: StardewValleyOptions) -> List[BundleRoom]:
valid_bundle_items = [bundle_item for bundle_item in all_bundle_items_except_money if bundle_item.can_appear(content, options)]
rooms = [room for room in get_remixed_bundles(random, content, options) if room.name != "Vault"]
rooms = [room for room in get_remixed_bundles(random, options) if room.name != "Vault"]
required_items = 0
for room in rooms:
for bundle in room.bundles:
@@ -104,21 +67,14 @@ def get_shuffled_bundles(random: Random, logic: StardewLogic, content: StardewCo
random.shuffle(room.bundles)
random.shuffle(rooms)
# Remove duplicates of the same item
valid_bundle_items = [item1 for i, item1 in enumerate(valid_bundle_items)
if not any(item1.item_name == item2.item_name and item1.quality == item2.quality for item2 in valid_bundle_items[:i])]
chosen_bundle_items = random.sample(valid_bundle_items, required_items)
sorted_bundle_items = sorted(chosen_bundle_items, key=lambda x: logic.has(x.item_name).get_difficulty())
for room in rooms:
for bundle in room.bundles:
num_items = len(bundle.items)
bundle.items = chosen_bundle_items[:num_items]
chosen_bundle_items = chosen_bundle_items[num_items:]
bundle.items = sorted_bundle_items[:num_items]
sorted_bundle_items = sorted_bundle_items[num_items:]
vault = vault_remixed.create_bundle_room(random, content, options)
vault = vault_remixed.create_bundle_room(options.bundle_price, random, options)
return [*rooms, vault]
def fix_raccoon_bundle_names(raccoon):
for i in range(len(raccoon.bundles)):
raccoon_bundle = raccoon.bundles[i]
raccoon_bundle.name = f"Raccoon Request {i + 1}"

View File

@@ -1,107 +0,0 @@
from . import content_packs
from .feature import cropsanity, friendsanity, fishsanity, booksanity
from .game_content import ContentPack, StardewContent, StardewFeatures
from .unpacking import unpack_content
from .. import options
def create_content(player_options: options.StardewValleyOptions) -> StardewContent:
active_packs = choose_content_packs(player_options)
features = choose_features(player_options)
return unpack_content(features, active_packs)
def choose_content_packs(player_options: options.StardewValleyOptions):
active_packs = [content_packs.pelican_town, content_packs.the_desert, content_packs.the_farm, content_packs.the_mines]
if player_options.exclude_ginger_island == options.ExcludeGingerIsland.option_false:
active_packs.append(content_packs.ginger_island_content_pack)
if player_options.special_order_locations & options.SpecialOrderLocations.value_qi:
active_packs.append(content_packs.qi_board_content_pack)
for mod in player_options.mods.value:
active_packs.append(content_packs.by_mod[mod])
return active_packs
def choose_features(player_options: options.StardewValleyOptions) -> StardewFeatures:
return StardewFeatures(
choose_booksanity(player_options.booksanity),
choose_cropsanity(player_options.cropsanity),
choose_fishsanity(player_options.fishsanity),
choose_friendsanity(player_options.friendsanity, player_options.friendsanity_heart_size)
)
booksanity_by_option = {
options.Booksanity.option_none: booksanity.BooksanityDisabled(),
options.Booksanity.option_power: booksanity.BooksanityPower(),
options.Booksanity.option_power_skill: booksanity.BooksanityPowerSkill(),
options.Booksanity.option_all: booksanity.BooksanityAll(),
}
def choose_booksanity(booksanity_option: options.Booksanity) -> booksanity.BooksanityFeature:
booksanity_feature = booksanity_by_option.get(booksanity_option)
if booksanity_feature is None:
raise ValueError(f"No booksanity feature mapped to {str(booksanity_option.value)}")
return booksanity_feature
cropsanity_by_option = {
options.Cropsanity.option_disabled: cropsanity.CropsanityDisabled(),
options.Cropsanity.option_enabled: cropsanity.CropsanityEnabled(),
}
def choose_cropsanity(cropsanity_option: options.Cropsanity) -> cropsanity.CropsanityFeature:
cropsanity_feature = cropsanity_by_option.get(cropsanity_option)
if cropsanity_feature is None:
raise ValueError(f"No cropsanity feature mapped to {str(cropsanity_option.value)}")
return cropsanity_feature
fishsanity_by_option = {
options.Fishsanity.option_none: fishsanity.FishsanityNone(),
options.Fishsanity.option_legendaries: fishsanity.FishsanityLegendaries(),
options.Fishsanity.option_special: fishsanity.FishsanitySpecial(),
options.Fishsanity.option_randomized: fishsanity.FishsanityAll(randomization_ratio=0.4),
options.Fishsanity.option_all: fishsanity.FishsanityAll(),
options.Fishsanity.option_exclude_legendaries: fishsanity.FishsanityExcludeLegendaries(),
options.Fishsanity.option_exclude_hard_fish: fishsanity.FishsanityExcludeHardFish(),
options.Fishsanity.option_only_easy_fish: fishsanity.FishsanityOnlyEasyFish(),
}
def choose_fishsanity(fishsanity_option: options.Fishsanity) -> fishsanity.FishsanityFeature:
fishsanity_feature = fishsanity_by_option.get(fishsanity_option)
if fishsanity_feature is None:
raise ValueError(f"No fishsanity feature mapped to {str(fishsanity_option.value)}")
return fishsanity_feature
def choose_friendsanity(friendsanity_option: options.Friendsanity, heart_size: options.FriendsanityHeartSize) -> friendsanity.FriendsanityFeature:
if friendsanity_option == options.Friendsanity.option_none:
return friendsanity.FriendsanityNone()
if friendsanity_option == options.Friendsanity.option_bachelors:
return friendsanity.FriendsanityBachelors(heart_size.value)
if friendsanity_option == options.Friendsanity.option_starting_npcs:
return friendsanity.FriendsanityStartingNpc(heart_size.value)
if friendsanity_option == options.Friendsanity.option_all:
return friendsanity.FriendsanityAll(heart_size.value)
if friendsanity_option == options.Friendsanity.option_all_with_marriage:
return friendsanity.FriendsanityAllWithMarriage(heart_size.value)
raise ValueError(f"No friendsanity feature mapped to {str(friendsanity_option.value)}")

View File

@@ -1,31 +0,0 @@
import importlib
import pkgutil
from . import mods
from .mod_registry import by_mod
from .vanilla.base import base_game
from .vanilla.ginger_island import ginger_island_content_pack
from .vanilla.pelican_town import pelican_town
from .vanilla.qi_board import qi_board_content_pack
from .vanilla.the_desert import the_desert
from .vanilla.the_farm import the_farm
from .vanilla.the_mines import the_mines
assert base_game
assert ginger_island_content_pack
assert pelican_town
assert qi_board_content_pack
assert the_desert
assert the_farm
assert the_mines
# Dynamically register everything currently in the mods folder. This would ideally be done through a metaclass, but I have not looked into that yet.
mod_modules = pkgutil.iter_modules(mods.__path__)
loaded_modules = {}
for mod_module in mod_modules:
module_name = mod_module.name
module = importlib.import_module("." + module_name, mods.__name__)
loaded_modules[module_name] = module
assert by_mod

View File

@@ -1,4 +0,0 @@
from . import booksanity
from . import cropsanity
from . import fishsanity
from . import friendsanity

View File

@@ -1,72 +0,0 @@
from abc import ABC, abstractmethod
from typing import ClassVar, Optional, Iterable
from ...data.game_item import GameItem, ItemTag
from ...strings.book_names import ordered_lost_books
item_prefix = "Power: "
location_prefix = "Read "
def to_item_name(book: str) -> str:
return item_prefix + book
def to_location_name(book: str) -> str:
return location_prefix + book
def extract_book_from_location_name(location_name: str) -> Optional[str]:
if not location_name.startswith(location_prefix):
return None
return location_name[len(location_prefix):]
class BooksanityFeature(ABC):
is_enabled: ClassVar[bool]
to_item_name = staticmethod(to_item_name)
progressive_lost_book = "Progressive Lost Book"
to_location_name = staticmethod(to_location_name)
extract_book_from_location_name = staticmethod(extract_book_from_location_name)
@abstractmethod
def is_included(self, book: GameItem) -> bool:
...
@staticmethod
def get_randomized_lost_books() -> Iterable[str]:
return []
class BooksanityDisabled(BooksanityFeature):
is_enabled = False
def is_included(self, book: GameItem) -> bool:
return False
class BooksanityPower(BooksanityFeature):
is_enabled = True
def is_included(self, book: GameItem) -> bool:
return ItemTag.BOOK_POWER in book.tags
class BooksanityPowerSkill(BooksanityFeature):
is_enabled = True
def is_included(self, book: GameItem) -> bool:
return ItemTag.BOOK_POWER in book.tags or ItemTag.BOOK_SKILL in book.tags
class BooksanityAll(BooksanityFeature):
is_enabled = True
def is_included(self, book: GameItem) -> bool:
return ItemTag.BOOK_POWER in book.tags or ItemTag.BOOK_SKILL in book.tags
@staticmethod
def get_randomized_lost_books() -> Iterable[str]:
return ordered_lost_books

View File

@@ -1,42 +0,0 @@
from abc import ABC, abstractmethod
from typing import ClassVar, Optional
from ...data.game_item import GameItem, ItemTag
location_prefix = "Harvest "
def to_location_name(crop: str) -> str:
return location_prefix + crop
def extract_crop_from_location_name(location_name: str) -> Optional[str]:
if not location_name.startswith(location_prefix):
return None
return location_name[len(location_prefix):]
class CropsanityFeature(ABC):
is_enabled: ClassVar[bool]
to_location_name = staticmethod(to_location_name)
extract_crop_from_location_name = staticmethod(extract_crop_from_location_name)
@abstractmethod
def is_included(self, crop: GameItem) -> bool:
...
class CropsanityDisabled(CropsanityFeature):
is_enabled = False
def is_included(self, crop: GameItem) -> bool:
return False
class CropsanityEnabled(CropsanityFeature):
is_enabled = True
def is_included(self, crop: GameItem) -> bool:
return ItemTag.CROPSANITY_SEED in crop.tags

View File

@@ -1,101 +0,0 @@
from abc import ABC, abstractmethod
from dataclasses import dataclass
from typing import ClassVar, Optional
from ...data.fish_data import FishItem
from ...strings.fish_names import Fish
location_prefix = "Fishsanity: "
def to_location_name(fish: str) -> str:
return location_prefix + fish
def extract_fish_from_location_name(location_name: str) -> Optional[str]:
if not location_name.startswith(location_prefix):
return None
return location_name[len(location_prefix):]
@dataclass(frozen=True)
class FishsanityFeature(ABC):
is_enabled: ClassVar[bool]
randomization_ratio: float = 1
to_location_name = staticmethod(to_location_name)
extract_fish_from_location_name = staticmethod(extract_fish_from_location_name)
@property
def is_randomized(self) -> bool:
return self.randomization_ratio != 1
@abstractmethod
def is_included(self, fish: FishItem) -> bool:
...
class FishsanityNone(FishsanityFeature):
is_enabled = False
def is_included(self, fish: FishItem) -> bool:
return False
class FishsanityLegendaries(FishsanityFeature):
is_enabled = True
def is_included(self, fish: FishItem) -> bool:
return fish.legendary
class FishsanitySpecial(FishsanityFeature):
is_enabled = True
included_fishes = {
Fish.angler,
Fish.crimsonfish,
Fish.glacierfish,
Fish.legend,
Fish.mutant_carp,
Fish.blobfish,
Fish.lava_eel,
Fish.octopus,
Fish.scorpion_carp,
Fish.ice_pip,
Fish.super_cucumber,
Fish.dorado
}
def is_included(self, fish: FishItem) -> bool:
return fish.name in self.included_fishes
class FishsanityAll(FishsanityFeature):
is_enabled = True
def is_included(self, fish: FishItem) -> bool:
return True
class FishsanityExcludeLegendaries(FishsanityFeature):
is_enabled = True
def is_included(self, fish: FishItem) -> bool:
return not fish.legendary
class FishsanityExcludeHardFish(FishsanityFeature):
is_enabled = True
def is_included(self, fish: FishItem) -> bool:
return fish.difficulty < 80
class FishsanityOnlyEasyFish(FishsanityFeature):
is_enabled = True
def is_included(self, fish: FishItem) -> bool:
return fish.difficulty < 50

View File

@@ -1,139 +0,0 @@
from abc import ABC, abstractmethod
from dataclasses import dataclass
from functools import lru_cache
from typing import Optional, Tuple, ClassVar
from ...data.villagers_data import Villager
from ...strings.villager_names import NPC
suffix = " <3"
location_prefix = "Friendsanity: "
def to_item_name(npc_name: str) -> str:
return npc_name + suffix
def to_location_name(npc_name: str, heart: int) -> str:
return location_prefix + npc_name + " " + str(heart) + suffix
pet_heart_item_name = to_item_name(NPC.pet)
def extract_npc_from_item_name(item_name: str) -> Optional[str]:
if not item_name.endswith(suffix):
return None
return item_name[:-len(suffix)]
def extract_npc_from_location_name(location_name: str) -> Tuple[Optional[str], int]:
if not location_name.endswith(suffix):
return None, 0
trimmed = location_name[len(location_prefix):-len(suffix)]
last_space = trimmed.rindex(" ")
return trimmed[:last_space], int(trimmed[last_space + 1:])
@lru_cache(maxsize=32) # Should not go pass 32 values if every friendsanity options are in the multi world
def get_heart_steps(max_heart: int, heart_size: int) -> Tuple[int, ...]:
return tuple(range(heart_size, max_heart + 1, heart_size)) + ((max_heart,) if max_heart % heart_size else ())
@dataclass(frozen=True)
class FriendsanityFeature(ABC):
is_enabled: ClassVar[bool]
heart_size: int
to_item_name = staticmethod(to_item_name)
to_location_name = staticmethod(to_location_name)
pet_heart_item_name = pet_heart_item_name
extract_npc_from_item_name = staticmethod(extract_npc_from_item_name)
extract_npc_from_location_name = staticmethod(extract_npc_from_location_name)
@abstractmethod
def get_randomized_hearts(self, villager: Villager) -> Tuple[int, ...]:
...
@property
def is_pet_randomized(self):
return bool(self.get_pet_randomized_hearts())
@abstractmethod
def get_pet_randomized_hearts(self) -> Tuple[int, ...]:
...
class FriendsanityNone(FriendsanityFeature):
is_enabled = False
def __init__(self):
super().__init__(1)
def get_randomized_hearts(self, villager: Villager) -> Tuple[int, ...]:
return ()
def get_pet_randomized_hearts(self) -> Tuple[int, ...]:
return ()
@dataclass(frozen=True)
class FriendsanityBachelors(FriendsanityFeature):
is_enabled = True
def get_randomized_hearts(self, villager: Villager) -> Tuple[int, ...]:
if not villager.bachelor:
return ()
return get_heart_steps(8, self.heart_size)
def get_pet_randomized_hearts(self) -> Tuple[int, ...]:
return ()
@dataclass(frozen=True)
class FriendsanityStartingNpc(FriendsanityFeature):
is_enabled = True
def get_randomized_hearts(self, villager: Villager) -> Tuple[int, ...]:
if not villager.available:
return ()
if villager.bachelor:
return get_heart_steps(8, self.heart_size)
return get_heart_steps(10, self.heart_size)
def get_pet_randomized_hearts(self) -> Tuple[int, ...]:
return get_heart_steps(5, self.heart_size)
@dataclass(frozen=True)
class FriendsanityAll(FriendsanityFeature):
is_enabled = True
def get_randomized_hearts(self, villager: Villager) -> Tuple[int, ...]:
if villager.bachelor:
return get_heart_steps(8, self.heart_size)
return get_heart_steps(10, self.heart_size)
def get_pet_randomized_hearts(self) -> Tuple[int, ...]:
return get_heart_steps(5, self.heart_size)
@dataclass(frozen=True)
class FriendsanityAllWithMarriage(FriendsanityFeature):
is_enabled = True
def get_randomized_hearts(self, villager: Villager) -> Tuple[int, ...]:
if villager.bachelor:
return get_heart_steps(14, self.heart_size)
return get_heart_steps(10, self.heart_size)
def get_pet_randomized_hearts(self) -> Tuple[int, ...]:
return get_heart_steps(5, self.heart_size)

View File

@@ -1,117 +0,0 @@
from __future__ import annotations
from dataclasses import dataclass, field
from typing import Dict, Iterable, Set, Any, Mapping, Type, Tuple, Union
from .feature import booksanity, cropsanity, fishsanity, friendsanity
from ..data.fish_data import FishItem
from ..data.game_item import GameItem, ItemSource, ItemTag
from ..data.skill import Skill
from ..data.villagers_data import Villager
@dataclass(frozen=True)
class StardewContent:
features: StardewFeatures
registered_packs: Set[str] = field(default_factory=set)
# regions -> To be used with can reach rule
game_items: Dict[str, GameItem] = field(default_factory=dict)
fishes: Dict[str, FishItem] = field(default_factory=dict)
villagers: Dict[str, Villager] = field(default_factory=dict)
skills: Dict[str, Skill] = field(default_factory=dict)
quests: Dict[str, Any] = field(default_factory=dict)
def find_sources_of_type(self, types: Union[Type[ItemSource], Tuple[Type[ItemSource]]]) -> Iterable[ItemSource]:
for item in self.game_items.values():
for source in item.sources:
if isinstance(source, types):
yield source
def source_item(self, item_name: str, *sources: ItemSource):
item = self.game_items.setdefault(item_name, GameItem(item_name))
item.add_sources(sources)
def tag_item(self, item_name: str, *tags: ItemTag):
item = self.game_items.setdefault(item_name, GameItem(item_name))
item.add_tags(tags)
def untag_item(self, item_name: str, tag: ItemTag):
self.game_items[item_name].tags.remove(tag)
def find_tagged_items(self, tag: ItemTag) -> Iterable[GameItem]:
# TODO might be worth caching this, but it need to only be cached once the content is finalized...
for item in self.game_items.values():
if tag in item.tags:
yield item
@dataclass(frozen=True)
class StardewFeatures:
booksanity: booksanity.BooksanityFeature
cropsanity: cropsanity.CropsanityFeature
fishsanity: fishsanity.FishsanityFeature
friendsanity: friendsanity.FriendsanityFeature
@dataclass(frozen=True)
class ContentPack:
name: str
dependencies: Iterable[str] = ()
""" Hard requirement, generation will fail if it's missing. """
weak_dependencies: Iterable[str] = ()
""" Not a strict dependency, only used only for ordering the packs to make sure hooks are applied correctly. """
# items
# def item_hook
# ...
harvest_sources: Mapping[str, Iterable[ItemSource]] = field(default_factory=dict)
"""Harvest sources contains both crops and forageables, but also fruits from trees, the cave farm and stuff harvested from tapping like maple syrup."""
def harvest_source_hook(self, content: StardewContent):
...
shop_sources: Mapping[str, Iterable[ItemSource]] = field(default_factory=dict)
def shop_source_hook(self, content: StardewContent):
...
fishes: Iterable[FishItem] = ()
def fish_hook(self, content: StardewContent):
...
crafting_sources: Mapping[str, Iterable[ItemSource]] = field(default_factory=dict)
def crafting_hook(self, content: StardewContent):
...
artisan_good_sources: Mapping[str, Iterable[ItemSource]] = field(default_factory=dict)
def artisan_good_hook(self, content: StardewContent):
...
villagers: Iterable[Villager] = ()
def villager_hook(self, content: StardewContent):
...
skills: Iterable[Skill] = ()
def skill_hook(self, content: StardewContent):
...
quests: Iterable[Any] = ()
def quest_hook(self, content: StardewContent):
...
def finalize_hook(self, content: StardewContent):
"""Last hook called on the pack, once all other content packs have been registered.
This is the place to do any final adjustments to the content, like adding rules based on tags applied by other packs.
"""
...

View File

@@ -1,7 +0,0 @@
from .game_content import ContentPack
by_mod = {}
def register_mod_content_pack(content_pack: ContentPack):
by_mod[content_pack.name] = content_pack

View File

@@ -1,33 +0,0 @@
from ..game_content import ContentPack, StardewContent
from ..mod_registry import register_mod_content_pack
from ...data import villagers_data
from ...data.harvest import ForagingSource
from ...data.requirement import QuestRequirement
from ...mods.mod_data import ModNames
from ...strings.quest_names import ModQuest
from ...strings.region_names import Region
from ...strings.seed_names import DistantLandsSeed
class AlectoContentPack(ContentPack):
def harvest_source_hook(self, content: StardewContent):
if ModNames.distant_lands in content.registered_packs:
content.game_items.pop(DistantLandsSeed.void_mint)
content.game_items.pop(DistantLandsSeed.vile_ancient_fruit)
content.source_item(DistantLandsSeed.void_mint,
ForagingSource(regions=(Region.witch_swamp,), other_requirements=(QuestRequirement(ModQuest.WitchOrder),)),),
content.source_item(DistantLandsSeed.vile_ancient_fruit,
ForagingSource(regions=(Region.witch_swamp,), other_requirements=(QuestRequirement(ModQuest.WitchOrder),)), ),
register_mod_content_pack(ContentPack(
ModNames.alecto,
weak_dependencies=(
ModNames.distant_lands, # For Witch's order
),
villagers=(
villagers_data.alecto,
)
))

View File

@@ -1,34 +0,0 @@
from ..game_content import ContentPack, StardewContent
from ..mod_registry import register_mod_content_pack
from ...data.artisan import MachineSource
from ...data.skill import Skill
from ...mods.mod_data import ModNames
from ...strings.craftable_names import ModMachine
from ...strings.fish_names import ModTrash
from ...strings.metal_names import all_artifacts, all_fossils
from ...strings.skill_names import ModSkill
class ArchaeologyContentPack(ContentPack):
def artisan_good_hook(self, content: StardewContent):
# Done as honestly there are too many display items to put into the initial registration traditionally.
display_items = all_artifacts + all_fossils
for item in display_items:
self.source_display_items(item, content)
content.source_item(ModTrash.rusty_scrap, *(MachineSource(item=artifact, machine=ModMachine.grinder) for artifact in all_artifacts))
def source_display_items(self, item: str, content: StardewContent):
wood_display = f"Wooden Display: {item}"
hardwood_display = f"Hardwood Display: {item}"
if item == "Trilobite":
wood_display = f"Wooden Display: Trilobite Fossil"
hardwood_display = f"Hardwood Display: Trilobite Fossil"
content.source_item(wood_display, MachineSource(item=str(item), machine=ModMachine.preservation_chamber))
content.source_item(hardwood_display, MachineSource(item=str(item), machine=ModMachine.hardwood_preservation_chamber))
register_mod_content_pack(ArchaeologyContentPack(
ModNames.archaeology,
skills=(Skill(name=ModSkill.archaeology, has_mastery=False),),
))

View File

@@ -1,7 +0,0 @@
from ..game_content import ContentPack
from ..mod_registry import register_mod_content_pack
from ...mods.mod_data import ModNames
register_mod_content_pack(ContentPack(
ModNames.big_backpack,
))

View File

@@ -1,13 +0,0 @@
from ..game_content import ContentPack
from ..mod_registry import register_mod_content_pack
from ...data import villagers_data
from ...mods.mod_data import ModNames
register_mod_content_pack(ContentPack(
ModNames.boarding_house,
villagers=(
villagers_data.gregory,
villagers_data.sheila,
villagers_data.joel,
)
))

View File

@@ -1,28 +0,0 @@
from ..game_content import ContentPack
from ..mod_registry import register_mod_content_pack
from ...data.harvest import ForagingSource
from ...mods.mod_data import ModNames
from ...strings.crop_names import Fruit
from ...strings.flower_names import Flower
from ...strings.region_names import DeepWoodsRegion
from ...strings.season_names import Season
register_mod_content_pack(ContentPack(
ModNames.deepwoods,
harvest_sources={
# Deep enough to have seen such a tree at least once
Fruit.apple: (ForagingSource(regions=(DeepWoodsRegion.floor_10,)),),
Fruit.apricot: (ForagingSource(regions=(DeepWoodsRegion.floor_10,)),),
Fruit.cherry: (ForagingSource(regions=(DeepWoodsRegion.floor_10,)),),
Fruit.orange: (ForagingSource(regions=(DeepWoodsRegion.floor_10,)),),
Fruit.peach: (ForagingSource(regions=(DeepWoodsRegion.floor_10,)),),
Fruit.pomegranate: (ForagingSource(regions=(DeepWoodsRegion.floor_10,)),),
Fruit.mango: (ForagingSource(regions=(DeepWoodsRegion.floor_10,)),),
Flower.tulip: (ForagingSource(seasons=Season.not_winter, regions=(DeepWoodsRegion.floor_10,)),),
Flower.blue_jazz: (ForagingSource(regions=(DeepWoodsRegion.floor_10,)),),
Flower.summer_spangle: (ForagingSource(seasons=Season.not_winter, regions=(DeepWoodsRegion.floor_10,)),),
Flower.poppy: (ForagingSource(seasons=Season.not_winter, regions=(DeepWoodsRegion.floor_10,)),),
Flower.fairy_rose: (ForagingSource(regions=(DeepWoodsRegion.floor_10,)),),
}
))

Some files were not shown because too many files have changed in this diff Show More