Skip to content

Commit

Permalink
isort.
Browse files Browse the repository at this point in the history
  • Loading branch information
Killklli committed Apr 12, 2022
1 parent 27fd21b commit 3bb8f2e
Show file tree
Hide file tree
Showing 38 changed files with 266 additions and 96 deletions.
25 changes: 6 additions & 19 deletions base-hack/Build/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,31 +9,18 @@

# Patcher functions for the extracted files
import patch_text
from adjust_exits import adjustExits
from convertPortalImage import convertPortalImage
from convertSetup import convertSetup

# Infrastructure for recomputing DK64 global pointer tables
from map_names import maps
from recompute_overlays import (
isROMAddressOverlay,
readOverlayOriginalData,
replaceOverlayData,
writeModifiedOverlaysToROM,
)
from recompute_pointer_table import (
dumpPointerTableDetails,
getFileInfo,
make_safe_filename,
parsePointerTables,
pointer_tables,
replaceROMFile,
writeModifiedPointerTablesToROM,
)
from populateSongData import writeVanillaSongData
from recompute_overlays import isROMAddressOverlay, readOverlayOriginalData, replaceOverlayData, writeModifiedOverlaysToROM
from recompute_pointer_table import dumpPointerTableDetails, getFileInfo, make_safe_filename, parsePointerTables, pointer_tables, replaceROMFile, writeModifiedPointerTablesToROM
from replace_simslam_text import replaceSimSlam
from staticcode import patchStaticCode
from vanilla_move_data import writeVanillaMoveData
from adjust_exits import adjustExits
from replace_simslam_text import replaceSimSlam
from populateSongData import writeVanillaSongData
from convertPortalImage import convertPortalImage

ROMName = "rom/dk64.z64"
newROMName = "rom/dk64-randomizer-base.z64"
Expand Down
3 changes: 2 additions & 1 deletion base-hack/Build/compile.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
import os
import shutil
import subprocess
import requests
import zipfile

import requests

# Compile C Code
avoids = []

Expand Down
1 change: 1 addition & 0 deletions base-hack/Build/convertPortalImage.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""Convert 63x63 Portal image into 4 32x32 segments."""
import os

from PIL import Image


Expand Down
1 change: 1 addition & 0 deletions base-hack/Build/convertSetup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import os
import shutil
import struct

from getMoveSignLocations import getMoveSignData


Expand Down
3 changes: 2 additions & 1 deletion base-hack/rom/pull_images_from_rom.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""Pull hash images from ROM."""
import zlib
import os
import zlib

from PIL import Image

images = [
Expand Down
1 change: 0 additions & 1 deletion base-hack/rom_tester/rom_tester.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import os
from typing import BinaryIO


levels = ["Japes", "Aztec", "Factory", "Galleon", "Fungi", "Caves", "Castle", "Helm"]
keys = [0x1A, 0x4A, 0x8A, 0xA8, 0xEC, 0x124, 0x13D]
special_moves = [
Expand Down
5 changes: 3 additions & 2 deletions generate_rando_ui.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
"""Generate UI elements via jinja2 to display on page load."""
import json

import js
import micropip
from jinja2 import Environment, FunctionLoader
from js import document
from pyodide import to_js

import js
from js import document


async def initialize():
"""Shifted code into an async function so we can properly lint await calls."""
Expand Down
3 changes: 2 additions & 1 deletion generate_ui.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
"""Generate UI elements via jinja2 to display on page load."""
import js
import micropip
from jinja2 import Environment, FunctionLoader
from pyodide import to_js

import js


async def initialize():
"""Shifted code into an async function so we can properly lint await calls."""
Expand Down
17 changes: 9 additions & 8 deletions randomizer/ApplyRandomizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,25 @@
import pickle

import js

from randomizer.BananaPortRando import randomize_bananaport
from randomizer.BarrelRando import randomize_barrels
from randomizer.BossRando import randomize_bosses
from randomizer.CompileHints import compileHints
from randomizer.CosmeticColors import apply_cosmetic_colors
from randomizer.DKTV import randomize_dktv
from randomizer.EnemyRando import randomize_enemies
from randomizer.EntranceRando import randomize_entrances
from randomizer.Enums.Transitions import Transitions
from randomizer.Hash import get_hash_images
from randomizer.KRoolRando import randomize_krool
from randomizer.MoveLocationRando import randomize_moves
from randomizer.MusicRando import randomize_music
from randomizer.Patcher import ROM
from randomizer.PriceRando import randomize_prices
from randomizer.BossRando import randomize_bosses
from randomizer.BarrelRando import randomize_barrels
from randomizer.BananaPortRando import randomize_bananaport
from randomizer.EnemyRando import randomize_enemies
from randomizer.Hash import get_hash_images
from randomizer.UpdateHints import PushHints
from randomizer.CompileHints import compileHints

# from randomizer.Spoiler import Spoiler
from randomizer.Settings import Settings
from randomizer.UpdateHints import PushHints
from ui.progress_bar import ProgressBar


Expand Down Expand Up @@ -236,6 +236,7 @@ def patching_response(responded_data):
randomize_barrels(spoiler)
randomize_bananaport(spoiler)
randomize_enemies(spoiler)
apply_cosmetic_colors(spoiler)
if spoiler.settings.wrinkly_hints:
compileHints(spoiler)
PushHints()
Expand Down
2 changes: 1 addition & 1 deletion randomizer/BackgroundRandomizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@ def generate_playthrough(form_string: str):
return codecs.encode(pickle.dumps(spoiler), "base64").decode()
except Exception as e:
print("error: " + traceback.format_exc())
return json.dumps({"error": str(traceback.format_exc())})
return json.dumps({"error": str(traceback.format_exc())})
4 changes: 2 additions & 2 deletions randomizer/BananaPortRando.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
"""Rando write bananaport locations."""
from imp import source_from_cache
import js

import js
from randomizer.Lists.Warps import BananaportVanilla
from randomizer.Patcher import ROM
from randomizer.Spoiler import Spoiler
from randomizer.Lists.Warps import BananaportVanilla


def randomize_bananaport(spoiler: Spoiler):
Expand Down
3 changes: 1 addition & 2 deletions randomizer/BarrelRando.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
"""Apply Boss Locations."""
import js

from randomizer.Lists.Minigame import BarrelMetaData, MinigameRequirements
from randomizer.Patcher import ROM
from randomizer.Spoiler import Spoiler
from randomizer.Lists.Minigame import MinigameRequirements, BarrelMetaData


def randomize_barrels(spoiler: Spoiler):
Expand Down
3 changes: 2 additions & 1 deletion randomizer/BossShuffle.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""Randomize Boss Locations."""
from array import array
import random
from array import array

from randomizer.Enums.Kongs import Kongs
from randomizer.MapsAndExits import Maps

Expand Down
2 changes: 1 addition & 1 deletion randomizer/CompileHints.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
"""Compile a list of hints based on the settings."""
import random

from randomizer.UpdateHints import updateRandomHint
from randomizer.Spoiler import Spoiler
from randomizer.UpdateHints import updateRandomHint


def compileHints(spoiler: Spoiler):
Expand Down
68 changes: 68 additions & 0 deletions randomizer/CosmeticColors.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
"""Apply cosmetic skins to kongs."""
from randomizer.Patcher import ROM
from randomizer.Spoiler import Spoiler


def apply_cosmetic_colors(spoiler: Spoiler):
"""Apply cosmetic skins to kongs."""
enable = False
sav = 0x1FED020
if spoiler.settings.dk_colors != "vanilla":
enable = True
color = 0
if spoiler.settings.dk_colors == "blue":
color = 1
elif spoiler.settings.dk_colors == "green":
color = 2
elif spoiler.settings.dk_colors == "purple":
color = 3
ROM().seek(sav + 0x127)
ROM().write(color)
if spoiler.settings.diddy_colors != "vanilla":
enable = True
color = 0
if spoiler.settings.diddy_colors == "dark_blue":
color = 1
elif spoiler.settings.diddy_colors == "yellow":
color = 2
elif spoiler.settings.diddy_colors == "light_blue":
color = 3
ROM().seek(sav + 0x128)
ROM().write(color)
if spoiler.settings.lanky_colors != "vanilla":
enable = True
color = 0
if spoiler.settings.lanky_colors == "green":
color = 1
elif spoiler.settings.lanky_colors == "purple":
color = 2
elif spoiler.settings.lanky_colors == "red":
color = 3
ROM().seek(sav + 0x129)
ROM().write(color)
if spoiler.settings.tiny_colors != "vanilla":
enable = True
color = 0
if spoiler.settings.tiny_colors == "green":
color = 1
elif spoiler.settings.tiny_colors == "purple":
color = 2
elif spoiler.settings.tiny_colors == "red":
color = 3
ROM().seek(sav + 0x12A)
ROM().write(color)
if spoiler.settings.chunky_colors != "vanilla":
enable = True
color = 0
if spoiler.settings.tiny_colors == "red":
color = 1
elif spoiler.settings.tiny_colors == "purple":
color = 2
elif spoiler.settings.tiny_colors == "green":
color = 3
ROM().seek(sav + 0x12B)
ROM().write(color)

if enable:
ROM().seek(sav + 0x126)
ROM().write(1)
1 change: 0 additions & 1 deletion randomizer/DKTV.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import random

import js

from randomizer.Patcher import ROM


Expand Down
7 changes: 4 additions & 3 deletions randomizer/EnemyRando.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
"""Apply Boss Locations."""
import js
import random

import js
from randomizer.EnemyTypes import Enemies, EnemyMetaData
from randomizer.MapsAndExits import Maps
from randomizer.Patcher import ROM
from randomizer.Spoiler import Spoiler
from randomizer.MapsAndExits import Maps
from randomizer.EnemyTypes import Enemies, EnemyMetaData


def randomize_enemies(spoiler: Spoiler):
Expand Down
1 change: 0 additions & 1 deletion randomizer/EntranceRando.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
"""Randomize Entrances passed from Misc options."""
import js

from randomizer.Enums.Transitions import Transitions
from randomizer.MapsAndExits import GetExitId, GetMapId, MapExitTable, Maps
from randomizer.Patcher import ROM
Expand Down
8 changes: 4 additions & 4 deletions randomizer/Fill.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
"""Module used to distribute items randomly."""
import random
import js

import js
import randomizer.ItemPool as ItemPool
import randomizer.Lists.Exceptions as Ex
import randomizer.Logic as Logic
from randomizer.Prices import GetPriceOfMoveItem
import randomizer.ShuffleExits as ShuffleExits
from randomizer.Enums.Items import Items
from randomizer.Enums.Kongs import Kongs
Expand All @@ -17,11 +16,12 @@
from randomizer.Enums.Types import Types
from randomizer.Lists.Item import ItemList
from randomizer.Lists.Location import Location, LocationList
from randomizer.Lists.Minigame import MinigameRequirements, BarrelMetaData
from randomizer.ShuffleKasplats import KasplatShuffle
from randomizer.Lists.Minigame import BarrelMetaData, MinigameRequirements
from randomizer.Logic import LogicVarHolder, LogicVariables
from randomizer.LogicClasses import TransitionFront
from randomizer.Prices import GetPriceOfMoveItem
from randomizer.ShuffleBarrels import BarrelShuffle, ShuffleBarrels
from randomizer.ShuffleKasplats import KasplatShuffle
from randomizer.ShuffleWarps import shuffleWarps


Expand Down
8 changes: 5 additions & 3 deletions randomizer/Hash.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
"""Locate Hash images for displaying on the website."""
import zlib
from randomizer.Patcher import ROM
from PIL import Image
import base64
import io
import zlib

from PIL import Image

from randomizer.Patcher import ROM


def get_hash_images():
Expand Down
1 change: 0 additions & 1 deletion randomizer/KRoolRando.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import js
from randomizer.EntranceRando import intToArr
from randomizer.MapsAndExits import Maps

from randomizer.Patcher import ROM
from randomizer.Spoiler import Spoiler

Expand Down
2 changes: 1 addition & 1 deletion randomizer/Lists/Item.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

from randomizer.Enums.Items import Items
from randomizer.Enums.Kongs import Kongs
from randomizer.Enums.Types import Types
from randomizer.Enums.MoveTypes import MoveTypes
from randomizer.Enums.Types import Types


class Item:
Expand Down
6 changes: 3 additions & 3 deletions randomizer/Lists/Location.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
"""Stores the Location class and a list of each location in the game."""

from randomizer.Enums.Items import Items
from randomizer.Enums.Locations import Locations
from randomizer.Enums.Types import Types
from randomizer.Enums.Levels import Levels
from randomizer.Enums.Kongs import Kongs
from randomizer.Enums.Levels import Levels
from randomizer.Enums.Locations import Locations
from randomizer.Enums.MoveTypes import MoveTypes
from randomizer.Enums.Types import Types
from randomizer.MapsAndExits import Maps


Expand Down
1 change: 0 additions & 1 deletion randomizer/MusicRando.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
from ast import And

import js

import randomizer.Lists.Exceptions as Ex
from randomizer.Enums.SongType import SongType
from randomizer.Lists.Songs import Song, SongGroup, song_data
Expand Down
Loading

0 comments on commit 3bb8f2e

Please sign in to comment.