mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-19 04:10:22 +07:00
AI no longer purchases non-contiguous tiles
This commit is contained in:
@ -391,6 +391,7 @@ object NextTurnAutomation {
|
|||||||
bfs.stepUntilDestination(highlyDesirableTile.key)
|
bfs.stepUntilDestination(highlyDesirableTile.key)
|
||||||
val tilesThatNeedBuying =
|
val tilesThatNeedBuying =
|
||||||
bfs.getPathTo(highlyDesirableTile.key).filter { it.getOwner() != civInfo }
|
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
|
// 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
|
// way how tile acquisition cost is calculated. Everytime you buy a tile, the next one
|
||||||
|
@ -68,6 +68,10 @@ class CityExpansionManager : IsPartOfGameInfoSerialization {
|
|||||||
fun buyTile(tile: Tile) {
|
fun buyTile(tile: Tile) {
|
||||||
val goldCost = getGoldCostOfTile(tile)
|
val goldCost = getGoldCostOfTile(tile)
|
||||||
|
|
||||||
|
class TriedToBuyNonContiguousTileException:Exception()
|
||||||
|
if (tile.neighbors.none { it.getCity() == city })
|
||||||
|
throw TriedToBuyNonContiguousTileException()
|
||||||
|
|
||||||
class NotEnoughGoldToBuyTileException : Exception()
|
class NotEnoughGoldToBuyTileException : Exception()
|
||||||
if (city.civ.gold < goldCost && !city.civ.gameInfo.gameParameters.godMode)
|
if (city.civ.gold < goldCost && !city.civ.gameInfo.gameParameters.godMode)
|
||||||
throw NotEnoughGoldToBuyTileException()
|
throw NotEnoughGoldToBuyTileException()
|
||||||
|
Reference in New Issue
Block a user