Skip to content

Commit

Permalink
Core: Band-aid fixes start_inventory_from_pool causing generation f…
Browse files Browse the repository at this point in the history
…ailures if any world doesn't utilize it. (ArchipelagoMW#1694)

* Core: Band-aid fixes `start_inventory_from_pool` causing generation failures if any world does utilize it.

* Core: Slightly better(?) solution

* Set default so it doesn't fail on WebHost.
  • Loading branch information
ThePhar authored Apr 11, 2023
1 parent 05d398a commit 3c3954f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 14 deletions.
6 changes: 3 additions & 3 deletions BaseClasses.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
import secrets
import typing # this can go away when Python 3.8 support is dropped
from argparse import Namespace
from collections import OrderedDict, Counter, deque, ChainMap
from collections import ChainMap, Counter, OrderedDict, deque
from enum import IntEnum, IntFlag
from typing import List, Dict, Optional, Set, Iterable, Union, Any, Tuple, TypedDict, Callable, NamedTuple
from typing import Any, Callable, Dict, Iterable, List, NamedTuple, Optional, Set, Tuple, TypedDict, Union

import NetUtils
import Options
Expand Down Expand Up @@ -121,7 +121,7 @@ def __init__(self, players: int):
self.early_items = {player: {} for player in self.player_ids}
self.local_early_items = {player: {} for player in self.player_ids}
self.indirect_connections = {}
self.start_inventory_from_pool = {player: Options.StartInventoryPool({}) for player in range(1, players + 1)}
self.start_inventory_from_pool: Dict[int, Options.StartInventoryPool] = {}
self.fix_trock_doors = self.AttributeProxy(
lambda player: self.shuffle[player] != 'vanilla' or self.mode[player] == 'inverted')
self.fix_skullwoods_exit = self.AttributeProxy(
Expand Down
24 changes: 13 additions & 11 deletions Main.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,24 @@
import collections
import concurrent.futures
import logging
import os
import time
import zlib
import concurrent.futures
import pickle
import tempfile
import time
import zipfile
from typing import Dict, List, Tuple, Optional, Set
import zlib
from typing import Dict, List, Optional, Set, Tuple

from BaseClasses import Item, MultiWorld, CollectionState, Region, LocationProgressType, Location
import worlds
from worlds.alttp.SubClasses import LTTPRegionType
from BaseClasses import CollectionState, Item, Location, LocationProgressType, MultiWorld, Region
from Fill import balance_multiworld_progression, distribute_items_restrictive, distribute_planned, flood_items
from Options import StartInventoryPool
from Utils import __version__, get_options, output_path, version_tuple
from worlds import AutoWorld
from worlds.alttp.Regions import is_main_entrance
from Fill import distribute_items_restrictive, flood_items, balance_multiworld_progression, distribute_planned
from worlds.alttp.Shops import FillDisabledShopSlots
from Utils import output_path, get_options, __version__, version_tuple
from worlds.generic.Rules import locality_rules, exclusion_rules
from worlds import AutoWorld
from worlds.alttp.SubClasses import LTTPRegionType
from worlds.generic.Rules import exclusion_rules, locality_rules

ordered_areas = (
'Light World', 'Dark World', 'Hyrule Castle', 'Agahnims Tower', 'Eastern Palace', 'Desert Palace',
Expand Down Expand Up @@ -115,7 +116,8 @@ def main(args, seed=None, baked_server_options: Optional[Dict[str, object]] = No
for item_name, count in world.start_inventory[player].value.items():
for _ in range(count):
world.push_precollected(world.create_item(item_name, player))
for item_name, count in world.start_inventory_from_pool[player].value.items():

for item_name, count in world.start_inventory_from_pool.setdefault(player, StartInventoryPool({})).value.items():
for _ in range(count):
world.push_precollected(world.create_item(item_name, player))

Expand Down

0 comments on commit 3c3954f

Please sign in to comment.