From 7958c795ddbce539b45556077127f05255506596 Mon Sep 17 00:00:00 2001 From: Yair Morgenstern Date: Wed, 19 Jun 2019 20:22:38 +0300 Subject: [PATCH] Fixed Coast start bias --- core/src/com/unciv/Constants.kt | 1 + core/src/com/unciv/GameStarter.kt | 1 + core/src/com/unciv/logic/GameInfo.kt | 2 +- core/src/com/unciv/logic/automation/SpecificUnitAutomation.kt | 3 ++- core/src/com/unciv/logic/map/RandomMapGenerator.kt | 4 ++-- core/src/com/unciv/logic/map/TileInfo.kt | 2 +- core/src/com/unciv/logic/map/UnitMovementAlgorithms.kt | 2 +- core/src/com/unciv/models/gamebasics/Building.kt | 4 ++-- core/src/com/unciv/models/gamebasics/unit/BaseUnit.kt | 2 +- 9 files changed, 12 insertions(+), 9 deletions(-) diff --git a/core/src/com/unciv/Constants.kt b/core/src/com/unciv/Constants.kt index 3b89fe43..00a1b7f5 100644 --- a/core/src/com/unciv/Constants.kt +++ b/core/src/com/unciv/Constants.kt @@ -9,6 +9,7 @@ class Constants{ const val forest = "Forest" const val jungle = "Jungle" const val hill = "Hill" + const val coast = "Coast" const val peaceTreaty = "Peace Treaty" const val barbarianEncampment = "Barbarian encampment" const val ancientRuins = "Ancient ruins" diff --git a/core/src/com/unciv/GameStarter.kt b/core/src/com/unciv/GameStarter.kt index 6d403f81..fb4fd939 100644 --- a/core/src/com/unciv/GameStarter.kt +++ b/core/src/com/unciv/GameStarter.kt @@ -116,6 +116,7 @@ class GameStarter{ val tileToAvoid = startBias.removePrefix("Avoid ") preferredTiles = preferredTiles.filter { it.baseTerrain != tileToAvoid && it.terrainFeature != tileToAvoid} } + else if(startBias==Constants.coast) preferredTiles = preferredTiles.filter { it.neighbors.any { n -> n.baseTerrain==startBias } } else preferredTiles = preferredTiles.filter { it.baseTerrain == startBias || it.terrainFeature==startBias } } val randomLocation = if(preferredTiles.isNotEmpty()) preferredTiles.random() else freeTiles.random() diff --git a/core/src/com/unciv/logic/GameInfo.kt b/core/src/com/unciv/logic/GameInfo.kt index fc54b310..e768870c 100644 --- a/core/src/com/unciv/logic/GameInfo.kt +++ b/core/src/com/unciv/logic/GameInfo.kt @@ -157,7 +157,7 @@ class GameInfo { val unit:String if (unitList.isEmpty()) unit="Warrior" - else if(waterUnits.isNotEmpty() && tileToPlace.neighbors.any{ it.baseTerrain=="Coast" } && Random().nextBoolean()) + else if(waterUnits.isNotEmpty() && tileToPlace.neighbors.any{ it.baseTerrain==Constants.coast } && Random().nextBoolean()) unit=waterUnits.random().name else unit = landUnits.random().name diff --git a/core/src/com/unciv/logic/automation/SpecificUnitAutomation.kt b/core/src/com/unciv/logic/automation/SpecificUnitAutomation.kt index c323ac0d..c80becc1 100644 --- a/core/src/com/unciv/logic/automation/SpecificUnitAutomation.kt +++ b/core/src/com/unciv/logic/automation/SpecificUnitAutomation.kt @@ -1,5 +1,6 @@ package com.unciv.logic.automation +import com.unciv.Constants import com.unciv.UnCivGame import com.unciv.logic.civilization.CivilizationInfo import com.unciv.logic.civilization.GreatPersonManager @@ -73,7 +74,7 @@ class SpecificUnitAutomation{ .take(5) .toList() var rank = top5Tiles.asSequence().map { nearbyTileRankings[it]!! }.sum() - if(tileInfo.neighbors.any{it.baseTerrain == "Coast"}) rank += 5 + if(tileInfo.neighbors.any{it.baseTerrain == Constants.coast}) rank += 5 return rank } diff --git a/core/src/com/unciv/logic/map/RandomMapGenerator.kt b/core/src/com/unciv/logic/map/RandomMapGenerator.kt index a4b91f0f..b7c752d4 100644 --- a/core/src/com/unciv/logic/map/RandomMapGenerator.kt +++ b/core/src/com/unciv/logic/map/RandomMapGenerator.kt @@ -162,7 +162,7 @@ class CelluarAutomataRandomMapGenerator(): SeedRandomMapGenerator() { //Coasts for (tile in map.values.filter { it.baseTerrain == ocean }) { if (HexMath().getVectorsInDistance(tile.position,2).any { hasLandTile(map,it) }) { - tile.baseTerrain = "Coast" + tile.baseTerrain = Constants.coast tile.setTransients() } } @@ -500,7 +500,7 @@ open class RandomMapGenerator { open fun setWaterTiles(map: HashMap) { for (tile in map.values.filter { it.baseTerrain == ocean }) { if (HexMath().getVectorsInDistance(tile.position,2).any { hasLandTile(map,it) }) { - tile.baseTerrain = "Coast" + tile.baseTerrain = Constants.coast tile.setTransients() } } diff --git a/core/src/com/unciv/logic/map/TileInfo.kt b/core/src/com/unciv/logic/map/TileInfo.kt index 415fc92b..5de853ae 100644 --- a/core/src/com/unciv/logic/map/TileInfo.kt +++ b/core/src/com/unciv/logic/map/TileInfo.kt @@ -123,7 +123,7 @@ open class TileInfo { fun getTileStats(city: CityInfo?, observingCiv: CivilizationInfo): Stats { var stats = getBaseTerrain().clone() - if((baseTerrain== Constants.ocean||baseTerrain=="Coast") && city!=null + if((baseTerrain== Constants.ocean||baseTerrain==Constants.coast) && city!=null && city.getBuildingUniques().contains("+1 food from Ocean and Coast tiles")) stats.food += 1 diff --git a/core/src/com/unciv/logic/map/UnitMovementAlgorithms.kt b/core/src/com/unciv/logic/map/UnitMovementAlgorithms.kt index 01894cbf..1ab5def2 100644 --- a/core/src/com/unciv/logic/map/UnitMovementAlgorithms.kt +++ b/core/src/com/unciv/logic/map/UnitMovementAlgorithms.kt @@ -37,7 +37,7 @@ class UnitMovementAlgorithms(val unit:MapUnit) { && (to.baseTerrain == Constants.hill || to.terrainFeature == Constants.forest || to.terrainFeature == Constants.jungle)) return 4f - if(unit.doubleMovementInCoast && to.baseTerrain=="Coast") + if(unit.doubleMovementInCoast && to.baseTerrain==Constants.coast) return 1/2f return to.getLastTerrain().movementCost.toFloat() // no road diff --git a/core/src/com/unciv/models/gamebasics/Building.kt b/core/src/com/unciv/models/gamebasics/Building.kt index 31709d4f..5ce628be 100644 --- a/core/src/com/unciv/models/gamebasics/Building.kt +++ b/core/src/com/unciv/models/gamebasics/Building.kt @@ -224,11 +224,11 @@ class Building : NamedStats(), IConstruction{ return "Must be next to desert" if ("Must be next to mountain" in uniques - && !construction.cityInfo.getCenterTile().neighbors.any { it.baseTerrain == "Mountain" }) + && !construction.cityInfo.getCenterTile().neighbors.any { it.baseTerrain == Constants.mountain }) return "Must be next to mountain" if("Can only be built in coastal cities" in uniques - && !construction.cityInfo.getCenterTile().neighbors.any { it.baseTerrain=="Coast" }) + && !construction.cityInfo.getCenterTile().neighbors.any { it.baseTerrain==Constants.coast }) return "Can only be built in coastal cities" val civInfo = construction.cityInfo.civInfo diff --git a/core/src/com/unciv/models/gamebasics/unit/BaseUnit.kt b/core/src/com/unciv/models/gamebasics/unit/BaseUnit.kt index fa5ec8c3..7bf704af 100644 --- a/core/src/com/unciv/models/gamebasics/unit/BaseUnit.kt +++ b/core/src/com/unciv/models/gamebasics/unit/BaseUnit.kt @@ -120,7 +120,7 @@ class BaseUnit : INamed, IConstruction, ICivilopedia { fun getRejectionReason(construction: CityConstructions): String { val civRejectionReason = getRejectionReason(construction.cityInfo.civInfo) if(civRejectionReason!="") return civRejectionReason - if(unitType.isWaterUnit() && construction.cityInfo.getCenterTile().neighbors.none { it.baseTerrain=="Coast" }) + if(unitType.isWaterUnit() && construction.cityInfo.getCenterTile().neighbors.none { it.baseTerrain==Constants.coast }) return "Can't build water units by the coast" return "" }