AI no longer purchases non-contiguous tiles

This commit is contained in:
Yair Morgenstern 2023-06-26 23:07:53 +03:00
parent 0536c5f24b
commit a6e4b72cf4
2 changed files with 5 additions and 0 deletions

View File

@ -391,6 +391,7 @@ object NextTurnAutomation {
bfs.stepUntilDestination(highlyDesirableTile.key)
val tilesThatNeedBuying =
bfs.getPathTo(highlyDesirableTile.key).filter { it.getOwner() != civInfo }
.toList().reversed() // getPathTo is from destination to source
// We're trying to acquire everything and revert if it fails, because of the difficult
// way how tile acquisition cost is calculated. Everytime you buy a tile, the next one

View File

@ -68,6 +68,10 @@ class CityExpansionManager : IsPartOfGameInfoSerialization {
fun buyTile(tile: Tile) {
val goldCost = getGoldCostOfTile(tile)
class TriedToBuyNonContiguousTileException:Exception()
if (tile.neighbors.none { it.getCity() == city })
throw TriedToBuyNonContiguousTileException()
class NotEnoughGoldToBuyTileException : Exception()
if (city.civ.gold < goldCost && !city.civ.gameInfo.gameParameters.godMode)
throw NotEnoughGoldToBuyTileException()