Hack in Spanish
This commit is contained in:
68
Main.py
68
Main.py
@@ -8,6 +8,9 @@ import random
|
||||
import time
|
||||
import zlib
|
||||
|
||||
from source.classes.BabelFish import BabelFish
|
||||
import CLI as cli
|
||||
|
||||
from BaseClasses import World, CollectionState, Item, Region, Location, Shop
|
||||
from Items import ItemFactory
|
||||
from KeyDoorShuffle import validate_key_placement
|
||||
@@ -34,6 +37,11 @@ def main(args, seed=None):
|
||||
|
||||
start = time.perf_counter()
|
||||
|
||||
settings = cli.get_args_priority(None, None, None)
|
||||
if "load" in settings:
|
||||
settings = settings["load"]
|
||||
fish = BabelFish(lang=settings["lang"] if "lang" in settings else "en")
|
||||
|
||||
# initialize the world
|
||||
world = World(args.multi, args.shuffle, args.door_shuffle, args.logic, args.mode, args.swords, args.difficulty, args.item_functionality, args.timer, args.progressive, args.goal, args.algorithm, args.accessibility, args.shuffleganon, args.retro, args.custom, args.customitemarray, args.hints)
|
||||
logger = logging.getLogger('')
|
||||
@@ -62,7 +70,14 @@ def main(args, seed=None):
|
||||
|
||||
world.rom_seeds = {player: random.randint(0, 999999999) for player in range(1, world.players + 1)}
|
||||
|
||||
logger.info('ALttP Door Randomizer Version %s - Seed: %s\n', __version__, world.seed)
|
||||
logger.info(
|
||||
'%s %s %s - %s: %s\n',
|
||||
fish.translate("cli","cli","app.title"),
|
||||
fish.translate("cli","cli","version"),
|
||||
__version__,
|
||||
fish.translate("cli","cli","seed"),
|
||||
world.seed
|
||||
)
|
||||
|
||||
parsed_names = parse_player_names(args.names, world.players, args.teams)
|
||||
world.teams = len(parsed_names)
|
||||
@@ -95,7 +110,7 @@ def main(args, seed=None):
|
||||
create_rooms(world, player)
|
||||
create_dungeons(world, player)
|
||||
|
||||
logger.info('Shuffling the World about.')
|
||||
logger.info(fish.translate("cli","cli","shuffling.world"))
|
||||
|
||||
for player in range(1, world.players + 1):
|
||||
if world.mode[player] != 'inverted':
|
||||
@@ -103,7 +118,7 @@ def main(args, seed=None):
|
||||
else:
|
||||
link_inverted_entrances(world, player)
|
||||
|
||||
logger.info('Shuffling dungeons')
|
||||
logger.info(fish.translate("cli","cli","shuffling.dungeons"))
|
||||
|
||||
for player in range(1, world.players + 1):
|
||||
link_doors(world, player)
|
||||
@@ -111,21 +126,21 @@ def main(args, seed=None):
|
||||
mark_light_world_regions(world, player)
|
||||
else:
|
||||
mark_dark_world_regions(world, player)
|
||||
logger.info('Generating Item Pool.')
|
||||
logger.info(fish.translate("cli","cli","generating.itempool"))
|
||||
|
||||
for player in range(1, world.players + 1):
|
||||
generate_itempool(world, player)
|
||||
|
||||
logger.info('Calculating Access Rules.')
|
||||
logger.info(fish.translate("cli","cli","calc.access.rules"))
|
||||
|
||||
for player in range(1, world.players + 1):
|
||||
set_rules(world, player)
|
||||
|
||||
logger.info('Placing Dungeon Prizes.')
|
||||
logger.info(fish.translate("cli","cli","placing.dungeon.prizes"))
|
||||
|
||||
fill_prizes(world)
|
||||
|
||||
logger.info('Placing Dungeon Items.')
|
||||
logger.info(fish.translate("cli","cli","placing.dungeon.items"))
|
||||
|
||||
shuffled_locations = None
|
||||
if args.algorithm in ['balanced', 'vt26'] or any(list(args.mapshuffle.values()) + list(args.compassshuffle.values()) +
|
||||
@@ -139,9 +154,17 @@ def main(args, seed=None):
|
||||
for player in range(1, world.players+1):
|
||||
for key_layout in world.key_layout[player].values():
|
||||
if not validate_key_placement(key_layout, world, player):
|
||||
raise RuntimeError("Keylock detected: %s (Player %d)" % (key_layout.sector.name, player))
|
||||
raise RuntimeError(
|
||||
"%s: %s (%s %d)" %
|
||||
(
|
||||
fish.translate("cli","cli","keylock.detected"),
|
||||
key_layout.sector.name,
|
||||
fish.translate("cli","cli","player"),
|
||||
player
|
||||
)
|
||||
)
|
||||
|
||||
logger.info('Fill the world.')
|
||||
logger.info(fish.translate("cli","cli","fill.world"))
|
||||
|
||||
if args.algorithm == 'flood':
|
||||
flood_items(world) # different algo, biased towards early game progress items
|
||||
@@ -160,14 +183,14 @@ def main(args, seed=None):
|
||||
distribute_items_restrictive(world, True)
|
||||
|
||||
if world.players > 1:
|
||||
logger.info('Balancing multiworld progression.')
|
||||
logger.info(fish.translate("cli","cli","balance.multiworld"))
|
||||
balance_multiworld_progression(world)
|
||||
|
||||
# if we only check for beatable, we can do this sanity check first before creating the rom
|
||||
if not world.can_beat_game():
|
||||
raise RuntimeError('Cannot beat game. Something went terribly wrong here!')
|
||||
raise RuntimeError(fish.translate("cli","cli","cannot.beat.game"))
|
||||
|
||||
logger.info('Patching ROM.')
|
||||
logger.info(fish.translate("cli","cli","patching.rom"))
|
||||
|
||||
outfilebase = 'DR_%s' % (args.outputname if args.outputname else world.seed)
|
||||
|
||||
@@ -191,8 +214,8 @@ def main(args, seed=None):
|
||||
if not args.jsonout:
|
||||
rom = LocalRom.fromJsonRom(rom, args.rom, 0x400000)
|
||||
else:
|
||||
logging.warning("EnemizerCLI not found at:" + args.enemizercli)
|
||||
logging.warning("No Enemizer options will be applied until this is resolved.")
|
||||
logging.warning(fish.translate("cli","cli","enemizer.not.found") + ': ' + args.enemizercli)
|
||||
logging.warning(fish.translate("cli","cli","enemizer.nothing.applied"))
|
||||
|
||||
if args.race:
|
||||
patch_race_rom(rom)
|
||||
@@ -246,7 +269,7 @@ def main(args, seed=None):
|
||||
world.spoiler.to_file(output_path('%s_Spoiler.txt' % outfilebase))
|
||||
|
||||
if not args.skip_playthrough:
|
||||
logger.info('Calculating playthrough.')
|
||||
logger.info(fish.translate("cli","cli","calc.playthrough"))
|
||||
create_playthrough(world)
|
||||
|
||||
if args.jsonout:
|
||||
@@ -254,8 +277,8 @@ def main(args, seed=None):
|
||||
elif args.create_spoiler and not args.skip_playthrough:
|
||||
world.spoiler.to_file(output_path('%s_Spoiler.txt' % outfilebase))
|
||||
|
||||
logger.info('Done. Enjoy.')
|
||||
logger.info('Total Time: %s', time.perf_counter() - start)
|
||||
logger.info(fish.translate("cli","cli","done"))
|
||||
logger.info('%s: %s', fish.translate("cli","cli","total.time"), time.perf_counter() - start)
|
||||
|
||||
# print_wiki_doors_by_room(dungeon_regions,world,1)
|
||||
|
||||
@@ -391,6 +414,11 @@ def copy_dynamic_regions_and_locations(world, ret):
|
||||
|
||||
|
||||
def create_playthrough(world):
|
||||
settings = cli.get_args_priority(None, None, None)
|
||||
if "load" in settings:
|
||||
settings = settings["load"]
|
||||
fish = BabelFish(lang=settings["lang"] if "lang" in settings else "en")
|
||||
|
||||
# create a copy as we will modify it
|
||||
old_world = world
|
||||
world = copy_world(world)
|
||||
@@ -401,7 +429,7 @@ def create_playthrough(world):
|
||||
collection_spheres = []
|
||||
state = CollectionState(world)
|
||||
sphere_candidates = list(prog_locations)
|
||||
logging.getLogger('').debug('Building up collection spheres.')
|
||||
logging.getLogger('').debug(fish.translate("cli","cli","building.collection.spheres"))
|
||||
while sphere_candidates:
|
||||
state.sweep_for_events(key_only=True)
|
||||
state.sweep_for_crystal_access()
|
||||
@@ -424,7 +452,7 @@ def create_playthrough(world):
|
||||
if not sphere:
|
||||
logging.getLogger('').debug('The following items could not be reached: %s', ['%s (Player %d) at %s (Player %d)' % (location.item.name, location.item.player, location.name, location.player) for location in sphere_candidates])
|
||||
if any([world.accessibility[location.item.player] != 'none' for location in sphere_candidates]):
|
||||
raise RuntimeError('Not all progression items reachable. Something went terribly wrong here.')
|
||||
raise RuntimeError(fish.translate("cli","cli","cannot.reach.progression"))
|
||||
else:
|
||||
old_world.spoiler.unreachables = sphere_candidates.copy()
|
||||
break
|
||||
@@ -478,7 +506,7 @@ def create_playthrough(world):
|
||||
|
||||
logging.getLogger('').debug('Calculated final sphere %i, containing %i of %i progress items.', len(collection_spheres), len(sphere), len(required_locations))
|
||||
if not sphere:
|
||||
raise RuntimeError('Not all required items reachable. Something went terribly wrong here.')
|
||||
raise RuntimeError(fish.translate("cli","cli","cannot.reach.required"))
|
||||
|
||||
# store the required locations for statistical analysis
|
||||
old_world.required_locations = [(location.name, location.player) for sphere in collection_spheres for location in sphere]
|
||||
|
||||
Reference in New Issue
Block a user