Skip to content

Commit

Permalink
Wargroove 2: Options for Multiple Locations per Check
Browse files Browse the repository at this point in the history
  • Loading branch information
FlySniper committed Sep 2, 2024
1 parent 7def399 commit 01be6c2
Show file tree
Hide file tree
Showing 6 changed files with 414 additions and 7 deletions.
24 changes: 22 additions & 2 deletions worlds/wargroove2/Levels.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,35 @@ def define_access_rules(self, multiworld: MultiWorld, additional_rule=lambda sta
for location_name, rule in self.location_rules.items():
set_rule(multiworld.get_location(location_name, self.player), lambda state, rule=rule:
state.can_reach(self.region, 'Region', self.player) and rule(state) and additional_rule(state))
loc_id = location_table.get(location_name, 0)
extras = 1
if loc_id is not None and location_name.endswith("Victory"):
extras = multiworld.worlds[self.player].options.victory_locations.value
elif loc_id is not None:
extras = multiworld.worlds[self.player].options.objective_locations.value
for i in range(1, extras):
set_rule(multiworld.get_location(location_name + f" Extra {i}", self.player), lambda state, rule=rule:
state.can_reach(self.region, 'Region', self.player) and rule(state) and additional_rule(state))
set_region_exit_rules(self.region, multiworld, self.player, self.victory_locations, operator='and')

def define_region(self, name: str, multiworld: MultiWorld, exits=None) -> Region:
self.region = Region(name, self.player, multiworld)
if self.location_rules.keys():
for location in self.location_rules.keys():
loc_id = location_table.get(location, 0)
location = Wargroove2Location(self.player, location, loc_id, self.region)
self.region.locations.append(location)
wg2_location = Wargroove2Location(self.player, location, loc_id, self.region)
self.region.locations.append(wg2_location)
extras = 1
if loc_id is not None and location.endswith("Victory"):
extras = multiworld.worlds[self.player].options.victory_locations.value
elif loc_id is not None:
extras = multiworld.worlds[self.player].options.objective_locations.value
for i in range(1, extras):
extra_location = location + f" Extra {i}"
loc_id = location_table.get(extra_location, 0)
wg2_location = Wargroove2Location(self.player, extra_location, loc_id, self.region)
self.region.locations.append(wg2_location)

if exits:
for exit in exits:
self.region.exits.append(Entrance(self.player, f"{name} exits to {exit}", self.region))
Expand Down
Loading

0 comments on commit 01be6c2

Please sign in to comment.