forked from tommadness/KH2Randomizer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cli_gen.py
64 lines (52 loc) · 2.31 KB
/
cli_gen.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import json
import os
import random
import string
from collections import namedtuple
from Class.seedSettings import ExtraConfigurationData, SeedSettings
from Module import appconfig
from Module.RandomizerSettings import RandomizerSettings
from Module.generate import generateSeedCLI
from Module.seedshare import SharedSeed
from Module.version import LOCAL_UI_VERSION
SeedInfo = namedtuple("SeedInfo",["seed_name","requested_preset","generator_string","hash_icons","spoiler_html"])
requested_preset = "League Spring 2024"
def make_random_seed_from_preset_name(requested_type:str):
preset_json = {}
for preset_file_name in os.listdir(appconfig.PRESET_FOLDER):
preset_name, extension = os.path.splitext(preset_file_name)
if extension == '.json':
with open(os.path.join(appconfig.PRESET_FOLDER, preset_file_name), 'r') as presetData:
try:
settings_json = json.load(presetData)
preset_json[preset_name] = settings_json
except Exception:
print('Unable to load preset [{}], skipping'.format(preset_file_name))
# get seed name at random
characters = string.ascii_letters + string.digits
seedString = (''.join(random.choice(characters) for i in range(30)))
makeSpoilerLog = False
settings = SeedSettings()
settings.apply_settings_json(preset_json[requested_type])
shared_seed = SharedSeed(
generator_version=LOCAL_UI_VERSION,
seed_name=seedString,
spoiler_log=makeSpoilerLog,
settings_string=settings.settings_string(),
tourney_gen=True
)
shared_string_text = shared_seed.to_share_string()
rando_settings = RandomizerSettings(seedString,makeSpoilerLog,LOCAL_UI_VERSION,settings,shared_string_text)
extra_data = ExtraConfigurationData(platform="PC", tourney=True, custom_cosmetics_executables=[])
spoiler_log = generateSeedCLI(rando_settings, extra_data)
return SeedInfo(
seed_name=seedString,
requested_preset=requested_type,
generator_string=shared_string_text,
hash_icons=rando_settings.seedHashIcons,
spoiler_html=spoiler_log
)
if __name__ == '__main__':
seed_info = make_random_seed_from_preset_name(requested_preset)
print(seed_info.generator_string)
print(seed_info.hash_icons)