Reimplement --securerandom

Seeds should be reproducable without the flag passed, and unreproducable with the flag passed.
With --securerandom, generate a 9-char alphanumeric string to use to make filenames differ.
This commit is contained in:
2021-06-29 10:36:53 -07:00
parent 11dcc719fb
commit 3896066193
16 changed files with 23 additions and 21 deletions

11
Main.py
View File

@@ -4,7 +4,8 @@ from itertools import zip_longest
import json
import logging
import os
import random
import RaceRandom as random
import string
import time
import zlib
@@ -41,8 +42,8 @@ def main(args, seed=None, fish=None):
start = time.perf_counter()
# if args.securerandom:
# random.use_secure()
if args.securerandom:
random.use_secure()
# initialize the world
if args.code:
@@ -61,7 +62,7 @@ def main(args, seed=None, fish=None):
random.seed(world.seed)
if args.securerandom:
world.seed = None
world.seed = ''.join(random.choice(string.ascii_uppercase + string.ascii_lowercase + string.digits) for _ in range(9))
world.remote_items = args.remote_items.copy()
world.mapshuffle = args.mapshuffle.copy()
@@ -332,7 +333,7 @@ def main(args, seed=None, fish=None):
logger.info(world.fish.translate("cli","cli","made.playthrough") % (YES if (args.calc_playthrough) else NO))
logger.info(world.fish.translate("cli","cli","made.spoiler") % (YES if (not args.jsonout and args.create_spoiler) else NO))
logger.info(world.fish.translate("cli","cli","used.enemizer") % (YES if enemized else NO))
logger.info(world.fish.translate("cli","cli","seed") + ": %d", world.seed)
logger.info(world.fish.translate("cli","cli","seed") + ": %s", world.seed)
logger.info(world.fish.translate("cli","cli","total.time"), time.perf_counter() - start)
# print_wiki_doors_by_room(dungeon_regions,world,1)