Skip to content

Commit

Permalink
save the seed in slot data to reuse it in UT
Browse files Browse the repository at this point in the history
  • Loading branch information
Jouramie committed Jul 10, 2024
1 parent c96c554 commit 2842064
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions worlds/stardew_valley/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
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
Expand Down Expand Up @@ -27,15 +28,18 @@
from .strings.metal_names import Ore
from .strings.region_names import Region as RegionName, LogicRegion

STARDEW_VALLEY = "Stardew Valley"
UNIVERSAL_TRACKER_SEED_PROPERTY = "ut_seed"

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):
Expand All @@ -60,7 +64,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()}
Expand Down Expand Up @@ -95,6 +99,13 @@ def __init__(self, multiworld: MultiWorld, player: int):
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]) -> int:
return slot_data[UNIVERSAL_TRACKER_SEED_PROPERTY]

def generate_early(self):
self.force_change_options_if_incompatible()
self.content = create_content(self.options)
Expand Down Expand Up @@ -413,6 +424,7 @@ def fill_slot_data(self) -> Dict[str, Any]:
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,
Expand Down

0 comments on commit 2842064

Please sign in to comment.