Skip to content

Commit 9537823

Browse files
Templates: Update template output and add min and max comments for named special_range options. (#1164)
* add min and max comments for named special_range options * comment all special range options and dictate the min and max in comment block * make it cleaner * make it cleanerer * make it cleanererer * Reformat template for more consistent comments. * Fixed missing note on some special settings. * Small tweak to template. * Update playerSettings.yaml to match auto-generated template with all ALTTP options. * Fix edge case with `special_range_cutoff` and revert playerSettings.yaml. Co-authored-by: Zach Parks <zach@alliware.com>
1 parent 85130f2 commit 9537823

File tree

4 files changed

+67
-53
lines changed

4 files changed

+67
-53
lines changed

Options.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -850,7 +850,7 @@ class Accessibility(Choice):
850850

851851
class ProgressionBalancing(SpecialRange):
852852
"""A system that can move progression earlier, to try and prevent the player from getting stuck and bored early.
853-
[0-99, default 50] A lower setting means more getting stuck. A higher setting means less getting stuck."""
853+
A lower setting means more getting stuck. A higher setting means less getting stuck."""
854854
default = 50
855855
range_start = 0
856856
range_end = 99

WebHostLib/options.py

+4-16
Original file line numberDiff line numberDiff line change
@@ -25,26 +25,14 @@ def create():
2525
os.unlink(full_path)
2626

2727
def dictify_range(option: typing.Union[Options.Range, Options.SpecialRange]):
28-
data = {}
29-
special = getattr(option, "special_range_cutoff", None)
30-
if special is not None:
31-
data[special] = 0
32-
data.update({
33-
option.range_start: 0,
34-
option.range_end: 0,
35-
option.default: 50
36-
})
37-
for sub_option in {"random", "random-low", "random-high"}:
28+
data = {option.default: 50}
29+
for sub_option in ["random", "random-low", "random-high"]:
3830
if sub_option != option.default:
3931
data[sub_option] = 0
4032

41-
notes = {
42-
special: "minimum value without special meaning",
43-
option.range_start: "minimum value",
44-
option.range_end: "maximum value"
45-
}
46-
33+
notes = {}
4734
for name, number in getattr(option, "special_range_names", {}).items():
35+
notes[name] = f"equivalent to {number}"
4836
if number in data:
4937
data[name] = data[number]
5038
del data[number]

WebHostLib/templates/options.yaml

+61-35
Original file line numberDiff line numberDiff line change
@@ -1,60 +1,86 @@
1-
# What is this file?
2-
# This file contains options which allow you to configure your multiworld experience while allowing others
3-
# to play how they want as well.
4-
5-
# How do I use it?
6-
# The options in this file are weighted. This means the higher number you assign to a value, the more
7-
# chances you have for that option to be chosen. For example, an option like this:
1+
# Q. What is this file?
2+
# A. This file contains options which allow you to configure your multiworld experience while allowing
3+
# others to play how they want as well.
4+
#
5+
# Q. How do I use it?
6+
# A. The options in this file are weighted. This means the higher number you assign to a value, the
7+
# more chances you have for that option to be chosen. For example, an option like this:
8+
#
9+
# map_shuffle:
10+
# on: 5
11+
# off: 15
812
#
9-
# map_shuffle:
10-
# on: 5
11-
# off: 15
13+
# Means you have 5 chances for map shuffle to occur, and 15 chances for map shuffle to be turned
14+
# off.
1215
#
13-
# Means you have 5 chances for map shuffle to occur, and 15 chances for map shuffle to be turned off
14-
15-
# I've never seen a file like this before. What characters am I allowed to use?
16-
# This is a .yaml file. You are allowed to use most characters.
17-
# To test if your yaml is valid or not, you can use this website:
18-
# http://www.yamllint.com/
19-
20-
description: Default {{ game }} Template # Used to describe your yaml. Useful if you have multiple files
21-
# Your name in-game. Spaces will be replaced with underscores and there is a 16 character limit
22-
name: YourName{number}
23-
#{player} will be replaced with the player's slot number.
24-
#{PLAYER} will be replaced with the player's slot number if that slot number is greater than 1.
25-
#{number} will be replaced with the counter value of the name.
26-
#{NUMBER} will be replaced with the counter value of the name if the counter value is greater than 1.
27-
game:
28-
{{ game }}: 1
16+
# Q. I've never seen a file like this before. What characters am I allowed to use?
17+
# A. This is a .yaml file. You are allowed to use most characters.
18+
# To test if your yaml is valid or not, you can use this website:
19+
# http://www.yamllint.com/
20+
# You can also verify your Archipelago settings are valid at this site:
21+
# https://archipelago.gg/check
22+
23+
# Your name in-game. Spaces will be replaced with underscores and there is a 16-character limit.
24+
# {player} will be replaced with the player's slot number.
25+
# {PLAYER} will be replaced with the player's slot number, if that slot number is greater than 1.
26+
# {number} will be replaced with the counter value of the name.
27+
# {NUMBER} will be replaced with the counter value of the name, if the counter value is greater than 1.
28+
name: Player{number}
29+
30+
# Used to describe your yaml. Useful if you have multiple files.
31+
description: Default {{ game }} Template
32+
33+
game: {{ game }}
2934
requires:
3035
version: {{ __version__ }} # Version of Archipelago required for this yaml to work as expected.
31-
# Shared Options supported by all games:
3236

3337
{%- macro range_option(option) %}
34-
# you can add additional values between minimum and maximum
38+
# You can define additional values between the minimum and maximum values.
39+
# Minimum value is {{ option.range_start }}
40+
# Maximum value is {{ option.range_end }}
3541
{%- set data, notes = dictify_range(option) %}
3642
{%- for entry, default in data.items() %}
3743
{{ entry }}: {{ default }}{% if notes[entry] %} # {{ notes[entry] }}{% endif %}
3844
{%- endfor -%}
3945
{% endmacro %}
46+
4047
{{ game }}:
4148
{%- for option_key, option in options.items() %}
42-
{{ option_key }}:{% if option.__doc__ %} # {{ option.__doc__ | replace('\n', '\n#') | indent(4, first=False) }}{% endif %}
49+
{{ option_key }}:
50+
{%- if option.__doc__ %}
51+
# {{ option.__doc__
52+
| trim
53+
| wordwrap(112, wrapstring="\n# ")
54+
| replace(' ', '')
55+
| replace('\n ', '\n# ')
56+
| indent(4, first=False)
57+
}}
58+
{%- endif -%}
59+
60+
{%- if option.__doc__ and option.range_start is defined %}
61+
#
62+
{%- endif -%}
63+
4364
{%- if option.range_start is defined and option.range_start is number %}
4465
{{- range_option(option) -}}
66+
4567
{%- elif option.options -%}
46-
{%- for suboption_option_id, sub_option_name in option.name_lookup.items() %}
68+
{%- for suboption_option_id, sub_option_name in option.name_lookup.items() %}
4769
{{ sub_option_name }}: {% if suboption_option_id == option.default %}50{% else %}0{% endif %}
48-
{%- endfor -%}
49-
{% if option.name_lookup[option.default] not in option.options %}
70+
{%- endfor -%}
71+
72+
{%- if option.name_lookup[option.default] not in option.options %}
5073
{{ option.default }}: 50
51-
{%- endif -%}
74+
{%- endif -%}
75+
5276
{%- elif option.default is string %}
5377
{{ option.default }}: 50
78+
5479
{%- elif option.default is iterable and option.default is not mapping %}
5580
{{ option.default | list }}
81+
5682
{%- else %}
57-
{{ yaml_dump(option.default) | indent(4, first=false) }}
83+
{{ yaml_dump(option.default) | trim | indent(4, first=false) }}
5884
{%- endif -%}
5985
{%- endfor %}
60-
{% if not options %}{}{% endif %}
86+

playerSettings.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -453,7 +453,7 @@ A Link to the Past:
453453
death_link:
454454
false: 50
455455
true: 0
456-
456+
457457
allow_collect: # Allows for !collect / co-op to auto-open chests containing items for other players.
458458
# Off by default, because it currently crashes on real hardware.
459459
false: 50

0 commit comments

Comments
 (0)