Allow %%, %player%, %number% variables in names.
This commit is contained in:
parent
6e129c3421
commit
a331c397aa
14
Mystery.py
14
Mystery.py
|
@ -5,6 +5,7 @@ import urllib.request
|
||||||
import urllib.parse
|
import urllib.parse
|
||||||
import typing
|
import typing
|
||||||
import os
|
import os
|
||||||
|
from collections import Counter
|
||||||
|
|
||||||
import ModuleUpdate
|
import ModuleUpdate
|
||||||
from BaseClasses import PlandoItem, PlandoConnection
|
from BaseClasses import PlandoItem, PlandoConnection
|
||||||
|
@ -171,6 +172,7 @@ def main(args=None, callback=ERmain):
|
||||||
elif type(players_meta) == dict and players_meta[key] and option not in players_meta[key]:
|
elif type(players_meta) == dict and players_meta[key] and option not in players_meta[key]:
|
||||||
weights_cache[path][key] = option
|
weights_cache[path][key] = option
|
||||||
|
|
||||||
|
name_counter = Counter()
|
||||||
for player in range(1, args.multi + 1):
|
for player in range(1, args.multi + 1):
|
||||||
path = player_path_cache[player]
|
path = player_path_cache[player]
|
||||||
if path:
|
if path:
|
||||||
|
@ -213,6 +215,16 @@ def main(args=None, callback=ERmain):
|
||||||
erargs.name[player] = f"Player{player}"
|
erargs.name[player] = f"Player{player}"
|
||||||
elif not erargs.name[player]: # if name was not specified, generate it from filename
|
elif not erargs.name[player]: # if name was not specified, generate it from filename
|
||||||
erargs.name[player] = os.path.split(path)[-1].split(".")[0]
|
erargs.name[player] = os.path.split(path)[-1].split(".")[0]
|
||||||
|
new_name = []
|
||||||
|
name_counter[erargs.name[player]] += 1
|
||||||
|
for name in erargs.name[player].split("%%"):
|
||||||
|
if "%number%" in name:
|
||||||
|
name = name.replace("%number%", str(name_counter[erargs.name[player]]))
|
||||||
|
if "%player%" in name:
|
||||||
|
name = name.replace("%player%", str(player))
|
||||||
|
new_name.append(name)
|
||||||
|
erargs.name[player] = handle_name("%".join(new_name))
|
||||||
|
logging.info(erargs.name[player])
|
||||||
erargs.names = ",".join(erargs.name[i] for i in range(1, args.multi + 1))
|
erargs.names = ",".join(erargs.name[i] for i in range(1, args.multi + 1))
|
||||||
del (erargs.name)
|
del (erargs.name)
|
||||||
if args.yaml_output:
|
if args.yaml_output:
|
||||||
|
@ -447,8 +459,6 @@ def roll_settings(weights: dict, plando_options: typing.Set[str] = frozenset(("b
|
||||||
|
|
||||||
ret = argparse.Namespace()
|
ret = argparse.Namespace()
|
||||||
ret.name = get_choice('name', weights)
|
ret.name = get_choice('name', weights)
|
||||||
if ret.name:
|
|
||||||
ret.name = handle_name(ret.name)
|
|
||||||
|
|
||||||
glitches_required = get_choice('glitches_required', weights)
|
glitches_required = get_choice('glitches_required', weights)
|
||||||
if glitches_required not in [None, 'none', 'no_logic', 'overworld_glitches', 'minor_glitches']:
|
if glitches_required not in [None, 'none', 'no_logic', 'overworld_glitches', 'minor_glitches']:
|
||||||
|
|
|
@ -18,7 +18,10 @@
|
||||||
# http://www.yamllint.com/
|
# http://www.yamllint.com/
|
||||||
|
|
||||||
description: Template Name # Used to describe your yaml. Useful if you have multiple files
|
description: Template Name # Used to describe your yaml. Useful if you have multiple files
|
||||||
name: YourName # Your name in-game. Spaces will be replaced with underscores and there is a 16 character limit
|
name: YourName%number% # Your name in-game. Spaces will be replaced with underscores and there is a 16 character limit
|
||||||
|
#%player% will be replaced with actual player number.
|
||||||
|
#%number% will be replaced with the counter value of the name.
|
||||||
|
#%% will become % after all of the above processing is complete on the name.
|
||||||
### Logic Section ###
|
### Logic Section ###
|
||||||
# Warning: overworld_glitches is not available and minor_glitches is only partially implemented on the door-rando version
|
# Warning: overworld_glitches is not available and minor_glitches is only partially implemented on the door-rando version
|
||||||
glitches_required: # Determine the logic required to complete the seed
|
glitches_required: # Determine the logic required to complete the seed
|
||||||
|
|
Loading…
Reference in New Issue