highlight if you have sufficient resources for construction/training
[browser-rts.git] / src / api.ts
index 0c37379dcb91d42cf8c0dbc1700cacfab07080dd..903c2358b153934f557b08bcb96f3fffeb6b2fd3 100644 (file)
@@ -198,6 +198,9 @@ server.post<{
                building_type: string
        }
 }, string>('/cost/construction', async req => {
+       const account = await accountRepo.validate(req.authInfo.accountId, req.authInfo.token);
+       const city = await cityRepo.getUsersCity(account.id);
+
        const amount = parseInt(req.body.amount.trim(), 10);
 
        if(isNaN(amount) || amount < 1) {
@@ -217,7 +220,7 @@ server.post<{
                time: building.time
   };
 
-  return renderCost(cost);
+  return renderCost(cost, city);
 });
 
 server.post<{
@@ -226,6 +229,8 @@ server.post<{
                type: string;
        }
 }, string>('/cost/training', async req => {
+       const account = await accountRepo.validate(req.authInfo.accountId, req.authInfo.token);
+       const city = await cityRepo.getUsersCity(account.id);
        const amount = parseInt(req.body.amount, 10);
 
        if(isNaN(amount) || amount < 1) {
@@ -245,7 +250,7 @@ server.post<{
                credits: unit.credits * amount,
                food: unit.food * amount,
     time: unit.time * amount
-       });
+       }, city);
 });
 
 server.post<{