Disable auto building of forts while a human can do that (#2436)

* Automate building forts for AI players only

* Using constants
This commit is contained in:
Jack Rainy 2020-04-16 20:39:05 +03:00 committed by GitHub
parent 248d7b5aa6
commit 31134d0fe5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 4 deletions

View file

@ -47,6 +47,9 @@ object Constants {
const val random = "Random"
val greatImprovements = listOf("Academy", "Landmark", "Manufactory", "Customs house", "Citadel")
const val fort = "Fort"
const val citadel = "Citadel"
const val unitActionSetUp = "Set Up"
const val unitActionSleep = "Sleep"
const val unitActionSleepUntilHealed = "Sleep until healed"

View file

@ -194,7 +194,8 @@ class WorkerAutomation(val unit: MapUnit) {
tile.containsUnfinishedGreatImprovement() -> null
// Defence is more important that civilian improvements
evaluateFortPlacement(tile,civInfo) -> "Fort"
// While AI sucks in strategical placement of forts, allow a human does it manually
!civInfo.isPlayerCivilization() && evaluateFortPlacement(tile,civInfo) -> Constants.fort
// I think we can assume that the unique improvement is better
uniqueImprovement!=null && tile.canBuildImprovement(uniqueImprovement,civInfo) -> uniqueImprovement.name
@ -228,7 +229,7 @@ class WorkerAutomation(val unit: MapUnit) {
// don't build fort in the city
if (tile.isCityCenter()) return false
// don't build fort if it is already here
if (tile.improvement == "Fort") return false
if (tile.improvement == Constants.fort) return false
// don't build on resource tiles
if (tile.hasViewableResource(civInfo)) return false
// don't build on great improvements
@ -249,8 +250,8 @@ class WorkerAutomation(val unit: MapUnit) {
// don't build forts too close to the cities
if (closeTile.isCityCenter()) return false
// don't build forts too close to other forts
if (closeTile.improvement == "Fort" || closeTile.improvement == "Citadel"
|| closeTile.improvementInProgress == "Fort") return false
if (closeTile.improvement == Constants.fort || closeTile.improvement == Constants.citadel
|| closeTile.improvementInProgress == Constants.fort) return false
// there is another better tile for the fort
if (!isHills && tile.getBaseTerrain().name == Constants.hill &&
isAcceptableTileForFort(closeTile, civInfo)) return false