new buildings: mining! increase alloy + max alloy cap
[browser-rts.git] / src / render / unit-training.ts
index dfbbb1bc40fee300ca5c66558f9e9059c8e65db0..0214bfe301402ff31de4ad328a4a1c5cd9b5ac54 100644 (file)
@@ -1,5 +1,5 @@
 import _ from "lodash";
-import { City } from "../repository/city";
+import { CityWithLocation } from "../repository/city";
 import { UnitTrainingQueue } from "../repository/training-queue";
 import { Unit } from "../repository/unit";
 
@@ -13,7 +13,7 @@ function progressBar(current, max): string {
     `;
 }
 
-export function renderUnitTraining(city: City, units: Unit[], trainingQueues: UnitTrainingQueue[]): string {
+export function renderUnitTraining(city: CityWithLocation, units: Unit[], trainingQueues: UnitTrainingQueue[]): string {
     const unit = _.keyBy(units, 'slug');
     let html = `
     <div hx-trigger="reload-unit-training, every 600s" hx-get="/poll/unit-training">
@@ -23,18 +23,19 @@ export function renderUnitTraining(city: City, units: Unit[], trainingQueues: Un
         <th>Unit</th>
         <th>Avail.</td>
         <th></th>
+        <th width="200">Cost</th>
     </tr>
     <tr>
         <th>Soldiers</th>
         <td>${city.population}</td>
         <td>
             <form hx-post="/units">
-                <input type="number" name="amount" size="6" max="${city.population}" hx-trigger="change" hx-post="/cost/training" hx-target="#${unit.soldiers.slug}-cost">
+                <input type="number" name="amount" size="6" max="${city.population}" hx-trigger="keyup" hx-post="/cost/training" hx-target="#${unit.soldiers.slug}-cost">
                 <input type="hidden" name="type" value="${unit.soldiers.slug}">
                 <button type="submit" ${city.population ? '' : 'disabled'}>Train</button>
             </form>
-            <span id="${unit.soldiers.slug}-cost"></span>
         </td>
+        <td id="${unit.soldiers.slug}-cost"></span>
     </tr>
     <tr>
         <th>Attackers</th>
@@ -45,8 +46,8 @@ export function renderUnitTraining(city: City, units: Unit[], trainingQueues: Un
                 <input type="hidden" name="type" value="${unit.attackers.slug}">
                 <button type="submit" ${city.soldiers ? '' : 'disabled'}>Train</button>
             </form>
-            <span id="${unit.attackers.slug}-cost"></span>
         </td>
+        <td id="${unit.attackers.slug}-cost"></span>
     </tr>
     <tr>
         <th>Defenders</th>
@@ -57,8 +58,8 @@ export function renderUnitTraining(city: City, units: Unit[], trainingQueues: Un
                 <input type="hidden" name="type" value="${unit.defenders.slug}">
                 <button type="submit" ${city.soldiers ? '' : 'disabled'}>Train</button>
             </form>
-            <span id="${unit.defenders.slug}-cost"></span>
         </td>
+        <td id="${unit.defenders.slug}-cost"></td>
     </tr>
     <tr>
         <th>Special Attackers</th>
@@ -71,6 +72,7 @@ export function renderUnitTraining(city: City, units: Unit[], trainingQueues: Un
             </form>
             <span id="${unit.sp_attackers.slug}-cost"></span>
         </td>
+        <td id="${unit.sp_attackers.slug}-cost"></td>
     </tr>
     <tr>
         <th>Special Defenders</th>
@@ -81,8 +83,8 @@ export function renderUnitTraining(city: City, units: Unit[], trainingQueues: Un
                 <input type="hidden" name="type" value="${unit.sp_defenders.slug}">
                 <button type="submit" ${city.defenders ? '': 'disabled'}>Train</button>
             </form>
-            <span id="${unit.sp_defenders.slug}-cost"></span>
         </td>
+        <td id="${unit.sp_defenders.slug}-cost"></td>
         </tr>
     </table>
     `;
@@ -115,4 +117,4 @@ export function renderUnitTraining(city: City, units: Unit[], trainingQueues: Un
     `;
 
     return html + queues;
-}
\ No newline at end of file
+}