Pull in fixes from Multiworld
This commit is contained in:
2
Fill.py
2
Fill.py
@@ -392,7 +392,7 @@ def balance_multiworld_progression(world):
|
|||||||
threshold = max(reachable_locations_count.values()) - 20
|
threshold = max(reachable_locations_count.values()) - 20
|
||||||
|
|
||||||
balancing_players = [player for player, reachables in reachable_locations_count.items() if reachables < threshold]
|
balancing_players = [player for player, reachables in reachable_locations_count.items() if reachables < threshold]
|
||||||
if balancing_players:
|
if balancing_players is not None and len(balancing_players) > 0:
|
||||||
balancing_state = state.copy()
|
balancing_state = state.copy()
|
||||||
balancing_unchecked_locations = unchecked_locations.copy()
|
balancing_unchecked_locations = unchecked_locations.copy()
|
||||||
balancing_reachables = reachable_locations_count.copy()
|
balancing_reachables = reachable_locations_count.copy()
|
||||||
|
|||||||
4
Main.py
4
Main.py
@@ -191,6 +191,7 @@ def main(args, seed=None, fish=None):
|
|||||||
for team in range(world.teams):
|
for team in range(world.teams):
|
||||||
for player in range(1, world.players + 1):
|
for player in range(1, world.players + 1):
|
||||||
sprite_random_on_hit = type(args.sprite[player]) is str and args.sprite[player].lower() == 'randomonhit'
|
sprite_random_on_hit = type(args.sprite[player]) is str and args.sprite[player].lower() == 'randomonhit'
|
||||||
|
enemized = False
|
||||||
use_enemizer = (world.boss_shuffle[player] != 'none' or world.enemy_shuffle[player] != 'none'
|
use_enemizer = (world.boss_shuffle[player] != 'none' or world.enemy_shuffle[player] != 'none'
|
||||||
or world.enemy_health[player] != 'default' or world.enemy_damage[player] != 'default'
|
or world.enemy_health[player] != 'default' or world.enemy_damage[player] != 'default'
|
||||||
or args.shufflepots[player] or sprite_random_on_hit)
|
or args.shufflepots[player] or sprite_random_on_hit)
|
||||||
@@ -204,6 +205,7 @@ def main(args, seed=None, fish=None):
|
|||||||
raise RuntimeError("Could not find valid base rom for enemizing at expected path %s." % args.rom)
|
raise RuntimeError("Could not find valid base rom for enemizing at expected path %s." % args.rom)
|
||||||
if os.path.exists(args.enemizercli):
|
if os.path.exists(args.enemizercli):
|
||||||
patch_enemizer(world, player, rom, args.rom, args.enemizercli, args.shufflepots[player], sprite_random_on_hit)
|
patch_enemizer(world, player, rom, args.rom, args.enemizercli, args.shufflepots[player], sprite_random_on_hit)
|
||||||
|
enemized = True
|
||||||
if not args.jsonout:
|
if not args.jsonout:
|
||||||
rom = LocalRom.fromJsonRom(rom, args.rom, 0x400000)
|
rom = LocalRom.fromJsonRom(rom, args.rom, 0x400000)
|
||||||
else:
|
else:
|
||||||
@@ -212,6 +214,8 @@ def main(args, seed=None, fish=None):
|
|||||||
logging.warning(enemizerMsg)
|
logging.warning(enemizerMsg)
|
||||||
raise EnemizerError(enemizerMsg)
|
raise EnemizerError(enemizerMsg)
|
||||||
|
|
||||||
|
patch_rom(world, rom, player, team, enemized)
|
||||||
|
|
||||||
if args.race:
|
if args.race:
|
||||||
patch_race_rom(rom)
|
patch_race_rom(rom)
|
||||||
|
|
||||||
|
|||||||
2
Rom.py
2
Rom.py
@@ -79,7 +79,7 @@ class LocalRom(object):
|
|||||||
self.hash = hash
|
self.hash = hash
|
||||||
self.orig_buffer = None
|
self.orig_buffer = None
|
||||||
if not os.path.isfile(file):
|
if not os.path.isfile(file):
|
||||||
raise RuntimeError("Could not find valid local base rom for patching at expected path %s." % args.rom)
|
raise RuntimeError("Could not find valid local base rom for patching at expected path %s." % file)
|
||||||
with open(file, 'rb') as stream:
|
with open(file, 'rb') as stream:
|
||||||
self.buffer = read_rom(stream)
|
self.buffer = read_rom(stream)
|
||||||
if patch:
|
if patch:
|
||||||
|
|||||||
@@ -36,7 +36,7 @@
|
|||||||
"cannot.reach.required": "Not all required items reachable. Something went terribly wrong here.",
|
"cannot.reach.required": "Not all required items reachable. Something went terribly wrong here.",
|
||||||
"patching.rom": "Patching ROM",
|
"patching.rom": "Patching ROM",
|
||||||
"patching.spoiler": "Creating Spoiler",
|
"patching.spoiler": "Creating Spoiler",
|
||||||
"calc.playthrough": "Calculating playthrough",
|
"calc.playthrough": "Calculating Playthrough",
|
||||||
"made.rom": "Patched ROM: %s",
|
"made.rom": "Patched ROM: %s",
|
||||||
"made.playthrough": "Printed Playthrough: %s",
|
"made.playthrough": "Printed Playthrough: %s",
|
||||||
"made.spoiler": "Printed Spoiler: %s",
|
"made.spoiler": "Printed Spoiler: %s",
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ from argparse import Namespace
|
|||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
import random
|
import random
|
||||||
|
import re
|
||||||
from CLI import parse_cli
|
from CLI import parse_cli
|
||||||
from Fill import FillError
|
from Fill import FillError
|
||||||
from Main import main, EnemizerError
|
from Main import main, EnemizerError
|
||||||
@@ -74,13 +75,30 @@ def bottom_frame(self, parent, args=None):
|
|||||||
setattr(guiargs, k, v)
|
setattr(guiargs, k, v)
|
||||||
elif type(v) is dict: # use same settings for every player
|
elif type(v) is dict: # use same settings for every player
|
||||||
setattr(guiargs, k, {player: getattr(guiargs, k) for player in range(1, guiargs.multi + 1)})
|
setattr(guiargs, k, {player: getattr(guiargs, k) for player in range(1, guiargs.multi + 1)})
|
||||||
|
argsDump = vars(guiargs)
|
||||||
|
hasEnemizer = "enemizercli" in argsDump and os.path.isfile(argsDump["enemizercli"])
|
||||||
|
needEnemizer = False
|
||||||
|
if not hasEnemizer:
|
||||||
|
falsey = [ "none", "default", "vanilla", False, 0 ]
|
||||||
|
for enemizerOption in [ "shufflepots", "shuffleenemies", "enemy_damage", "shufflebosses", "enemy_health" ]:
|
||||||
|
if enemizerOption in argsDump:
|
||||||
|
if isinstance(argsDump[enemizerOption], dict):
|
||||||
|
for playerID,playerSetting in argsDump[enemizerOption].items():
|
||||||
|
if not playerSetting in falsey:
|
||||||
|
needEnemizer = True
|
||||||
|
elif not argsDump[enemizerOption] in falsey:
|
||||||
|
needEnemizer = True
|
||||||
|
seeds = []
|
||||||
|
if not needEnemizer or (needEnemizer and hasEnemizer):
|
||||||
try:
|
try:
|
||||||
if guiargs.count is not None:
|
if guiargs.count is not None:
|
||||||
seed = guiargs.seed
|
seed = guiargs.seed
|
||||||
for _ in range(guiargs.count):
|
for _ in range(guiargs.count):
|
||||||
|
seeds.append(seed)
|
||||||
main(seed=seed, args=guiargs, fish=parent.fish)
|
main(seed=seed, args=guiargs, fish=parent.fish)
|
||||||
seed = random.randint(0, 999999999)
|
seed = random.randint(0, 999999999)
|
||||||
else:
|
else:
|
||||||
|
seeds.append(guiargs.seed)
|
||||||
main(seed=guiargs.seed, args=guiargs, fish=parent.fish)
|
main(seed=guiargs.seed, args=guiargs, fish=parent.fish)
|
||||||
except (FillError, EnemizerError, Exception, RuntimeError) as e:
|
except (FillError, EnemizerError, Exception, RuntimeError) as e:
|
||||||
logging.exception(e)
|
logging.exception(e)
|
||||||
@@ -89,9 +107,19 @@ def bottom_frame(self, parent, args=None):
|
|||||||
YES = parent.fish.translate("cli","cli","yes")
|
YES = parent.fish.translate("cli","cli","yes")
|
||||||
NO = parent.fish.translate("cli","cli","no")
|
NO = parent.fish.translate("cli","cli","no")
|
||||||
successMsg = ""
|
successMsg = ""
|
||||||
successMsg += (parent.fish.translate("cli","cli","made.rom").strip() % (YES if (guiargs.create_rom) else NO)) + "\n"
|
made = {}
|
||||||
successMsg += (parent.fish.translate("cli","cli","made.playthrough").strip() % (YES if (guiargs.calc_playthrough) else NO)) + "\n"
|
for k in [ "rom", "playthrough", "spoiler" ]:
|
||||||
successMsg += (parent.fish.translate("cli","cli","made.spoiler").strip() % (YES if (not guiargs.jsonout and guiargs.create_spoiler) else NO))
|
made[k] = parent.fish.translate("cli","cli","made." + k)
|
||||||
|
for k in made:
|
||||||
|
v = made[k]
|
||||||
|
pattern = "([\w]+)(:)([\s]+)(.*)"
|
||||||
|
m = re.search(pattern,made[k])
|
||||||
|
made[k] = m.group(1) + m.group(2) + ' ' + m.group(4)
|
||||||
|
successMsg += (made["rom"] % (YES if (guiargs.create_rom) else NO)) + "\n"
|
||||||
|
successMsg += (made["playthrough"] % (YES if (guiargs.calc_playthrough) else NO)) + "\n"
|
||||||
|
successMsg += (made["spoiler"] % (YES if (not guiargs.jsonout and guiargs.create_spoiler) else NO)) + "\n"
|
||||||
|
# FIXME: English
|
||||||
|
successMsg += ("Seed%s: %s" % ('s' if len(seeds) > 1 else "", ','.join(seeds)))
|
||||||
|
|
||||||
messagebox.showinfo(title="Success", message=successMsg)
|
messagebox.showinfo(title="Success", message=successMsg)
|
||||||
|
|
||||||
|
|||||||
@@ -124,7 +124,7 @@ def loadcliargs(gui, args, settings=None):
|
|||||||
widget = "seed"
|
widget = "seed"
|
||||||
setting = "seed"
|
setting = "seed"
|
||||||
if args[setting]:
|
if args[setting]:
|
||||||
gui.pages[mainpage].widgets[widget].storageVar.set(args[setting])
|
gui.pages[mainpage].pages[subpage].widgets[widget].storageVar.set(args[setting])
|
||||||
# set textbox/frame label
|
# set textbox/frame label
|
||||||
label = fish.translate("gui","gui",mainpage + '.' + subpage + '.' + widget)
|
label = fish.translate("gui","gui",mainpage + '.' + subpage + '.' + widget)
|
||||||
gui.pages[mainpage].pages[subpage].widgets[widget].pieces["frame"].label.configure(text=label)
|
gui.pages[mainpage].pages[subpage].widgets[widget].pieces["frame"].label.configure(text=label)
|
||||||
|
|||||||
Reference in New Issue
Block a user