From 75624042f7a56b7c394b5a5e36936635cb45e0f8 Mon Sep 17 00:00:00 2001 From: agilbert1412 Date: Tue, 26 Nov 2024 18:44:33 -0500 Subject: [PATCH] Stardew Valley: Make progressive movie theater a progression trap (#3985) --- worlds/stardew_valley/__init__.py | 2 +- worlds/stardew_valley/data/items.csv | 2 +- worlds/stardew_valley/items.py | 3 ++- worlds/stardew_valley/test/TestGeneration.py | 4 ++-- worlds/stardew_valley/test/__init__.py | 2 +- worlds/stardew_valley/test/mods/TestMods.py | 4 ++-- worlds/stardew_valley/test/rules/TestStateRules.py | 2 +- 7 files changed, 10 insertions(+), 9 deletions(-) diff --git a/worlds/stardew_valley/__init__.py b/worlds/stardew_valley/__init__.py index f9df8c292e37..44306011361c 100644 --- a/worlds/stardew_valley/__init__.py +++ b/worlds/stardew_valley/__init__.py @@ -319,7 +319,7 @@ def create_item(self, item: Union[str, ItemData], override_classification: ItemC if override_classification is None: override_classification = item.classification - if override_classification == ItemClassification.progression: + if override_classification & ItemClassification.progression: self.total_progression_items += 1 return StardewItem(item.name, override_classification, item.code, self.player) diff --git a/worlds/stardew_valley/data/items.csv b/worlds/stardew_valley/data/items.csv index ffcae223e251..05af275ba472 100644 --- a/worlds/stardew_valley/data/items.csv +++ b/worlds/stardew_valley/data/items.csv @@ -7,7 +7,7 @@ id,name,classification,groups,mod_name 19,Glittering Boulder Removed,progression,COMMUNITY_REWARD, 20,Minecarts Repair,useful,COMMUNITY_REWARD, 21,Bus Repair,progression,COMMUNITY_REWARD, -22,Progressive Movie Theater,progression,COMMUNITY_REWARD, +22,Progressive Movie Theater,"progression,trap",COMMUNITY_REWARD, 23,Stardrop,progression,, 24,Progressive Backpack,progression,, 25,Rusty Sword,filler,"WEAPON,DEPRECATED", diff --git a/worlds/stardew_valley/items.py b/worlds/stardew_valley/items.py index 31c7da5e3ade..730cb24ce6e3 100644 --- a/worlds/stardew_valley/items.py +++ b/worlds/stardew_valley/items.py @@ -2,6 +2,7 @@ import enum import logging from dataclasses import dataclass, field +from functools import reduce from pathlib import Path from random import Random from typing import Dict, List, Protocol, Union, Set, Optional @@ -134,7 +135,7 @@ def load_item_csv(): item_reader = csv.DictReader(file) for item in item_reader: id = int(item["id"]) if item["id"] else None - classification = ItemClassification[item["classification"]] + classification = reduce((lambda a, b: a | b), {ItemClassification[str_classification] for str_classification in item["classification"].split(",")}) groups = {Group[group] for group in item["groups"].split(",") if group} mod_name = str(item["mod_name"]) if item["mod_name"] else None items.append(ItemData(id, item["name"], classification, mod_name, groups)) diff --git a/worlds/stardew_valley/test/TestGeneration.py b/worlds/stardew_valley/test/TestGeneration.py index 8431e6857eaf..56f338fe8e11 100644 --- a/worlds/stardew_valley/test/TestGeneration.py +++ b/worlds/stardew_valley/test/TestGeneration.py @@ -35,7 +35,7 @@ def test_all_progression_items_are_added_to_the_pool(self): items_to_ignore.extend(baby.name for baby in items.items_by_group[Group.BABY]) items_to_ignore.extend(resource_pack.name for resource_pack in items.items_by_group[Group.RESOURCE_PACK]) items_to_ignore.append("The Gateway Gazette") - progression_items = [item for item in items.all_items if item.classification is ItemClassification.progression and item.name not in items_to_ignore] + progression_items = [item for item in items.all_items if item.classification & ItemClassification.progression and item.name not in items_to_ignore] for progression_item in progression_items: with self.subTest(f"{progression_item.name}"): self.assertIn(progression_item.name, all_created_items) @@ -86,7 +86,7 @@ def test_all_progression_items_except_island_are_added_to_the_pool(self): items_to_ignore.extend(season.name for season in items.items_by_group[Group.WEAPON]) items_to_ignore.extend(baby.name for baby in items.items_by_group[Group.BABY]) items_to_ignore.append("The Gateway Gazette") - progression_items = [item for item in items.all_items if item.classification is ItemClassification.progression and item.name not in items_to_ignore] + progression_items = [item for item in items.all_items if item.classification & ItemClassification.progression and item.name not in items_to_ignore] for progression_item in progression_items: with self.subTest(f"{progression_item.name}"): if Group.GINGER_ISLAND in progression_item.groups: diff --git a/worlds/stardew_valley/test/__init__.py b/worlds/stardew_valley/test/__init__.py index 3fe05d205ce0..8f4e5af28f84 100644 --- a/worlds/stardew_valley/test/__init__.py +++ b/worlds/stardew_valley/test/__init__.py @@ -306,7 +306,7 @@ def collect(self, item: Union[str, Item, Iterable[Item]], count: int = 1) -> Uni def create_item(self, item: str) -> StardewItem: created_item = self.world.create_item(item) - if created_item.classification == ItemClassification.progression: + if created_item.classification & ItemClassification.progression: self.multiworld.worlds[self.player].total_progression_items -= 1 return created_item diff --git a/worlds/stardew_valley/test/mods/TestMods.py b/worlds/stardew_valley/test/mods/TestMods.py index 97184b1338b8..07a75f21b1de 100644 --- a/worlds/stardew_valley/test/mods/TestMods.py +++ b/worlds/stardew_valley/test/mods/TestMods.py @@ -75,7 +75,7 @@ def test_all_progression_items_are_added_to_the_pool(self): items_to_ignore.extend(baby.name for baby in items.items_by_group[Group.BABY]) items_to_ignore.extend(resource_pack.name for resource_pack in items.items_by_group[Group.RESOURCE_PACK]) items_to_ignore.append("The Gateway Gazette") - progression_items = [item for item in items.all_items if item.classification is ItemClassification.progression + progression_items = [item for item in items.all_items if item.classification & ItemClassification.progression and item.name not in items_to_ignore] for progression_item in progression_items: with self.subTest(f"{progression_item.name}"): @@ -105,7 +105,7 @@ def test_all_progression_items_except_island_are_added_to_the_pool(self): items_to_ignore.extend(baby.name for baby in items.items_by_group[Group.BABY]) items_to_ignore.extend(resource_pack.name for resource_pack in items.items_by_group[Group.RESOURCE_PACK]) items_to_ignore.append("The Gateway Gazette") - progression_items = [item for item in items.all_items if item.classification is ItemClassification.progression + progression_items = [item for item in items.all_items if item.classification & ItemClassification.progression and item.name not in items_to_ignore] for progression_item in progression_items: with self.subTest(f"{progression_item.name}"): diff --git a/worlds/stardew_valley/test/rules/TestStateRules.py b/worlds/stardew_valley/test/rules/TestStateRules.py index 4f53b9a7f536..7d10f4ceb1d3 100644 --- a/worlds/stardew_valley/test/rules/TestStateRules.py +++ b/worlds/stardew_valley/test/rules/TestStateRules.py @@ -8,5 +8,5 @@ class TestHasProgressionPercent(unittest.TestCase): def test_max_item_amount_is_full_collection(self): # Not caching because it fails too often for some reason with solo_multiworld(world_caching=False) as (multiworld, world): - progression_item_count = sum(1 for i in multiworld.get_items() if ItemClassification.progression in i.classification) + progression_item_count = sum(1 for i in multiworld.get_items() if i.classification & ItemClassification.progression) self.assertEqual(world.total_progression_items, progression_item_count - 1) # -1 to skip Victory