From 4027d2f96d0267bcf8af7edfef103b93f0498e89 Mon Sep 17 00:00:00 2001 From: CookieCat Date: Wed, 15 May 2024 16:44:02 -0400 Subject: [PATCH] starting inventory hats fix --- worlds/ahit/Items.py | 18 ++++-------------- worlds/ahit/Rules.py | 4 ---- worlds/ahit/__init__.py | 16 +++++++++++++++- 3 files changed, 19 insertions(+), 19 deletions(-) diff --git a/worlds/ahit/Items.py b/worlds/ahit/Items.py index 93b3d2bb9d..6513d7800c 100644 --- a/worlds/ahit/Items.py +++ b/worlds/ahit/Items.py @@ -2,7 +2,7 @@ from BaseClasses import Item, ItemClassification from .Types import HatDLC, HatType, hat_type_to_item, Difficulty, ItemData, HatInTimeItem from .Locations import get_total_locations from .Rules import get_difficulty -from .Options import get_total_time_pieces +from .Options import get_total_time_pieces, CTRLogic from typing import List, Dict, TYPE_CHECKING if TYPE_CHECKING: @@ -39,10 +39,7 @@ def create_itempool(world: "HatInTimeWorld") -> List[Item]: continue else: if name == "Scooter Badge": - if world.options.CTRLogic or get_difficulty(world) >= Difficulty.MODERATE: - item_type = ItemClassification.progression - elif name == "No Bonk Badge": - if get_difficulty(world) >= Difficulty.MODERATE: + if world.options.CTRLogic is CTRLogic.option_scooter or get_difficulty(world) >= Difficulty.MODERATE: item_type = ItemClassification.progression # some death wish bonuses require one hit hero + hookshot @@ -58,8 +55,7 @@ def create_itempool(world: "HatInTimeWorld") -> List[Item]: if name in alps_hooks.keys() and not world.options.ShuffleAlpineZiplines: continue - if name == "Progressive Painting Unlock" \ - and not world.options.ShuffleSubconPaintings: + if name == "Progressive Painting Unlock" and not world.options.ShuffleSubconPaintings: continue if world.options.StartWithCompassBadge and name == "Compass Badge": @@ -85,14 +81,8 @@ def calculate_yarn_costs(world: "HatInTimeWorld"): max_cost = 0 for i in range(5): - precollected: bool = False hat: HatType = HatType(i) - for item in world.multiworld.precollected_items[world.player]: - if item.name == hat_type_to_item[hat]: - precollected = True - break - - if not precollected: + if not world.is_hat_precollected(hat): cost: int = world.random.randint(min_yarn_cost, max_yarn_cost) world.hat_yarn_costs[hat] = cost max_cost += cost diff --git a/worlds/ahit/Rules.py b/worlds/ahit/Rules.py index 797a5a71d0..f88fe3f950 100644 --- a/worlds/ahit/Rules.py +++ b/worlds/ahit/Rules.py @@ -91,10 +91,6 @@ def can_hit(state: CollectionState, world: "HatInTimeWorld", umbrella_only: bool return state.has("Umbrella", world.player) or not umbrella_only and can_use_hat(state, world, HatType.BREWING) -def can_surf(state: CollectionState, world: "HatInTimeWorld"): - return state.has("No Bonk Badge", world.player) - - def has_relic_combo(state: CollectionState, world: "HatInTimeWorld", relic: str) -> bool: return state.has_group(relic, world.player, len(world.item_name_groups[relic])) diff --git a/worlds/ahit/__init__.py b/worlds/ahit/__init__.py index 759e9e52e2..738ad955e7 100644 --- a/worlds/ahit/__init__.py +++ b/worlds/ahit/__init__.py @@ -6,7 +6,7 @@ from .Locations import location_table, contract_locations, is_location_valid, ge get_total_locations from .Rules import set_rules from .Options import AHITOptions, slot_data_options, adjust_options, RandomizeHatOrder, EndGoal -from .Types import HatType, ChapterIndex, HatInTimeItem +from .Types import HatType, ChapterIndex, HatInTimeItem, hat_type_to_item from .DeathWishLocations import create_dw_regions, dw_classes, death_wishes from .DeathWishRules import set_dw_rules, create_enemy_events, hit_list, bosses from worlds.AutoWorld import World, WebWorld, CollectionState @@ -130,6 +130,13 @@ class HatInTimeWorld(World): self.hat_craft_order.remove(HatType.TIME_STOP) self.hat_craft_order.append(HatType.TIME_STOP) + # move precollected hats to the start of the list + for i in range(5): + hat = HatType(i) + if self.is_hat_precollected(hat): + self.hat_craft_order.remove(hat) + self.hat_craft_order.insert(0, hat) + self.multiworld.itempool += create_itempool(self) def set_rules(self): @@ -329,6 +336,13 @@ class HatInTimeWorld(World): def has_yarn(self) -> bool: return not self.is_dw_only() and not self.options.HatItems + def is_hat_precollected(self, hat: HatType) -> bool: + for item in self.multiworld.precollected_items[self.player]: + if item.name == hat_type_to_item[hat]: + return True + + return False + def is_dlc1(self) -> bool: return bool(self.options.EnableDLC1)