Skip to content

Commit

Permalink
Fix generation (ArchipelagoMW#13)
Browse files Browse the repository at this point in the history
* Fix generation

* Remove unnecessary code, add TODO for later
  • Loading branch information
SunnyBat authored Jun 20, 2023
1 parent ee99de4 commit 58074b8
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 35 deletions.
9 changes: 3 additions & 6 deletions worlds/yooka_laylee/Items.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,12 @@
with open(os.path.join(os.path.dirname(__file__), 'items.json'), 'r') as file:
item_table = json.loads(file.read())

lookup_id_to_name = {}
lookup_name_to_item = {}
lookup_name_to_id = {}

lastItemId = -1
for item in item_table:
item_name = item["name"]
lookup_id_to_name[item["id"]] = item_name
lookup_name_to_item[item_name] = item
lastItemId = max(lastItemId, item["id"])
lookup_name_to_id[item_name] = item["id"]

lookup_id_to_name[None] = "Victory"
lookup_name_to_id = {name: id for id, name in lookup_id_to_name.items()}
lookup_name_to_id["Victory"] = None
10 changes: 3 additions & 7 deletions worlds/yooka_laylee/Locations.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,8 @@
with open(os.path.join(os.path.dirname(__file__), 'locations.json'), 'r') as file:
location_table = json.loads(file.read())

lookup_id_to_name = {}
j = 0
lookup_name_to_id = {}
for item in location_table:
j = j + 1
lookup_id_to_name[item["id"]] = item["name"]
print(j)
lookup_name_to_id[item["name"]] = item["id"]

lookup_id_to_name[None] = "Game Complete"
lookup_name_to_id = {name: id for id, name in lookup_id_to_name.items()}
lookup_name_to_id["Game Complete"] = None
2 changes: 1 addition & 1 deletion worlds/yooka_laylee/Rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def fullLocationCheck(state, location=location):
break
if "requiresItems" in location:
for item in location["requiresItems"]:
if not state.has(player, item):
if not state.has(item, player):
canAccess = False
break
return canAccess
Expand Down
32 changes: 11 additions & 21 deletions worlds/yooka_laylee/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,10 @@ class YookaWorld(World):
def create_items(self):
# Generate item pool
pool = []
j = 0
for item in item_table:

for i in range(0, item["quantity"]):
print(i, item["name"])
yooka_item = self.create_item(item["name"])
pool.append(yooka_item)
j = j + 1
print(j)
self.multiworld.itempool += pool

def set_rules(self):
Expand All @@ -72,26 +67,22 @@ def create_item(self, name: str) -> Item:

def create_resourcePack(self, rpName: str) -> Item:
return YookaItem(rpName, ItemClassification.filler, self.item_name_to_id[rpName], player=self.player)

#TODO: Delete if unnecessary
# def collect_item(self, state, item, remove=False):
# if item.name in progressive_item_list:
# prog_table = progressive_item_list[item.name]
# if remove:
# for item_name in reversed(prog_table):
# if state.has(item_name, item.player):
# return item_name
# else:
# for item_name in prog_table:
# if not state.has(item_name, item.player):
# return item_name

# return super(YookaWorld, self).collect_item(state, item, remove)

def pre_fill(self):
# Victory item
self.multiworld.get_location("Game Complete", self.player).place_locked_item(
YookaItem("Victory", ItemClassification.progression, None, player=self.player))
# TODO Prefill these if Mollycools and/or Play Coin randomization is disabled
# self.setLocationItem("Tropics Mollycool", "Tropics Mollycool")
# self.setLocationItem("Glacier Mollycool", "Glacier Mollycool")
# self.setLocationItem("Marsh Mollycool", "Marsh Mollycool")
# self.setLocationItem("Cashino Mollycool", "Cashino Mollycool")
# self.setLocationItem("Galaxy Mollycool", "Galaxy Mollycool")
# self.setLocationItem("Tropics Play Coin", "Tropics Play Coin")
# self.setLocationItem("Glacier Play Coin", "Glacier Play Coin")
# self.setLocationItem("Marsh Play Coin", "Marsh Play Coin")
# self.setLocationItem("Cashino Play Coin", "Cashino Play Coin")
# self.setLocationItem("Galaxy Play Coin", "Galaxy Play Coin")

def setLocationItem(self, location: str, itemName: str):
itemToUse = next(filter(lambda itm: itm.name == itemName, self.multiworld.itempool))
Expand Down Expand Up @@ -124,6 +115,5 @@ def create_region(world: MultiWorld, player: int, name: str, locations=None, exi
class YookaLocation(Location):
game = "Yooka Laylee"


class YookaItem(Item):
game = "Yooka Laylee"

0 comments on commit 58074b8

Please sign in to comment.