diff options
author | Daniel Weipert <git@mail.dweipert.de> | 2024-01-02 20:42:01 +0100 |
---|---|---|
committer | Daniel Weipert <git@mail.dweipert.de> | 2024-01-05 12:33:59 +0100 |
commit | b21316248572cb27ed1f504529ad6680a473022e (patch) | |
tree | f8a2f81258cae3b1d2429fb7df5a3287954b683a /views/http/village.twig | |
parent | f621d95f89ded05a2e916c5ee363bfe75ea37482 (diff) |
gemini
Diffstat (limited to 'views/http/village.twig')
-rw-r--r-- | views/http/village.twig | 361 |
1 files changed, 361 insertions, 0 deletions
diff --git a/views/http/village.twig b/views/http/village.twig new file mode 100644 index 0000000..c72018c --- /dev/null +++ b/views/http/village.twig @@ -0,0 +1,361 @@ +{% extends 'base.twig' %} + +{% block main %} +<div class="village"> + + <div class="village__top"> + <div> + <span> + <a href="/map/{{ village.x }}/{{ village.y }}"> + {{ village.x }} x {{ village.y }} + </a> + </span> + — + {{ village.name }} + </div> + + <div class="resources"> + <div> + <i class="icon icon-wood"></i> + <span>{{ village.wood }} / {{ village.getStorage(village.id).getResourceCapacity('wood') }}</span> + <i class="icon icon-per-increment"></i> + <span>{{ village.getBuilding(village.id, 'WoodCutter').getResourceIncrementor() }}</span> + </div> + <div> + <i class="icon icon-clay"></i> + <span>{{ village.clay }} / {{ village.getStorage(village.id).getResourceCapacity('clay') }}</span> + <i class="icon icon-per-increment"></i> + <span>{{ village.getBuilding(village.id, 'ClayPit').getResourceIncrementor() }}</span> + </div> + <div> + <i class="icon icon-iron"></i> + <span>{{ village.iron }} / {{ village.getStorage(village.id).getResourceCapacity('iron') }}</span> + <i class="icon icon-per-increment"></i> + <span>{{ village.getBuilding(village.id, 'IronMine').getResourceIncrementor() }}</span> + </div> + <div> + <i class="icon icon-food"></i> + <span>{{ village.food }} / {{ village.getStorage(village.id).getResourceCapacity('food') }}</span> + <i class="icon icon-per-increment"></i> + <span>{{ village.getBuilding(village.id, 'Farm').getResourceIncrementor() }}</span> + </div> + + <div onclick="javascript:this.nextElementSibling.showModal()"> + <i class="icon icon-storage"></i> + <span>{{ village.getStorage(village.id).getCapacity() }}</span> + </div> + <dialog> + <button onclick="javascript:this.parentNode.close()">Close</button> + <h3 align="center">Storage Config</h3> + <form method="post" action="/village/{{ village.x }}/{{ village.y }}/storage/config"> + <label> + <i class="icon icon-wood"></i> + <input type="text" name="wood" value="{{ village.getStorageConfig(village.id).wood }}"> + </label> + <label> + <i class="icon icon-clay"></i> + <input type="text" name="clay" value="{{ village.getStorageConfig(village.id).clay }}"> + </label> + <label> + <i class="icon icon-iron"></i> + <input type="text" name="iron" value="{{ village.getStorageConfig(village.id).iron }}"> + </label> + <label> + <i class="icon icon-food"></i> + <input type="text" name="food" value="{{ village.getStorageConfig(village.id).food }}"> + </label> + <button>Save</button> + </form> + </dialog> + </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 typeEvents in events['UpgradeBuilding'] %} + {% for event in typeEvents %} + <tr> + <td>{{ event.type }}</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/UpgradeBuilding/build/cancel"> + Cancel + </a> + </td> + </tr> + {% endfor %} + {% endfor %} + </tbody> + </table> + {% endif %} + + {% if events['TrainUnits'] %} + <h4>Train Units</h4> + <table> + <thead> + <tr> + <th>Unit</th> + <th>Time</th> + <th></th> + </tr> + </thead> + <tbody> + {% for event in events['TrainUnits'] %} + <tr> + <td>{{ event.type }}</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 }}/unit/train/cancel"> + Cancel + </a> + </td> + </tr> + {% endfor %} + </tbody> + </table> + {% endif %} + + {% if events['SendUnits'] %} + <h4>Send Resources / Units</h4> + <table> + <thead> + <tr> + <th>Type</th> + <th>Unit</th> + <th>Amount</th> + <th>Origin</th> + <th>Destination</th> + <th>Time</th> + <th></th> + </tr> + </thead> + <tbody> + {% for event in events['SendUnits'] %} + <tr> + <td>{{ event.type }}</td> + <td>{{ event.unit }}</td> + <td>{{ event.amount }}</td> + <td>{{ village.get(event.source).name }}</td> + <td>{{ village.get(event.destination).name }}</td> + <td class="timer"> + {% include 'components/timer.twig' with { 'time': event.event.time|date('c') } %} + </td> + <td> + {% if event.isCanceled %} + Canceled + {% else %} + {% if event.event.villageId == village.id %} + <form action="/event/{{ event.event.id }}/cancel" method="post"> + <input type="submit" value="Cancel"> + </form> + {% endif %} + {% endif %} + </td> + </tr> + {% endfor %} + </tbody> + </table> + {% 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 buildings %} + <tr class="village__buildings__row"> + <td>{{ building.type | default(type) }}</td> + <td>{{ building.level | default(0) }}</td> + <td>{{ building.getBuildTimeForLevel(building.getEffectiveLevel() + 1) | buildTime }}</td> + <td class="resources"> + <span> + <i class="icon icon-wood"></i> + {{ building.getResourceRequirementsForLevel(building.getEffectiveLevel() + 1)['wood'] }} + </span> + + <span> + <i class="icon icon-clay"></i> + {{ building.getResourceRequirementsForLevel(building.getEffectiveLevel() + 1)['clay'] }} + </span> + + <span> + <i class="icon icon-iron"></i> + {{ building.getResourceRequirementsForLevel(building.getEffectiveLevel() + 1)['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></th> + <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, 3) %} + <tr> + <td><i class="icon icon-{{ unit.type|lower }}"></i></td> + <td>{{ unit.type }}</td> + <td>{{ unit.amount }}</td> + {% if not unit.isTraveling %} + <td> + {{ unit.getBuildTime(1) | buildTime }} + </td> + <td> + <span> + <i class="icon icon-wood"></i> + {{ unit.getResourceRequirements(unit, 1)['wood'] }} + </span> + + <span> + <i class="icon icon-clay"></i> + {{ unit.getResourceRequirements(unit, 1)['clay'] }} + </span> + + <span> + <i class="icon icon-iron"></i> + {{ unit.getResourceRequirements(unit, 1)['iron'] }} + </span> + + <span> + <i class="icon icon-food"></i> + {{ unit.getResourceRequirements(unit, 1)['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="Train" {{ village.canTrain(village, unit, 1) ? '' : 'disabled' }}> + </form> + </td> + {% else %} + <td>~traveling~</td> + {% endif %} + </tr> + {% endfor %} + </tbody> + </table> + + <h4>Supporting Units</h4> + <table> + <thead> + <tr> + <th></th> + <th>Type</th> + <th>Amount</th> + <th>Origin</th> + <th>Location</th> + <th>Travel Time</th> + <th></th> + </tr> + </thead> + <tbody> + {% for unit in village.getUnits(village.id, 2) | merge(village.getUnits(village.id, 3)) %} + <tr> + <td><i class="icon icon-{{ unit.type|lower }}"></i></td> + <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>{{ unit.getTravelTime(unit, village.getDistance(unit.getHomeVillage().x, unit.getHomeVillage().x, unit.getResidenceVillage().x, unit.getResidenceVillage().y)) | buildTime }}</td> + <td> + {% if not unit.isTraveling %} + {% if unit.homeVillageId == village.id %} + <form action="/village/{{ village.x }}/{{ village.y }}/unit/{{ unit.type }}/location/{{ unit.getResidenceVillage().x }}/{{ unit.getResidenceVillage().y }}/recall" method="post"> + <input type="number" min="1" max="{{ unit.amount }}" name="amount" placeholder="Amount" required> + <input type="submit" value="Recall Home"> + </form> + {% else %} + <form action="/village/{{ village.x }}/{{ village.y }}/unit/{{ unit.type }}/location/{{ unit.getHomeVillage().x }}/{{ unit.getHomeVillage().y }}/send-back" method="post"> + <input type="number" min="1" max="{{ unit.amount }}" name="amount" placeholder="Amount" required> + <input type="submit" value="Send Back"> + </form> + {% endif %} + {% endif %} + </td> + </tr> + {% endfor %} + </tbody> + </table> + + <h4>Send Units</h4> + <form action="/village/{{ village.x }}/{{ village.y }}/send-units" method="post"> + <select name="unit"> + {% for unit in village.getUnits(village.id, 1) %} + <option>{{ unit.type }}</option> + {% endfor %} + </select> + <input type="number" min="1" name="amount" placeholder="Amount" required> + <select name="village"> + {% for v in villages %} + <option value="{{ v.id }}">{{ v.name }}</option> + {% endfor %} + </select> + <select name="type"> + <option>Borrow</option> + <option>Gift</option> + </select> + <button>Send</button> + </form> + </div> + + {% if village.getBuilding(village.id, 'Marketplace') %} + <h3>Send Resources</h3> + <form action="/village/{{ village.x }}/{{ village.y }}/send-resources" method="post"> + <input type="number" min="1" name="wood" placeholder="Amount Wood" required> + <input type="number" min="1" name="clay" placeholder="Amount Clay" required> + <input type="number" min="1" name="iron" placeholder="Amount Iron" required> + <input type="number" min="1" name="food" placeholder="Amount Food" required> + <select name="village"> + {% for v in villages %} + <option value="{{ v.id }}">{{ v.name }}</option> + {% endfor %} + </select> + <button>Send</button> + </form> + {% endif %} + </div> +</div> +{% endblock %} |