def main(args, seed=None): start = time.clock() # initialize the world world = World('vanilla', 'noglitches', 'standard', 'normal', 'none', 'on', 'ganon', 'freshness', False, False, False, args.quickswap, args.fastmenu, False) logger = logging.getLogger('') hasher = hashlib.md5() with open(args.plando, 'rb') as plandofile: buf = plandofile.read() hasher.update(buf) world.seed = int(hasher.hexdigest(), 16) % 1000000000 random.seed(world.seed) logger.info('ALttP Plandomizer Version %s - Seed: %s\n\n' % (__version__, args.plando)) create_regions(world) create_dungeons(world) link_entrances(world) logger.info('Calculating Access Rules.') set_rules(world) logger.info('Fill the world.') text_patches = [] fill_world(world, args.plando, text_patches) if world.get_entrance( 'Dam').connected_region.name != 'Dam' or world.get_entrance( 'Swamp Palace' ).connected_region.name != 'Swamp Palace (Entrance)': world.swamp_patch_required = True logger.info('Calculating playthrough.') try: create_playthrough(world) except RuntimeError: if args.ignore_unsolvable: pass else: raise logger.info('Patching ROM.') if args.sprite is not None: sprite = bytearray(open(args.sprite, 'rb').read()) else: sprite = None rom = LocalRom(args.rom) patch_rom(world, rom, logic_hash, args.heartbeep, sprite) for textname, texttype, text in text_patches: if texttype == 'text': write_string_to_rom(rom, textname, text) elif texttype == 'credit': write_credits_string_to_rom(rom, textname, text) outfilebase = 'Plando_%s_%s' % (os.path.splitext( os.path.basename(args.plando))[0], world.seed) rom.write_to_file('%s.sfc' % outfilebase) if args.create_spoiler: world.spoiler.to_file('%s_Spoiler.txt' % outfilebase) logger.info('Done. Enjoy.') logger.debug('Total Time: %s' % (time.clock() - start)) return world
def main(args): start_time = time.perf_counter() # initialize the world world = World(1, 'vanilla', 'noglitches', 'standard', 'normal', 'none', 'on', 'ganon', 'freshness', False, False, False, False, False, False, None, False) world.player_names[1].append("Player1") logger = logging.getLogger('') hasher = hashlib.md5() with open(args.plando, 'rb') as plandofile: buf = plandofile.read() hasher.update(buf) world.seed = int(hasher.hexdigest(), 16) % 1000000000 random.seed(world.seed) logger.info('ALttP Plandomizer Version %s - Seed: %s\n\n', __version__, args.plando) world.difficulty_requirements[1] = difficulties[world.difficulty[1]] create_regions(world, 1) create_dungeons(world, 1) link_entrances(world, 1) logger.info('Calculating Access Rules.') set_rules(world, 1) logger.info('Fill the world.') text_patches = [] fill_world(world, args.plando, text_patches) if world.get_entrance( 'Dam', 1).connected_region.name != 'Dam' or world.get_entrance( 'Swamp Palace', 1).connected_region.name != 'Swamp Palace (Entrance)': world.swamp_patch_required[1] = True logger.info('Calculating playthrough.') try: create_playthrough(world) except RuntimeError: if args.ignore_unsolvable: pass else: raise logger.info('Patching ROM.') rom = LocalRom(args.rom) patch_rom(world, rom, 1, 1, False) apply_rom_settings(rom, args.heartbeep, args.heartcolor, args.quickswap, args.fastmenu, args.disablemusic, args.sprite, args.ow_palettes, args.uw_palettes) for textname, texttype, text in text_patches: if texttype == 'text': write_string_to_rom(rom, textname, text) #elif texttype == 'credit': # write_credits_string_to_rom(rom, textname, text) outfilebase = 'Plando_%s_%s' % (os.path.splitext( os.path.basename(args.plando))[0], world.seed) rom.write_to_file('%s.sfc' % outfilebase) if args.create_spoiler: world.spoiler.to_file('%s_Spoiler.txt' % outfilebase) logger.info('Done. Enjoy.') logger.debug('Total Time: %s', time.perf_counter() - start_time) return world