From 3f36c436adfd55754ee5ceea97589afaa622eac7 Mon Sep 17 00:00:00 2001 From: Jarno Westhof Date: Sun, 12 Dec 2021 23:43:30 +0100 Subject: [PATCH] TS: putting items as non local will correctly be handled by your starting orbs and your first progression item excluding locations now correctly works for your first progression item in an non inverted seed Aura blast can now be your starting spell --- worlds/timespinner/Items.py | 1 + worlds/timespinner/__init__.py | 52 +++++++++++++++++++++++++--------- 2 files changed, 40 insertions(+), 13 deletions(-) diff --git a/worlds/timespinner/Items.py b/worlds/timespinner/Items.py index 82958eba..78bfcd8b 100644 --- a/worlds/timespinner/Items.py +++ b/worlds/timespinner/Items.py @@ -213,6 +213,7 @@ starter_melee_weapons: Tuple[str, ...] = ( ) starter_spells: Tuple[str, ...] = ( + 'Aura Blast', 'Colossal Blade', 'Infernal Flames', 'Plasma Geyser', diff --git a/worlds/timespinner/__init__.py b/worlds/timespinner/__init__.py index a70ddee2..1791c360 100644 --- a/worlds/timespinner/__init__.py +++ b/worlds/timespinner/__init__.py @@ -1,4 +1,4 @@ -from typing import Dict, List, Set, TextIO +from typing import Dict, List, Set, Tuple, TextIO from BaseClasses import Item, MultiWorld, Location from ..AutoWorld import World from .LogicMixin import TimespinnerLogic @@ -115,20 +115,38 @@ def get_excluded_items(self: TimespinnerWorld, world: MultiWorld, player: int) - def assign_starter_items(world: MultiWorld, player: int, excluded_items: Set[str], locked_locations: List[str]): - melee_weapon = world.random.choice(starter_melee_weapons) - spell = world.random.choice(starter_spells) + non_local_items = world.non_local_items[player].value - excluded_items.add(melee_weapon) - excluded_items.add(spell) + local_starter_melee_weapons = tuple(item for item in starter_melee_weapons if item not in non_local_items) + if not local_starter_melee_weapons: + if 'Plasma Orb' in non_local_items: + raise Exception("Atleast one melee orb must be local") + else: + local_starter_melee_weapons = ('Plasma Orb',) - melee_weapon_item = create_item_with_correct_settings(world, player, melee_weapon) - spell_item = create_item_with_correct_settings(world, player, spell) + local_starter_spells = tuple(item for item in starter_spells if item not in non_local_items) + if not local_starter_spells: + if 'Lightwall' in non_local_items: + raise Exception("Atleast one spell must be local") + else: + local_starter_spells = ('Lightwall',) - world.get_location('Yo Momma 1', player).place_locked_item(melee_weapon_item) - world.get_location('Yo Momma 2', player).place_locked_item(spell_item) + assign_starter_item(world, player, excluded_items, locked_locations, 'Yo Momma 1', local_starter_melee_weapons) + assign_starter_item(world, player, excluded_items, locked_locations, 'Yo Momma 2', local_starter_spells) - locked_locations.append('Yo Momma 1') - locked_locations.append('Yo Momma 2') + +def assign_starter_item(world: MultiWorld, player: int, excluded_items: Set[str], locked_locations: List[str], + location: str, item_list: Tuple[str, ...]): + + item_name = world.random.choice(item_list) + + excluded_items.add(item_name) + + item = create_item_with_correct_settings(world, player, item_name) + + world.get_location(location, player).place_locked_item(item) + + locked_locations.append(location) def get_item_pool(world: MultiWorld, player: int, excluded_items: Set[str]) -> List[Item]: @@ -155,8 +173,16 @@ def place_first_progression_item(world: MultiWorld, player: int, excluded_items: if item.name in starter_progression_items: return - progression_item = world.random.choice(starter_progression_items) - location = world.random.choice(starter_progression_locations) + local_starter_progression_items = tuple( + item for item in starter_progression_items if item not in world.non_local_items[player].value) + non_excluded_starter_progression_locations = tuple( + location for location in starter_progression_locations if location not in world.exclude_locations[player].value) + + if not local_starter_progression_items or not non_excluded_starter_progression_locations: + return + + progression_item = world.random.choice(local_starter_progression_items) + location = world.random.choice(non_excluded_starter_progression_locations) excluded_items.add(progression_item) locked_locations.append(location)