FrankProjects/UltimateWarfare

View on GitHub
templates/game/region.html.twig

Summary

Maintainability
Test Coverage
{% extends 'game.html.twig' %}

{% block title %}Ultimate Warfare - Region{% endblock title %}

{% block content %}
    <table class="table text-center">
        <tr class="tabletop">
            {% if player.worldRegions|length > 1 and region.player.id is defined and region.player.id == player.id %}
            <td colspan="3">
                {% if previousRegion is not null %}
                    <a class="B" href="{{ path('Game/World/Region', {'regionId': previousRegion.id}) }}"><<</a>
                {% endif %}
                <b>Region</b>
                {% if nextRegion is not null %}
                    <a class="B" href="{{ path('Game/World/Region', {'regionId': nextRegion.id}) }}">>></a>
                {% endif %}
            </td>
            {% else %}
            <td colspan="3"><b>Region</b></td>
            {% endif %}
        </tr>
        <tr>
            <td rowspan="3" width="120">
                <img src="{{ asset('images/map/' ~ region.type ~ '.jpg') }}" alt="Region {{ region.id }}" width="120" height="100"><br />
            </td>
            <td width="300">Location:</td>
            <td width="280">{{ region.x }}, {{ region.y }}</td>
        </tr>
        <tr>
            <td width="300">Owner:</td>
            {% if region.player is not null %}
                <td width="280"><a class="B" href="{{ path('Game/Profile', {'playerName': region.player.name}) }}">{{ region.player.name }}</a></td>
            {% else %}
                <td width="280">Nobody</td>
            {% endif %}
        </tr>
        <tr>
            <td width="300">Space:</td>
            <td width="280">
                {{ region.space }}
            </td>
        </tr>
    </table>

    <br />
    <br />

    {% if region.player.id is defined and region.player.id != player.id %}
        <a class="B" href="{{ path('Game/Message/New', {'playerName': region.player.name}) }}">Send message</a>
    {% endif %}

    {% if region.state == 1 %}
        <br /><b>This region was hit by a nuclear blast.</b><br />
        There is a huge amount of toxic radiation so this region will not be liveable for an unknown amount of time!
    {% elseif region.player == null %}
        <a class="B" href="{{ path('Game/World/Region/Buy', {'regionId': region.id}) }}">Buy</a>
    {% elseif region.player.id == player.id %}

    {% for gameUnitType in gameUnitTypes %}
        <table class="table text-center">
            <tr class="tabletop">
                <td colspan="2"><b>{{ gameUnitType.name }}</b></td>
            </tr>
            {% set hasGameUnit = 0 %}
            {% for gameUnit in gameUnitType.gameUnits %}
                {% if gameUnitsData[gameUnit.id] is defined and gameUnitsData[gameUnit.id] > 0 %}
                    {% set hasGameUnit = 1 %}
                    <tr>
                        <td width="350">{{ gameUnit.name }}</td>
                        <td width="350">{{ gameUnitsData[gameUnit.id] }}</td>
                    </tr>
                {% endif %}
            {% endfor %}

            {% if hasGameUnit == 0 %}
                <tr>
                    <td colspan="2">You don't have any {{ gameUnitType.name }}</td>
                </tr>
            {% endif %}

            <td colspan="2">
                <a class="B" href="{{ path('Game/World/Region/Build', {'regionId': region.id, 'gameUnitTypeId': gameUnitType.id}) }}">{{ gameUnitType.name }}</a><br />
                <a class="B" href="{{ path('Game/World/Region/RemoveGameUnits', {'regionId': region.id, 'gameUnitTypeId': gameUnitType.id}) }}">Demolish {{ gameUnitType.name }}</a><br />
            </td>
        </table>
    {% endfor %}

        <br />
    <table width="350" class="table text-center">
        <tr class="tabletop">
            <td width="350" colspan="2"><b>Other Actions</b></td>
        </tr>
        <tr>
            <td colspan="2">
                 <a class="B" href="{{ path('Game/World/Region/SendUnits', {'regionId': region.id}) }}">Send Units</a>
            </td>
        </tr>
    </table>

        <a name="bottom"></a>

        {% if player.worldRegions|length > 1 %}
            {% if previousRegion is not null %}
                <a class="B" href="{{ path('Game/World/Region', {'regionId': previousRegion.id}) }}#bottom"><<</a>
            {% endif %}
            <b>Region</b>
            {% if nextRegion is not null %}
                <a class="B" href="{{ path('Game/World/Region', {'regionId': nextRegion.id}) }}#bottom">>></a>
            {% endif %}
        {% endif %}
    {% else %}
        <br /><br /><a class="B" href="{{ path('Game/World/Region/Attack', {'regionId': region.id}) }}">Attack</a>
        <br /><br /><a class="B" href="{{ path('Game/Operation/SelectOperation', {'regionId': region.id}) }}">Launch Operation</a>
    {% endif %}

    <br />
    <br />
{% endblock %}