@@ -373,15 +373,12 @@ class CityConstructions : IsPartOfGameInfoSerialization {
373
373
val construction = getConstruction(constructionName)
374
374
// First construction will be built next turn, we need to make sure it has the correct resources
375
375
if (constructionQueue.isEmpty() && getWorkDone(constructionName) == 0 ) {
376
- val costUniques = construction.getMatchingUniquesNotConflicting(UniqueType .CostsResources ,
377
- city.state
378
- )
376
+ val stockpileCosts = construction.getStockpiledResourceRequirements(city.state)
379
377
val civResources = city.civ.getCivResourcesByName()
380
378
381
- if (costUniques.any {
382
- val resourceName = it.params[1 ]
379
+ if (stockpileCosts.any { (resourceName, amount) ->
383
380
civResources[resourceName] == null
384
- || it.params[ 0 ].toInt() > civResources[resourceName]!! })
381
+ || amount > civResources[resourceName]!! })
385
382
continue // Removes this construction from the queue
386
383
}
387
384
if (construction.isBuildable(this ))
@@ -431,11 +428,7 @@ class CityConstructions : IsPartOfGameInfoSerialization {
431
428
}
432
429
433
430
private fun constructionBegun (construction : IConstruction ) {
434
- val costUniques = construction.getMatchingUniquesNotConflicting(UniqueType .CostsResources , city.state)
435
-
436
- for (unique in costUniques) {
437
- val amount = unique.params[0 ].toInt()
438
- val resourceName = unique.params[1 ]
431
+ for ((resourceName, amount) in construction.getStockpiledResourceRequirements(city.state)) {
439
432
val resource = city.civ.gameInfo.ruleset.tileResources[resourceName] ? : continue
440
433
city.gainStockpiledResource(resource, - amount)
441
434
}
@@ -735,11 +728,7 @@ class CityConstructions : IsPartOfGameInfoSerialization {
735
728
736
729
// Consume stockpiled resources - usually consumed when construction starts, but not when bought
737
730
if (getWorkDone(construction.name) == 0 ){ // we didn't pay the resources when we started building
738
- val costUniques = construction.getMatchingUniques(UniqueType .CostsResources , conditionalState)
739
-
740
- for (unique in costUniques) {
741
- val amount = unique.params[0 ].toInt()
742
- val resourceName = unique.params[1 ]
731
+ for ((resourceName, amount) in construction.getStockpiledResourceRequirements(conditionalState)) {
743
732
val resource = city.civ.gameInfo.ruleset.tileResources[resourceName] ? : continue
744
733
city.gainStockpiledResource(resource, - amount)
745
734
}
0 commit comments