mirror of
https://github.com/yairm210/Unciv.git
synced 2024-12-22 23:44:24 +07:00
Resolved #12488 - don't reject constructions for missing stockpiled resource costs, AFTER you've already paid them
This commit is contained in:
parent
f5b0727732
commit
0655cc63a4
@ -398,13 +398,15 @@ class Building : RulesetStatsObject(), INonPerpetualConstruction {
|
||||
}
|
||||
}
|
||||
|
||||
for (unique in getMatchingUniques(UniqueType.CostsResources, stateForConditionals)) {
|
||||
val amount = unique.params[0].toInt()
|
||||
val resourceName = unique.params[1]
|
||||
val availableResources = cityConstructions.city.getAvailableResourceAmount(resourceName)
|
||||
if (availableResources < amount)
|
||||
yield(RejectionReasonType.ConsumesResources.toInstance(resourceName.getNeedMoreAmountString(amount - availableResources)))
|
||||
}
|
||||
// If we've already paid the unit costs, we don't need to pay it again
|
||||
if (cityConstructions.getWorkDone(name) == 0)
|
||||
for (unique in getMatchingUniques(UniqueType.CostsResources, stateForConditionals)) {
|
||||
val amount = unique.params[0].toInt()
|
||||
val resourceName = unique.params[1]
|
||||
val availableResources = cityConstructions.city.getAvailableResourceAmount(resourceName)
|
||||
if (availableResources < amount)
|
||||
yield(RejectionReasonType.ConsumesResources.toInstance(resourceName.getNeedMoreAmountString(amount - availableResources)))
|
||||
}
|
||||
|
||||
if (requiredNearbyImprovedResources != null) {
|
||||
val containsResourceWithImprovement = cityConstructions.city.getWorkableTiles()
|
||||
|
@ -191,7 +191,8 @@ enum class UniqueType(
|
||||
//todo should these two be merged to avoid the confusion?
|
||||
/** @see UnitActionStockpileCost */
|
||||
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"
|
||||
// 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
|
||||
|
@ -258,13 +258,15 @@ class BaseUnit : RulesetObject(), INonPerpetualConstruction {
|
||||
}
|
||||
}
|
||||
|
||||
for (unique in getMatchingUniques(UniqueType.CostsResources, stateForConditionals)) {
|
||||
val amount = unique.params[0].toInt()
|
||||
val resourceName = unique.params[1]
|
||||
val availableResources = city?.getAvailableResourceAmount(resourceName) ?: civ.getResourceAmount(resourceName)
|
||||
if (availableResources < amount)
|
||||
yield(RejectionReasonType.ConsumesResources.toInstance(resourceName.getNeedMoreAmountString(amount - availableResources)))
|
||||
}
|
||||
// If we've already paid the unit costs, we don't need to pay it again
|
||||
if (city == null || city.cityConstructions.getWorkDone(name) == 0)
|
||||
for (unique in getMatchingUniques(UniqueType.CostsResources, stateForConditionals)) {
|
||||
val amount = unique.params[0].toInt()
|
||||
val resourceName = unique.params[1]
|
||||
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))
|
||||
|
Loading…
Reference in New Issue
Block a user