mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-19 20:28:56 +07:00
Resolved #12488 - don't reject constructions for missing stockpiled resource costs, AFTER you've already paid them
This commit is contained in:
@ -398,13 +398,15 @@ class Building : RulesetStatsObject(), INonPerpetualConstruction {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (unique in getMatchingUniques(UniqueType.CostsResources, stateForConditionals)) {
|
// If we've already paid the unit costs, we don't need to pay it again
|
||||||
val amount = unique.params[0].toInt()
|
if (cityConstructions.getWorkDone(name) == 0)
|
||||||
val resourceName = unique.params[1]
|
for (unique in getMatchingUniques(UniqueType.CostsResources, stateForConditionals)) {
|
||||||
val availableResources = cityConstructions.city.getAvailableResourceAmount(resourceName)
|
val amount = unique.params[0].toInt()
|
||||||
if (availableResources < amount)
|
val resourceName = unique.params[1]
|
||||||
yield(RejectionReasonType.ConsumesResources.toInstance(resourceName.getNeedMoreAmountString(amount - availableResources)))
|
val availableResources = cityConstructions.city.getAvailableResourceAmount(resourceName)
|
||||||
}
|
if (availableResources < amount)
|
||||||
|
yield(RejectionReasonType.ConsumesResources.toInstance(resourceName.getNeedMoreAmountString(amount - availableResources)))
|
||||||
|
}
|
||||||
|
|
||||||
if (requiredNearbyImprovedResources != null) {
|
if (requiredNearbyImprovedResources != null) {
|
||||||
val containsResourceWithImprovement = cityConstructions.city.getWorkableTiles()
|
val containsResourceWithImprovement = cityConstructions.city.getWorkableTiles()
|
||||||
|
@ -191,7 +191,8 @@ enum class UniqueType(
|
|||||||
//todo should these two be merged to avoid the confusion?
|
//todo should these two be merged to avoid the confusion?
|
||||||
/** @see UnitActionStockpileCost */
|
/** @see UnitActionStockpileCost */
|
||||||
CostsResources("Costs [amount] [stockpiledResource]", UniqueTarget.Improvement, UniqueTarget.Building, UniqueTarget.Unit,
|
CostsResources("Costs [amount] [stockpiledResource]", UniqueTarget.Improvement, UniqueTarget.Building, UniqueTarget.Unit,
|
||||||
docDescription = "Do not confuse with \"costs [amount] [stockpiledResource]\" (lowercase 'c'), the Unit Action Modifier."),
|
docDescription = "These resources are removed *when work begins* on the construction. " +
|
||||||
|
"Do not confuse with \"costs [amount] [stockpiledResource]\" (lowercase 'c'), the Unit Action Modifier."),
|
||||||
// Todo: Get rid of forced sign (+[relativeAmount]) and unify these two, e.g.: "[relativeAmount]% [resource/resourceType] production"
|
// Todo: Get rid of forced sign (+[relativeAmount]) and unify these two, e.g.: "[relativeAmount]% [resource/resourceType] production"
|
||||||
// Note that the parameter type 'resourceType' (strategic, luxury, bonus) currently doesn't exist and should then be added as well
|
// Note that the parameter type 'resourceType' (strategic, luxury, bonus) currently doesn't exist and should then be added as well
|
||||||
StrategicResourcesIncrease("Quantity of strategic resources produced by the empire +[relativeAmount]%", UniqueTarget.Global), // used by Policies
|
StrategicResourcesIncrease("Quantity of strategic resources produced by the empire +[relativeAmount]%", UniqueTarget.Global), // used by Policies
|
||||||
|
@ -258,13 +258,15 @@ class BaseUnit : RulesetObject(), INonPerpetualConstruction {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (unique in getMatchingUniques(UniqueType.CostsResources, stateForConditionals)) {
|
// If we've already paid the unit costs, we don't need to pay it again
|
||||||
val amount = unique.params[0].toInt()
|
if (city == null || city.cityConstructions.getWorkDone(name) == 0)
|
||||||
val resourceName = unique.params[1]
|
for (unique in getMatchingUniques(UniqueType.CostsResources, stateForConditionals)) {
|
||||||
val availableResources = city?.getAvailableResourceAmount(resourceName) ?: civ.getResourceAmount(resourceName)
|
val amount = unique.params[0].toInt()
|
||||||
if (availableResources < amount)
|
val resourceName = unique.params[1]
|
||||||
yield(RejectionReasonType.ConsumesResources.toInstance(resourceName.getNeedMoreAmountString(amount - availableResources)))
|
val availableResources = city?.getAvailableResourceAmount(resourceName) ?: civ.getResourceAmount(resourceName)
|
||||||
}
|
if (availableResources < amount)
|
||||||
|
yield(RejectionReasonType.ConsumesResources.toInstance(resourceName.getNeedMoreAmountString(amount - availableResources)))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (unique in civ.getMatchingUniques(UniqueType.CannotBuildUnits, stateForConditionals))
|
for (unique in civ.getMatchingUniques(UniqueType.CannotBuildUnits, stateForConditionals))
|
||||||
|
Reference in New Issue
Block a user