Skip to content

Commit

Permalink
Zillion: webhost config fix (ArchipelagoMW#2145)
Browse files Browse the repository at this point in the history
  • Loading branch information
beauxq authored and Jouramie committed Feb 28, 2024
1 parent 73a1b6b commit 1dd010b
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
4 changes: 2 additions & 2 deletions worlds/zillion/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

from BaseClasses import ItemClassification, LocationProgressType, \
MultiWorld, Item, CollectionState, Entrance, Tutorial
from .config import detect_test
from .logic import cs_to_zz_locs
from .region import ZillionLocation, ZillionRegion
from .options import ZillionStartChar, zillion_options, validate
Expand Down Expand Up @@ -145,8 +146,7 @@ def generate_early(self) -> None:

self._item_counts = item_counts

import __main__
rom_dir_name = "" if "test" in __main__.__file__ else os.path.dirname(get_base_rom_path())
rom_dir_name = "" if detect_test() else os.path.dirname(get_base_rom_path())
with redirect_stdout(self.lsi): # type: ignore
self.zz_system.make_patcher(rom_dir_name)
self.zz_system.make_randomizer(zz_op)
Expand Down
17 changes: 17 additions & 0 deletions worlds/zillion/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,20 @@

base_id = 8675309
zillion_map = os.path.join(os.path.dirname(__file__), "empty-zillion-map-row-col-labels-281.png")


def detect_test() -> bool:
"""
Parts of generation that are in unit tests need the rom.
This is to detect whether we are running unit tests
so we can work around the need for the rom.
"""
import __main__
try:
if "test" in __main__.__file__:
return True
except AttributeError:
# In some environments, __main__ doesn't have __file__
# We'll assume that's not unit tests.
pass
return False

0 comments on commit 1dd010b

Please sign in to comment.