diff --git a/Adjuster.py b/Adjuster.py index ba502c8a..27ac4093 100755 --- a/Adjuster.py +++ b/Adjuster.py @@ -1,13 +1,14 @@ #!/usr/bin/env python3 import argparse -import os import logging -import textwrap +import os import sys +import textwrap from AdjusterMain import adjust from Rom import get_sprite_from_name + class ArgumentDefaultsHelpFormatter(argparse.RawTextHelpFormatter): def _get_help_string(self, action): diff --git a/AdjusterMain.py b/AdjusterMain.py index 6b886a4b..76379453 100644 --- a/AdjusterMain.py +++ b/AdjusterMain.py @@ -1,6 +1,6 @@ +import logging import os import time -import logging try: import bps.apply @@ -8,9 +8,9 @@ try: except ImportError: raise Exception('Could not load BPS module') -from Utils import output_path from Rom import LocalRom, apply_rom_settings from source.tools.BPS import bps_read_vlv +from Utils import output_path def adjust(args): diff --git a/BaseClasses.py b/BaseClasses.py index f75617e9..99af09b9 100644 --- a/BaseClasses.py +++ b/BaseClasses.py @@ -2,7 +2,7 @@ import base64 import copy import json import logging -from collections import OrderedDict, Counter, deque, defaultdict +from collections import Counter, OrderedDict, defaultdict, deque from enum import Enum, IntEnum, unique try: @@ -10,12 +10,17 @@ try: except ImportError: from enum import IntFlag as FastEnum -from source.classes.BabelFish import BabelFish -from Utils import int16_as_bytes -from Tables import normal_offset_table, spiral_offset_table, multiply_lookup, divisor_lookup from RoomData import Room +from source.classes.BabelFish import BabelFish from source.dungeon.RoomObject import RoomObject from source.overworld.EntranceData import door_addresses +from Tables import ( + divisor_lookup, + multiply_lookup, + normal_offset_table, + spiral_offset_table, +) +from Utils import int16_as_bytes class World(object): @@ -1664,8 +1669,8 @@ class Region(object): self.crystal_switch = False def can_reach(self, state): - from Utils import stack_size3a from DungeonGenerator import GenerationException + from Utils import stack_size3a if stack_size3a() > self.world.players * 1000: raise GenerationException(f'Infinite loop detected for "{self.name}" located at \'Region.can_reach\'') diff --git a/Bosses.py b/Bosses.py index f60489a2..22ae3180 100644 --- a/Bosses.py +++ b/Bosses.py @@ -1,6 +1,6 @@ import logging -import RaceRandom as random +import RaceRandom as random from BaseClasses import Boss, FillError from source.enemizer.Bossmizer import boss_adjust diff --git a/CLI.py b/CLI.py index ca1b3dff..21f21a6a 100644 --- a/CLI.py +++ b/CLI.py @@ -2,14 +2,13 @@ import argparse import copy import json import os -import textwrap import shlex import sys +import textwrap from source.classes.BabelFish import BabelFish - -from Utils import update_deprecated_args from source.classes.CustomSettings import CustomSettings +from Utils import update_deprecated_args class ArgumentDefaultsHelpFormatter(argparse.RawTextHelpFormatter): diff --git a/DamageTable.py b/DamageTable.py index b3fb8d0a..14fa18eb 100644 --- a/DamageTable.py +++ b/DamageTable.py @@ -3,6 +3,7 @@ from typing import List import RaceRandom as random + def _load_entries(): entries = [] with open("data/damage_table.bin", 'rb') as stream: diff --git a/DoorShuffle.py b/DoorShuffle.py index 3ba2584f..5d0036b3 100644 --- a/DoorShuffle.py +++ b/DoorShuffle.py @@ -1,27 +1,62 @@ -import RaceRandom as random -from collections import defaultdict, deque import logging import time -from enum import unique, Flag -from typing import DefaultDict, Dict, List +from collections import defaultdict, deque +from enum import Flag, unique from itertools import chain +from typing import DefaultDict, Dict, List -from BaseClasses import RegionType, Region, Door, DoorType, Sector, CrystalBarrier, DungeonInfo, dungeon_keys -from BaseClasses import PotFlags, LocationType, Direction, KeyRuleType +import RaceRandom as random +from BaseClasses import ( + CrystalBarrier, + Direction, + Door, + DoorType, + DungeonInfo, + KeyRuleType, + LocationType, + PotFlags, + Region, + RegionType, + Sector, + dungeon_keys, +) from Doors import reset_portals -from Dungeons import dungeon_regions, region_starts, standard_starts, split_region_starts -from Dungeons import dungeon_bigs, dungeon_hints +from DungeonGenerator import ( + ExplorationState, + connect_doors, + convert_regions, + count_reserved_locations, + create_dungeon_builders, + default_dungeon_entrances, + determine_required_paths, + drop_entrances, + dungeon_drops, + dungeon_portals, + simple_dungeon_builder, + split_dungeon_builder, + valid_region_to_explore, +) +from Dungeons import ( + dungeon_bigs, + dungeon_hints, + dungeon_regions, + region_starts, + split_region_starts, + standard_starts, +) from Items import ItemFactory +from KeyDoorShuffle import ( + DoorRules, + analyze_dungeon, + build_key_layout, + determine_prize_lock, + validate_bk_layout, + validate_key_layout, +) from RoomData import DoorKind, PairedDoor, reset_rooms -from source.dungeon.DungeonStitcher import GenerationException, generate_dungeon from source.dungeon.DungeonStitcher import ExplorationState as ExplorationState2 -from DungeonGenerator import ExplorationState, convert_regions, determine_required_paths, drop_entrances -from DungeonGenerator import create_dungeon_builders, split_dungeon_builder, simple_dungeon_builder, default_dungeon_entrances -from DungeonGenerator import dungeon_portals, dungeon_drops, connect_doors, count_reserved_locations -from DungeonGenerator import valid_region_to_explore -from KeyDoorShuffle import analyze_dungeon, build_key_layout, validate_key_layout, determine_prize_lock -from KeyDoorShuffle import validate_bk_layout, DoorRules -from Utils import ncr, kth_combination +from source.dungeon.DungeonStitcher import GenerationException, generate_dungeon +from Utils import kth_combination, ncr def link_doors(world, player): diff --git a/Doors.py b/Doors.py index 909fe40b..6026c212 100644 --- a/Doors.py +++ b/Doors.py @@ -1,5 +1,5 @@ -from BaseClasses import Door, DoorType, Direction, CrystalBarrier, Portal +from BaseClasses import CrystalBarrier, Direction, Door, DoorType, Portal from RoomData import PairedDoor # constants diff --git a/DungeonGenerator.py b/DungeonGenerator.py index 3306b71d..474d8b56 100644 --- a/DungeonGenerator.py +++ b/DungeonGenerator.py @@ -1,22 +1,32 @@ -import RaceRandom as random import collections import itertools -from collections import defaultdict, deque -from functools import reduce import logging import math import operator as op import time +from collections import defaultdict, deque +from functools import reduce from typing import List -from BaseClasses import DoorType, Direction, CrystalBarrier, RegionType, Polarity, PolSlot, flooded_keys, Sector -from BaseClasses import Hook, hook_from_door, Door -from Regions import location_events, flooded_keys_reverse +import RaceRandom as random +from BaseClasses import ( + CrystalBarrier, + Direction, + Door, + DoorType, + Hook, + Polarity, + PolSlot, + RegionType, + Sector, + flooded_keys, + hook_from_door, +) from Dungeons import split_region_starts +from Regions import flooded_keys_reverse, location_events from RoomData import DoorKind - -from source.dungeon.DungeonStitcher import generate_dungeon_find_proposal from source.dungeon.DungeonStitcher import GenerationException as OtherGenException +from source.dungeon.DungeonStitcher import generate_dungeon_find_proposal class GraphPiece: diff --git a/DungeonRandomizer.py b/DungeonRandomizer.py index 06fec596..1c3f82e9 100755 --- a/DungeonRandomizer.py +++ b/DungeonRandomizer.py @@ -3,19 +3,19 @@ if __name__ == '__main__': from source.meta.check_requirements import check_requirements check_requirements(console=True) -import os import logging -import RaceRandom as random +import os import sys -from source.classes.BabelFish import BabelFish +import RaceRandom as random import source.classes.diags as diagnostics - -from CLI import parse_cli, get_args_priority -from Main import main, EnemizerError, __version__ -from Rom import get_sprite_from_name -from Utils import is_bundled, close_console +from CLI import get_args_priority, parse_cli from Fill import FillError +from Main import EnemizerError, __version__, main +from Rom import get_sprite_from_name +from source.classes.BabelFish import BabelFish +from Utils import close_console, is_bundled + def start(): args = parse_cli(None) diff --git a/Fill.py b/Fill.py index c47a2f3d..106f51f9 100644 --- a/Fill.py +++ b/Fill.py @@ -1,4 +1,3 @@ -import RaceRandom as random import collections import itertools import logging @@ -6,11 +5,18 @@ import math from collections import Counter from contextlib import suppress +import RaceRandom as random from BaseClasses import CollectionState, FillError, LocationType from Items import ItemFactory -from Regions import shop_to_location_table, retro_shops -from source.item.FillUtil import filter_locations, classify_major_items, replace_trash_item, vanilla_fallback -from source.item.FillUtil import filter_special_locations, valid_pot_items +from Regions import retro_shops, shop_to_location_table +from source.item.FillUtil import ( + classify_major_items, + filter_locations, + filter_special_locations, + replace_trash_item, + valid_pot_items, + vanilla_fallback, +) def get_dungeon_item_pool(world): diff --git a/Gui.py b/Gui.py index bbb3eada..8c9146bd 100755 --- a/Gui.py +++ b/Gui.py @@ -5,29 +5,41 @@ if __name__ == '__main__': import json import os import sys -from tkinter import Tk, Button, BOTTOM, TOP, StringVar, BooleanVar, X, BOTH, RIGHT, ttk, messagebox +from tkinter import ( + BOTH, + BOTTOM, + RIGHT, + TOP, + BooleanVar, + Button, + StringVar, + Tk, + X, + messagebox, + ttk, +) from CLI import get_args_priority from DungeonRandomizer import parse_cli -from source.gui.adjust.overview import adjust_page -from source.gui.startinventory.overview import startinventory_page -from source.gui.custom.overview import custom_page -from source.gui.loadcliargs import loadcliargs, loadadjustargs -from source.gui.randomize.item import item_page -from source.gui.randomize.overworld import overworld_page -from source.gui.randomize.entrando import entrando_page -from source.gui.randomize.enemizer import enemizer_page -from source.gui.randomize.dungeon import dungeon_page -#from source.gui.randomize.multiworld import multiworld_page -from source.gui.randomize.gameoptions import gameoptions_page -from source.gui.randomize.generation import generation_page -from source.gui.bottom import bottom_frame, create_guiargs from GuiUtils import set_icon from Main import __version__ as ESVersion from OverworldShuffle import __version__ as ORVersion - from source.classes.BabelFish import BabelFish from source.classes.Empty import Empty +from source.gui.adjust.overview import adjust_page +from source.gui.bottom import bottom_frame, create_guiargs +from source.gui.custom.overview import custom_page +from source.gui.loadcliargs import loadadjustargs, loadcliargs +from source.gui.randomize.dungeon import dungeon_page +from source.gui.randomize.enemizer import enemizer_page +from source.gui.randomize.entrando import entrando_page + +#from source.gui.randomize.multiworld import multiworld_page +from source.gui.randomize.gameoptions import gameoptions_page +from source.gui.randomize.generation import generation_page +from source.gui.randomize.item import item_page +from source.gui.randomize.overworld import overworld_page +from source.gui.startinventory.overview import startinventory_page def check_python_version(fish): diff --git a/GuiUtils.py b/GuiUtils.py index 840e8520..10181099 100644 --- a/GuiUtils.py +++ b/GuiUtils.py @@ -1,10 +1,11 @@ -import queue import os +import queue import threading import tkinter as tk from Utils import local_path + def set_icon(window): er16 = tk.PhotoImage(file=local_path(os.path.join("data","ER16.gif"))) er32 = tk.PhotoImage(file=local_path(os.path.join("data","ER32.gif"))) diff --git a/ItemList.py b/ItemList.py index 44d1dde9..21acfcbb 100644 --- a/ItemList.py +++ b/ItemList.py @@ -1,21 +1,39 @@ -from collections import namedtuple, defaultdict import logging import math +from collections import defaultdict, namedtuple + import RaceRandom as random - -from BaseClasses import LocationType, Region, RegionType, Shop, ShopType, Location, CollectionState, PotItem -from Regions import location_events, shop_to_location_table, retro_shops, shop_table_by_location, valid_pot_location -from Fill import FillError, fill_restrictive, get_dungeon_item_pool, track_dungeon_items, track_outside_keys -from PotShuffle import vanilla_pots -from Tables import bonk_prize_lookup -from Items import ItemFactory - -from source.dungeon.EnemyList import add_drop_contents -from source.overworld.EntranceShuffle2 import exit_ids, door_addresses -from source.item.FillUtil import trash_items, pot_items - import source.classes.constants as CONST - +from BaseClasses import ( + CollectionState, + Location, + LocationType, + PotItem, + Region, + RegionType, + Shop, + ShopType, +) +from Fill import ( + FillError, + fill_restrictive, + get_dungeon_item_pool, + track_dungeon_items, + track_outside_keys, +) +from Items import ItemFactory +from PotShuffle import vanilla_pots +from Regions import ( + location_events, + retro_shops, + shop_table_by_location, + shop_to_location_table, + valid_pot_location, +) +from source.dungeon.EnemyList import add_drop_contents +from source.item.FillUtil import pot_items, trash_items +from source.overworld.EntranceShuffle2 import door_addresses, exit_ids +from Tables import bonk_prize_lookup #This file sets the item pools for various modes. Timed modes and triforce hunt are enforced first, and then extra items are specified per mode to fill in the remaining space. #Some basic items that various modes require are placed here, including pendants and crystals. Medallion requirements for the two relevant entrances are also decided. @@ -691,7 +709,7 @@ def create_farm_locations(world, player): world.dynamic_locations.append(loc) return loc - from Rules import set_rule, add_rule, add_bunny_rule + from Rules import add_bunny_rule, add_rule, set_rule for region in bush_bombs: loc = create_and_fill_location(region, 'Bush Drop', 'Farmable Bombs') add_bunny_rule(loc, player) diff --git a/KeyDoorShuffle.py b/KeyDoorShuffle.py index 65ad0faf..5ce19e4f 100644 --- a/KeyDoorShuffle.py +++ b/KeyDoorShuffle.py @@ -2,11 +2,17 @@ import itertools import logging from collections import defaultdict, deque -from BaseClasses import DoorType, dungeon_keys, KeyRuleType, RegionType +from BaseClasses import DoorType, KeyRuleType, RegionType, dungeon_keys +from DungeonGenerator import ( + ExplorationState, + blind_boss_unavail, + count_locations_exclude_big_chest, + get_special_big_key_doors, + prize_or_event, + reserved_location, +) +from Dungeons import dungeon_bigs, dungeon_keys, dungeon_table from Regions import location_events -from Dungeons import dungeon_keys, dungeon_bigs, dungeon_table -from DungeonGenerator import ExplorationState, get_special_big_key_doors, count_locations_exclude_big_chest, prize_or_event -from DungeonGenerator import reserved_location, blind_boss_unavail class KeyLayout(object): diff --git a/Main.py b/Main.py index 3548a399..d633f16b 100644 --- a/Main.py +++ b/Main.py @@ -1,44 +1,97 @@ +import base64 import copy -from itertools import zip_longest import json import logging import os -import RaceRandom as random import string import time import zlib -import base64 +from itertools import zip_longest -from BaseClasses import World, CollectionState, Item, Region, Location, Shop, Entrance, Settings +import RaceRandom as random +from BaseClasses import ( + CollectionState, + Entrance, + Item, + Location, + Region, + Settings, + Shop, + World, +) from Bosses import place_bosses +from Doors import create_doors +from DoorShuffle import connect_portal, link_doors, link_doors_prep +from Dungeons import create_dungeons +from Fill import ( + balance_money_progression, + balance_multiworld_progression, + distribute_items_restrictive, + dungeon_tracking, + ensure_good_items, + fill_dungeons_restrictive, + lock_shop_locations, + promote_dungeon_items, + sell_keys, + sell_potions, + set_prize_drops, +) +from ItemList import ( + create_farm_locations, + customize_shops, + difficulties, + fill_prizes, + fill_specific_items, + follower_pickups, + generate_itempool, + shuffle_event_items, +) from Items import ItemFactory from KeyDoorShuffle import validate_key_placement from OverworldGlitchRules import create_owg_connections -from PotShuffle import shuffle_pots, shuffle_pot_switches -from Regions import create_regions, create_shops, mark_light_dark_world_regions, create_dungeon_regions, adjust_locations +from OverworldShuffle import ( + create_dynamic_flute_exits, + create_dynamic_mirror_exits, + link_overworld, + update_world_regions, +) from OWEdges import create_owedges -from OverworldShuffle import link_overworld, update_world_regions, create_dynamic_flute_exits, create_dynamic_mirror_exits -from Rom import patch_rom, patch_race_rom, apply_rom_settings, LocalRom, JsonRom, get_hash_string -from Doors import create_doors -from DoorShuffle import link_doors, connect_portal, link_doors_prep +from PotShuffle import shuffle_pot_switches, shuffle_pots +from Regions import ( + adjust_locations, + create_dungeon_regions, + create_regions, + create_shops, + mark_light_dark_world_regions, +) +from Rom import ( + JsonRom, + LocalRom, + apply_rom_settings, + get_hash_string, + patch_race_rom, + patch_rom, +) from RoomData import create_rooms from Rules import set_rules -from Dungeons import create_dungeons -from Fill import distribute_items_restrictive, promote_dungeon_items, fill_dungeons_restrictive, ensure_good_items -from Fill import dungeon_tracking -from Fill import sell_potions, sell_keys, balance_multiworld_progression, balance_money_progression, lock_shop_locations, set_prize_drops -from ItemList import generate_itempool, difficulties, fill_prizes, customize_shops, fill_specific_items, create_farm_locations, shuffle_event_items, follower_pickups -from UnderworldGlitchRules import connect_hmg_entrances_regions, create_hmg_entrances_regions -from Utils import output_path, parse_player_names - -from source.item.District import init_districts -from source.item.FillUtil import create_item_pool_config, massage_item_pool, district_item_pool_config, verify_item_pool_config -from source.overworld.EntranceShuffle2 import link_entrances_new -from source.tools.BPS import create_bps_from_data from source.classes.CustomSettings import CustomSettings from source.enemizer.DamageTables import DamageTable from source.enemizer.Enemizer import randomize_enemies +from source.item.District import init_districts +from source.item.FillUtil import ( + create_item_pool_config, + district_item_pool_config, + massage_item_pool, + verify_item_pool_config, +) +from source.overworld.EntranceShuffle2 import link_entrances_new from source.rom.DataTables import init_data_tables +from source.tools.BPS import create_bps_from_data +from UnderworldGlitchRules import ( + connect_hmg_entrances_regions, + create_hmg_entrances_regions, +) +from Utils import output_path, parse_player_names version_number = '1.5.0' version_branch = '-u' diff --git a/MultiClient.py b/MultiClient.py index 0d238392..98afc42f 100644 --- a/MultiClient.py +++ b/MultiClient.py @@ -1,19 +1,20 @@ -import aioconsole import argparse import asyncio -import colorama import json import logging import shlex import urllib.parse + +import aioconsole +import colorama import websockets -from BaseClasses import PotItem, PotFlags, LocationType import Items -import Regions import PotShuffle +import Regions import source.dungeon.EnemyList as EnemyList import source.rom.DataTables as DataTables +from BaseClasses import LocationType, PotFlags, PotItem class ReceivedItem: @@ -975,8 +976,8 @@ async def track_locations(ctx : Context, roomid, roomdata): ow_unchecked[location] = (screenid, 0x40) ow_begin = min(ow_begin, screenid) ow_end = max(ow_end, screenid + 1) - from Regions import bonk_prize_table from OWEdges import OWTileRegions + from Regions import bonk_prize_table for location, (_, flag, _, _, region_name, _) in bonk_prize_table.items(): if location not in ctx.locations_checked: if region_name in OWTileRegions: diff --git a/MultiServer.py b/MultiServer.py index 44559953..f6cefe22 100644 --- a/MultiServer.py +++ b/MultiServer.py @@ -1,4 +1,3 @@ -import aioconsole import argparse import asyncio import functools @@ -8,16 +7,23 @@ import re import shlex import ssl import urllib.request -import websockets import zlib -from BaseClasses import PotItem, PotFlags +import aioconsole +import websockets + import Items -import Regions import PotShuffle -from MultiClient import ReceivedItem, get_item_name_from_id, get_location_name_from_address +import Regions import source.dungeon.EnemyList as EnemyList import source.rom.DataTables as DataTables +from BaseClasses import PotFlags, PotItem +from MultiClient import ( + ReceivedItem, + get_item_name_from_id, + get_location_name_from_address, +) + class Client: def __init__(self, socket): diff --git a/Mystery.py b/Mystery.py index ca79541d..834e709f 100644 --- a/Mystery.py +++ b/Mystery.py @@ -1,13 +1,13 @@ import argparse import logging -import RaceRandom as random +from yaml.constructor import SafeConstructor + +import RaceRandom as random from DungeonRandomizer import parse_cli from Main import main as DRMain from source.classes.BabelFish import BabelFish -from yaml.constructor import SafeConstructor - -from source.tools.MysteryUtils import roll_settings, get_weights +from source.tools.MysteryUtils import get_weights, roll_settings def add_bool(self, node): diff --git a/OWEdges.py b/OWEdges.py index 645e05ad..aa198675 100644 --- a/OWEdges.py +++ b/OWEdges.py @@ -1,8 +1,10 @@ -from BaseClasses import OWEdge, Direction, Terrain, WorldType, PolSlot from enum import Enum, unique + +from BaseClasses import Direction, OWEdge, PolSlot, Terrain, WorldType from Utils import bidict + @unique class OpenStd(Enum): Open = 0 diff --git a/OverworldShuffle.py b/OverworldShuffle.py index 616a85a2..d8f663a4 100644 --- a/OverworldShuffle.py +++ b/OverworldShuffle.py @@ -1,11 +1,30 @@ -import RaceRandom as random, logging, copy +import copy +import logging from collections import OrderedDict, defaultdict + +import RaceRandom as random +from BaseClasses import ( + Direction, + Entrance, + OWEdge, + PolSlot, + RegionType, + Terrain, + WorldType, +) from DungeonGenerator import GenerationException -from BaseClasses import OWEdge, WorldType, RegionType, Direction, Terrain, PolSlot, Entrance +from OverworldGlitchRules import create_owg_connections +from OWEdges import ( + IsParallel, + OpenStd, + OWEdgeGroups, + OWEdgeGroupsTerrain, + OWExitTypes, + OWTileRegions, + parallel_links, +) from Regions import mark_light_dark_world_regions from source.overworld.EntranceShuffle2 import connect_simple -from OWEdges import OWTileRegions, OWEdgeGroups, OWEdgeGroupsTerrain, OWExitTypes, OpenStd, parallel_links, IsParallel -from OverworldGlitchRules import create_owg_connections from Utils import bidict version_number = '0.6.1.7' @@ -1370,8 +1389,8 @@ def update_world_regions(world, player): world.get_region(name, player).type = RegionType.LightWorld def can_reach_smith(world, player): - from Items import ItemFactory from BaseClasses import CollectionState + from Items import ItemFactory def explore_region(region_name, region=None): nonlocal found @@ -1426,7 +1445,7 @@ def can_reach_smith(world, player): def build_sectors(world, player): from Main import copy_world_premature from OWEdges import OWTileRegions - + # perform accessibility check on duplicate world for p in range(1, world.players + 1): world.key_logic[p] = {} @@ -1478,8 +1497,8 @@ def build_sectors(world, player): def build_accessible_region_list(world, start_region, player, build_copy_world=False, cross_world=False, region_rules=True, ignore_ledges=False, restrictive_follower=False): from BaseClasses import CollectionState - from Main import copy_world_premature from Items import ItemFactory + from Main import copy_world_premature from Utils import stack_size3a def explore_region(region_name, region=None): @@ -1552,7 +1571,14 @@ def validate_layout(world, player): } # TODO: Find a better source for the below lists, original sourced was deprecated - from source.overworld.EntranceData import default_dungeon_connections, default_connector_connections, default_item_connections, default_shop_connections, default_drop_connections, default_dropexit_connections + from source.overworld.EntranceData import ( + default_connector_connections, + default_drop_connections, + default_dropexit_connections, + default_dungeon_connections, + default_item_connections, + default_shop_connections, + ) dungeon_entrances = list(zip(*default_dungeon_connections + [('Ganons Tower', '')]))[0] connector_entrances = list(zip(*default_connector_connections))[0] diff --git a/Plando.py b/Plando.py index 25003f24..41e4d5e9 100755 --- a/Plando.py +++ b/Plando.py @@ -3,20 +3,31 @@ import argparse import hashlib import logging import os -import RaceRandom as random -import time import sys +import time +import RaceRandom as random from BaseClasses import World -from Regions import create_regions -from OverworldShuffle import link_overworld -from source.overworld.EntranceShuffle2 import link_entrances_new, connect_entrance, connect_two_way, connect_exit -from Rom import patch_rom, LocalRom, write_string_to_rom, apply_rom_settings, get_sprite_from_name -from Rules import set_rules from Dungeons import create_dungeons -from Items import ItemFactory from ItemList import difficulties +from Items import ItemFactory from Main import create_playthrough +from OverworldShuffle import link_overworld +from Regions import create_regions +from Rom import ( + LocalRom, + apply_rom_settings, + get_sprite_from_name, + patch_rom, + write_string_to_rom, +) +from Rules import set_rules +from source.overworld.EntranceShuffle2 import ( + connect_entrance, + connect_exit, + connect_two_way, + link_entrances_new, +) __version__ = '0.2-dev' diff --git a/PotShuffle.py b/PotShuffle.py index bd970182..8303ee3a 100644 --- a/PotShuffle.py +++ b/PotShuffle.py @@ -1,11 +1,9 @@ -import RaceRandom as random - from collections import defaultdict -from BaseClasses import PotItem, Pot, PotFlags, CrystalBarrier, LocationType, RegionType -from Utils import int16_as_bytes, pc_to_snes, snes_to_pc - +import RaceRandom as random +from BaseClasses import CrystalBarrier, LocationType, Pot, PotFlags, PotItem, RegionType from source.dungeon.RoomObject import RoomObject, Shuffled_Pot +from Utils import int16_as_bytes, pc_to_snes, snes_to_pc movable_switch_rooms = defaultdict(lambda: [], {'PoD Stalfos Basement': ['PoD Basement Ledge'], diff --git a/Regions.py b/Regions.py index 0d187310..dc94fdf1 100644 --- a/Regions.py +++ b/Regions.py @@ -1,9 +1,20 @@ import collections -from Items import ItemFactory -from BaseClasses import Region, Location, Entrance, RegionType, Terrain, Shop, ShopType, LocationType, PotItem, PotFlags -from PotShuffle import key_drop_data, vanilla_pots, choose_pots, PotSecretTable -from source.dungeon.EnemyList import setup_enemy_locations, enemy_names +from BaseClasses import ( + Entrance, + Location, + LocationType, + PotFlags, + PotItem, + Region, + RegionType, + Shop, + ShopType, + Terrain, +) +from Items import ItemFactory +from PotShuffle import PotSecretTable, choose_pots, key_drop_data, vanilla_pots +from source.dungeon.EnemyList import enemy_names, setup_enemy_locations def create_regions(world, player): diff --git a/Rom.py b/Rom.py index c4404d0d..16aedc3f 100644 --- a/Rom.py +++ b/Rom.py @@ -1,47 +1,86 @@ import bisect import collections +import hashlib import io import json -import hashlib import logging import os +import struct +import sys import Items import RaceRandom as random -import struct -import sys + try: import bps.apply import bps.io except ImportError: raise Exception('Could not load BPS module') -from BaseClasses import ShopType, Region, Location, OWEdge, Door, DoorType, RegionType, LocationType -from DoorShuffle import compass_data, DROptions, boss_indicator, dungeon_portals -from Dungeons import dungeon_music_addresses, dungeon_table -from Regions import location_table, shop_to_location_table, retro_shops -from RoomData import DoorKind -from Text import MultiByteTextMapper, CompressedTextMapper, text_addresses, Credits, TextTable -from Text import Uncle_texts, Ganon1_texts, Ganon_Phase_3_No_Silvers_texts, Ganon_Phase_3_No_Weakness_texts, TavernMan_texts, Sahasrahla2_texts -from Text import Triforce_texts, Blind_texts, BombShop2_texts, junk_texts -from Text import KingsReturn_texts, Sanctuary_texts, Kakariko_texts, Blacksmiths_texts, DeathMountain_texts -from Text import LostWoods_texts, WishingWell_texts, DesertPalace_texts, MountainTower_texts, LinksHouse_texts -from Text import Lumberjacks_texts, SickKid_texts, FluteBoy_texts, Zora_texts, MagicShop_texts, Sahasrahla_names -from Utils import local_path, int16_as_bytes, int32_as_bytes, snes_to_pc -from Items import ItemFactory, prize_item_table -from source.overworld.EntranceData import door_addresses, ow_prize_table -from source.overworld.EntranceShuffle2 import exit_ids -from OverworldShuffle import default_flute_connections, flute_data -from InitialSram import InitialSram +from BaseClasses import ( + Door, + DoorType, + Location, + LocationType, + OWEdge, + Region, + RegionType, + ShopType, +) from DamageTable import DamageTable - -from source.classes.SFX import randomize_sfx, randomize_sfxinstruments, randomize_songinstruments -from source.item.FillUtil import valid_pot_items +from DoorShuffle import DROptions, boss_indicator, compass_data, dungeon_portals +from Dungeons import dungeon_music_addresses, dungeon_table +from InitialSram import InitialSram +from Items import ItemFactory, prize_item_table +from OverworldShuffle import default_flute_connections, flute_data +from Regions import location_table, retro_shops, shop_to_location_table +from RoomData import DoorKind +from source.classes.SFX import ( + randomize_sfx, + randomize_sfxinstruments, + randomize_songinstruments, +) from source.dungeon.EnemyList import EnemySprite, setup_enemy_dungeon_tables from source.dungeon.RoomObject import DoorObject from source.enemizer.Bossmizer import boss_writes from source.enemizer.Enemizer import write_enemy_shuffle_settings - +from source.item.FillUtil import valid_pot_items +from source.overworld.EntranceData import door_addresses, ow_prize_table +from source.overworld.EntranceShuffle2 import exit_ids +from Text import ( + Blacksmiths_texts, + Blind_texts, + BombShop2_texts, + CompressedTextMapper, + Credits, + DeathMountain_texts, + DesertPalace_texts, + FluteBoy_texts, + Ganon1_texts, + Ganon_Phase_3_No_Silvers_texts, + Ganon_Phase_3_No_Weakness_texts, + Kakariko_texts, + KingsReturn_texts, + LinksHouse_texts, + LostWoods_texts, + Lumberjacks_texts, + MagicShop_texts, + MountainTower_texts, + MultiByteTextMapper, + Sahasrahla2_texts, + Sahasrahla_names, + Sanctuary_texts, + SickKid_texts, + TavernMan_texts, + TextTable, + Triforce_texts, + Uncle_texts, + WishingWell_texts, + Zora_texts, + junk_texts, + text_addresses, +) +from Utils import int16_as_bytes, int32_as_bytes, local_path, snes_to_pc JAP10HASH = '03a63945398191337e896e5771f77173' RANDOMIZERBASEHASH = '76dc2d00e5dd5b925ad01574b327d364' diff --git a/RoomData.py b/RoomData.py index 13339364..3b4e0ad7 100644 --- a/RoomData.py +++ b/RoomData.py @@ -1,4 +1,5 @@ from enum import Enum, unique + from Tables import door_pair_offset_table diff --git a/Rules.py b/Rules.py index 91637cce..67cc06bb 100644 --- a/Rules.py +++ b/Rules.py @@ -3,18 +3,28 @@ import logging from collections import deque import OverworldGlitchRules -from BaseClasses import CollectionState, RegionType, DoorType, Entrance, CrystalBarrier, KeyRuleType, LocationType, Terrain -from BaseClasses import PotFlags +from BaseClasses import ( + CollectionState, + CrystalBarrier, + DoorType, + Entrance, + KeyRuleType, + LocationType, + PotFlags, + RegionType, + Terrain, +) from Dungeons import dungeon_table -from RoomData import DoorKind -from OWEdges import OWExitTypes from OverworldGlitchRules import overworld_glitches_rules -from UnderworldGlitchRules import underworld_glitches_rules - -from source.logic.Rule import RuleFactory +from OWEdges import OWExitTypes +from RoomData import DoorKind from source.dungeon.EnemyList import EnemySprite, Sprite -from source.enemizer.EnemyLogic import special_rules_check, special_rules_for_region, defeat_rule_single -from source.enemizer.EnemyLogic import defeat_rule_multiple, and_rule as and_rule_new, or_rule as or_rule_new +from source.enemizer.EnemyLogic import and_rule as and_rule_new +from source.enemizer.EnemyLogic import defeat_rule_multiple, defeat_rule_single +from source.enemizer.EnemyLogic import or_rule as or_rule_new +from source.enemizer.EnemyLogic import special_rules_check, special_rules_for_region +from source.logic.Rule import RuleFactory +from UnderworldGlitchRules import underworld_glitches_rules def set_rules(world, player): diff --git a/TestSuite.py b/TestSuite.py index ca734581..639dc079 100644 --- a/TestSuite.py +++ b/TestSuite.py @@ -1,8 +1,8 @@ +import argparse +import concurrent.futures +import multiprocessing import subprocess import sys -import multiprocessing -import concurrent.futures -import argparse from collections import OrderedDict cpu_threads = multiprocessing.cpu_count() diff --git a/TestSuiteStat.py b/TestSuiteStat.py index 574e3fb4..a6b4d393 100644 --- a/TestSuiteStat.py +++ b/TestSuiteStat.py @@ -1,10 +1,10 @@ +import argparse +import concurrent.futures +import csv +import multiprocessing import subprocess import sys -import multiprocessing -import concurrent.futures -import argparse from collections import OrderedDict -import csv cpu_threads = multiprocessing.cpu_count() py_version = f"{sys.version_info.major}.{sys.version_info.minor}" diff --git a/Text.py b/Text.py index 81a5a6a1..7e753328 100644 --- a/Text.py +++ b/Text.py @@ -1,8 +1,9 @@ # -*- coding: UTF-8 -*- -from collections import OrderedDict import logging import re import warnings +from collections import OrderedDict + warnings.filterwarnings("ignore", category=SyntaxWarning) text_addresses = {'Pedestal': (0x180300, 256), diff --git a/UnderworldGlitchRules.py b/UnderworldGlitchRules.py index 56e64f71..f35fb41d 100644 --- a/UnderworldGlitchRules.py +++ b/UnderworldGlitchRules.py @@ -1,7 +1,8 @@ import functools -from BaseClasses import Entrance, DoorType, Door -from DoorShuffle import connect_simple_door + import Rules +from BaseClasses import Door, DoorType, Entrance +from DoorShuffle import connect_simple_door kikiskip_spots = [ ("Kiki Skip", "Spectacle Rock Cave (Bottom)", "Palace of Darkness Portal") diff --git a/Utils.py b/Utils.py index 6f1a38be..d7436309 100644 --- a/Utils.py +++ b/Utils.py @@ -1,19 +1,19 @@ #!/usr/bin/env python3 +import fileinput import os import re import subprocess import sys +import urllib.parse +import urllib.request import xml.etree.ElementTree as ET from collections import defaultdict -from math import factorial from itertools import count -import fileinput - -import urllib.request -import urllib.parse -import yaml +from math import factorial from pathlib import Path +import yaml + def int16_as_bytes(value): value = value & 0xFFFF @@ -103,9 +103,9 @@ def close_console(): def make_new_base2current(old_rom='Zelda no Densetsu - Kamigami no Triforce (Japan).sfc', new_rom='working.sfc'): - from collections import OrderedDict - import json import hashlib + import json + from collections import OrderedDict with open(old_rom, 'rb') as stream: old_rom_data = bytearray(stream.read()) with open(new_rom, 'rb') as stream: diff --git a/_vendor/collections_extended/__init__.py b/_vendor/collections_extended/__init__.py index 039fee03..3b39cf66 100644 --- a/_vendor/collections_extended/__init__.py +++ b/_vendor/collections_extended/__init__.py @@ -1,9 +1,9 @@ """collections_extended contains a few extra basic data structures.""" from ._compat import Collection from .bags import bag, frozenbag -from .setlists import setlist, frozensetlist from .bijection import bijection -from .range_map import RangeMap, MappedRange +from .range_map import MappedRange, RangeMap +from .setlists import frozensetlist, setlist __version__ = '1.0.2' diff --git a/_vendor/collections_extended/_compat.py b/_vendor/collections_extended/_compat.py index bbf0fbd9..451eec54 100644 --- a/_vendor/collections_extended/_compat.py +++ b/_vendor/collections_extended/_compat.py @@ -12,7 +12,7 @@ else: if sys.version_info < (3, 6): - from collections import Sized, Iterable, Container + from collections import Container, Iterable, Sized def _check_methods(C, *methods): mro = C.__mro__ diff --git a/_vendor/collections_extended/bags.py b/_vendor/collections_extended/bags.py index cce132fe..2373abc8 100644 --- a/_vendor/collections_extended/bags.py +++ b/_vendor/collections_extended/bags.py @@ -1,7 +1,7 @@ """Bag class definitions.""" import heapq +from collections import Hashable, MutableSet, Set from operator import itemgetter -from collections import Set, MutableSet, Hashable from . import _compat diff --git a/_vendor/collections_extended/bijection.py b/_vendor/collections_extended/bijection.py index f9641de4..7e71a29f 100644 --- a/_vendor/collections_extended/bijection.py +++ b/_vendor/collections_extended/bijection.py @@ -1,6 +1,6 @@ """Class definition for bijection.""" -from collections import MutableMapping, Mapping +from collections import Mapping, MutableMapping class bijection(MutableMapping): diff --git a/_vendor/collections_extended/range_map.py b/_vendor/collections_extended/range_map.py index 19a61238..85439bd3 100644 --- a/_vendor/collections_extended/range_map.py +++ b/_vendor/collections_extended/range_map.py @@ -1,7 +1,6 @@ """RangeMap class definition.""" from bisect import bisect_left, bisect_right -from collections import namedtuple, Mapping, MappingView, Set - +from collections import Mapping, MappingView, Set, namedtuple # Used to mark unmapped ranges _empty = object() diff --git a/_vendor/collections_extended/setlists.py b/_vendor/collections_extended/setlists.py index 2976077c..394a3eea 100644 --- a/_vendor/collections_extended/setlists.py +++ b/_vendor/collections_extended/setlists.py @@ -1,13 +1,12 @@ """Setlist class definitions.""" import random as random_ - from collections import ( - Sequence, - Set, - MutableSequence, - MutableSet, - Hashable, - ) + Hashable, + MutableSequence, + MutableSet, + Sequence, + Set, +) from . import _util diff --git a/build-app_version.py b/build-app_version.py index 69332cba..d1686b89 100644 --- a/build-app_version.py +++ b/build-app_version.py @@ -1,5 +1,6 @@ -from OverworldShuffle import __version__ as OWVersion import os +from OverworldShuffle import __version__ as OWVersion + with(open(os.path.join("resources","app","meta","manifests","app_version.txt"),"w+")) as f: f.write(OWVersion) diff --git a/bundle/_rt_hook.py b/bundle/_rt_hook.py index 17ea446b..2c897afc 100644 --- a/bundle/_rt_hook.py +++ b/bundle/_rt_hook.py @@ -1,4 +1,4 @@ -import sys import os +import sys sys.path.append(os.path.join(sys._MEIPASS, "ext")) diff --git a/pyproject.toml b/pyproject.toml index 9ed1480e..5d0023a2 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -14,3 +14,6 @@ dependencies = [ "pyyaml>=6.0.1", "websockets>=11.0.3", ] + +[tool.isort] +profile = "black" diff --git a/resources/ci/common/common.py b/resources/ci/common/common.py index 17b37434..342e1e0f 100644 --- a/resources/ci/common/common.py +++ b/resources/ci/common/common.py @@ -1,6 +1,7 @@ -import os # for env vars -import stat # file statistics +import os # for env vars +import stat # file statistics import sys # default system info + try: import distro except ModuleNotFoundError as e: diff --git a/resources/ci/common/get_get_pip.py b/resources/ci/common/get_get_pip.py index 1de2898b..b076d37f 100644 --- a/resources/ci/common/get_get_pip.py +++ b/resources/ci/common/get_get_pip.py @@ -1,8 +1,10 @@ -import common import argparse import os -import urllib.request, ssl -import subprocess # do stuff at the shell level +import ssl +import subprocess # do stuff at the shell level +import urllib.request + +import common env = common.prepare_env() diff --git a/resources/ci/common/get_pipline.py b/resources/ci/common/get_pipline.py index edc5714a..53110a5c 100644 --- a/resources/ci/common/get_pipline.py +++ b/resources/ci/common/get_pipline.py @@ -1,11 +1,11 @@ # import modules -import common # app common functions +import json # json manipulation +import os # for os data, filesystem manipulation +import subprocess # for running shell commands +import sys # for system commands +import traceback # for errors -import json # json manipulation -import os # for os data, filesystem manipulation -import subprocess # for running shell commands -import sys # for system commands -import traceback # for errors +import common # app common functions # get env env = common.prepare_env() # get environment variables diff --git a/resources/ci/common/get_upx.py b/resources/ci/common/get_upx.py index 16982aaf..d3f8c520 100644 --- a/resources/ci/common/get_upx.py +++ b/resources/ci/common/get_upx.py @@ -1,9 +1,10 @@ -import common -import os # for env vars -import sys # for path -import urllib.request # for downloads +import os # for env vars +import sys # for path +import urllib.request # for downloads from shutil import unpack_archive +import common + # only do stuff if we don't have a UPX folder if not os.path.isdir(os.path.join(".","upx")): diff --git a/resources/ci/common/git_clean.py b/resources/ci/common/git_clean.py index b6e9668b..f4431b7b 100644 --- a/resources/ci/common/git_clean.py +++ b/resources/ci/common/git_clean.py @@ -1,5 +1,6 @@ -import subprocess # do stuff at the shell level import os +import subprocess # do stuff at the shell level + def git_clean(clean_ignored=True, clean_user=False): excludes = [ diff --git a/resources/ci/common/install.py b/resources/ci/common/install.py index 3d0b5965..3b54a3f4 100644 --- a/resources/ci/common/install.py +++ b/resources/ci/common/install.py @@ -1,8 +1,9 @@ -import common import argparse import os import platform -import subprocess # do stuff at the shell level +import subprocess # do stuff at the shell level + +import common env = common.prepare_env() diff --git a/resources/ci/common/list_actions.py b/resources/ci/common/list_actions.py index ec4caf5f..52515837 100644 --- a/resources/ci/common/list_actions.py +++ b/resources/ci/common/list_actions.py @@ -6,9 +6,10 @@ import json import os import ssl import urllib.request -import yaml from json.decoder import JSONDecodeError +import yaml + allACTIONS = {} listACTIONS = [] diff --git a/resources/ci/common/local_install.py b/resources/ci/common/local_install.py index 02cc25a5..ec4aec2f 100644 --- a/resources/ci/common/local_install.py +++ b/resources/ci/common/local_install.py @@ -1,8 +1,8 @@ -import install -import get_get_pip - import argparse +import get_get_pip +import install + parser = argparse.ArgumentParser(add_help=False) parser.add_argument('--py', default=0) parser.add_argument('--user', default=False, action="store_true") diff --git a/resources/ci/common/my_path.py b/resources/ci/common/my_path.py index 7d91f15e..61c4546e 100644 --- a/resources/ci/common/my_path.py +++ b/resources/ci/common/my_path.py @@ -1,6 +1,7 @@ import os import sys + def get_py_path(): user_paths = os.environ["PATH"].split(os.pathsep) (python,py) = ("","") diff --git a/resources/ci/common/prepare_appversion.py b/resources/ci/common/prepare_appversion.py index 0f413298..47c71d84 100644 --- a/resources/ci/common/prepare_appversion.py +++ b/resources/ci/common/prepare_appversion.py @@ -1,6 +1,7 @@ +import os # for env vars +from shutil import copy # file manipulation + import common -import os # for env vars -from shutil import copy # file manipulation env = common.prepare_env() diff --git a/resources/ci/common/prepare_binary.py b/resources/ci/common/prepare_binary.py index 4d9ac5e4..a4b9626a 100644 --- a/resources/ci/common/prepare_binary.py +++ b/resources/ci/common/prepare_binary.py @@ -2,11 +2,12 @@ Locate and prepare binary builds """ # import distutils.dir_util # for copying trees -import os # for env vars +import os # for env vars +from shutil import move # file manipulation + # import stat # for file stats # import subprocess # do stuff at the shell level import common -from shutil import move # file manipulation env = common.prepare_env() diff --git a/resources/ci/common/prepare_release.py b/resources/ci/common/prepare_release.py index c4b4bce3..0b9896a9 100644 --- a/resources/ci/common/prepare_release.py +++ b/resources/ci/common/prepare_release.py @@ -1,10 +1,11 @@ -import distutils.dir_util # for copying trees -import os # for env vars -import stat # for file stats -import subprocess # do stuff at the shell level +import distutils.dir_util # for copying trees +import os # for env vars +import stat # for file stats +import subprocess # do stuff at the shell level +from shutil import copy, make_archive, move, rmtree # file manipulation + import common from git_clean import git_clean -from shutil import copy, make_archive, move, rmtree # file manipulation env = common.prepare_env() # get env vars diff --git a/source/classes/BabelFish.py b/source/classes/BabelFish.py index 40b6463f..e20dd536 100644 --- a/source/classes/BabelFish.py +++ b/source/classes/BabelFish.py @@ -2,6 +2,7 @@ import json import locale import os + class BabelFish(): def __init__(self,subpath=["resources","app","meta"],lang=None): localization_string = locale.getdefaultlocale()[0] #get set localization diff --git a/source/classes/CustomSettings.py b/source/classes/CustomSettings.py index 7a3f3712..780b4969 100644 --- a/source/classes/CustomSettings.py +++ b/source/classes/CustomSettings.py @@ -1,17 +1,18 @@ import os -import urllib.request import urllib.parse -import yaml -from typing import Any -from yaml.representer import Representer -from Utils import HexInt, hex_representer +import urllib.request from collections import defaultdict from pathlib import Path +from typing import Any + +import yaml +from yaml.representer import Representer import RaceRandom as random -from BaseClasses import LocationType, DoorType +from BaseClasses import DoorType, LocationType from OverworldShuffle import default_flute_connections, flute_data -from source.tools.MysteryUtils import roll_settings, get_weights +from source.tools.MysteryUtils import get_weights, roll_settings +from Utils import HexInt, hex_representer class CustomSettings(object): diff --git a/source/classes/ItemGfxSelector.py b/source/classes/ItemGfxSelector.py index ee5d528d..5f8b561a 100644 --- a/source/classes/ItemGfxSelector.py +++ b/source/classes/ItemGfxSelector.py @@ -1,5 +1,20 @@ -from tkinter import Button, Canvas, Label, LabelFrame, Frame, PhotoImage, Scrollbar, Toplevel, LEFT, BOTTOM, X, RIGHT, TOP import os +from tkinter import ( + BOTTOM, + LEFT, + RIGHT, + TOP, + Button, + Canvas, + Frame, + Label, + LabelFrame, + PhotoImage, + Scrollbar, + Toplevel, + X, +) + from GuiUtils import ToolTips, set_icon from Utils import local_path diff --git a/source/classes/SFX.py b/source/classes/SFX.py index b98a76f8..c3724a3d 100644 --- a/source/classes/SFX.py +++ b/source/classes/SFX.py @@ -1,5 +1,6 @@ -from enum import IntEnum import random +from enum import IntEnum + from Utils import int16_as_bytes, snes_to_pc diff --git a/source/classes/SpriteSelector.py b/source/classes/SpriteSelector.py index 9a18cacd..ed5d3c54 100644 --- a/source/classes/SpriteSelector.py +++ b/source/classes/SpriteSelector.py @@ -1,16 +1,36 @@ -from tkinter import filedialog, messagebox, Button, Canvas, Label, LabelFrame, Frame, PhotoImage, Scrollbar, Toplevel, ALL, LEFT, BOTTOM, X, RIGHT, TOP, EW, NS -from glob import glob import json import os import random import shutil import ssl +import webbrowser +from glob import glob +from tkinter import ( + ALL, + BOTTOM, + EW, + LEFT, + NS, + RIGHT, + TOP, + Button, + Canvas, + Frame, + Label, + LabelFrame, + PhotoImage, + Scrollbar, + Toplevel, + X, + filedialog, + messagebox, +) from urllib.parse import urlparse from urllib.request import urlopen -import webbrowser -from GuiUtils import ToolTips, set_icon, BackgroundTaskProgress + +from GuiUtils import BackgroundTaskProgress, ToolTips, set_icon from Rom import Sprite -from Utils import is_bundled, local_path, output_path, open_file +from Utils import is_bundled, local_path, open_file, output_path class SpriteSelector(object): diff --git a/source/classes/appversion.py b/source/classes/appversion.py index 3d677d1e..527d8212 100644 --- a/source/classes/appversion.py +++ b/source/classes/appversion.py @@ -1,6 +1,7 @@ import os from OverworldShuffle import __version__ + OWR_VERSION = __version__ def write_appversion(): diff --git a/source/classes/diags.py b/source/classes/diags.py index e26c4e43..80791519 100644 --- a/source/classes/diags.py +++ b/source/classes/diags.py @@ -1,4 +1,8 @@ -import platform, sys, os, subprocess +import os +import platform +import subprocess +import sys + try: import pkg_resources except ModuleNotFoundError as e: @@ -6,9 +10,11 @@ except ModuleNotFoundError as e: import datetime from Main import __version__ + DR_VERSION = __version__ from OverworldShuffle import __version__ + OWR_VERSION = __version__ PROJECT_NAME = "ALttP Overworld Randomizer" diff --git a/source/dungeon/DungeonStitcher.py b/source/dungeon/DungeonStitcher.py index d7ce3c4f..abdc5df6 100644 --- a/source/dungeon/DungeonStitcher.py +++ b/source/dungeon/DungeonStitcher.py @@ -1,11 +1,18 @@ -import RaceRandom as random import collections import logging import time -from BaseClasses import CrystalBarrier, DoorType, Hook, RegionType, Sector -from BaseClasses import hook_from_door, flooded_keys -from Regions import location_events, flooded_keys_reverse +import RaceRandom as random +from BaseClasses import ( + CrystalBarrier, + DoorType, + Hook, + RegionType, + Sector, + flooded_keys, + hook_from_door, +) +from Regions import flooded_keys_reverse, location_events def pre_validate(builder, entrance_region_names, split_dungeon, world, player): diff --git a/source/dungeon/EnemyList.py b/source/dungeon/EnemyList.py index 32909d37..2511361f 100644 --- a/source/dungeon/EnemyList.py +++ b/source/dungeon/EnemyList.py @@ -1,5 +1,5 @@ -from collections import defaultdict, deque import typing +from collections import defaultdict, deque import yaml from yaml.representer import Representer @@ -13,9 +13,9 @@ import RaceRandom as random from BaseClasses import Location, LocationType, RegionType from Items import ItemFactory from PotShuffle import key_drop_special -from Utils import snes_to_pc, pc_to_snes, int16_as_bytes - from source.overworld.EntranceData import door_addresses +from Utils import int16_as_bytes, pc_to_snes, snes_to_pc + class EnemyStats: def __init__(self, sprite, static, drop_flag=False, prize_pack: typing.Union[tuple, int] = 0, diff --git a/source/dungeon/RoomList.py b/source/dungeon/RoomList.py index 951f5b33..bb81fb2a 100644 --- a/source/dungeon/RoomList.py +++ b/source/dungeon/RoomList.py @@ -3,9 +3,8 @@ try: except ImportError: from enum import IntFlag as FastEnum - from RoomData import DoorKind, Position -from source.dungeon.RoomObject import RoomObject, DoorObject +from source.dungeon.RoomObject import DoorObject, RoomObject class Room: diff --git a/source/enemizer/Bossmizer.py b/source/enemizer/Bossmizer.py index 7b10262e..55cb2833 100644 --- a/source/enemizer/Bossmizer.py +++ b/source/enemizer/Bossmizer.py @@ -1,10 +1,9 @@ import RaceRandom as random -from Utils import snes_to_pc - -from source.dungeon.EnemyList import EnemySprite, SpriteType, Sprite -from source.dungeon.RoomList import boss_rooms, gt_boss_room, Room0006 +from source.dungeon.EnemyList import EnemySprite, Sprite, SpriteType +from source.dungeon.RoomList import Room0006, boss_rooms, gt_boss_room from source.dungeon.RoomObject import RoomObject from source.enemizer.SpriteSheets import required_boss_sheets +from Utils import snes_to_pc def get_dungeon_boss_room(dungeon_name, level): diff --git a/source/enemizer/Enemizer.py b/source/enemizer/Enemizer.py index c1d37981..3ad3214a 100644 --- a/source/enemizer/Enemizer.py +++ b/source/enemizer/Enemizer.py @@ -1,13 +1,17 @@ -import RaceRandom as random from collections import defaultdict -from Utils import snes_to_pc -from source.dungeon.EnemyList import SpriteType, EnemySprite, sprite_translation +import RaceRandom as random +from source.dungeon.EnemyList import EnemySprite, SpriteType, sprite_translation from source.dungeon.RoomList import Room010C from source.enemizer.SpecialEnemyModes import set_mimics, write_mimic_changes -from source.enemizer.SpriteSheets import sub_group_choices, sheets_with_free_gfx -from source.enemizer.SpriteSheets import randomize_underworld_sprite_sheets, randomize_overworld_sprite_sheets +from source.enemizer.SpriteSheets import ( + randomize_overworld_sprite_sheets, + randomize_underworld_sprite_sheets, + sheets_with_free_gfx, + sub_group_choices, +) from source.enemizer.TilePattern import tile_patterns +from Utils import snes_to_pc shutter_sprites = { 0xb8: {0, 1, 2, 3, 4, 5}, 0xb: {4, 5, 6, 7, 8, 9}, 0x1b: {3, 4, 5}, 0x4b: {0, 3, 4}, 0x4: {9, 13, 14}, diff --git a/source/enemizer/EnemizerTestHarness.py b/source/enemizer/EnemizerTestHarness.py index c8f1070c..d8b5ba26 100644 --- a/source/enemizer/EnemizerTestHarness.py +++ b/source/enemizer/EnemizerTestHarness.py @@ -1,12 +1,18 @@ -from types import SimpleNamespace from collections import Counter, defaultdict +from types import SimpleNamespace -from source.dungeon.EnemyList import enemy_names, SpriteType -from source.enemizer.Enemizer import randomize_underworld_rooms, randomize_overworld_enemies -from source.enemizer.SpriteSheets import randomize_underworld_sprite_sheets, randomize_overworld_sprite_sheets -from source.rom.DataTables import init_data_tables -from source.enemizer.DamageTables import DamageTable import RaceRandom as random +from source.dungeon.EnemyList import SpriteType, enemy_names +from source.enemizer.DamageTables import DamageTable +from source.enemizer.Enemizer import ( + randomize_overworld_enemies, + randomize_underworld_rooms, +) +from source.enemizer.SpriteSheets import ( + randomize_overworld_sprite_sheets, + randomize_underworld_sprite_sheets, +) +from source.rom.DataTables import init_data_tables def calculate_odds(): diff --git a/source/enemizer/EnemyLogic.py b/source/enemizer/EnemyLogic.py index df8a21c5..a460851b 100644 --- a/source/enemizer/EnemyLogic.py +++ b/source/enemizer/EnemyLogic.py @@ -2,9 +2,8 @@ import math from collections import defaultdict import RaceRandom as random - -from source.logic.Rule import RuleFactory from source.dungeon.EnemyList import EnemySprite +from source.logic.Rule import RuleFactory # these are for drops only diff --git a/source/enemizer/OwEnemyList.py b/source/enemizer/OwEnemyList.py index f89b16c6..581d2477 100644 --- a/source/enemizer/OwEnemyList.py +++ b/source/enemizer/OwEnemyList.py @@ -1,4 +1,5 @@ -from source.dungeon.EnemyList import Sprite, EnemySprite +from source.dungeon.EnemyList import EnemySprite, Sprite + vanilla_sprites_ow = {} diff --git a/source/enemizer/SpecialEnemyModes.py b/source/enemizer/SpecialEnemyModes.py index 5e80310c..fd061f42 100644 --- a/source/enemizer/SpecialEnemyModes.py +++ b/source/enemizer/SpecialEnemyModes.py @@ -1,8 +1,12 @@ import RaceRandom as random +from source.dungeon.EnemyList import ( + EnemySprite, + SpriteType, + enemy_names, + sprite_translation, +) from Utils import snes_to_pc -from source.dungeon.EnemyList import EnemySprite, SpriteType, sprite_translation, enemy_names - change_idx_1 = [0, 1, 2, 3, 4, 5, 6, 7, 8, 10, 11, 13, 16, 18, 19, 20, 21, 22, 23, 24, 25, 26, 28, 31, 32, 35, 38, 65, 66, 67, 68, 70, 71, 76, 77, 78, 81, 83, 89, 91, 92, 94, 97, 100, 101, 102, 103, 104, 105, 106, 107] diff --git a/source/enemizer/SpriteSheets.py b/source/enemizer/SpriteSheets.py index f558eb7d..97235910 100644 --- a/source/enemizer/SpriteSheets.py +++ b/source/enemizer/SpriteSheets.py @@ -1,8 +1,14 @@ import logging from collections import defaultdict -import RaceRandom as random -from source.dungeon.EnemyList import EnemySprite, SpriteType, enemy_names, sprite_translation, overlord_names +import RaceRandom as random +from source.dungeon.EnemyList import ( + EnemySprite, + SpriteType, + enemy_names, + overlord_names, + sprite_translation, +) from source.dungeon.RoomConstants import * diff --git a/source/enemizer/TilePattern.py b/source/enemizer/TilePattern.py index a452c547..f85b94dc 100644 --- a/source/enemizer/TilePattern.py +++ b/source/enemizer/TilePattern.py @@ -1,6 +1,6 @@ -import os -import json import codecs +import json +import os if __name__ == '__main__': directory = './EnemizerCLI.Core/tiles' diff --git a/source/gui/adjust/overview.py b/source/gui/adjust/overview.py index 2d062c8a..1c61267d 100644 --- a/source/gui/adjust/overview.py +++ b/source/gui/adjust/overview.py @@ -1,15 +1,31 @@ -from tkinter import ttk, filedialog, messagebox, StringVar, Button, Entry, Frame, Label, E, W, LEFT, RIGHT, X, BOTTOM -from AdjusterMain import adjust, patch -from argparse import Namespace -from source.classes.SpriteSelector import SpriteSelector -from source.classes.ItemGfxSelector import ItemGfxSelector -import source.gui.widgets as widgets import json import logging import os +from argparse import Namespace +from tkinter import ( + BOTTOM, + LEFT, + RIGHT, + Button, + E, + Entry, + Frame, + Label, + StringVar, + W, + X, + filedialog, + messagebox, + ttk, +) +import source.gui.widgets as widgets +from AdjusterMain import adjust, patch +from source.classes.ItemGfxSelector import ItemGfxSelector +from source.classes.SpriteSelector import SpriteSelector from Utils import output_path + def adjust_page(top, parent, settings): # Adjust page self = ttk.Frame(parent) diff --git a/source/gui/bottom.py b/source/gui/bottom.py index 35b6c516..2784ea62 100644 --- a/source/gui/bottom.py +++ b/source/gui/bottom.py @@ -1,17 +1,29 @@ -from tkinter import ttk, messagebox, StringVar, Button, Entry, Frame, Label, LEFT, RIGHT, X -from argparse import Namespace import logging import os import random import re +from argparse import Namespace +from tkinter import ( + LEFT, + RIGHT, + Button, + Entry, + Frame, + Label, + StringVar, + X, + messagebox, + ttk, +) + +import source.classes.constants as CONST +import source.gui.widgets as widgets from CLI import parse_cli from Fill import FillError -from Main import main, export_yaml, EnemizerError -from Utils import local_path, output_path, open_file, update_deprecated_args -import source.classes.constants as CONST -from source.gui.randomize.multiworld import multiworld_page -import source.gui.widgets as widgets +from Main import EnemizerError, export_yaml, main from source.classes.Empty import Empty +from source.gui.randomize.multiworld import multiworld_page +from Utils import local_path, open_file, output_path, update_deprecated_args def bottom_frame(self, parent, args=None): diff --git a/source/gui/custom/overview.py b/source/gui/custom/overview.py index b62bff71..5fccbf03 100644 --- a/source/gui/custom/overview.py +++ b/source/gui/custom/overview.py @@ -1,9 +1,10 @@ -from tkinter import ttk, Frame, N, E, W, LEFT, TOP, X, VERTICAL, Y -import source.gui.widgets as widgets import json import os +from tkinter import LEFT, TOP, VERTICAL, E, Frame, N, W, X, Y, ttk import source.classes.constants as CONST +import source.gui.widgets as widgets + def custom_page(top,parent): # Custom Item Pool diff --git a/source/gui/loadcliargs.py b/source/gui/loadcliargs.py index 6ca7ad60..bf5584fe 100644 --- a/source/gui/loadcliargs.py +++ b/source/gui/loadcliargs.py @@ -1,10 +1,11 @@ -from source.classes.SpriteSelector import SpriteSelector as spriteSelector -from source.gui.randomize.gameoptions import set_sprite -from Rom import Sprite, get_sprite_from_name -from Utils import update_deprecated_args import source.classes.constants as CONST +from Rom import Sprite, get_sprite_from_name from source.classes.BabelFish import BabelFish from source.classes.Empty import Empty +from source.classes.SpriteSelector import SpriteSelector as spriteSelector +from source.gui.randomize.gameoptions import set_sprite +from Utils import update_deprecated_args + # Load args/settings for most tabs def loadcliargs(gui, args, settings=None): diff --git a/source/gui/randomize/dungeon.py b/source/gui/randomize/dungeon.py index 88f11379..efce57a3 100644 --- a/source/gui/randomize/dungeon.py +++ b/source/gui/randomize/dungeon.py @@ -1,7 +1,9 @@ -from tkinter import ttk, Frame, Label, E, W, LEFT, RIGHT, TOP -import source.gui.widgets as widgets import json import os +from tkinter import LEFT, RIGHT, TOP, E, Frame, Label, W, ttk + +import source.gui.widgets as widgets + def dungeon_page(parent): # Dungeon Shuffle diff --git a/source/gui/randomize/enemizer.py b/source/gui/randomize/enemizer.py index 40bf055c..a98f89ca 100644 --- a/source/gui/randomize/enemizer.py +++ b/source/gui/randomize/enemizer.py @@ -1,10 +1,27 @@ -from tkinter import ttk, filedialog, StringVar, Button, Entry, Frame, Label, N, E, W, LEFT, RIGHT, BOTTOM, X -import source.gui.widgets as widgets import json import os import webbrowser +from tkinter import ( + BOTTOM, + LEFT, + RIGHT, + Button, + E, + Entry, + Frame, + Label, + N, + StringVar, + W, + X, + filedialog, + ttk, +) + +import source.gui.widgets as widgets from source.classes.Empty import Empty + def enemizer_page(parent,settings): # Enemizer self = ttk.Frame(parent) diff --git a/source/gui/randomize/entrando.py b/source/gui/randomize/entrando.py index ba2bc365..45578470 100644 --- a/source/gui/randomize/entrando.py +++ b/source/gui/randomize/entrando.py @@ -1,7 +1,9 @@ -from tkinter import ttk, Frame, E, W, LEFT, RIGHT -import source.gui.widgets as widgets import json import os +from tkinter import LEFT, RIGHT, E, Frame, W, ttk + +import source.gui.widgets as widgets + def entrando_page(parent): # Entrance Randomizer diff --git a/source/gui/randomize/gameoptions.py b/source/gui/randomize/gameoptions.py index 5f3dfddf..e2e45691 100644 --- a/source/gui/randomize/gameoptions.py +++ b/source/gui/randomize/gameoptions.py @@ -1,10 +1,25 @@ -from tkinter import ttk, StringVar, Button, Entry, Frame, Label, NE, NW, E, W, LEFT, RIGHT -from functools import partial -import source.classes.SpriteSelector as spriteSelector -import source.classes.ItemGfxSelector as itemGfxSelector -import source.gui.widgets as widgets import json import os +from functools import partial +from tkinter import ( + LEFT, + NE, + NW, + RIGHT, + Button, + E, + Entry, + Frame, + Label, + StringVar, + W, + ttk, +) + +import source.classes.ItemGfxSelector as itemGfxSelector +import source.classes.SpriteSelector as spriteSelector +import source.gui.widgets as widgets + def gameoptions_page(top, parent): # Game Options diff --git a/source/gui/randomize/generation.py b/source/gui/randomize/generation.py index 868402e4..37f28d68 100644 --- a/source/gui/randomize/generation.py +++ b/source/gui/randomize/generation.py @@ -1,11 +1,28 @@ -from tkinter import ttk, filedialog, StringVar, Button, Entry, Frame, Label, E, W, LEFT, X, Text, Tk, INSERT -import source.classes.diags as diagnostics -import source.gui.widgets as widgets import json import os from functools import partial -from source.classes.Empty import Empty +from tkinter import ( + INSERT, + LEFT, + Button, + E, + Entry, + Frame, + Label, + StringVar, + Text, + Tk, + W, + X, + filedialog, + ttk, +) + +import source.classes.diags as diagnostics +import source.gui.widgets as widgets from Main import __version__ +from source.classes.Empty import Empty + def generation_page(parent,settings): # Generation Setup diff --git a/source/gui/randomize/item.py b/source/gui/randomize/item.py index bdb47747..4d183c50 100644 --- a/source/gui/randomize/item.py +++ b/source/gui/randomize/item.py @@ -1,8 +1,24 @@ -from tkinter import messagebox, ttk, font, Button, Frame, E, W, TOP, LEFT, RIGHT, X, Y, Label -import source.gui.widgets as widgets -from source.classes.Empty import Empty import json import os +from tkinter import ( + LEFT, + RIGHT, + TOP, + Button, + E, + Frame, + Label, + W, + X, + Y, + font, + messagebox, + ttk, +) + +import source.gui.widgets as widgets +from source.classes.Empty import Empty + def item_page(parent): # Item Randomizer diff --git a/source/gui/randomize/multiworld.py b/source/gui/randomize/multiworld.py index 493f31b5..a3e53fbf 100644 --- a/source/gui/randomize/multiworld.py +++ b/source/gui/randomize/multiworld.py @@ -1,9 +1,11 @@ -from tkinter import ttk, StringVar, Entry, Frame, Label, N, E, W, X, LEFT -import source.gui.widgets as widgets import json import os +from tkinter import LEFT, E, Entry, Frame, Label, N, StringVar, W, X, ttk + +import source.gui.widgets as widgets from source.classes.Empty import Empty + def multiworld_page(parent,settings): # Multiworld self = ttk.Frame(parent) diff --git a/source/gui/randomize/overworld.py b/source/gui/randomize/overworld.py index 54120417..b453195b 100644 --- a/source/gui/randomize/overworld.py +++ b/source/gui/randomize/overworld.py @@ -1,7 +1,9 @@ -from tkinter import ttk, Frame, Label, W, E, NW, LEFT, RIGHT, X, Y, TOP -import source.gui.widgets as widgets import json import os +from tkinter import LEFT, NW, RIGHT, TOP, E, Frame, Label, W, X, Y, ttk + +import source.gui.widgets as widgets + def overworld_page(parent): # Overworld Shuffle diff --git a/source/gui/startinventory/overview.py b/source/gui/startinventory/overview.py index 97784521..c2820649 100644 --- a/source/gui/startinventory/overview.py +++ b/source/gui/startinventory/overview.py @@ -1,9 +1,10 @@ -from tkinter import ttk, Frame, N, E, W, LEFT, TOP, X, VERTICAL, Y -import source.gui.widgets as widgets import json import os +from tkinter import LEFT, TOP, VERTICAL, E, Frame, N, W, X, Y, ttk import source.classes.constants as CONST +import source.gui.widgets as widgets + def startinventory_page(top,parent): # Starting Inventory diff --git a/source/gui/widgets.py b/source/gui/widgets.py index 6038e3a2..001d76a7 100644 --- a/source/gui/widgets.py +++ b/source/gui/widgets.py @@ -1,7 +1,22 @@ -from tkinter import messagebox, Checkbutton, Entry, Frame, IntVar, Label, OptionMenu, Spinbox, StringVar, LEFT, RIGHT, X -from tkinter import Button +from tkinter import ( + LEFT, + RIGHT, + Button, + Checkbutton, + Entry, + Frame, + IntVar, + Label, + OptionMenu, + Spinbox, + StringVar, + X, + messagebox, +) + from source.classes.Empty import Empty + # Override Spinbox to include mousewheel support for changing value class mySpinbox(Spinbox): def __init__(self, *args, **kwargs): diff --git a/source/item/District.py b/source/item/District.py index bec993bd..867e356d 100644 --- a/source/item/District.py +++ b/source/item/District.py @@ -2,7 +2,8 @@ from collections import deque from BaseClasses import CollectionState, RegionType from Dungeons import dungeon_table -from OWEdges import OWTileRegions, OWTileDistricts +from OWEdges import OWTileDistricts, OWTileRegions + class District(object): diff --git a/source/item/FillUtil.py b/source/item/FillUtil.py index 25bebbcd..365a803f 100644 --- a/source/item/FillUtil.py +++ b/source/item/FillUtil.py @@ -1,13 +1,13 @@ -import RaceRandom as random import logging from collections import defaultdict -from source.item.District import resolve_districts -from BaseClasses import PotItem, PotFlags, LocationType +import RaceRandom as random +from BaseClasses import LocationType, PotFlags, PotItem from DoorShuffle import validate_vanilla_reservation from Dungeons import dungeon_table -from Items import item_table, ItemFactory +from Items import ItemFactory, item_table from PotShuffle import vanilla_pots +from source.item.District import resolve_districts class ItemPoolConfig(object): diff --git a/source/logic/Rule.py b/source/logic/Rule.py index 970062bb..fc60842b 100644 --- a/source/logic/Rule.py +++ b/source/logic/Rule.py @@ -1,6 +1,6 @@ import itertools - from collections import OrderedDict + try: from fast_enum import FastEnum except ImportError: diff --git a/source/meta/build.py b/source/meta/build.py index 4cc29436..b5c22b2c 100644 --- a/source/meta/build.py +++ b/source/meta/build.py @@ -2,11 +2,11 @@ Build Entrypoints ''' import json -import platform import os # for checking for dirs +import platform import re from json.decoder import JSONDecodeError -from subprocess import Popen, PIPE, STDOUT, CalledProcessError +from subprocess import PIPE, STDOUT, CalledProcessError, Popen DEST_DIRECTORY = "." diff --git a/source/meta/check_requirements.py b/source/meta/check_requirements.py index 6976f707..c6fcd576 100644 --- a/source/meta/check_requirements.py +++ b/source/meta/check_requirements.py @@ -25,7 +25,7 @@ def check_requirements(console=False): logger.error('https://github.com/aerinon/ALttPDoorRandomizer/blob/DoorDev/docs/BUILDING.md') else: import webbrowser - from tkinter import Tk, Label, Button, Frame + from tkinter import Button, Frame, Label, Tk master = Tk() master.title('Error') diff --git a/source/overworld/EntranceShuffle2.py b/source/overworld/EntranceShuffle2.py index 8ef10110..b0779e18 100644 --- a/source/overworld/EntranceShuffle2.py +++ b/source/overworld/EntranceShuffle2.py @@ -1,10 +1,9 @@ -import RaceRandom as random -import logging import copy +import logging +from collections import OrderedDict, defaultdict -from collections import defaultdict, OrderedDict +import RaceRandom as random from BaseClasses import RegionType - from source.overworld.EntranceData import door_addresses @@ -857,9 +856,9 @@ def get_nearby_entrances(avail, start_region): def get_accessible_entrances(start_region, avail, assumed_inventory=[], cross_world=False, region_rules=True, exit_rules=True, include_one_ways=False, restrictive_follower=False): - from Main import copy_world_premature from BaseClasses import CollectionState from Items import ItemFactory + from Main import copy_world_premature from OverworldShuffle import build_accessible_region_list, one_way_ledges for p in range(1, avail.world.players + 1): diff --git a/source/rom/DataTables.py b/source/rom/DataTables.py index f082a4f5..0ba42bab 100644 --- a/source/rom/DataTables.py +++ b/source/rom/DataTables.py @@ -1,13 +1,28 @@ from collections import defaultdict -from Utils import snes_to_pc, int24_as_bytes, int16_as_bytes, load_cached_yaml, pc_to_snes - -from source.dungeon.EnemyList import EnemyTable, init_vanilla_sprites, vanilla_sprites, init_enemy_stats, EnemySprite -from source.dungeon.EnemyList import sprite_translation +from source.dungeon.EnemyList import ( + EnemySprite, + EnemyTable, + init_enemy_stats, + init_vanilla_sprites, + sprite_translation, + vanilla_sprites, +) from source.dungeon.RoomHeader import init_room_headers from source.dungeon.RoomList import Room0127 from source.enemizer.OwEnemyList import init_vanilla_sprites_ow, vanilla_sprites_ow -from source.enemizer.SpriteSheets import init_sprite_sheets, init_sprite_requirements, SheetChoice +from source.enemizer.SpriteSheets import ( + SheetChoice, + init_sprite_requirements, + init_sprite_sheets, +) +from Utils import ( + int16_as_bytes, + int24_as_bytes, + load_cached_yaml, + pc_to_snes, + snes_to_pc, +) def convert_area_id_to_offset(area_id): diff --git a/source/tools/BPS.py b/source/tools/BPS.py index 78c374cb..53c151ee 100644 --- a/source/tools/BPS.py +++ b/source/tools/BPS.py @@ -1,11 +1,10 @@ # Code derived from https://github.com/marcrobledo/RomPatcher.js (MIT License) import sys - +from binascii import crc32 +from collections import defaultdict from time import perf_counter -from collections import defaultdict -from binascii import crc32 try: from fast_enum import FastEnum except ImportError: diff --git a/source/tools/MysteryUtils.py b/source/tools/MysteryUtils.py index ac130d8b..441d4fdc 100644 --- a/source/tools/MysteryUtils.py +++ b/source/tools/MysteryUtils.py @@ -1,12 +1,13 @@ import argparse -import RaceRandom as random import os +import urllib.parse +import urllib.request from pathlib import Path -import urllib.request -import urllib.parse import yaml +import RaceRandom as random + def get_weights(path): if os.path.exists(Path(path)): diff --git a/test-options.py b/test-options.py index 324d38c6..1ceb34bd 100644 --- a/test-options.py +++ b/test-options.py @@ -1,9 +1,12 @@ from __future__ import annotations -from aenum import Enum, IntEnum, extend_enum -from source.classes.BabelFish import BabelFish + import json import os +from aenum import Enum, IntEnum, extend_enum + +from source.classes.BabelFish import BabelFish + fish = BabelFish(lang="en") def tokenize(token): diff --git a/test/MysteryTestSuite.py b/test/MysteryTestSuite.py index e14baa61..429c95c9 100644 --- a/test/MysteryTestSuite.py +++ b/test/MysteryTestSuite.py @@ -1,9 +1,9 @@ +import argparse +import concurrent.futures +import multiprocessing import os import subprocess import sys -import multiprocessing -import concurrent.futures -import argparse from collections import OrderedDict cpu_threads = multiprocessing.cpu_count() diff --git a/test/NewTestSuite.py b/test/NewTestSuite.py index c5beba4f..6c974855 100644 --- a/test/NewTestSuite.py +++ b/test/NewTestSuite.py @@ -1,10 +1,10 @@ +import argparse +import concurrent.futures import fnmatch +import multiprocessing import os import subprocess import sys -import multiprocessing -import concurrent.futures -import argparse from collections import OrderedDict cpu_threads = multiprocessing.cpu_count() diff --git a/test/dungeons/TestDungeon.py b/test/dungeons/TestDungeon.py index 1db87e39..e4da82bc 100644 --- a/test/dungeons/TestDungeon.py +++ b/test/dungeons/TestDungeon.py @@ -1,12 +1,12 @@ import unittest -from BaseClasses import World, CollectionState +from BaseClasses import CollectionState, World from Dungeons import create_dungeons, get_dungeon_item_pool from ItemList import difficulties, generate_itempool from Items import ItemFactory from Regions import create_regions from Rules import set_rules -from source.overworld.EntranceShuffle2 import mandatory_connections, connect_simple +from source.overworld.EntranceShuffle2 import connect_simple, mandatory_connections class TestDungeon(unittest.TestCase): diff --git a/test/inverted/TestInverted.py b/test/inverted/TestInverted.py index 70e3fd6b..24f518b8 100644 --- a/test/inverted/TestInverted.py +++ b/test/inverted/TestInverted.py @@ -1,16 +1,21 @@ +from test.TestBase import TestBase + from BaseClasses import World -from DoorShuffle import link_doors from Doors import create_doors +from DoorShuffle import link_doors from Dungeons import create_dungeons, get_dungeon_item_pool -from OverworldShuffle import link_overworld -from ItemList import generate_itempool, difficulties +from ItemList import difficulties, generate_itempool from Items import ItemFactory -from Regions import create_regions, mark_light_dark_world_regions, create_dungeon_regions, create_shops +from OverworldShuffle import link_overworld +from Regions import ( + create_dungeon_regions, + create_regions, + create_shops, + mark_light_dark_world_regions, +) from RoomData import create_rooms from Rules import set_rules - from source.overworld.EntranceShuffle2 import link_entrances_new -from test.TestBase import TestBase class TestInverted(TestBase): diff --git a/test/inverted/TestInvertedBombRules.py b/test/inverted/TestInvertedBombRules.py index c3a94ff8..d8675569 100644 --- a/test/inverted/TestInvertedBombRules.py +++ b/test/inverted/TestInvertedBombRules.py @@ -1,14 +1,29 @@ import unittest +from test.inverted.TestInverted import TestInverted from BaseClasses import World from Dungeons import create_dungeons -# todo: this test needs to be rewritten unfortunately -from source.overworld.EntranceShuffle2 import connect_entrance, Inverted_LW_Entrances, Inverted_LW_Dungeon_Entrances, Inverted_LW_Single_Cave_Doors, Inverted_Old_Man_Entrances, Inverted_DW_Entrances, Inverted_DW_Dungeon_Entrances, Inverted_DW_Single_Cave_Doors, \ - Inverted_LW_Entrances_Must_Exit, Inverted_LW_Dungeon_Entrances_Must_Exit, Inverted_Bomb_Shop_Multi_Cave_Doors, Inverted_Bomb_Shop_Single_Cave_Doors, Inverted_Blacksmith_Single_Cave_Doors, Inverted_Blacksmith_Multi_Cave_Doors -from Regions import create_regions from ItemList import difficulties +from Regions import create_regions from Rules import set_inverted_big_bomb_rules -from test.inverted.TestInverted import TestInverted + +# todo: this test needs to be rewritten unfortunately +from source.overworld.EntranceShuffle2 import ( + Inverted_Blacksmith_Multi_Cave_Doors, + Inverted_Blacksmith_Single_Cave_Doors, + Inverted_Bomb_Shop_Multi_Cave_Doors, + Inverted_Bomb_Shop_Single_Cave_Doors, + Inverted_DW_Dungeon_Entrances, + Inverted_DW_Entrances, + Inverted_DW_Single_Cave_Doors, + Inverted_LW_Dungeon_Entrances, + Inverted_LW_Dungeon_Entrances_Must_Exit, + Inverted_LW_Entrances, + Inverted_LW_Entrances_Must_Exit, + Inverted_LW_Single_Cave_Doors, + Inverted_Old_Man_Entrances, + connect_entrance, +) class TestInvertedBombRules(TestInverted): diff --git a/test/inverted_owg/TestDungeons.py b/test/inverted_owg/TestDungeons.py index 3864bff6..4001039d 100644 --- a/test/inverted_owg/TestDungeons.py +++ b/test/inverted_owg/TestDungeons.py @@ -1,5 +1,6 @@ from test.inverted_owg.TestInvertedOWG import TestInvertedOWG + class TestDungeons(TestInvertedOWG): def testFirstDungeonChests(self): diff --git a/test/inverted_owg/TestInvertedOWG.py b/test/inverted_owg/TestInvertedOWG.py index d0b0ba6b..6f13e050 100644 --- a/test/inverted_owg/TestInvertedOWG.py +++ b/test/inverted_owg/TestInvertedOWG.py @@ -1,16 +1,22 @@ +from test.TestBase import TestBase + from BaseClasses import World -from DoorShuffle import link_doors from Doors import create_doors +from DoorShuffle import link_doors from Dungeons import create_dungeons, get_dungeon_item_pool -from OverworldShuffle import link_overworld -from source.overworld.EntranceShuffle2 import link_entrances_new -from ItemList import generate_itempool, difficulties +from ItemList import difficulties, generate_itempool from Items import ItemFactory from OverworldGlitchRules import create_owg_connections -from Regions import create_regions, mark_light_dark_world_regions, create_dungeon_regions, create_shops +from OverworldShuffle import link_overworld +from Regions import ( + create_dungeon_regions, + create_regions, + create_shops, + mark_light_dark_world_regions, +) from RoomData import create_rooms from Rules import set_rules -from test.TestBase import TestBase +from source.overworld.EntranceShuffle2 import link_entrances_new class TestInvertedOWG(TestBase): diff --git a/test/owg/TestVanillaOWG.py b/test/owg/TestVanillaOWG.py index 989cf64e..5669524e 100644 --- a/test/owg/TestVanillaOWG.py +++ b/test/owg/TestVanillaOWG.py @@ -1,16 +1,22 @@ +from test.TestBase import TestBase + from BaseClasses import World -from DoorShuffle import link_doors from Doors import create_doors +from DoorShuffle import link_doors from Dungeons import create_dungeons, get_dungeon_item_pool -from OverworldShuffle import link_overworld -from source.overworld.EntranceShuffle2 import link_entrances_new from ItemList import difficulties, generate_itempool from Items import ItemFactory from OverworldGlitchRules import create_owg_connections -from Regions import create_regions, create_dungeon_regions, create_shops, mark_light_dark_world_regions +from OverworldShuffle import link_overworld +from Regions import ( + create_dungeon_regions, + create_regions, + create_shops, + mark_light_dark_world_regions, +) from RoomData import create_rooms from Rules import set_rules -from test.TestBase import TestBase +from source.overworld.EntranceShuffle2 import link_entrances_new class TestVanillaOWG(TestBase): diff --git a/test/stats/EntranceShuffleStats.py b/test/stats/EntranceShuffleStats.py index 53b2e7e5..a47f5888 100644 --- a/test/stats/EntranceShuffleStats.py +++ b/test/stats/EntranceShuffleStats.py @@ -1,16 +1,16 @@ import os import sys -sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..')) -import RaceRandom as random -import time +sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..')) +import time from collections import Counter, defaultdict -from source.overworld.EntranceShuffle2 import link_entrances_new +import RaceRandom as random + # from source.oEntranceShuffle import link_entrances_new from BaseClasses import World -from Regions import create_regions, create_dungeon_regions - +from Regions import create_dungeon_regions, create_regions +from source.overworld.EntranceShuffle2 import link_entrances_new # probably deprecated diff --git a/test/vanilla/TestVanilla.py b/test/vanilla/TestVanilla.py index 91ec449b..2da6100d 100644 --- a/test/vanilla/TestVanilla.py +++ b/test/vanilla/TestVanilla.py @@ -1,15 +1,21 @@ +from test.TestBase import TestBase + from BaseClasses import World -from DoorShuffle import link_doors from Doors import create_doors +from DoorShuffle import link_doors from Dungeons import create_dungeons, get_dungeon_item_pool -from OverworldShuffle import link_overworld -from source.overworld.EntranceShuffle2 import link_entrances_new from ItemList import difficulties, generate_itempool from Items import ItemFactory -from Regions import create_regions, create_dungeon_regions, create_shops, mark_light_dark_world_regions +from OverworldShuffle import link_overworld +from Regions import ( + create_dungeon_regions, + create_regions, + create_shops, + mark_light_dark_world_regions, +) from RoomData import create_rooms from Rules import set_rules -from test.TestBase import TestBase +from source.overworld.EntranceShuffle2 import link_entrances_new class TestVanilla(TestBase):