Skip to content

Commit

Permalink
Fixed starting items issue
Browse files Browse the repository at this point in the history
Added locations
  • Loading branch information
gaithern committed Jan 13, 2024
1 parent ce9c2a1 commit be3308f
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 25 deletions.
39 changes: 20 additions & 19 deletions worlds/kh1/Client.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ def on_package(self, cmd: str, args: dict):
item_id = str(f.readline()).replace("\n", "")
location_id = str(f.readline()).replace("\n", "")
player = str(f.readline()).replace("\n", "")
if str(item_id) == str(NetworkItem(*item).item) and str(location_id) == str(NetworkItem(*item).location) and str(player) == str(NetworkItem(*item).player):
if str(item_id) == str(NetworkItem(*item).item) and str(location_id) == str(NetworkItem(*item).location) and str(player) == str(NetworkItem(*item).player) and int(location_id) > 0:
found = True
if not found:
filename = f"AP_{str(check_num+1)}.item"
Expand All @@ -132,24 +132,25 @@ def on_package(self, cmd: str, args: dict):
with open(os.path.join(self.game_communication_path, filename), 'w') as f:
f.close()

if cmd in {"PrintJSON"} and args["type"] == "ItemSend":
item = args["item"]
networkItem = NetworkItem(*item)
recieverID = args["receiving"]
senderID = networkItem.player
locationID = networkItem.location
if recieverID != self.slot and senderID == self.slot:
itemName = self.item_names[networkItem.item]
itemCategory = networkItem.flags
recieverName = self.player_names[recieverID]
filename = "sent"
with open(os.path.join(self.game_communication_path, filename), 'w') as f:
f.write(
re.sub('[^A-Za-z0-9 ]+', '',str(itemName))[:15] + "\n"
+ re.sub('[^A-Za-z0-9 ]+', '',str(recieverName))[:6] + "\n"
+ str(itemCategory) + "\n"
+ str(locationID))
f.close()
if cmd in {"PrintJSON"} and "type" in args:
if args["type"] == "ItemSend":
item = args["item"]
networkItem = NetworkItem(*item)
recieverID = args["receiving"]
senderID = networkItem.player
locationID = networkItem.location
if recieverID != self.slot and senderID == self.slot:
itemName = self.item_names[networkItem.item]
itemCategory = networkItem.flags
recieverName = self.player_names[recieverID]
filename = "sent"
with open(os.path.join(self.game_communication_path, filename), 'w') as f:
f.write(
re.sub('[^A-Za-z0-9 ]+', '',str(itemName))[:15] + "\n"
+ re.sub('[^A-Za-z0-9 ]+', '',str(recieverName))[:6] + "\n"
+ str(itemCategory) + "\n"
+ str(locationID))
f.close()

def on_deathlink(self, data: typing.Dict[str, typing.Any]):
with open(os.path.join(self.game_communication_path, 'dlreceive'), 'w') as f:
Expand Down
6 changes: 4 additions & 2 deletions worlds/kh1/Locations.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,9 @@ def get_locations_by_category(category: str) -> Dict[str, KH1LocationData]:
"Traverse Town Item Workshop Left Chest": KH1LocationData("Chests", 265_0893),
"Traverse Town Secret Waterway Near Stairs Chest": KH1LocationData("Chests", 265_0894),
"Wonderland Rabbit Hole Green Trinity Chest": KH1LocationData("Chests", 265_0931),
#"Wonderland Rabbit Hole Defeat Heartless After Trial Chest": KH1LocationData("Chests", 265_0933), missable
#"Wonderland Rabbit Hole Defeat Heartless After Hollow Bastion Chest": KH1LocationData("Chests", 265_0934), Go mode, just remove
"Wonderland Rabbit Hole Defeat Heartless 1 Chest": KH1LocationData("Chests", 265_0932),
"Wonderland Rabbit Hole Defeat Heartless 2 Chest": KH1LocationData("Chests", 265_0933),
"Wonderland Rabbit Hole Defeat Heartless 3 Chest": KH1LocationData("Chests", 265_0934),
"Wonderland Bizarre Room Green Trinity Chest": KH1LocationData("Chests", 265_0971),
"Wonderland Queen's Castle Hedge Left Red Chest": KH1LocationData("Chests", 265_1011),
"Wonderland Queen's Castle Hedge Right Blue Chest": KH1LocationData("Chests", 265_1012),
Expand Down Expand Up @@ -221,6 +222,7 @@ def get_locations_by_category(category: str) -> Dict[str, KH1LocationData]:
"Hollow Bastion Grand Hall Oblivion Chest": KH1LocationData("Chests", 265_4491),
"Hollow Bastion Grand Hall Left of Gate Chest": KH1LocationData("Chests", 265_4492),
#"Hollow Bastion Entrance Hall Push the Statue Chest": KH1LocationData("Chests", 265_4493),
"Hollow Bastion Entrance Hall Left of Emblem Door Chest": KH1LocationData("Chests", 265_4212),
"Hollow Bastion Rising Falls White Trinity Chest": KH1LocationData("Chests", 265_4494),
#"End of the World Final Dimension 1st Chest": KH1LocationData("Chests", 265_4531),
#"End of the World Final Dimension 2nd Chest": KH1LocationData("Chests", 265_4532),
Expand Down
6 changes: 4 additions & 2 deletions worlds/kh1/Regions.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,9 @@ def create_regions(multiworld: MultiWorld, player: int, goal: str, atlantica: bo
regions["Traverse Town"].locations.append("Traverse Town Item Workshop Left Chest"),
regions["Traverse Town"].locations.append("Traverse Town Secret Waterway Near Stairs Chest"),
regions["Wonderland"].locations.append("Wonderland Rabbit Hole Green Trinity Chest"),
#regions["Wonderland"].locations.append("Wonderland Rabbit Hole Defeat Heartless After Trial Chest"),
#regions["Wonderland"].locations.append("Wonderland Rabbit Hole Defeat Heartless After Hollow Bastion Chest"),
regions["Wonderland"].locations.append("Wonderland Rabbit Hole Defeat Heartless 1 Chest"),
regions["Wonderland"].locations.append("Wonderland Rabbit Hole Defeat Heartless 2 Chest"),
regions["Wonderland"].locations.append("Wonderland Rabbit Hole Defeat Heartless 3 Chest"),
regions["Wonderland"].locations.append("Wonderland Bizarre Room Green Trinity Chest"),
regions["Wonderland"].locations.append("Wonderland Queen's Castle Hedge Left Red Chest"),
regions["Wonderland"].locations.append("Wonderland Queen's Castle Hedge Right Blue Chest"),
Expand Down Expand Up @@ -231,6 +232,7 @@ def create_regions(multiworld: MultiWorld, player: int, goal: str, atlantica: bo
regions["Hollow Bastion"].locations.append("Hollow Bastion Grand Hall Oblivion Chest"),
regions["Hollow Bastion"].locations.append("Hollow Bastion Grand Hall Left of Gate Chest"),
#regions["Hollow Bastion"].locations.append("Hollow Bastion Entrance Hall Push the Statue Chest"),
regions["Hollow Bastion"].locations.append("Hollow Bastion Entrance Hall Left of Emblem Door Chest"),
regions["Hollow Bastion"].locations.append("Hollow Bastion Rising Falls White Trinity Chest"),
#regions["End of the World"].locations.append("End of the World Final Dimension 1st Chest"),
#regions["End of the World"].locations.append("End of the World Final Dimension 2nd Chest"),
Expand Down
6 changes: 4 additions & 2 deletions worlds/kh1/Rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,9 @@ def set_rules(multiworld: MultiWorld, player: int, goal: str, atlantica: bool):
multiworld.get_location("Traverse Town Item Workshop Left Chest" , player).access_rule = lambda state: has_item(state, player, "Green Trinity")
#multiworld.get_location("Traverse Town Secret Waterway Near Stairs Chest" , player).access_rule = lambda state: has_item(state, player, "Red Trinity")
multiworld.get_location("Wonderland Rabbit Hole Green Trinity Chest" , player).access_rule = lambda state: has_item(state, player, "Green Trinity")
#multiworld.get_location("Wonderland Rabbit Hole Defeat Heartless After Trial Chest" , player).access_rule = lambda state: has_item(state, player, "")
#multiworld.get_location("Wonderland Rabbit Hole Defeat Heartless After Hollow Bastion Chest" , player).access_rule = lambda state: has_item(state, player, "Hollow Bastion") and has_x_worlds(state, player, 7)
#multiworld.get_location("Wonderland Rabbit Hole Defeat Heartless 1 Chest" , player).access_rule = lambda state: has_item(state, player, "")
#multiworld.get_location("Wonderland Rabbit Hole Defeat Heartless 2 Chest" , player).access_rule = lambda state: has_item(state, player, "")
#multiworld.get_location("Wonderland Rabbit Hole Defeat Heartless 3 Chest" , player).access_rule = lambda state: has_item(state, player, "")
multiworld.get_location("Wonderland Bizarre Room Green Trinity Chest" , player).access_rule = lambda state: has_item(state, player, "Green Trinity")
multiworld.get_location("Wonderland Queen's Castle Hedge Left Red Chest" , player).access_rule = lambda state: has_evidence(state, player) or has_item(state, player, "High Jump") or can_glide(state, player)
multiworld.get_location("Wonderland Queen's Castle Hedge Right Blue Chest" , player).access_rule = lambda state: has_evidence(state, player) or has_item(state, player, "High Jump") or can_glide(state, player)
Expand Down Expand Up @@ -248,6 +249,7 @@ def set_rules(multiworld: MultiWorld, player: int, goal: str, atlantica: bool):
multiworld.get_location("Hollow Bastion Grand Hall Oblivion Chest" , player).access_rule = lambda state: has_emblems(state, player)
multiworld.get_location("Hollow Bastion Grand Hall Left of Gate Chest" , player).access_rule = lambda state: has_emblems(state, player)
#multiworld.get_location("Hollow Bastion Entrance Hall Push the Statue Chest" , player).access_rule = lambda state: has_item(state, player, "")
multiworld.get_location("Hollow Bastion Entrance Hall Left of Emblem Door Chest" , player).access_rule = lambda state: has_item(state, player, "High Jump")
multiworld.get_location("Hollow Bastion Rising Falls White Trinity Chest" , player).access_rule = lambda state: has_item(state, player, "White Trinity")
#multiworld.get_location("End of the World Final Dimension 1st Chest" , player).access_rule = lambda state: has_item(state, player, "")
#multiworld.get_location("End of the World Final Dimension 2nd Chest" , player).access_rule = lambda state: has_item(state, player, "")
Expand Down

0 comments on commit be3308f

Please sign in to comment.