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
// ok they have everything, lets update their city
city.credits -= unit.credits * amount;
city.food -= unit.food * amount;
- city.population -= coalesce(unit.population, 0) * amount;
- city.soldiers -= coalesce(unit.soldiers, 0) * amount;
- city.attackers -= coalesce(unit.attackers, 0) * amount;
- city.defenders -= coalesce(unit.defenders, 0) * amount;
+ city.population -= unit.population * amount;
+ city.soldiers -= unit.soldiers * amount;
+ city.attackers -= unit.attackers * amount;
+ city.defenders -= unit.defenders * amount;
+
+ console.log(city);
await this.save(city);