Fixed Coast start bias

This commit is contained in:
Yair Morgenstern 2019-06-19 20:22:38 +03:00
parent a1e1b91b9a
commit 7958c795dd
9 changed files with 12 additions and 9 deletions

View file

@ -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"

View file

@ -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()

View file

@ -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

View file

@ -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
}

View file

@ -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<String, TileInfo>) {
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()
}
}

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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 ""
}