diff options
author | Daniel Weipert <code@drogueronin.de> | 2023-09-24 13:40:25 +0200 |
---|---|---|
committer | Daniel Weipert <code@drogueronin.de> | 2023-09-24 13:40:25 +0200 |
commit | fa00b957378a393f8edbfc98ef111d35d18ecb09 (patch) | |
tree | 654e7dc5414f7f2795dbe996d3e1570793a5b1b8 /views/village.twig |
initial commit
Diffstat (limited to 'views/village.twig')
-rw-r--r-- | views/village.twig | 169 |
1 files changed, 169 insertions, 0 deletions
diff --git a/views/village.twig b/views/village.twig new file mode 100644 index 0000000..7bb55b2 --- /dev/null +++ b/views/village.twig @@ -0,0 +1,169 @@ +{% extends 'base.twig' %} + +{% block main %} +<div class="village"> + + <div class="village__top"> + <div><span>{{ village.x }} x {{ village.y }}</span> — {{ village.name }}</div> + + <div class="resources"> + <span>wood: <b>{{ village.wood }}</b> / {{ village.getStorage(village.id).getResourceCapacity('wood') }} – {{ village.getBuilding(village.id, 'WoodCutter').getResourceIncrementor() }}</span> + <span>clay: <b>{{ village.clay }}</b> / {{ village.getStorage(village.id).getResourceCapacity('clay') }} – {{ village.getBuilding(village.id, 'ClayPit').getResourceIncrementor() }}</span> + <span>iron: <b>{{ village.iron }}</b> / {{ village.getStorage(village.id).getResourceCapacity('iron') }} – {{ village.getBuilding(village.id, 'IronMine').getResourceIncrementor() }}</span> + <span>food: <b>{{ village.food }}</b> / {{ village.getStorage(village.id).getResourceCapacity('food') }} – {{ village.getBuilding(village.id, 'Farm').getResourceIncrementor() }}</span> + + <span>capacity: {{ village.getStorage(village.id).getCapacity() }}</span> + </div> + </div> + + <div class="village__events"> + <h3>Events</h3> + + {% if events['UpgradeBuilding'] %} + <h4>Upgrade Buildings</h4> + <table> + <thead> + <tr> + <th>Building</th> + <th>Time</th> + <th></th> + </tr> + </thead> + <tbody> + {% for event in events['UpgradeBuilding'] %} + <tr> + <td>{{ event.data.building }}</td> + <td class="timer"> + {% include 'components/timer.twig' with { 'time': event.event.time|date('c') } %} + </td> + <td> + <a class="btn" href="/village/{{ village.x }}/{{ village.y }}/building/{{ event.data.building }}/build/cancel"> + Cancel + </a> + </td> + </tr> + {% endfor %} + </tbody> + </table> + {% endif %} + + {% if events.train %} + <h4>Train Units</h4> + {% endif %} + + {% if events.send %} + <h4>Send Resources / Units</h4> + {% endif %} + </div> + + <div class="village__main"> + <div class="village__buildings"> + <h3>Buildings</h3> + <table> + <thead> + <tr> + <th>Type</th> + <th>Level</th> + <th>Build Time</th> + <th>Resources</th> + <th></th> + </tr> + </thead> + <tbody> + {% for building in village.getBuildings(village.id) %} + <tr class="village__buildings__row"> + <td>{{ building.type }}</td> + <td>{{ building.level }}</td> + <td>{{ building.getBuildTime() | buildTime }}</td> + <td class="resources"> + <span>wood: {{ building.getResourceRequirements()['wood'] }}</span> + + <span>clay: {{ building.getResourceRequirements()['clay'] }}</span> + + <span>iron: {{ building.getResourceRequirements()['iron'] }}</span> + </td> + <td> + <form action="/village/{{ village.x }}/{{ village.y }}/building/{{ building.type }}/level-up" method="post"> + <input type="submit" value="Level up" {{ village.canBuild(village, building) ? '' : 'disabled' }}> + </form> + </td> + </tr> + {% endfor %} + </tbody> + </table> + </div> + + <div class="village_units"> + <h3>Units</h3> + <table> + <thead> + <tr> + <th>Type</th> + <th>Amount</th> + <th>Build Time</th> + <th>Resources</th> + <th></th> + </tr> + </thead> + <tbody> + {% for unit in village.getUnits(village.id, 1) %} + <tr> + <td>{{ unit.type }}</td> + <td>{{ unit.amount }}</td> + <td> + {{ unit.getBuildTime(1) | buildTime }} + </td> + <td> + <span>wood: {{ unit.getResourceRequirements()['wood'] }}</span> + + <span>clay: {{ unit.getResourceRequirements()['clay'] }}</span> + + <span>iron: {{ unit.getResourceRequirements()['iron'] }}</span> + + <span>food: {{ unit.getResourceRequirements()['food'] ?? 0 }}</span> + </td> + <td> + <form action="/village/{{ village.x }}/{{ village.y }}/unit/{{ unit.type }}/create" method="post" class="inline"> + <input type="number" min="0" name="amount" placeholder="Amount"> + <input type="submit" value="Create"> + </form> + </td> + </tr> + {% endfor %} + </tbody> + </table> + + <h4>Supporting Units</h4> + <table> + <thead> + <tr> + <th>Type</th> + <th>Amount</th> + <th>Origin</th> + <th>Location</th> + <th></th> + </tr> + </thead> + <tbody> + {% for unit in village.getUnits(village.id, 2) | merge(village.getUnits(village.id, 3)) %} + <tr> + <td>{{ unit.type }}</td> + <td>{{ unit.amount }}</td> + <td>{{ village.get(unit.homeVillageId).name }}</td> + <td>{{ not unit.isTraveling ? village.get(unit.residenceVillageId).name : '~traveling~' }}</td> + <td> + {% if not unit.isTraveling %} + <form action="/village/{{ village.id }}/unit/{{ unit.id }}/send-back" method="post" class="inline"> + <input type="number" min="1" max="{{ unit.amount }}" name="amount" placeholder="Amount" required> + <input type="submit" value="{{ (unit.homeVillageId != unit.residenceVillageId) ? 'Send Back' : 'Recall Home' }}"> + </form> + {% endif %} + </td> + </tr> + {% endfor %} + </tbody> + </table> + </div> + </div> +</div> +{% endblock %} |