diff options
Diffstat (limited to 'views')
-rw-r--r-- | views/http/account.twig | 22 | ||||
-rw-r--r-- | views/http/base.twig | 7 | ||||
-rw-r--r-- | views/http/components/timer.twig | 6 | ||||
-rw-r--r-- | views/http/map.twig | 12 | ||||
-rw-r--r-- | views/http/village.twig | 88 |
5 files changed, 118 insertions, 17 deletions
diff --git a/views/http/account.twig b/views/http/account.twig new file mode 100644 index 0000000..8b32feb --- /dev/null +++ b/views/http/account.twig @@ -0,0 +1,22 @@ +{% extends 'base.twig' %} + +{% block main %} +<h1>Account</h1> + +<form action="/account" method="post"> + <label> + Username + <input type="text" name="username" value="{{ user.username }}"> + </label> + <label> + E-Mail + <input type="email" name="email" value="{{ user.email }}"> + </label> + <label> + Password + <input type="password" name="password"> + </label> + + <input type="submit" value="Save"> +</form> +{% endblock %} diff --git a/views/http/base.twig b/views/http/base.twig index 15ddafd..bd59207 100644 --- a/views/http/base.twig +++ b/views/http/base.twig @@ -5,7 +5,12 @@ <header> <nav> <a href="/villages">Overview</a> - <a href="/logout">Logout</a> + {% if session.user %} + <a href="/account">Account</a> + <a href="/logout">Logout</a> + {% else %} + <a href="/login">Login</a> + {% endif %} </nav> <span>Logged in as {{ session.user.username }}</span> </header> diff --git a/views/http/components/timer.twig b/views/http/components/timer.twig index ccb31a7..4898a2e 100644 --- a/views/http/components/timer.twig +++ b/views/http/components/timer.twig @@ -14,12 +14,18 @@ document.addEventListener('DOMContentLoaded', function (ev) { window.location.reload(); } + const dd = Math.floor(diff/1000/60/60/24); + diff -= dd*1000*60*60*24; const hh = Math.floor(diff/1000/60/60); diff -= hh*1000*60*60; const mm = Math.floor(diff/1000/60); diff -= mm*1000*60; const ss = Math.floor(diff/1000); + timer.innerHTML = `${('00' + hh).slice(-2)}:${('00' + mm).slice(-2)}:${('00' + ss).slice(-2)}`; + if (dd > 0) { + timer.innerHTML = `${('00' + dd).slice(-2)}:${timer.innerHTML}`; + } } setTime(); }); diff --git a/views/http/map.twig b/views/http/map.twig index 29f0294..a05fea2 100644 --- a/views/http/map.twig +++ b/views/http/map.twig @@ -3,13 +3,13 @@ {% block main %} <div class="map"> <div class="map__up"> - <a href="/map/{{ x }}/{{ y - 1 }}"> + <a href="/map/{{ x }}/{{ y - 1 }}/{{ range }}"> <i class="icon icon-arrow-up"></i> </a> </div> <div> <div class="map__left"> - <a href="/map/{{ x - 1 }}/{{ y }}"> + <a href="/map/{{ x - 1 }}/{{ y }}/{{ range }}"> <i class="icon icon-arrow-left"></i> </a> </div> @@ -17,7 +17,9 @@ {% for row in range(-range, range) %} {% for column in range(-range, range) %} {% set village = map[x + column][y + row] %} - <div class="map__village"> + <div class="map__village {% if row == 0 and column == 0 %}map__village--center{% endif %}"> + <!-- TODO: add link to center on tile in top left --> + <a class="center-anchor" title="move to center" href="/map/{{ x + column }}/{{ y + row }}/{{ range }}">c</a> {% if village %} <a href="/village/{{ village.x }}/{{ village.y }}"> {{ map[x + column][y + row].name }} @@ -28,13 +30,13 @@ {% endfor %} </div> <div class="map__right"> - <a href="/map/{{ x + 1 }}/{{ y }}"> + <a href="/map/{{ x + 1 }}/{{ y }}/{{ range }}"> <i class="icon icon-arrow-right"></i> </a> </div> </div> <div class="map__down"> - <a href="/map/{{ x }}/{{ y + 1 }}"> + <a href="/map/{{ x }}/{{ y + 1 }}/{{ range }}"> <i class="icon icon-arrow-down"></i> </a> </div> diff --git a/views/http/village.twig b/views/http/village.twig index c157a04..48bb16d 100644 --- a/views/http/village.twig +++ b/views/http/village.twig @@ -92,9 +92,11 @@ {% 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> + {% if event.event.villageId == village.id %} + <form action="/event/{{ event.event.id }}/cancel" method="post"> + <input type="submit" value="Cancel"> + </form> + {% endif %} </td> </tr> {% endfor %} @@ -121,9 +123,11 @@ {% 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> + {% if event.event.villageId == village.id %} + <form action="/event/{{ event.event.id }}/cancel" method="post"> + <input type="submit" value="Cancel"> + </form> + {% endif %} </td> </tr> {% endfor %} @@ -132,7 +136,7 @@ {% endif %} {% if events['SendUnits'] %} - <h4>Send Resources / Units</h4> + <h4>Send Units</h4> <table> <thead> <tr> @@ -172,6 +176,68 @@ </tbody> </table> {% endif %} + + {% if events['SendResources'] %} + <h4>Send Resources</h4> + <table> + <thead> + <tr> + <th>Source</th> + <th>Destination</th> + <th>Resources</th> + <th>Time</th> + <th></th> + </tr> + </thead> + <tbody> + {% for event in events['SendResources'] %} + <tr> + <td>{{ village.get(event.source).name }}</td> + <td>{{ village.get(event.destination).name }}</td> + <td>Resources</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 %} + + {% if events['SendResourcesCarriers'] %} + <h4>Send Resources Carriers</h4> + <table> + <thead> + <tr> + <th>Source</th> + <th>Destination</th> + <th>Time</th> + </tr> + </thead> + <tbody> + {% for event in events['SendResourcesCarriers'] %} + <tr> + <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> + </tr> + {% endfor %} + </tbody> + </table> + {% endif %} </div> <div class="village__main"> @@ -344,10 +410,10 @@ {% if village.getBuilding(village.id, 'PostOffice') %} <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> + <input type="number" min="0" name="wood" placeholder="Amount Wood" required> + <input type="number" min="0" name="clay" placeholder="Amount Clay" required> + <input type="number" min="0" name="iron" placeholder="Amount Iron" required> + <input type="number" min="0" name="food" placeholder="Amount Food" required> <select name="village"> {% for v in villages %} <option value="{{ v.id }}">{{ v.name }}</option> |