# Q. What is this file?
# A. This file contains options which allow you to configure your multiworld experience while allowing
#    others to play how they want as well.
#
# Q. How do I use it?
# A. The options in this file are weighted. This means the higher number you assign to a value, the
#    more chances you have for that option to be chosen. For example, an option like this:
#
#    map_shuffle:
#      on: 5
#      off: 15
#
#    Means you have 5 chances for map shuffle to occur, and 15 chances for map shuffle to be turned
#    off.
#
# Q. I've never seen a file like this before. What characters am I allowed to use?
# A. This is a .yaml file. You are allowed to use most characters.
#    To test if your yaml is valid or not, you can use this website:
#        http://www.yamllint.com/
#    You can also verify that your Archipelago options are valid at this site:
#        https://archipelago.gg/check

# Your name in-game, limited to 16 characters.
#     {player} will be replaced with the player's slot number.
#     {PLAYER} will be replaced with the player's slot number, if that slot number is greater than 1.
#     {number} will be replaced with the counter value of the name.
#     {NUMBER} will be replaced with the counter value of the name, if the counter value is greater than 1.
name: Player{number}

# Used to describe your yaml. Useful if you have multiple files.
description: {{ yaml_dump("Default %s Template" % game) }}

game: {{ yaml_dump(game) }}
requires:
  version: {{ __version__ }} # Version of Archipelago required for this yaml to work as expected.

{%- macro range_option(option) %}
    # You can define additional values between the minimum and maximum values.
    # Minimum value is {{ option.range_start }}
    # Maximum value is {{ option.range_end }}
    {%- set data, notes = dictify_range(option) %}
    {%- for entry, default in data.items() %}
    {{ entry }}: {{ default }}{% if notes[entry] %} # {{ notes[entry] }}{% endif %}
    {%- endfor -%}
{% endmacro %}

{{ yaml_dump(game) }}:
  {%- for group_name, group_options in option_groups.items() %}
  # {{ group_name }}

  {%- for option_key, option in group_options.items() %}
  {{ option_key }}:
    {%- if option.__doc__ %}
    # {{ option.__doc__
        | trim
        | replace('\n\n', '\n    \n')
        | replace('\n    ', '\n# ')
        | indent(4, first=False)
      }}
    {%- endif -%}

    {%- if option.__doc__ and option.range_start is defined %}
    #
    {%- endif -%}

    {%- if option.range_start is defined and option.range_start is number %}
    {{- range_option(option) -}}

    {%- elif option.options -%}
    {%- for suboption_option_id, sub_option_name in option.name_lookup.items() %}
    {{ yaml_dump(sub_option_name) }}: {% if suboption_option_id == option.default %}50{% else %}0{% endif %}
    {%- endfor -%}

    {%- if option.name_lookup[option.default] not in option.options %}
    {{ yaml_dump(option.default) }}: 50
    {%- endif -%}

    {%- elif option.default is string %}
    {{ yaml_dump(option.default) }}: 50

    {%- elif option.default is iterable and option.default is not mapping %}
    {{ option.default | list }}

    {%- else %}
    {{ yaml_dump(option.default) | indent(4, first=false) }}
    {%- endif -%}
    {{ "\n" }}
  {%- endfor %}
  {%- endfor %}
