{% extends 'pageWrapper.html' %}

{% block head %}
    <title>Generate Game</title>
    <link rel="stylesheet" type="text/css" href="{{ url_for('static', filename="styles/generate.css") }}" />
    <script type="application/ecmascript" src="{{ url_for('static', filename="assets/generate.js") }}"></script>
{% endblock %}

{% block body %}
    {% include 'header/oceanIslandHeader.html' %}
    <div id="generate-game-wrapper">
        <div id="generate-game" class="grass-island">
            <h1>Generate Game{% if race %} (Race Mode){% endif %}</h1>
            <p>
                This page allows you to generate a game by uploading a config file or a zip file containing config
                files. If you do not have a config (.yaml) file yet, you may create one on the game's settings page,
                which you can find on the <a href="{{ url_for("games") }}">supported games list</a>.
            </p>
            <p>
                Note: This website will always generate games using the current release version of Archipelago,
                currently {{ version }}.
            </p>
            <p>
                {% if race -%}
                    This game will be generated in race mode,
                    meaning the spoiler log will be unavailable and game specific protections will be in place,
                    like ROM encryption or cheat mode removal.
                {%- else -%}
                    If you would like to generate a race game,
                    <a href="{{ url_for("generate", race=True) }}">click here.</a><br />
                    Race games are generated without a spoiler log and game specific protections will be in place,
                    like ROM encryption or cheat mode removal.
                {%- endif -%}
            </p>
            <div id="generate-game-form-wrapper">
                <form id="generate-game-form" method="post" enctype="multipart/form-data">
                    <div id="generate-game-tables-container">
                        <div class="table-wrapper">
                        <table>
                            <tbody>
                                <tr>
                                    <td>
                                        <label for="release_mode">Release Permission:
                                            <span class="interactive" data-tooltip="Permissions on when players are able to release all remaining items from their world.">
                                                (?)
                                            </span>
                                        </label>
                                    </td>
                                    <td>
                                        <select name="release_mode" id="release_mode">
                                            <option value="auto">Automatic on goal completion</option>
                                            <option value="goal">Allow !release after goal completion</option>
                                            <option value="auto-enabled">
                                                Automatic on goal completion and manual !release
                                            </option>
                                            <option value="enabled">Manual !release</option>
                                            <option value="disabled">Disabled</option>
                                        </select>
                                    </td>
                                </tr>

                                <tr>
                                    <td>
                                        <label for="collect_mode">Collect Permission:
                                            <span class="interactive" data-tooltip="Permissions on when players are able to collect all their remaining items from across the multiworld.">
                                                (?)
                                            </span>
                                        </label>
                                    </td>
                                    <td>
                                        <select name="collect_mode" id="collect_mode">
                                            <option value="auto">Automatic on goal completion</option>
                                            <option value="goal">Allow !collect after goal completion</option>
                                            <option value="auto-enabled">
                                                Automatic on goal completion and manual !collect
                                            </option>
                                            <option value="enabled">Manual !collect</option>
                                            <option value="disabled">Disabled</option>
                                        </select>
                                    </td>
                                </tr>

                                <tr>
                                    <td>
                                        <label for="remaining_mode">Remaining Permission:
                                            <span class="interactive" data-tooltip="Remaining lists all items still in your world by name only.">
                                                (?)
                                            </span>
                                        </label>
                                    </td>
                                    <td>
                                        <select name="remaining_mode" id="remaining_mode">
                                            {% if race -%}
                                                <option value="disabled">Disabled in Race mode</option>
                                            {%- else -%}
                                                <option value="goal">Allow !remaining after goal completion</option>
                                                <option value="enabled">Manual !remaining</option>
                                                <option value="disabled">Disabled</option>
                                            {%- endif -%}
                                        </select>
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        <label for="item_cheat">Item Cheat:
                                            <span class="interactive" data-tooltip="Allows players to use the !getitem command.">
                                                (?)
                                            </span>
                                        </label>
                                    </td>
                                    <td>
                                        <select name="item_cheat" id="item_cheat">
                                            {% if race -%}
                                                <option value="0">Disabled in Race mode</option>
                                            {%- else -%}
                                                <option value="1">Enabled</option>
                                                <option value="0">Disabled</option>
                                            {%- endif -%}
                                        </select>
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        <label for="spoiler">Spoiler Log:
                                            <span class="interactive" data-tooltip="Generates a text listing all randomized elements.
Warning: playthrough can take a significant amount of time for larger multiworlds.">
                                                (?)
                                            </span>
                                        </label>
                                    </td>
                                    <td>
                                        <select name="spoiler" id="spoiler">
                                            {% if race -%}
                                                <option value="0">Disabled in Race mode</option>
                                            {%- else -%}
                                                <option value="3">Enabled with playthrough and traversal</option>
                                                <option value="2">Enabled with playthrough</option>
                                                <option value="1">Enabled</option>
                                                <option value="0">Disabled</option>
                                            {%- endif -%}
                                        </select>
                                    </td>
                                </tr>
                            </tbody>
                        </table>
                        </div>
                        <div class="table-wrapper">
                            <table>
                                <tbody>
                                    <tr>
                                        <td>
                                            <label for="hint_cost"> Hint Cost:
                                                <span class="interactive" data-tooltip="After gathering this many checks, players can !hint <itemname> to get the location of that hint item.">
                                                    (?)
                                                </span>
                                            </label>
                                        </td>
                                        <td>
                                            <select name="hint_cost" id="hint_cost">
                                                {% for n in range(0, 110, 5) %}
                                                    <option {% if n == 10 %}selected="selected" {% endif %} value="{{ n }}">
                                                        {% if n > 100 %}Off{% else %}{{ n }}%{% endif %}
                                                    </option>
                                                {% endfor %}
                                            </select>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td>
                                            <label for="server_password">Server Password:
                                                <span class="interactive" data-tooltip="Allows for issuing of server console commands from any text client or in-game client using the !admin command.">
                                                    (?)
                                                </span>
                                            </label>
                                        </td>
                                        <td>
                                            <input id="server_password" name="server_password">
                                        </td>
                                    </tr>
                                    <tr>
                                        <td>
                                            Plando Options:
                                            <span class="interactive" data-tooltip="Allows players to plan some of the randomization. See the 'Archipelago Plando Guide' in 'Setup Guides' for more information.">
                                                (?)
                                            </span>
                                        </td>
                                        <td>
                                            <input type="checkbox" id="plando_items" name="plando_items" value="items">
                                            <label for="plando_items">Items</label><br>

                                            <input type="checkbox" id="plando_bosses" name="plando_bosses" value="bosses" checked>
                                            <label for="plando_bosses">Bosses</label><br>

                                            <input type="checkbox" id="plando_connections" name="plando_connections" value="connections" checked>
                                            <label for="plando_connections">Connections</label><br>

                                            <input type="checkbox" id="plando_texts" name="plando_texts" value="texts" checked>
                                            <label for="plando_texts">Text</label>
                                        </td>
                                    </tr>
                                </tbody>
                            </table>
                        </div>
                    </div>
                    <div id="generate-form-button-row">
                        <input id="file-input" type="file" name="file" multiple>
                    </div>
                </form>
                <button id="generate-game-button">Upload File(s)</button>
            </div>
        </div>
    </div>
    {%  include 'islandFooter.html' %}
{% endblock %}
