Skip to content

Commit

Permalink
Juicy progress and improvements, except for Rules
Browse files Browse the repository at this point in the history
  • Loading branch information
heinermann committed Oct 26, 2023
1 parent c7607be commit 4402c09
Show file tree
Hide file tree
Showing 7 changed files with 142 additions and 193 deletions.
13 changes: 6 additions & 7 deletions worlds/diablo2/Events.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,20 @@ def create_location(player: int, name: str, region: Region) -> Location:
return Locations.D2Location(player, name, None, region)


def create_locked_location_event(multiworld: MultiWorld, player: int, region_name: str, item: str) -> Location:
region = multiworld.get_region(region_name, player)

def create_locked_location_event(player: int, region: Region, item: str) -> Location:
new_location = create_location(player, item, region)
new_location.place_locked_item(create_event(player, item))

region.locations.append(new_location)
return new_location


def create_all_events(multiworld: MultiWorld, player: int) -> None:
for region, event in event_locks.items():
create_locked_location_event(multiworld, player, region, event)
def create_all_events(world: "Diablo2World", regions: Dict[str, Region]) -> None:
for region_name, event in event_locks.items():
region = regions[region_name]
create_locked_location_event(world.player, region, event)

multiworld.completion_condition[player] = lambda state: state.has("Victory", player)
world.multiworld.completion_condition[world.player] = lambda state: state.has("Victory", world.player)


# Maps region names to event names
Expand Down
21 changes: 8 additions & 13 deletions worlds/diablo2/Items.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,32 +27,27 @@ def create_fixed_item_pool() -> List[str]:
return list(Counter(required_items).elements())


def create_random_items(multiworld: MultiWorld, player: int, random_count: int) -> List[str]:
def create_random_items(world: "Diablo2World", random_count: int) -> List[str]:
filler_pool = filler_weights.copy()
if multiworld.traps[player].value == 0:
if world.options.traps.value == 0:
del filler_pool["Trap"]

return multiworld.random.choices(
return world.random.choices(
population=list(filler_pool.keys()),
weights=list(filler_pool.values()),
k=random_count
)


def create_all_items(multiworld: MultiWorld, player: int) -> None:
sum_locations = len(multiworld.get_unfilled_locations(player))
def create_all_items(world: "Diablo2World") -> None:
sum_locations = len(world.multiworld.get_unfilled_locations(world.player))

itempool = (
create_fixed_item_pool()
+ create_orb_items(multiworld.victory_condition[player], multiworld.extra_orbs[player])
+ create_spatial_awareness_item(multiworld.bosses_as_checks[player])
+ create_kantele(multiworld.victory_condition[player])
)
itempool = create_fixed_item_pool()

random_count = sum_locations - len(itempool)
itempool += create_random_items(multiworld, player, random_count)
itempool += create_random_items(world, random_count)

multiworld.itempool += [create_item(player, name) for name in itempool]
multiworld.itempool += [create_item(world.player, name) for name in itempool]


# Total: 33
Expand Down
7 changes: 1 addition & 6 deletions worlds/diablo2/Locations.py
Original file line number Diff line number Diff line change
Expand Up @@ -360,11 +360,6 @@ class LocationData(NamedTuple):
}


# Iterating the hidden chest and pedestal locations here to avoid clutter above
def generate_location_entries(locname: str, locinfo: LocationData) -> Dict[str, int]:
return {locname: locinfo.id}


location_name_groups: Dict[str, Set[str]] = {
"Act 1": set(), "Act 2": set(), "Act 3": set(), "Act 4": set(), "Act 5": set()
}
Expand All @@ -373,5 +368,5 @@ def generate_location_entries(locname: str, locinfo: LocationData) -> Dict[str,

for location_group in location_region_mapping.values():
for locname, locinfo in location_group.items():
location_name_to_id.update(generate_location_entries(locname, locinfo))
location_name_to_id[locname] = locinfo.id
location_name_groups[locinfo.group].add(locname)
26 changes: 16 additions & 10 deletions worlds/diablo2/Options.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from typing import Dict
from Options import AssembleOptions, DeathLink, DefaultOnToggle, Toggle
from Options import AssembleOptions, DeathLink, DefaultOnToggle, PerGameCommonOptions, Toggle
from dataclasses import dataclass


class Traps(DefaultOnToggle):
class Traps(Toggle):
"""Whether negative effects that can hinder your character are added to the item pool."""
display_name = "Traps"

Expand All @@ -22,10 +22,16 @@ class GoldenChestsAsChecks(Toggle):
display_name = "Golden Chests as Checks"


diablo2_options: Dict[str, AssembleOptions] = {
"death_link": DeathLink,
"traps": Traps,
"waypoints_as_checks": WaypointsAsChecks,
"superuniques_as_checks": SuperuniquesAsChecks,
"goldenchests_as_checks": GoldenChestsAsChecks,
}
class IsLordOfDestruction(DefaultOnToggle):
"""Includes the Diablo II: Lord of Destruction expansion content."""
display_name = "Is Expansion"


@dataclass
class Diablo2Options(PerGameCommonOptions):
death_link: DeathLink
traps: Traps
waypoints_as_checks: WaypointsAsChecks
superuniques_as_checks: SuperuniquesAsChecks
goldenchests_as_checks: GoldenChestsAsChecks
is_expansion: IsLordOfDestruction
Loading

0 comments on commit 4402c09

Please sign in to comment.