Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add feature to automatically send checks when UT says they're in logic #89

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions schemas/Manual.game.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@
"type": "integer",
"default": 1
},
"auto_send": {
"description": "(Optional) Will your client automatically send in-logic checks? WARNING: This should only be used for non-game manual worlds.",
"type": "boolean"
},
"_comment": {"$ref": "#/definitions/comment"}
},
"required":["game", "filler_item_name"],
Expand Down
2 changes: 2 additions & 0 deletions src/Game.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,5 @@
raise Exception("The value of data/game.json:'starting_index' should be an int")
else:
starting_index = 1

auto_send = game_table["auto_send"] if "auto_send" in game_table else False
19 changes: 18 additions & 1 deletion src/ManualClient.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,11 @@ def _cmd_send(self, location_name: str) -> bool:
self.output(response)
return False


def _cmd_toggle_autosend(self) -> bool:
"""Toggle autosend. If enabled, the client will automatically send checks out as soon as UT says they're in logic."""
self.ctx.auto_send = not self.ctx.auto_send
self.output(f"Auto-send is now {self.ctx.auto_send}")
return True



Expand All @@ -72,6 +76,8 @@ class ManualContext(SuperContext):
last_death_link = 0
deathlink_out = False

auto_send = False

colors = {
'location_default': [219/255, 218/255, 213/255, 1],
'location_in_logic': [2/255, 242/255, 42/255, 1],
Expand Down Expand Up @@ -187,6 +193,10 @@ def on_package(self, cmd: str, args: dict):
self.ui.enable_death_link()
self.set_deathlink = True
self.last_death_link = 0

if hasattr(AutoWorldRegister.world_types[self.game], "auto_send") and AutoWorldRegister.world_types[self.game].auto_send:
self.auto_send = True

logger.info(f"Slot data: {args['slot_data']}")

self.ui.build_tracker_and_locations_table()
Expand All @@ -205,6 +215,13 @@ def on_deathlink(self, data: typing.Dict[str, typing.Any]) -> None:
def on_tracker_updated(self, reachable_locations: list[str]):
self.tracker_reachable_locations = reachable_locations
self.ui.update_tracker_and_locations_table(update_highlights=True)
if self.auto_send:
sync = False
for location in reachable_locations:
location_id = self.location_names_to_id[location]
self.locations_checked.append(location_id)
sync = True
self.syncing = sync

def on_tracker_events(self, events: list[str]):
self.tracker_reachable_events = events
Expand Down
4 changes: 3 additions & 1 deletion src/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from worlds.LauncherComponents import Component, SuffixIdentifier, components, Type, launch_subprocess

from .Data import item_table, location_table, region_table, category_table, meta_table
from .Game import game_name, filler_item_name, starting_items
from .Game import game_name, filler_item_name, starting_items, auto_send
from .Meta import world_description, world_webworld, enable_region_diagram
from .Locations import location_id_to_name, location_name_to_id, location_name_to_location, location_name_groups, victory_names
from .Items import item_id_to_name, item_name_to_id, item_name_to_item, item_name_groups
Expand Down Expand Up @@ -63,6 +63,8 @@ class ManualWorld(World):
location_name_groups = location_name_groups
victory_names = victory_names

auto_send = auto_send

def get_filler_item_name(self) -> str:
return hook_get_filler_item_name(self, self.multiworld, self.player) or filler_item_name

Expand Down