From a532ceeb0a7ce5ba0e3e921ced18a8f221e16bfd Mon Sep 17 00:00:00 2001 From: Fabian Dill Date: Tue, 10 Aug 2021 09:47:28 +0200 Subject: [PATCH] AutoWorld: Should no longer need to overwrite collect, collect_item should be used instead AutoWorld: Now correctly automatically applies State.remove if collect_item is also correct LttP: Make keys advancement items This feels like it improved generation chance. Might not be the case. --- BaseClasses.py | 55 ++++--------------------------------- Fill.py | 2 +- worlds/AutoWorld.py | 27 ++++++++++++++---- worlds/alttp/Dungeons.py | 5 ---- worlds/alttp/Items.py | 52 +++++++++++++++++------------------ worlds/alttp/__init__.py | 47 ++++++++++++------------------- worlds/factorio/__init__.py | 8 +++--- worlds/generic/Rules.py | 2 +- 8 files changed, 76 insertions(+), 122 deletions(-) diff --git a/BaseClasses.py b/BaseClasses.py index 32ae1908..a73d22a6 100644 --- a/BaseClasses.py +++ b/BaseClasses.py @@ -263,8 +263,6 @@ class MultiWorld(): def push_precollected(self, item: Item): item.world = self - if (item.smallkey and self.keyshuffle[item.player]) or (item.bigkey and self.bigkeyshuffle[item.player]): - item.advancement = True self.precollected_items.append(item) self.state.collect(item, True) @@ -758,53 +756,12 @@ class CollectionState(object): return changed def remove(self, item): - if item.advancement: - to_remove = item.name - if item.game == "A Link to the Past" and to_remove.startswith('Progressive '): - if 'Sword' in to_remove: - if self.has('Golden Sword', item.player): - to_remove = 'Golden Sword' - elif self.has('Tempered Sword', item.player): - to_remove = 'Tempered Sword' - elif self.has('Master Sword', item.player): - to_remove = 'Master Sword' - elif self.has('Fighter Sword', item.player): - to_remove = 'Fighter Sword' - else: - to_remove = None - elif 'Glove' in item.name: - if self.has('Titans Mitts', item.player): - to_remove = 'Titans Mitts' - elif self.has('Power Glove', item.player): - to_remove = 'Power Glove' - else: - to_remove = None - elif 'Shield' in item.name: - if self.has('Mirror Shield', item.player): - to_remove = 'Mirror Shield' - elif self.has('Red Shield', item.player): - to_remove = 'Red Shield' - elif self.has('Blue Shield', item.player): - to_remove = 'Blue Shield' - else: - to_remove = None - elif 'Bow' in item.name: - if self.has('Silver Bow', item.player): - to_remove = 'Silver Bow' - elif self.has('Bow', item.player): - to_remove = 'Bow' - else: - to_remove = None - - if to_remove: - - self.prog_items[to_remove, item.player] -= 1 - if self.prog_items[to_remove, item.player] < 1: - del (self.prog_items[to_remove, item.player]) - # invalidate caches, nothing can be trusted anymore now - self.reachable_regions[item.player] = set() - self.blocked_connections[item.player] = set() - self.stale[item.player] = True + changed = self.world.worlds[item.player].remove(self, item) + if changed: + # invalidate caches, nothing can be trusted anymore now + self.reachable_regions[item.player] = set() + self.blocked_connections[item.player] = set() + self.stale[item.player] = True @unique class RegionType(int, Enum): diff --git a/Fill.py b/Fill.py index 940865e4..e9d1f2cb 100644 --- a/Fill.py +++ b/Fill.py @@ -187,7 +187,7 @@ def flood_items(world: MultiWorld): location_list = world.get_reachable_locations() world.random.shuffle(location_list) for location in location_list: - if location.item is not None and not location.item.advancement and not location.item.smallkey and not location.item.bigkey: + if location.item is not None and not location.item.advancement: # safe to replace replace_item = location.item replace_item.location = None diff --git a/worlds/AutoWorld.py b/worlds/AutoWorld.py index d22ff52f..71a2dcc9 100644 --- a/worlds/AutoWorld.py +++ b/worlds/AutoWorld.py @@ -1,5 +1,5 @@ from __future__ import annotations -from typing import Dict, Set, Tuple, List +from typing import Dict, Set, Tuple, List, Optional from BaseClasses import MultiWorld, Item, CollectionState, Location @@ -150,18 +150,33 @@ class World(metaclass=AutoWorldRegister): # end of Main.py calls - def collect(self, state: CollectionState, item: Item) -> bool: - """Collect an item into state. For speed reasons items that aren't logically useful get skipped.""" + def collect_item(self, state: CollectionState, item: Item) -> Optional[str]: + """Collect an item name into state. For speed reasons items that aren't logically useful get skipped. + Collect None to skip item.""" if item.advancement: - state.prog_items[item.name, item.player] += 1 - return True # indicate that a logical state change has occured - return False + return item.name def create_item(self, name: str) -> Item: """Create an item for this world type and player. Warning: this may be called with self.world = None, for example by MultiServer""" raise NotImplementedError + # following methods should not need to be overriden. + def collect(self, state: CollectionState, item: Item) -> bool: + name = self.collect_item(state, item) + if name: + state.prog_items[name, item.player] += 1 + return True + return False + + def remove(self, state: CollectionState, item: Item) -> bool: + name = self.collect_item(state, item) + if name: + state.prog_items[name, item.player] -= 1 + if state.prog_items[name, item.player] < 1: + del (state.prog_items[name, item.player]) + return True + return False # any methods attached to this can be used as part of CollectionState, # please use a prefix as all of them get clobbered together diff --git a/worlds/alttp/Dungeons.py b/worlds/alttp/Dungeons.py index 115ffdf9..b8f2c76c 100644 --- a/worlds/alttp/Dungeons.py +++ b/worlds/alttp/Dungeons.py @@ -67,11 +67,6 @@ def fill_dungeons_restrictive(world): world.random.shuffle(locations) all_state_base = world.get_all_state() - # with shuffled dungeon items they are distributed as part of the normal item pool - for item in world.get_items(): - if (item.smallkey and world.keyshuffle[item.player]) or (item.bigkey and world.bigkeyshuffle[item.player]): - all_state_base.collect(item, True) - item.advancement = True # sort in the order Big Key, Small Key, Other before placing dungeon items sort_order = {"BigKey": 3, "SmallKey": 2} dungeon_items.sort(key=lambda item: sort_order.get(item.type, 1)) diff --git a/worlds/alttp/Items.py b/worlds/alttp/Items.py index 8e53ea1a..f8b30a2d 100644 --- a/worlds/alttp/Items.py +++ b/worlds/alttp/Items.py @@ -136,58 +136,58 @@ item_table = {'Bow': ItemData(True, None, 0x0B, 'You have\nchosen the\narcher cl 'Multi RNG': ItemData(False, None, 0x63, 'something you may already have', None, None, None, None, 'unknown boy somethings again', 'a total mystery'), 'Magic Upgrade (1/2)': ItemData(True, None, 0x4E, 'Your magic\npower has been\ndoubled!', 'and the spell power', 'the magic-saving kid', 'wizardry for sale', 'mekalekahi mekahiney ho', 'magic boy saves magic again', 'Half Magic'), # can be required to beat mothula in an open seed in very very rare circumstance 'Magic Upgrade (1/4)': ItemData(True, None, 0x4F, 'Your magic\npower has been\nquadrupled!', 'and the spell power', 'the magic-saving kid', 'wizardry for sale', 'mekalekahi mekahiney ho', 'magic boy saves magic again', 'Quarter Magic'), # can be required to beat mothula in an open seed in very very rare circumstance - 'Small Key (Eastern Palace)': ItemData(False, 'SmallKey', 0xA2, 'A small key to Armos Knights', 'and the key', 'the unlocking kid', 'keys for sale', 'unlock the fungus', 'key boy opens door again', 'a small key to Eastern Palace'), - 'Big Key (Eastern Palace)': ItemData(False, 'BigKey', 0x9D, 'A big key to Armos Knights', 'and the big key', 'the big-unlock kid', 'big key for sale', 'face key fungus', 'key boy opens chest again', 'a big key to Eastern Palace'), + 'Small Key (Eastern Palace)': ItemData(True, 'SmallKey', 0xA2, 'A small key to Armos Knights', 'and the key', 'the unlocking kid', 'keys for sale', 'unlock the fungus', 'key boy opens door again', 'a small key to Eastern Palace'), + 'Big Key (Eastern Palace)': ItemData(True, 'BigKey', 0x9D, 'A big key to Armos Knights', 'and the big key', 'the big-unlock kid', 'big key for sale', 'face key fungus', 'key boy opens chest again', 'a big key to Eastern Palace'), 'Compass (Eastern Palace)': ItemData(False, 'Compass', 0x8D, 'Now you can find the Armos Knights!', 'and the compass', 'the magnetic kid', 'compass for sale', 'magnetic fungus', 'compass boy finds boss again', 'a compass to Eastern Palace'), 'Map (Eastern Palace)': ItemData(False, 'Map', 0x7D, 'A tightly folded map rests here', 'and the map', 'cartography kid', 'map for sale', 'a map to shrooms', 'map boy navigates again', 'a map to Eastern Palace'), - 'Small Key (Desert Palace)': ItemData(False, 'SmallKey', 0xA3, 'A small key to the desert', 'and the key', 'the unlocking kid', 'keys for sale', 'unlock the fungus', 'key boy opens door again', 'a small key to Desert Palace'), - 'Big Key (Desert Palace)': ItemData(False, 'BigKey', 0x9C, 'A big key to the desert', 'and the big key', 'the big-unlock kid', 'big key for sale', 'face key fungus', 'key boy opens chest again', 'a big key to Desert Palace'), + 'Small Key (Desert Palace)': ItemData(True, 'SmallKey', 0xA3, 'A small key to the desert', 'and the key', 'the unlocking kid', 'keys for sale', 'unlock the fungus', 'key boy opens door again', 'a small key to Desert Palace'), + 'Big Key (Desert Palace)': ItemData(True, 'BigKey', 0x9C, 'A big key to the desert', 'and the big key', 'the big-unlock kid', 'big key for sale', 'face key fungus', 'key boy opens chest again', 'a big key to Desert Palace'), 'Compass (Desert Palace)': ItemData(False, 'Compass', 0x8C, 'Now you can find Lanmolas!', 'and the compass', 'the magnetic kid', 'compass for sale', 'magnetic fungus', 'compass boy finds boss again', 'a compass to Desert Palace'), 'Map (Desert Palace)': ItemData(False, 'Map', 0x7C, 'A tightly folded map rests here', 'and the map', 'cartography kid', 'map for sale', 'a map to shrooms', 'map boy navigates again', 'a map to Desert Palace'), - 'Small Key (Tower of Hera)': ItemData(False, 'SmallKey', 0xAA, 'A small key to Hera', 'and the key', 'the unlocking kid', 'keys for sale', 'unlock the fungus', 'key boy opens door again', 'a small key to Tower of Hera'), - 'Big Key (Tower of Hera)': ItemData(False, 'BigKey', 0x95, 'A big key to Hera', 'and the big key', 'the big-unlock kid', 'big key for sale', 'face key fungus', 'key boy opens chest again', 'a big key to Tower of Hera'), + 'Small Key (Tower of Hera)': ItemData(True, 'SmallKey', 0xAA, 'A small key to Hera', 'and the key', 'the unlocking kid', 'keys for sale', 'unlock the fungus', 'key boy opens door again', 'a small key to Tower of Hera'), + 'Big Key (Tower of Hera)': ItemData(True, 'BigKey', 0x95, 'A big key to Hera', 'and the big key', 'the big-unlock kid', 'big key for sale', 'face key fungus', 'key boy opens chest again', 'a big key to Tower of Hera'), 'Compass (Tower of Hera)': ItemData(False, 'Compass', 0x85, 'Now you can find Moldorm!', 'and the compass', 'the magnetic kid', 'compass for sale', 'magnetic fungus', 'compass boy finds boss again', 'a compass to Tower of Hera'), 'Map (Tower of Hera)': ItemData(False, 'Map', 0x75, 'A tightly folded map rests here', 'and the map', 'cartography kid', 'map for sale', 'a map to shrooms', 'map boy navigates again', 'a map to Tower of Hera'), - 'Small Key (Hyrule Castle)': ItemData(False, 'SmallKey', 0xA0, 'A small key to the castle', 'and the key', 'the unlocking kid', 'keys for sale', 'unlock the fungus', 'key boy opens door again', 'a small key to Hyrule Castle'), - 'Big Key (Hyrule Castle)': ItemData(False, 'BigKey', 0x9F, 'A big key to the castle', 'and the big key', 'the big-unlock kid', 'big key for sale', 'face key fungus', 'key boy opens chest again', 'a big key to Hyrule Castle'), + 'Small Key (Hyrule Castle)': ItemData(True, 'SmallKey', 0xA0, 'A small key to the castle', 'and the key', 'the unlocking kid', 'keys for sale', 'unlock the fungus', 'key boy opens door again', 'a small key to Hyrule Castle'), + 'Big Key (Hyrule Castle)': ItemData(True, 'BigKey', 0x9F, 'A big key to the castle', 'and the big key', 'the big-unlock kid', 'big key for sale', 'face key fungus', 'key boy opens chest again', 'a big key to Hyrule Castle'), 'Compass (Hyrule Castle)': ItemData(False, 'Compass', 0x8F, 'Now you can find no boss!', 'and the compass', 'the magnetic kid', 'compass for sale', 'magnetic fungus', 'compass boy finds boss again', 'a compass to Hyrule Castle'), 'Map (Hyrule Castle)': ItemData(False, 'Map', 0x7F, 'A tightly folded map rests here', 'and the map', 'cartography kid', 'map for sale', 'a map to shrooms', 'map boy navigates again', 'a map to Hyrule Castle'), - 'Small Key (Agahnims Tower)': ItemData(False, 'SmallKey', 0xA4, 'A small key to Agahnim', 'and the key', 'the unlocking kid', 'keys for sale', 'unlock the fungus', 'key boy opens door again', 'a small key to Castle Tower'), + 'Small Key (Agahnims Tower)': ItemData(True, 'SmallKey', 0xA4, 'A small key to Agahnim', 'and the key', 'the unlocking kid', 'keys for sale', 'unlock the fungus', 'key boy opens door again', 'a small key to Castle Tower'), # doors-specific items, baserom will not be able to understand these - 'Big Key (Agahnims Tower)': ItemData(False, 'BigKey', 0x9B, 'A big key to Agahnim', 'and the big key', 'the big-unlock kid', 'big key for sale', 'face key fungus', 'key boy opens chest again', 'a big key to Castle Tower'), + 'Big Key (Agahnims Tower)': ItemData(True, 'BigKey', 0x9B, 'A big key to Agahnim', 'and the big key', 'the big-unlock kid', 'big key for sale', 'face key fungus', 'key boy opens chest again', 'a big key to Castle Tower'), 'Compass (Agahnims Tower)': ItemData(False, 'Compass', 0x8B, 'Now you can find Aga1!', 'and the compass', 'the magnetic kid', 'compass for sale', 'magnetic fungus', 'compass boy finds null again', 'a compass to Castle Tower'), 'Map (Agahnims Tower)': ItemData(False, 'Map', 0x7B, 'A tightly folded map rests here', 'and the map', 'cartography kid', 'map for sale', 'a map to shrooms', 'map boy navigates again', 'a map to Castle Tower'), # end of doors-specific items - 'Small Key (Palace of Darkness)': ItemData(False, 'SmallKey', 0xA6, 'A small key to darkness', 'and the key', 'the unlocking kid', 'keys for sale', 'unlock the fungus', 'key boy opens door again', 'a small key to Palace of Darkness'), - 'Big Key (Palace of Darkness)': ItemData(False, 'BigKey', 0x99, 'A big key to darkness', 'and the big key', 'the big-unlock kid', 'big key for sale', 'face key fungus', 'key boy opens chest again', 'a big key to Palace of Darkness'), + 'Small Key (Palace of Darkness)': ItemData(True, 'SmallKey', 0xA6, 'A small key to darkness', 'and the key', 'the unlocking kid', 'keys for sale', 'unlock the fungus', 'key boy opens door again', 'a small key to Palace of Darkness'), + 'Big Key (Palace of Darkness)': ItemData(True, 'BigKey', 0x99, 'A big key to darkness', 'and the big key', 'the big-unlock kid', 'big key for sale', 'face key fungus', 'key boy opens chest again', 'a big key to Palace of Darkness'), 'Compass (Palace of Darkness)': ItemData(False, 'Compass', 0x89, 'Now you can find Helmasaur King!', 'and the compass', 'the magnetic kid', 'compass for sale', 'magnetic fungus', 'compass boy finds boss again', 'a compass to Palace of Darkness'), 'Map (Palace of Darkness)': ItemData(False, 'Map', 0x79, 'A tightly folded map rests here', 'and the map', 'cartography kid', 'map for sale', 'a map to shrooms', 'map boy navigates again', 'a map to Palace of Darkness'), - 'Small Key (Thieves Town)': ItemData(False, 'SmallKey', 0xAB, 'A small key to thievery', 'and the key', 'the unlocking kid', 'keys for sale', 'unlock the fungus', 'key boy opens door again', 'a small key to Thieves\' Town'), - 'Big Key (Thieves Town)': ItemData(False, 'BigKey', 0x94, 'A big key to thievery', 'and the big key', 'the big-unlock kid', 'big key for sale', 'face key fungus', 'key boy opens chest again', 'a big key to Thieves\' Town'), + 'Small Key (Thieves Town)': ItemData(True, 'SmallKey', 0xAB, 'A small key to thievery', 'and the key', 'the unlocking kid', 'keys for sale', 'unlock the fungus', 'key boy opens door again', 'a small key to Thieves\' Town'), + 'Big Key (Thieves Town)': ItemData(True, 'BigKey', 0x94, 'A big key to thievery', 'and the big key', 'the big-unlock kid', 'big key for sale', 'face key fungus', 'key boy opens chest again', 'a big key to Thieves\' Town'), 'Compass (Thieves Town)': ItemData(False, 'Compass', 0x84, 'Now you can find Blind!', 'and the compass', 'the magnetic kid', 'compass for sale', 'magnetic fungus', 'compass boy finds boss again', 'a compass to Thieves\' Town'), 'Map (Thieves Town)': ItemData(False, 'Map', 0x74, 'A tightly folded map rests here', 'and the map', 'cartography kid', 'map for sale', 'a map to shrooms', 'map boy navigates again', 'a map to Thieves\' Town'), - 'Small Key (Skull Woods)': ItemData(False, 'SmallKey', 0xA8, 'A small key to the woods', 'and the key', 'the unlocking kid', 'keys for sale', 'unlock the fungus', 'key boy opens door again', 'a small key to Skull Woods'), - 'Big Key (Skull Woods)': ItemData(False, 'BigKey', 0x97, 'A big key to the woods', 'and the big key', 'the big-unlock kid', 'big key for sale', 'face key fungus', 'key boy opens chest again', 'a big key to Skull Woods'), + 'Small Key (Skull Woods)': ItemData(True, 'SmallKey', 0xA8, 'A small key to the woods', 'and the key', 'the unlocking kid', 'keys for sale', 'unlock the fungus', 'key boy opens door again', 'a small key to Skull Woods'), + 'Big Key (Skull Woods)': ItemData(True, 'BigKey', 0x97, 'A big key to the woods', 'and the big key', 'the big-unlock kid', 'big key for sale', 'face key fungus', 'key boy opens chest again', 'a big key to Skull Woods'), 'Compass (Skull Woods)': ItemData(False, 'Compass', 0x87, 'Now you can find Mothula!', 'and the compass', 'the magnetic kid', 'compass for sale', 'magnetic fungus', 'compass boy finds boss again', 'a compass to Skull Woods'), 'Map (Skull Woods)': ItemData(False, 'Map', 0x77, 'A tightly folded map rests here', 'and the map', 'cartography kid', 'map for sale', 'a map to shrooms', 'map boy navigates again', 'a map to Skull Woods'), - 'Small Key (Swamp Palace)': ItemData(False, 'SmallKey', 0xA5, 'A small key to the swamp', 'and the key', 'the unlocking kid', 'keys for sale', 'unlock the fungus', 'key boy opens door again', 'a small key to Swamp Palace'), - 'Big Key (Swamp Palace)': ItemData(False, 'BigKey', 0x9A, 'A big key to the swamp', 'and the big key', 'the big-unlock kid', 'big key for sale', 'face key fungus', 'key boy opens chest again', 'a big key to Swamp Palace'), + 'Small Key (Swamp Palace)': ItemData(True, 'SmallKey', 0xA5, 'A small key to the swamp', 'and the key', 'the unlocking kid', 'keys for sale', 'unlock the fungus', 'key boy opens door again', 'a small key to Swamp Palace'), + 'Big Key (Swamp Palace)': ItemData(True, 'BigKey', 0x9A, 'A big key to the swamp', 'and the big key', 'the big-unlock kid', 'big key for sale', 'face key fungus', 'key boy opens chest again', 'a big key to Swamp Palace'), 'Compass (Swamp Palace)': ItemData(False, 'Compass', 0x8A, 'Now you can find Arrghus!', 'and the compass', 'the magnetic kid', 'compass for sale', 'magnetic fungus', 'compass boy finds boss again', 'a compass to Swamp Palace'), 'Map (Swamp Palace)': ItemData(False, 'Map', 0x7A, 'A tightly folded map rests here', 'and the map', 'cartography kid', 'map for sale', 'a map to shrooms', 'map boy navigates again', 'a map to Swamp Palace'), - 'Small Key (Ice Palace)': ItemData(False, 'SmallKey', 0xA9, 'A small key to the iceberg', 'and the key', 'the unlocking kid', 'keys for sale', 'unlock the fungus', 'key boy opens door again', 'a small key to Ice Palace'), - 'Big Key (Ice Palace)': ItemData(False, 'BigKey', 0x96, 'A big key to the iceberg', 'and the big key', 'the big-unlock kid', 'big key for sale', 'face key fungus', 'key boy opens chest again', 'a big key to Ice Palace'), + 'Small Key (Ice Palace)': ItemData(True, 'SmallKey', 0xA9, 'A small key to the iceberg', 'and the key', 'the unlocking kid', 'keys for sale', 'unlock the fungus', 'key boy opens door again', 'a small key to Ice Palace'), + 'Big Key (Ice Palace)': ItemData(True, 'BigKey', 0x96, 'A big key to the iceberg', 'and the big key', 'the big-unlock kid', 'big key for sale', 'face key fungus', 'key boy opens chest again', 'a big key to Ice Palace'), 'Compass (Ice Palace)': ItemData(False, 'Compass', 0x86, 'Now you can find Kholdstare!', 'and the compass', 'the magnetic kid', 'compass for sale', 'magnetic fungus', 'compass boy finds boss again', 'a compass to Ice Palace'), 'Map (Ice Palace)': ItemData(False, 'Map', 0x76, 'A tightly folded map rests here', 'and the map', 'cartography kid', 'map for sale', 'a map to shrooms', 'map boy navigates again', 'a map to Ice Palace'), - 'Small Key (Misery Mire)': ItemData(False, 'SmallKey', 0xA7, 'A small key to the mire', 'and the key', 'the unlocking kid', 'keys for sale', 'unlock the fungus', 'key boy opens door again', 'a small key to Misery Mire'), - 'Big Key (Misery Mire)': ItemData(False, 'BigKey', 0x98, 'A big key to the mire', 'and the big key', 'the big-unlock kid', 'big key for sale', 'face key fungus', 'key boy opens chest again', 'a big key to Misery Mire'), + 'Small Key (Misery Mire)': ItemData(True, 'SmallKey', 0xA7, 'A small key to the mire', 'and the key', 'the unlocking kid', 'keys for sale', 'unlock the fungus', 'key boy opens door again', 'a small key to Misery Mire'), + 'Big Key (Misery Mire)': ItemData(True, 'BigKey', 0x98, 'A big key to the mire', 'and the big key', 'the big-unlock kid', 'big key for sale', 'face key fungus', 'key boy opens chest again', 'a big key to Misery Mire'), 'Compass (Misery Mire)': ItemData(False, 'Compass', 0x88, 'Now you can find Vitreous!', 'and the compass', 'the magnetic kid', 'compass for sale', 'magnetic fungus', 'compass boy finds boss again', 'a compass to Misery Mire'), 'Map (Misery Mire)': ItemData(False, 'Map', 0x78, 'A tightly folded map rests here', 'and the map', 'cartography kid', 'map for sale', 'a map to shrooms', 'map boy navigates again', 'a map to Misery Mire'), - 'Small Key (Turtle Rock)': ItemData(False, 'SmallKey', 0xAC, 'A small key to the pipe maze', 'and the key', 'the unlocking kid', 'keys for sale', 'unlock the fungus', 'key boy opens door again', 'a small key to Turtle Rock'), - 'Big Key (Turtle Rock)': ItemData(False, 'BigKey', 0x93, 'A big key to the pipe maze', 'and the big key', 'the big-unlock kid', 'big key for sale', 'face key fungus', 'key boy opens chest again', 'a big key to Turtle Rock'), + 'Small Key (Turtle Rock)': ItemData(True, 'SmallKey', 0xAC, 'A small key to the pipe maze', 'and the key', 'the unlocking kid', 'keys for sale', 'unlock the fungus', 'key boy opens door again', 'a small key to Turtle Rock'), + 'Big Key (Turtle Rock)': ItemData(True, 'BigKey', 0x93, 'A big key to the pipe maze', 'and the big key', 'the big-unlock kid', 'big key for sale', 'face key fungus', 'key boy opens chest again', 'a big key to Turtle Rock'), 'Compass (Turtle Rock)': ItemData(False, 'Compass', 0x83, 'Now you can find Trinexx!', 'and the compass', 'the magnetic kid', 'compass for sale', 'magnetic fungus', 'compass boy finds boss again', 'a compass to Turtle Rock'), 'Map (Turtle Rock)': ItemData(False, 'Map', 0x73, 'A tightly folded map rests here', 'and the map', 'cartography kid', 'map for sale', 'a map to shrooms', 'map boy navigates again', 'a map to Turtle Rock'), - 'Small Key (Ganons Tower)': ItemData(False, 'SmallKey', 0xAD, 'A small key to the evil tower', 'and the key', 'the unlocking kid', 'keys for sale', 'unlock the fungus', 'key boy opens door again', 'a small key to Ganon\'s Tower'), - 'Big Key (Ganons Tower)': ItemData(False, 'BigKey', 0x92, 'A big key to the evil tower', 'and the big key', 'the big-unlock kid', 'big key for sale', 'face key fungus', 'key boy opens chest again', 'a big key to Ganon\'s Tower'), + 'Small Key (Ganons Tower)': ItemData(True, 'SmallKey', 0xAD, 'A small key to the evil tower', 'and the key', 'the unlocking kid', 'keys for sale', 'unlock the fungus', 'key boy opens door again', 'a small key to Ganon\'s Tower'), + 'Big Key (Ganons Tower)': ItemData(True, 'BigKey', 0x92, 'A big key to the evil tower', 'and the big key', 'the big-unlock kid', 'big key for sale', 'face key fungus', 'key boy opens chest again', 'a big key to Ganon\'s Tower'), 'Compass (Ganons Tower)': ItemData(False, 'Compass', 0x82, 'Now you can find Agahnim!', 'and the compass', 'the magnetic kid', 'compass for sale', 'magnetic fungus', 'compass boy finds boss again', 'a compass to Ganon\'s Tower'), 'Map (Ganons Tower)': ItemData(False, 'Map', 0x72, 'A tightly folded map rests here', 'and the map', 'cartography kid', 'map for sale', 'a map to shrooms', 'map boy navigates again', 'a map to Ganon\'s Tower'), 'Small Key (Universal)': ItemData(False, None, 0xAF, 'A small key for any door', 'and the key', 'the unlocking kid', 'keys for sale', 'unlock the fungus', 'key boy opens door again', 'a small key'), diff --git a/worlds/alttp/__init__.py b/worlds/alttp/__init__.py index 4019d006..5b44d137 100644 --- a/worlds/alttp/__init__.py +++ b/worlds/alttp/__init__.py @@ -86,59 +86,46 @@ class ALTTPWorld(World): world.random = old_random plando_connect(world, player) - def collect(self, state: CollectionState, item: Item) -> bool: + def collect_item(self, state: CollectionState, item: Item): if item.name.startswith('Progressive '): if 'Sword' in item.name: if state.has('Golden Sword', item.player): pass elif state.has('Tempered Sword', item.player) and self.world.difficulty_requirements[ item.player].progressive_sword_limit >= 4: - state.prog_items['Golden Sword', item.player] += 1 - return True + return 'Golden Sword' elif state.has('Master Sword', item.player) and self.world.difficulty_requirements[ item.player].progressive_sword_limit >= 3: - state.prog_items['Tempered Sword', item.player] += 1 - return True + return 'Tempered Sword' elif state.has('Fighter Sword', item.player) and self.world.difficulty_requirements[item.player].progressive_sword_limit >= 2: - state.prog_items['Master Sword', item.player] += 1 - return True + return 'Master Sword' elif self.world.difficulty_requirements[item.player].progressive_sword_limit >= 1: - state.prog_items['Fighter Sword', item.player] += 1 - return True + return 'Fighter Sword' elif 'Glove' in item.name: if state.has('Titans Mitts', item.player): - pass + return elif state.has('Power Glove', item.player): - state.prog_items['Titans Mitts', item.player] += 1 - return True + return 'Titans Mitts' else: - state.prog_items['Power Glove', item.player] += 1 - return True + return 'Power Glove' elif 'Shield' in item.name: if state.has('Mirror Shield', item.player): - pass + return elif state.has('Red Shield', item.player) and self.world.difficulty_requirements[item.player].progressive_shield_limit >= 3: - state.prog_items['Mirror Shield', item.player] += 1 - return True + return 'Mirror Shield' elif state.has('Blue Shield', item.player) and self.world.difficulty_requirements[item.player].progressive_shield_limit >= 2: - state.prog_items['Red Shield', item.player] += 1 - return True + return 'Red Shield' elif self.world.difficulty_requirements[item.player].progressive_shield_limit >= 1: - state.prog_items['Blue Shield', item.player] += 1 - return True + return 'Blue Shield' elif 'Bow' in item.name: if state.has('Silver', item.player): - pass + return elif state.has('Bow', item.player) and self.world.difficulty_requirements[item.player].progressive_bow_limit >= 2: - state.prog_items['Silver Bow', item.player] += 1 - return True + return 'Silver Bow' elif self.world.difficulty_requirements[item.player].progressive_bow_limit >= 1: - state.prog_items['Bow', item.player] += 1 - return True - elif item.advancement or item.smallkey or item.bigkey: - state.prog_items[item.name, item.player] += 1 - return True - return False + return 'Bow' + elif item.advancement: + return item.name def pre_fill(self): from Fill import fill_restrictive, FillError diff --git a/worlds/factorio/__init__.py b/worlds/factorio/__init__.py index 8d04801a..24b62965 100644 --- a/worlds/factorio/__init__.py +++ b/worlds/factorio/__init__.py @@ -140,14 +140,14 @@ class Factorio(World): world.completion_condition[player] = lambda state: state.has('Victory', player) - def collect(self, state, item) -> bool: + def collect_item(self, state, item): if item.advancement and item.name in progressive_technology_table: prog_table = progressive_technology_table[item.name].progressive for item_name in prog_table: if not state.has(item_name, item.player): - state.prog_items[item_name, item.player] += 1 - return True - return super(Factorio, self).collect(state, item) + return item_name + + return super(Factorio, self).collect_item(state, item) def get_required_client_version(self) -> tuple: return max((0, 1, 6), super(Factorio, self).get_required_client_version()) diff --git a/worlds/generic/Rules.py b/worlds/generic/Rules.py index bce1eeab..eb769bd0 100644 --- a/worlds/generic/Rules.py +++ b/worlds/generic/Rules.py @@ -12,7 +12,7 @@ def locality_rules(world, player): def exclusion_rules(world, player: int, excluded_locations: set): for loc_name in excluded_locations: location = world.get_location(loc_name, player) - add_item_rule(location, lambda i: not (i.advancement or i.smallkey or i.bigkey or i.never_exclude)) + add_item_rule(location, lambda i: not (i.advancement or i.never_exclude)) def set_rule(spot, rule):