special_attacker_trainer: number;
special_defender_trainer: number;
icon: string;
+ max_construction_queue: number;
+ max_training_queue: number;
}
export type CityWithLocation = {
barracks: 0,
special_attacker_trainer: 0,
special_defender_trainer: 0,
+ max_construction_queue: 2,
+ max_training_queue: 2,
icon
};
throw new InsufficientResourceError('energy', building.energy, city.energy);
}
+ // 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);
+ }
+
city.usedSpace += (building.land * amount);
city.credits -= (building.credits * amount);
city.alloys -= (building.alloys * amount);
throw new InsufficientResourceError('defenders', unit.defenders, city.defenders);
}
- console.log(city);
- console.log(unit, amount);
-
- // validate that they have enough of the buildings to support this
+ // validate that they have enough empty training queues
+ const concurrentTraining = await this.unitTrainigQueue.list(city.owner);
+ if(concurrentTraining.length >= city.max_training_queue) {
+ throw new InsufficientResourceError('Training queues', concurrentTraining.length + 1, city.max_training_queue);
+ }
// ok they have everything, lets update their city
// and create the entry in the training queue