diff --git a/base-hack/Build/build.py b/base-hack/Build/build.py index 7254397a6..64ec3fca3 100644 --- a/base-hack/Build/build.py +++ b/base-hack/Build/build.py @@ -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" diff --git a/base-hack/Build/compile.py b/base-hack/Build/compile.py index 46dfff236..cb07328bc 100644 --- a/base-hack/Build/compile.py +++ b/base-hack/Build/compile.py @@ -2,9 +2,10 @@ import os import shutil import subprocess -import requests import zipfile +import requests + # Compile C Code avoids = [] diff --git a/base-hack/Build/convertPortalImage.py b/base-hack/Build/convertPortalImage.py index 4334d571a..1e457445b 100644 --- a/base-hack/Build/convertPortalImage.py +++ b/base-hack/Build/convertPortalImage.py @@ -1,5 +1,6 @@ """Convert 63x63 Portal image into 4 32x32 segments.""" import os + from PIL import Image diff --git a/base-hack/Build/convertSetup.py b/base-hack/Build/convertSetup.py index 65ace3b65..e13973c86 100644 --- a/base-hack/Build/convertSetup.py +++ b/base-hack/Build/convertSetup.py @@ -2,6 +2,7 @@ import os import shutil import struct + from getMoveSignLocations import getMoveSignData diff --git a/base-hack/rom/pull_images_from_rom.py b/base-hack/rom/pull_images_from_rom.py index 9b5edb9a1..57ca1843a 100644 --- a/base-hack/rom/pull_images_from_rom.py +++ b/base-hack/rom/pull_images_from_rom.py @@ -1,6 +1,7 @@ """Pull hash images from ROM.""" -import zlib import os +import zlib + from PIL import Image images = [ diff --git a/base-hack/rom_tester/rom_tester.py b/base-hack/rom_tester/rom_tester.py index 499c4dc41..62f89ca04 100644 --- a/base-hack/rom_tester/rom_tester.py +++ b/base-hack/rom_tester/rom_tester.py @@ -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 = [ diff --git a/generate_rando_ui.py b/generate_rando_ui.py index fb9c001c9..e85ce4c36 100644 --- a/generate_rando_ui.py +++ b/generate_rando_ui.py @@ -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.""" diff --git a/generate_ui.py b/generate_ui.py index 56161a069..d55959de4 100644 --- a/generate_ui.py +++ b/generate_ui.py @@ -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.""" diff --git a/randomizer/ApplyRandomizer.py b/randomizer/ApplyRandomizer.py index ddb8a7b46..22f94bec3 100644 --- a/randomizer/ApplyRandomizer.py +++ b/randomizer/ApplyRandomizer.py @@ -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 @@ -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() diff --git a/randomizer/BackgroundRandomizer.py b/randomizer/BackgroundRandomizer.py index df536e67f..51bc4645f 100644 --- a/randomizer/BackgroundRandomizer.py +++ b/randomizer/BackgroundRandomizer.py @@ -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())}) \ No newline at end of file + return json.dumps({"error": str(traceback.format_exc())}) diff --git a/randomizer/BananaPortRando.py b/randomizer/BananaPortRando.py index 622b8b82b..b77708b01 100644 --- a/randomizer/BananaPortRando.py +++ b/randomizer/BananaPortRando.py @@ -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): diff --git a/randomizer/BarrelRando.py b/randomizer/BarrelRando.py index f6718591d..974673043 100644 --- a/randomizer/BarrelRando.py +++ b/randomizer/BarrelRando.py @@ -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): diff --git a/randomizer/BossShuffle.py b/randomizer/BossShuffle.py index 4a9dd9263..a9c1fb58b 100644 --- a/randomizer/BossShuffle.py +++ b/randomizer/BossShuffle.py @@ -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 diff --git a/randomizer/CompileHints.py b/randomizer/CompileHints.py index e95d5eb72..c6b34798d 100644 --- a/randomizer/CompileHints.py +++ b/randomizer/CompileHints.py @@ -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): diff --git a/randomizer/CosmeticColors.py b/randomizer/CosmeticColors.py new file mode 100644 index 000000000..78cc5cf21 --- /dev/null +++ b/randomizer/CosmeticColors.py @@ -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) diff --git a/randomizer/DKTV.py b/randomizer/DKTV.py index cac9e264f..f0837d4a0 100644 --- a/randomizer/DKTV.py +++ b/randomizer/DKTV.py @@ -2,7 +2,6 @@ import random import js - from randomizer.Patcher import ROM diff --git a/randomizer/EnemyRando.py b/randomizer/EnemyRando.py index 4f7681d56..ca8ba923a 100644 --- a/randomizer/EnemyRando.py +++ b/randomizer/EnemyRando.py @@ -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): diff --git a/randomizer/EntranceRando.py b/randomizer/EntranceRando.py index e520c10cc..f8ce7a2de 100644 --- a/randomizer/EntranceRando.py +++ b/randomizer/EntranceRando.py @@ -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 diff --git a/randomizer/Fill.py b/randomizer/Fill.py index 7b24268b9..8b03ae48f 100644 --- a/randomizer/Fill.py +++ b/randomizer/Fill.py @@ -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 @@ -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 diff --git a/randomizer/Hash.py b/randomizer/Hash.py index 63d355080..2322e18aa 100644 --- a/randomizer/Hash.py +++ b/randomizer/Hash.py @@ -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(): diff --git a/randomizer/KRoolRando.py b/randomizer/KRoolRando.py index c52c3ba4e..fb12f1157 100644 --- a/randomizer/KRoolRando.py +++ b/randomizer/KRoolRando.py @@ -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 diff --git a/randomizer/Lists/Item.py b/randomizer/Lists/Item.py index a72448f38..6179ff1ab 100644 --- a/randomizer/Lists/Item.py +++ b/randomizer/Lists/Item.py @@ -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: diff --git a/randomizer/Lists/Location.py b/randomizer/Lists/Location.py index 6aa2aa959..b76221b9b 100644 --- a/randomizer/Lists/Location.py +++ b/randomizer/Lists/Location.py @@ -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 diff --git a/randomizer/MusicRando.py b/randomizer/MusicRando.py index 693c94902..a4f7d4ce8 100644 --- a/randomizer/MusicRando.py +++ b/randomizer/MusicRando.py @@ -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 diff --git a/randomizer/Prices.py b/randomizer/Prices.py index ca605ff6c..628c7f1db 100644 --- a/randomizer/Prices.py +++ b/randomizer/Prices.py @@ -2,17 +2,10 @@ import random +from randomizer.Enums.Items import Items from randomizer.Enums.Kongs import Kongs from randomizer.Enums.Locations import Locations -from randomizer.Enums.Items import Items -from randomizer.ItemPool import ( - ChunkyMoveLocations, - DiddyMoveLocations, - DonkeyMoveLocations, - LankyMoveLocations, - SharedMoveLocations, - TinyMoveLocations, -) +from randomizer.ItemPool import ChunkyMoveLocations, DiddyMoveLocations, DonkeyMoveLocations, LankyMoveLocations, SharedMoveLocations, TinyMoveLocations from randomizer.Lists.Location import LocationList VanillaPrices = { diff --git a/randomizer/Settings.py b/randomizer/Settings.py index ba97f2b28..36545315d 100644 --- a/randomizer/Settings.py +++ b/randomizer/Settings.py @@ -4,9 +4,10 @@ import json import random import sys -from randomizer.BossShuffle import ShuffleBossKongs, ShuffleBosses, ShuffleKutoutKongs -from randomizer.Enums.Kongs import Kongs + +from randomizer.BossShuffle import ShuffleBosses, ShuffleBossKongs, ShuffleKutoutKongs from randomizer.Enums.Events import Events +from randomizer.Enums.Kongs import Kongs from randomizer.Prices import RandomizePrices, VanillaPrices diff --git a/randomizer/ShuffleBarrels.py b/randomizer/ShuffleBarrels.py index 1c3b3e4cf..947acdfcf 100644 --- a/randomizer/ShuffleBarrels.py +++ b/randomizer/ShuffleBarrels.py @@ -1,11 +1,11 @@ """Module used to handle setting and randomizing bonus barrels.""" import random -import js +import js import randomizer.Fill as Fill import randomizer.Lists.Exceptions as Ex from randomizer.Enums.Minigames import Minigames -from randomizer.Lists.Minigame import MinigameRequirements, BarrelMetaData +from randomizer.Lists.Minigame import BarrelMetaData, MinigameRequirements from randomizer.MapsAndExits import Maps diff --git a/randomizer/ShuffleExits.py b/randomizer/ShuffleExits.py index cffa70707..aeb1f2c5d 100644 --- a/randomizer/ShuffleExits.py +++ b/randomizer/ShuffleExits.py @@ -1,8 +1,8 @@ """File that shuffles loading zone exits.""" import random from ast import And -import js +import js import randomizer.Fill as Fill import randomizer.Lists.Exceptions as Ex import randomizer.Logic as Logic @@ -246,7 +246,7 @@ def UpdateLevelProgression(settings: Settings): for levelIndex in range(len(lobbies)): shuffledEntrance = ShufflableExits[LobbyEntrancePool[levelIndex]].shuffledId newDestRegion = ShufflableExits[shuffledEntrance].back.regionId - print(LobbyEntrancePool[levelIndex].name + " goes to " + newDestRegion.name) + # print(LobbyEntrancePool[levelIndex].name + " goes to " + newDestRegion.name) newIndex = lobbies.index(newDestRegion) newEntryGBs[newIndex] = settings.EntryGBs[levelIndex] newBossBananas[newIndex] = settings.BossBananas[levelIndex] diff --git a/randomizer/ShuffleKasplats.py b/randomizer/ShuffleKasplats.py index 56a489663..35a87569c 100644 --- a/randomizer/ShuffleKasplats.py +++ b/randomizer/ShuffleKasplats.py @@ -1,15 +1,14 @@ """Module used to handle setting and randomizing kasplats.""" import random -import js +import js import randomizer.Fill as Fill import randomizer.Lists.Exceptions as Ex import randomizer.Logic as Logic -from randomizer.Lists.Location import LocationList +from randomizer.Enums.Kongs import Kongs from randomizer.Enums.Levels import Levels from randomizer.Enums.Locations import Locations -from randomizer.Enums.Kongs import Kongs - +from randomizer.Lists.Location import LocationList shufflable = { Locations.IslesDonkeyKasplat: Kongs.donkey, diff --git a/randomizer/ShuffleWarps.py b/randomizer/ShuffleWarps.py index 280c19a4f..6cb870f48 100644 --- a/randomizer/ShuffleWarps.py +++ b/randomizer/ShuffleWarps.py @@ -1,10 +1,10 @@ """Randomizes Bananaports.""" import random -import js -from randomizer.MapsAndExits import Maps -from randomizer.Lists.Warps import BananaportVanilla +import js from randomizer.Enums.Warps import Warps +from randomizer.Lists.Warps import BananaportVanilla +from randomizer.MapsAndExits import Maps def getShuffleMaps(): diff --git a/randomizer/Spoiler.py b/randomizer/Spoiler.py index c5353c7d3..e93d0d51a 100644 --- a/randomizer/Spoiler.py +++ b/randomizer/Spoiler.py @@ -6,19 +6,19 @@ from randomizer import Logic from randomizer.Enums.Events import Events from randomizer.Enums.Items import Items +from randomizer.Enums.Kongs import Kongs from randomizer.Enums.Levels import Levels from randomizer.Enums.Locations import Locations -from randomizer.Enums.Kongs import Kongs +from randomizer.Enums.MoveTypes import MoveTypes from randomizer.Enums.Transitions import Transitions from randomizer.Enums.Types import Types -from randomizer.Enums.MoveTypes import MoveTypes from randomizer.Lists.Item import ItemFromKong, ItemList +from randomizer.Lists.KasplatLocations import KasplatLocationData from randomizer.Lists.Location import LocationList -from randomizer.Lists.Minigame import MinigameRequirements, BarrelMetaData +from randomizer.Lists.Minigame import BarrelMetaData, MinigameRequirements from randomizer.MapsAndExits import GetExitId, GetMapId, Maps from randomizer.Settings import Settings from randomizer.ShuffleExits import ShufflableExits -from randomizer.Lists.KasplatLocations import KasplatLocationData class Spoiler: diff --git a/randomizer/UpdateHints.py b/randomizer/UpdateHints.py index 535d0b4fd..7f162b0fb 100644 --- a/randomizer/UpdateHints.py +++ b/randomizer/UpdateHints.py @@ -1,9 +1,8 @@ """Update wrinkly hints compressed file.""" +import random from io import BytesIO import js -import random - from randomizer.Enums.WrinklyKong import WrinklyKong from randomizer.Lists.WrinklyHints import Hint, hints from randomizer.Patcher import ROM diff --git a/static/js/webworker_main.js b/static/js/webworker_main.js index eaf8fa012..7580351ab 100644 --- a/static/js/webworker_main.js +++ b/static/js/webworker_main.js @@ -17,7 +17,7 @@ function generate_worker() { if isinstance(loaded_data, str): js.document.getElementById('progress-text').innerHTML = loaded_data current_percentage = int(str(js.document.getElementById('patchprogress').style.width).replace("%", "")) - new_percentage = current_percentage + 3 + new_percentage = current_percentage + 1 js.document.getElementById('patchprogress').style.width = str(new_percentage) + "%" else: exec(loaded_data.get("returning_func")) diff --git a/templates/cosmetics.html.jinja2 b/templates/cosmetics.html.jinja2 index 153e69022..a73b33220 100644 --- a/templates/cosmetics.html.jinja2 +++ b/templates/cosmetics.html.jinja2 @@ -65,8 +65,126 @@ type="file" id="music_file" name="music_file"/> -
+
+ DK
+
+
+ |
+
+
+ Diddy
+
+
+ |
+
+
+ Lanky
+
+
+ |
+
+
+ Tiny
+
+
+ |
+
+
+ Chunky
+
+
+ |
+