Skip to content

Commit

Permalink
Maintain panel count via items instead of locations
Browse files Browse the repository at this point in the history
  • Loading branch information
hatkirby committed Nov 19, 2023
1 parent c920ee0 commit 0aa02ac
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 11 deletions.
12 changes: 12 additions & 0 deletions worlds/lingo/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,3 +110,15 @@ def fill_slot_data(self):
slot_data["painting_entrance_to_exit"] = self.player_logic.painting_mapping

return slot_data

def collect(self, state, item: Item) -> bool:
if item.name.endswith("Counting Panels Solved"):
state.prog_items[self.player]["COUNTING PANELS"] += int(item.name.rstrip(" Counting Panels Solved"))
return True
return super().collect(state, item)

def remove(self, state, item: Item) -> bool:
if item.name.endswith("Counting Panels Solved"):
state.prog_items[self.player]["COUNTING PANELS"] -= int(item.name.rstrip(" Counting Panels Solved"))
return True
return super().remove(state, item)
1 change: 0 additions & 1 deletion worlds/lingo/locations.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ class LingoLocation(Location):
Location from the game Lingo
"""
game: str = "Lingo"
counting_panels: int = 0


ALL_LOCATION_TABLE: Dict[str, LocationData] = {}
Expand Down
12 changes: 5 additions & 7 deletions worlds/lingo/player_logic.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ class PlayerLocation(NamedTuple):
name: str
code: Optional[int]
access: AccessRequirements
counting_panels: int


class LingoPlayerLogic:
Expand Down Expand Up @@ -76,7 +75,7 @@ def add_location(self, room: str, name: str, code: Optional[int], panels: List[R
sub_access_reqs = self.calculate_panel_requirements(panel_room, panel.panel)
access_reqs.merge(sub_access_reqs)

self.locations_by_room.setdefault(room, []).append(PlayerLocation(name, code, access_reqs, 0))
self.locations_by_room.setdefault(room, []).append(PlayerLocation(name, code, access_reqs))

def set_door_item(self, room: str, door: str, item: str):
self.item_by_door.setdefault(room, {})[door] = item
Expand Down Expand Up @@ -410,9 +409,9 @@ def create_panel_hunt_events(self, world: "LingoWorld"):
or len(panel_data.required_rooms) > 0\
or (world.options.shuffle_colors and len(panel_data.colors) > 1):
event_name = f"{room_name} - {panel_name} (Counted)"
self.event_loc_to_item[event_name] = "Counting Panel Solved"
self.event_loc_to_item[event_name] = "1 Counting Panels Solved"
self.locations_by_room.setdefault(room_name, []).append(
PlayerLocation(event_name, None, self.calculate_panel_requirements(room_name, panel_name), 1))
PlayerLocation(event_name, None, self.calculate_panel_requirements(room_name, panel_name)))
else:
if len(panel_data.colors) == 0 or not world.options.shuffle_colors:
color = None
Expand All @@ -429,6 +428,5 @@ def create_panel_hunt_events(self, world: "LingoWorld"):
event_name = f"{room_name} - {panel_count} {color.capitalize()} Panels (Counted)"
access_reqs.colors.add(color)

self.locations_by_room.setdefault(room_name, []).append(PlayerLocation(event_name, None, access_reqs,
panel_count))
self.event_loc_to_item[event_name] = "Counting Panels Solved"
self.locations_by_room.setdefault(room_name, []).append(PlayerLocation(event_name, None, access_reqs))
self.event_loc_to_item[event_name] = f"{panel_count} Counting Panels Solved"
1 change: 0 additions & 1 deletion worlds/lingo/regions.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ def create_region(room: Room, world: "LingoWorld", player_logic: LingoPlayerLogi
new_region = Region(room.name, world.player, world.multiworld)
for location in player_logic.locations_by_room.get(room.name, {}):
new_location = LingoLocation(world.player, location.name, location.code, new_region)
new_location.counting_panels = location.counting_panels
new_location.access_rule = make_location_lambda(location, world, player_logic)
new_region.locations.append(new_location)
if location.name in player_logic.event_loc_to_item:
Expand Down
3 changes: 1 addition & 2 deletions worlds/lingo/rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,7 @@ def lingo_can_use_mastery_location(state: CollectionState, world: "LingoWorld"):


def lingo_can_use_level_2_location(state: CollectionState, world: "LingoWorld"):
return sum(location.counting_panels for location in state.locations_checked)\
>= world.options.level_2_requirement.value
return state.has("COUNTING PANELS", world.player, world.options.level_2_requirement.value)


def _lingo_can_open_door(state: CollectionState, room: str, door: str, player: int, player_logic: LingoPlayerLogic):
Expand Down

0 comments on commit 0aa02ac

Please sign in to comment.