Merge branch 'queue-sizes'
[browser-rts.git] / src / repository / city.ts
index 272ee3b960a410c018d07cc723b5620f8922da3c..c9ecb91b0aa358d96c9de6d4487087b328cd2670 100644 (file)
@@ -134,7 +134,10 @@ export class CityRepository extends Repository<City> {
         return sample.sector_id;
     }
 
-    async save(city: City) {
+    async save(city: Partial<City>) {
+      if(!city.id) {
+        throw new Error('Unknown city to save');
+      }
       const fieldsToSave = [
         'totalSpace', 'usedSpace', 'credits', 'alloys', 'energy', 'food',
         'poulation', 'soldiers', 'attackers', 'defenders', 'sp_attackers', 'sp_defenders',
@@ -206,7 +209,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);