mirror of
https://github.com/yairm210/Unciv.git
synced 2025-09-23 03:23:17 -04:00
Since improvement buildings with no relevant tiles are unbuildable, we don't need to explicitly check for this in allowAutomatedConstruction
See #13831
This commit is contained in:
parent
05f549955b
commit
36e3b64bcd
@ -329,26 +329,9 @@ object Automation {
|
||||
city: City,
|
||||
construction: INonPerpetualConstruction
|
||||
): Boolean {
|
||||
return allowCreateImprovementBuildings(civInfo, city, construction)
|
||||
&& allowSpendingResource(civInfo, construction, city)
|
||||
return allowSpendingResource(civInfo, construction, city)
|
||||
}
|
||||
|
||||
@Suppress("MemberVisibilityCanBePrivate")
|
||||
/** Checks both feasibility of Buildings with a [UniqueType.CreatesOneImprovement] unique (appropriate tile available).
|
||||
* Constructions without pass uncontested. */
|
||||
@Readonly
|
||||
fun allowCreateImprovementBuildings(
|
||||
civInfo: Civilization,
|
||||
city: City,
|
||||
construction: INonPerpetualConstruction
|
||||
): Boolean {
|
||||
if (construction !is Building) return true
|
||||
if (!construction.hasCreateOneImprovementUnique()) return true // redundant but faster???
|
||||
val improvement = construction.getImprovementToCreate(city.getRuleset(), civInfo) ?: return true
|
||||
return city.getTiles().any {
|
||||
it.improvementFunctions.canBuildImprovement(improvement, city.state)
|
||||
}
|
||||
}
|
||||
|
||||
/** Determines whether the AI should be willing to spend strategic resources to build
|
||||
* [construction] for [civInfo], assumes that we are actually able to do so. */
|
||||
|
Loading…
x
Reference in New Issue
Block a user