display error when cant build something
authorxangelo <git@xangelo.ca>
Thu, 2 Jun 2022 17:52:46 +0000 (13:52 -0400)
committerxangelo <git@xangelo.ca>
Thu, 2 Jun 2022 18:27:22 +0000 (14:27 -0400)
src/render/land-development.ts
src/render/unit-training.ts
src/repository/city.ts

index 0c1fad915890fe43330a3feb61683a9a6443a117..9cd4eb7418c2f601412311bcd19176a168f4b767 100644 (file)
@@ -32,8 +32,8 @@ export function renderLandDevelopment(city: CityWithLocation, buildings: Buildin
                 <th>${building.display}</th>
                 <td>${city[building.slug]}</td>
                 <td>
-                    <form hx-post="/build">
-                        <input type="number" size="6" name="amount" hx-post="/cost/construction" hx-trigger="keyup" hx-target="#${building.slug}-cost">
+                    <form hx-post="/build" hx-swap="innerHTML" hx-target="#notifications">
+                        <input type="number" size="6" name="amount" hx-post="/cost/construction" hx-trigger="keyup" hx-target="#${building.slug}-cost" hx-swap="innerHTML">
                         <input type="hidden" name="building_type" value="${building.slug}">
                         <button type="submit">Build</button>
                     </form>
index a177dec3cbec67caf3a1a7d64a99d425ab085f56..5742d9453bf4704df05134fe07f70100e2f8a909 100644 (file)
@@ -30,8 +30,8 @@ export function renderUnitTraining(city: CityWithLocation, units: Unit[], traini
         <th>Soldiers</th>
         <td>${city.soldiers}</td>
         <td>
-            <form hx-post="/units">
-                <input type="number" name="amount" size="6" max="${city.population}" hx-trigger="keyup" hx-post="/cost/training" hx-target="#${unit.soldiers.slug}-cost">
+            <form hx-post="/units" hx-swap="innerHTML" hx-target="#notifications">
+                <input type="number" name="amount" size="6" max="${city.population}" hx-trigger="keyup" hx-post="/cost/training" hx-target="#${unit.soldiers.slug}-cost" hx-swap="innerHTML">
                 <input type="hidden" name="type" value="${unit.soldiers.slug}">
                 <button type="submit" ${city.population ? '' : 'disabled'}>Train</button>
             </form>
@@ -42,8 +42,8 @@ export function renderUnitTraining(city: CityWithLocation, units: Unit[], traini
         <th>Attackers</th>
         <td>${city.attackers}</td>
         <td>
-            <form hx-post="/units">
-                <input type="number" name="amount" size="6" max="${city.soldiers}" hx-trigger="keyup" hx-post="/cost/training" hx-target="#${unit.attackers.slug}-cost">
+            <form hx-post="/units" hx-swap="innerHTML" hx-target="#notifications">
+                <input type="number" name="amount" size="6" max="${city.soldiers}" hx-trigger="keyup" hx-post="/cost/training" hx-target="#${unit.attackers.slug}-cost" hx-swap="innerHTML">
                 <input type="hidden" name="type" value="${unit.attackers.slug}">
                 <button type="submit" ${city.soldiers ? '' : 'disabled'}>Train</button>
             </form>
@@ -54,8 +54,8 @@ export function renderUnitTraining(city: CityWithLocation, units: Unit[], traini
         <th>Defenders</th>
         <td>${city.defenders}</td>
         <td>
-            <form hx-post="/units">
-                <input type="number" name="amount" size="6" max="${city.soldiers}" hx-trigger="keyup" hx-post="/cost/training" hx-target="#${unit.defenders.slug}-cost">
+            <form hx-post="/units" hx-swap="innerHTML" hx-target="#notifications">
+                <input type="number" name="amount" size="6" max="${city.soldiers}" hx-trigger="keyup" hx-post="/cost/training" hx-target="#${unit.defenders.slug}-cost" hx-swap="innerHTML">
                 <input type="hidden" name="type" value="${unit.defenders.slug}">
                 <button type="submit" ${city.soldiers ? '' : 'disabled'}>Train</button>
             </form>
@@ -66,8 +66,8 @@ export function renderUnitTraining(city: CityWithLocation, units: Unit[], traini
         <th>Special Attackers</th>
         <td>${city.sp_attackers}</td>
         <td>
-            <form hx-post="/units">
-                <input type="number" name="amount" size="6" max="${city.attackers}" hx-trigger="keyup" hx-post="/cost/training" hx-target="#${unit.sp_attackers.slug}-cost">
+            <form hx-post="/units" hx-swap="innerHTML" hx-target="#notifications">
+                <input type="number" name="amount" size="6" max="${city.attackers}" hx-trigger="keyup" hx-post="/cost/training" hx-target="#${unit.sp_attackers.slug}-cost" hx-swap="innerHTML">
                 <input type="hidden" name="type" value="${unit.sp_attackers.slug}">
                 <button type="submit" ${city.attackers ? '': 'disabled'}>Train</button>
             </form>
@@ -79,8 +79,8 @@ export function renderUnitTraining(city: CityWithLocation, units: Unit[], traini
         <th>Special Defenders</th>
         <td>${city.sp_defenders}</td>
         <td>
-            <form hx-post="/units">
-                <input type="number" name="amount" size="6" max="${city.defenders}" hx-trigger="keyup" hx-post="/cost/training" hx-target="#${unit.sp_defenders.slug}-cost">
+            <form hx-post="/units" hx-swap="innerHTML" hx-target="#notifications">
+                <input type="number" name="amount" size="6" max="${city.defenders}" hx-trigger="keyup" hx-post="/cost/training" hx-target="#${unit.sp_defenders.slug}-cost" hx-swap="innerHTML">
                 <input type="hidden" name="type" value="${unit.sp_defenders.slug}">
                 <button type="submit" ${city.defenders ? '': 'disabled'}>Train</button>
             </form>
index 272ee3b960a410c018d07cc723b5620f8922da3c..a17d1d9696a0510ba62f1b6023c383a988e33b9a 100644 (file)
@@ -206,7 +206,7 @@ where l.sector_id = ?`, [sector_id]);
         // validate that they have enough empty construction queues
         const concurrentConstruction = await this.buildQueue.list(city.owner);
         if(concurrentConstruction.length >= city.max_construction_queue) {
-          throw new InsufficientResourceError('Training queues', concurrentConstruction.length + 1, city.max_construction_queue);
+          throw new InsufficientResourceError('Construction queues', concurrentConstruction.length + 1, city.max_construction_queue);
         }
 
         city.usedSpace += (building.land * amount);