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

Stardew Valley: Add tracker text client integrated with UT and commands to explain the logic #4378

Open
wants to merge 34 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
7eae4f7
add basic text client with UT integration
Jouramie Jun 28, 2024
d2eee35
add basic text client with UT integration
Jouramie Jun 28, 2024
14f3c61
self review
Jouramie Jun 28, 2024
77e818b
disable menu entry if tracker feature flag if False (which it is)
Jouramie Jun 28, 2024
79c0ba5
except ImportError
Jouramie Jul 3, 2024
6168034
Merge branch 'main' into StardewValley/stardew-text-client
Jouramie Jul 3, 2024
0d11c51
Merge branch 'main' into StardewValley/stardew-text-client
Jouramie Jul 4, 2024
35479f4
Merge branch 'main' into StardewValley/stardew-text-client
Jouramie Jul 7, 2024
2666698
Merge branch 'main' into StardewValley/stardew-text-client
Jouramie Jul 14, 2024
1c4efc8
Merge branch 'main' into StardewValley/stardew-text-client
Jouramie Oct 15, 2024
feab978
Merge remote-tracking branch 'origin/main' into StardewValley/stardew…
Jouramie Nov 30, 2024
b230b11
Merge remote-tracking branch 'archipelago/main' into StardewValley/st…
Jouramie Dec 9, 2024
21bd402
prove that's it's possible to log explain
Jouramie Jun 30, 2024
9f2011f
add missing command
Jouramie Jul 1, 2024
c86dc7b
implement commands
Jouramie Jul 1, 2024
e24c338
add command to explain more
Jouramie Dec 15, 2024
f2204a8
allow no expectation, and add more space in client mode
Jouramie Dec 15, 2024
ca894ab
copied stuff from UT to get a working state
Jouramie Dec 15, 2024
485d254
use ut context as base tracker
Jouramie Dec 15, 2024
45d3d04
add fuzzy matching on names
Jouramie Dec 15, 2024
f67c31a
best effet to find out if ut is installed
Jouramie Dec 15, 2024
bd98460
best effet to find out if ut is installed
Jouramie Dec 15, 2024
bf443eb
move icon in stardew apworld
Jouramie Dec 15, 2024
71f3f5f
adapt to new ut versions
Jouramie Dec 15, 2024
2a50bd4
color true and false for better readability
Jouramie Dec 15, 2024
b53c982
add color to location, region, entrances and items
Jouramie Dec 15, 2024
72a2685
fix count explain being way to big
Jouramie Dec 15, 2024
4738ce7
add colors to other commands
Jouramie Dec 15, 2024
9260891
add color in count explanation
Jouramie Dec 15, 2024
2227fc7
Pushback location explains in more explain
Jouramie Dec 15, 2024
770dae0
properly color count subrules
Jouramie Dec 15, 2024
f1d7f7b
change get_updated_state to call directly updateTracker
Jouramie Dec 16, 2024
90f920a
get the state from .state
Jouramie Dec 17, 2024
7af0458
add some better error handling
Jouramie Dec 17, 2024
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
34 changes: 3 additions & 31 deletions worlds/stardew_valley/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,17 @@
import re
# webserver imports
import urllib.parse
from collections import Counter

import Utils
from BaseClasses import MultiWorld, CollectionState, ItemClassification
from BaseClasses import MultiWorld, CollectionState
from CommonClient import logger, get_base_parser, gui_enabled, server_loop
from MultiServer import mark_raw
from NetUtils import JSONMessagePart
from .logic.logic import StardewLogic
from .stardew_rule.rule_explain import explain, ExplainMode, RuleExplanation

try:
from worlds.tracker.TrackerClient import TrackerGameContext, TrackerCommandProcessor as ClientCommandProcessor, UT_VERSION # noqa
from worlds.tracker.TrackerClient import TrackerGameContext, TrackerCommandProcessor as ClientCommandProcessor, UT_VERSION, updateTracker # noqa

tracker_loaded = True
except ImportError:
Expand Down Expand Up @@ -210,35 +209,8 @@ def parse_explanation(explanation: RuleExplanation) -> list[JSONMessagePart]:
return messages


# Don't mind me I just copy-pasted that from UT because it was too complicated to access their updated state.
def get_updated_state(ctx: TrackerGameContext) -> CollectionState:
if ctx.player_id is None or ctx.multiworld is None:
logger.error("Player YAML not installed or Generator failed")
ctx.log_to_tab("Check Player YAMLs for error", False)
ctx.tracker_failed = True
raise ValueError("Player YAML not installed or Generator failed")

state = CollectionState(ctx.multiworld)
state.sweep_for_advancements(
locations=(location for location in ctx.multiworld.get_locations() if (not location.address)))
prog_items = Counter()
all_items = Counter()

item_id_to_name = ctx.multiworld.worlds[ctx.player_id].item_id_to_name
for item_name in [item_id_to_name[item[0]] for item in ctx.items_received] + ctx.manual_items:
try:
world_item = ctx.multiworld.create_item(item_name, ctx.player_id)
state.collect(world_item, True)
if world_item.classification == ItemClassification.progression or world_item.classification == ItemClassification.progression_skip_balancing:
prog_items[world_item.name] += 1
if world_item.code is not None:
all_items[world_item.name] += 1
except:
ctx.log_to_tab("Item id " + str(item_name) + " not able to be created", False)
state.sweep_for_advancements(
locations=(location for location in ctx.multiworld.get_locations() if (not location.address)))

return state
return updateTracker(ctx)[3]
Jouramie marked this conversation as resolved.
Show resolved Hide resolved


async def main(args):
Expand Down
Loading