More massive performance boosts

This commit is contained in:
Yair Morgenstern 2019-05-03 16:59:46 +03:00
parent 7400f6e874
commit cdfdbb40b8
24 changed files with 84 additions and 60 deletions

View File

@ -22,7 +22,7 @@ android {
minSdkVersion 14
targetSdkVersion 28
versionCode 236
versionName "2.16.0"
versionName "2.16.0-patch1"
}
// Had to add this crap for Travis to build, it wanted to sign the app

View File

@ -0,0 +1,10 @@
package com.unciv
class Constants{
companion object {
const val worker="Worker"
const val settler="Settler"
const val ocean="Ocean"
const val mountain="Mountain"
}
}

View File

@ -74,7 +74,7 @@ class GameStarter{
for (civ in gameInfo.civilizations.filter { !it.isBarbarianCivilization() }) {
val startingLocation = startingLocations.pop()!!
civ.placeUnitNearTile(startingLocation.position, "Settler")
civ.placeUnitNearTile(startingLocation.position, Constants.settler)
civ.placeUnitNearTile(startingLocation.position, "Warrior")
civ.placeUnitNearTile(startingLocation.position, "Scout")
}

View File

@ -1,6 +1,7 @@
package com.unciv.logic.automation
import com.badlogic.gdx.graphics.Color
import com.unciv.Constants
import com.unciv.logic.battle.CityCombatant
import com.unciv.logic.city.CityConstructions
import com.unciv.logic.city.CityInfo
@ -76,7 +77,7 @@ class Automation {
val civUnits = cityInfo.civInfo.getCivUnits()
val militaryUnits = civUnits.filter { !it.type.isCivilian()}.size
val workers = civUnits.filter { it.name == CityConstructions.Worker }.size.toFloat()
val workers = civUnits.filter { it.name == Constants.worker }.size.toFloat()
val cities = cityInfo.civInfo.cities.size
val canBuildWorkboat = cityInfo.cityConstructions.getConstructableUnits().map { it.name }.contains("Work Boats")
&& !cityInfo.getTiles().any { it.civilianUnit?.name == "Work Boats" }
@ -159,7 +160,7 @@ class Automation {
//worker
if (workers < cities * 0.6f) {
relativeCostEffectiveness.add(ConstructionChoice(CityConstructions.Worker,cities.toFloat()/(workers+0.1f)))
relativeCostEffectiveness.add(ConstructionChoice(Constants.worker,cities.toFloat()/(workers+0.1f)))
}
//Work boat

View File

@ -8,6 +8,7 @@ import com.unciv.logic.civilization.diplomacy.DiplomaticStatus
import com.unciv.logic.civilization.diplomacy.RelationshipLevel
import com.unciv.logic.map.MapUnit
import com.unciv.logic.trade.*
import com.unciv.Constants
import com.unciv.models.gamebasics.GameBasics
import com.unciv.models.gamebasics.tech.Technology
import com.unciv.models.gamebasics.tr
@ -316,12 +317,12 @@ class NextTurnAutomation{
if(civInfo.isAtWar()) return // don't train settlers when you could be training troops.
if (civInfo.cities.any()
&& civInfo.happiness > civInfo.cities.size + 5
&& civInfo.getCivUnits().none { it.name == "Settler" }
&& civInfo.cities.none { it.cityConstructions.currentConstruction == "Settler" }) {
&& civInfo.getCivUnits().none { it.name == Constants.settler }
&& civInfo.cities.none { it.cityConstructions.currentConstruction == Constants.settler }) {
val bestCity = civInfo.cities.maxBy { it.cityStats.currentCityStats.production }!!
if (bestCity.cityConstructions.builtBuildings.size > 1) // 2 buildings or more, otherwise focus on self first
bestCity.cityConstructions.currentConstruction = "Settler"
bestCity.cityConstructions.currentConstruction = Constants.settler
}
}

View File

@ -1,5 +1,6 @@
package com.unciv.logic.automation
import com.unciv.Constants
import com.unciv.UnCivGame
import com.unciv.logic.battle.*
import com.unciv.logic.city.CityInfo
@ -15,11 +16,11 @@ class UnitAutomation{
fun automateUnitMoves(unit: MapUnit) {
if (unit.name == "Settler") {
if (unit.name == Constants.settler) {
return SpecificUnitAutomation().automateSettlerActions(unit)
}
if (unit.name == "Worker") {
if (unit.name == Constants.worker) {
return WorkerAutomation(unit).automateWorkerAction()
}
@ -201,7 +202,7 @@ class UnitAutomation{
private fun tryAccompanySettlerOrGreatPerson(unit: MapUnit): Boolean {
val settlerOrGreatPersonToAccompany = unit.civInfo.getCivUnits()
.firstOrNull { val tile = it.currentTile
(it.name=="Settler" || it.name.startsWith("Great") && it.type.isCivilian())
(it.name== Constants.settler || it.name.startsWith("Great") && it.type.isCivilian())
&& tile.militaryUnit==null && unit.canMoveTo(tile) && unit.movementAlgs().canReach(tile) }
if(settlerOrGreatPersonToAccompany==null) return false
unit.movementAlgs().headTowards(settlerOrGreatPersonToAccompany.currentTile)

View File

@ -8,6 +8,7 @@ import com.unciv.logic.civilization.AlertType
import com.unciv.logic.civilization.PopupAlert
import com.unciv.logic.civilization.diplomacy.DiplomaticModifiers
import com.unciv.logic.map.TileInfo
import com.unciv.Constants
import com.unciv.models.gamebasics.unit.UnitType
import java.util.*
import kotlin.math.max
@ -238,7 +239,7 @@ class Battle(val gameInfo:GameInfo) {
defender.takeDamage(100)
return
} // barbarians don't capture civilians!
if (attacker.getCivInfo().isCityState() && defender.getName() == "Settler") {
if (attacker.getCivInfo().isCityState() && defender.getName() == Constants.settler) {
defender.takeDamage(100)
return
}

View File

@ -2,6 +2,7 @@ package com.unciv.logic.city
import com.badlogic.gdx.graphics.Color
import com.unciv.logic.automation.Automation
import com.unciv.Constants
import com.unciv.models.gamebasics.Building
import com.unciv.models.gamebasics.GameBasics
import com.unciv.models.gamebasics.tr
@ -125,7 +126,7 @@ class CityConstructions {
cityInfo.cityStats.update()
var production = Math.round(cityStatsForConstruction.production)
if (constructionName == Settler) production += cityStatsForConstruction.food.toInt()
if (constructionName == Constants.settler) production += cityStatsForConstruction.food.toInt()
return Math.ceil((workLeft / production.toDouble())).toInt()
}
@ -222,9 +223,4 @@ class CityConstructions {
}
//endregion
companion object {
internal const val Worker = "Worker"
internal const val Settler = "Settler"
}
} // for json parsing, we need to have a default constructor

View File

@ -6,6 +6,7 @@ import com.unciv.logic.civilization.CivilizationInfo
import com.unciv.logic.map.RoadStatus
import com.unciv.logic.map.TileInfo
import com.unciv.logic.map.TileMap
import com.unciv.Constants
import com.unciv.models.Counter
import com.unciv.models.gamebasics.GameBasics
import com.unciv.models.gamebasics.tile.ResourceType
@ -62,7 +63,7 @@ class CityInfo {
if (civInfo.policies.isAdopted("Legalism") && civInfo.cities.size <= 4) cityConstructions.addCultureBuilding()
if (civInfo.cities.size == 1) {
cityConstructions.addBuilding("Palace")
cityConstructions.currentConstruction = "Worker" // Default for first city only!
cityConstructions.currentConstruction = Constants.worker // Default for first city only!
}
expansion.reset()
@ -205,7 +206,7 @@ class CityInfo {
fun endTurn() {
val stats = cityStats.currentCityStats
if (cityConstructions.currentConstruction == CityConstructions.Settler && stats.food > 0) {
if (cityConstructions.currentConstruction == Constants.settler && stats.food > 0) {
stats.production += stats.food
stats.food = 0f
}

View File

@ -3,6 +3,7 @@ package com.unciv.logic.city
import com.unciv.UnCivGame
import com.unciv.logic.map.BFS
import com.unciv.logic.map.RoadStatus
import com.unciv.Constants
import com.unciv.models.gamebasics.Building
import com.unciv.models.gamebasics.GameBasics
import com.unciv.models.gamebasics.unit.BaseUnit
@ -269,7 +270,7 @@ class CityStats {
val currentConstruction = cityConstructions.getCurrentConstruction()
if (policies.contains("Collective Rule") && cityInfo.isCapital()
&& currentConstruction.name == "Settler")
&& currentConstruction.name == Constants.settler)
stats.production += 50f
if (policies.contains("Republic") && currentConstruction is Building)
stats.production += 5f

View File

@ -3,6 +3,7 @@ package com.unciv.logic.civilization
import com.badlogic.gdx.Gdx
import com.badlogic.gdx.graphics.Color
import com.badlogic.gdx.math.Vector2
import com.unciv.Constants
import com.unciv.UnCivGame
import com.unciv.logic.GameInfo
import com.unciv.logic.city.CityInfo
@ -331,7 +332,7 @@ class CivilizationInfo {
override fun toString(): String {return civName} // for debug
fun isDefeated()= cities.isEmpty() && (citiesCreated > 0 || !getCivUnits().any{it.name=="Settler"})
fun isDefeated()= cities.isEmpty() && (citiesCreated > 0 || !getCivUnits().any{it.name== Constants.settler})
fun getEra(): TechEra {
val maxEraOfTech = tech.researchedTechnologies

View File

@ -1,5 +1,6 @@
package com.unciv.logic.civilization
import com.unciv.Constants
import com.unciv.models.gamebasics.GameBasics
import com.unciv.models.gamebasics.Policy
@ -64,8 +65,8 @@ class PolicyManager {
val hasCapital = civInfo.cities.any{it.isCapital()}
when (policy.name) {
"Collective Rule" -> if(hasCapital) civInfo.placeUnitNearTile(civInfo.getCapital().location, "Settler")
"Citizenship" -> if(hasCapital) civInfo.placeUnitNearTile(civInfo.getCapital().location, "Worker")
"Collective Rule" -> if(hasCapital) civInfo.placeUnitNearTile(civInfo.getCapital().location, Constants.settler)
"Citizenship" -> if(hasCapital) civInfo.placeUnitNearTile(civInfo.getCapital().location, Constants.worker)
"Representation", "Reformation" -> civInfo.goldenAges.enterGoldenAge()
"Scientific Revolution" -> civInfo.tech.freeTechs += 2
"Legalism" ->

View File

@ -19,6 +19,8 @@ class TechManager {
@Transient var unitsCanEmbark=false
@Transient var embarkedUnitsCanEnterOcean=false
// UnitMovementAlgorithms.getMovementCostBetweenAdjacentTiles is a close second =)
@Transient var movementSpeedOnRoadsImproved=false
var freeTechs = 0
var techsResearched = HashSet<String>()
@ -188,6 +190,6 @@ class TechManager {
fun updateTransientBooleans(){
if(researchedTechUniques.contains("Enables embarkation for land units")) unitsCanEmbark=true
if(researchedTechUniques.contains("Enables embarked units to enter ocean tiles")) embarkedUnitsCanEnterOcean=true
if(researchedTechUniques.contains("Improves movement speed on roads")) movementSpeedOnRoadsImproved = true
}
}

View File

@ -28,9 +28,8 @@ class BFS(val startingPoint: TileInfo, val predicate : (TileInfo) -> Boolean){
for(tileInfo in tilesToCheck){
val fitNeighbors = tileInfo.neighbors.asSequence()
.filter(predicate)
.filter{!tilesReached.containsKey(it)}.toList()
fitNeighbors.forEach { tilesReached[it] = tileInfo }
newTilesToCheck.addAll(fitNeighbors)
.filter{!tilesReached.containsKey(it)}
fitNeighbors.forEach { tilesReached[it] = tileInfo; newTilesToCheck.add(it) }
}
tilesToCheck = newTilesToCheck
}

View File

@ -2,6 +2,7 @@ package com.unciv.logic.map
import com.badlogic.gdx.graphics.Color
import com.badlogic.gdx.math.Vector2
import com.unciv.Constants
import com.unciv.logic.automation.UnitAutomation
import com.unciv.logic.automation.WorkerAutomation
import com.unciv.logic.civilization.CivilizationInfo
@ -136,14 +137,13 @@ class MapUnit {
if(tile.isLand && type.isWaterUnit() && !tile.isCityCenter())
return false
val isOcean = tile.baseTerrain == "Ocean"
if(tile.isWater && type.isLandUnit()){
if(!civInfo.tech.unitsCanEmbark) return false
if(isOcean && !civInfo.tech.embarkedUnitsCanEnterOcean)
if(tile.isOcean && !civInfo.tech.embarkedUnitsCanEnterOcean)
return false
}
if(isOcean && baseUnit.uniques.contains("Cannot enter ocean tiles")) return false
if(isOcean && baseUnit.uniques.contains("Cannot enter ocean tiles until Astronomy")
if(tile.isOcean && baseUnit.uniques.contains("Cannot enter ocean tiles")) return false
if(tile.isOcean && baseUnit.uniques.contains("Cannot enter ocean tiles until Astronomy")
&& !civInfo.tech.isResearched("Astronomy"))
return false
@ -174,7 +174,7 @@ class MapUnit {
fun isIdle(): Boolean {
if (currentMovement == 0f) return false
if (name == "Worker" && getTile().improvementInProgress != null) return false
if (name == Constants.worker && getTile().improvementInProgress != null) return false
if (hasUnique("Can construct roads") && currentTile.improvementInProgress=="Road") return false
if (isFortified()) return false
if (action=="Sleep") return false
@ -271,6 +271,7 @@ class MapUnit {
}
fun doPreTurnAction() {
if(action==null) return
val currentTile = getTile()
if (currentMovement == 0f) return // We've already done stuff this turn, and can't do any more stuff
@ -300,7 +301,7 @@ class MapUnit {
}
private fun doPostTurnAction() {
if (name == "Worker" && getTile().improvementInProgress != null) workOnImprovement()
if (name == Constants.worker && getTile().improvementInProgress != null) workOnImprovement()
if(hasUnique("Can construct roads") && currentTile.improvementInProgress=="Road") workOnImprovement()
if(currentMovement== getMaxMovement().toFloat()
&& isFortified()){
@ -437,8 +438,8 @@ class MapUnit {
}
actions.add {
val chosenUnit = listOf("Settler","Worker","Warrior").random()
if (!civInfo.isCityState() || chosenUnit != "Settler") { //City states don't get settler from ruins
val chosenUnit = listOf(Constants.settler, Constants.worker,"Warrior").random()
if (!civInfo.isCityState() || chosenUnit != Constants.settler) { //City states don't get settler from ruins
civInfo.placeUnitNearTile(currentTile.position, chosenUnit)
civInfo.addNotification("A [$chosenUnit] has joined us!", currentTile.position, Color.BROWN)
}

View File

@ -1,6 +1,8 @@
package com.unciv.logic.map
import com.badlogic.gdx.math.Vector2
import com.unciv.Constants.Companion.mountain
import com.unciv.Constants.Companion.ocean
import com.unciv.logic.HexMath
import com.unciv.models.gamebasics.GameBasics
import com.unciv.models.gamebasics.tile.ResourceType
@ -120,7 +122,7 @@ class CelluarAutomataRandomMapGenerator(): SeedRandomMapGenerator() {
val tile=TileInfo()
tile.position=vector
if (type == TerrainType.Land) tile.baseTerrain = ""
else tile.baseTerrain = "Ocean"
else tile.baseTerrain = ocean
return tile
}
@ -157,7 +159,7 @@ class CelluarAutomataRandomMapGenerator(): SeedRandomMapGenerator() {
}
//Coasts
for (tile in map.values.filter { it.baseTerrain == "Ocean" }) {
for (tile in map.values.filter { it.baseTerrain == ocean }) {
if (HexMath().getVectorsInDistance(tile.position,2).any { hasLandTile(map,it) }) {
tile.baseTerrain = "Coast"
tile.setTransients()
@ -167,7 +169,7 @@ class CelluarAutomataRandomMapGenerator(): SeedRandomMapGenerator() {
override fun randomizeTile(tileInfo: TileInfo, map: HashMap<String, TileInfo>){
if(tileInfo.getBaseTerrain().type==TerrainType.Land && Math.random()<0.05f){
tileInfo.baseTerrain = "Mountain"
tileInfo.baseTerrain = mountain
tileInfo.setTransients()
}
addRandomTerrainFeature(tileInfo)
@ -183,7 +185,7 @@ class CelluarAutomataRandomMapGenerator(): SeedRandomMapGenerator() {
val areas = ArrayList<Area>()
val terrains = GameBasics.Terrains.values.filter { it.type === TerrainType.Land && it.name != "Lakes"
&& it.name != "Mountain"}
&& it.name != mountain}
while(map.values.any { it.baseTerrain=="" }) // the world could be split into lots off tiny islands, and every island deserves land types
{
@ -193,7 +195,7 @@ class CelluarAutomataRandomMapGenerator(): SeedRandomMapGenerator() {
for (i in 0 until numberOfSeeds) {
var terrain = if (Math.random() > waterPercent) terrains.random().name
else "Ocean"
else ocean
val tile = emptyTiles.random()
//change grassland to desert or tundra based on y
@ -201,7 +203,7 @@ class CelluarAutomataRandomMapGenerator(): SeedRandomMapGenerator() {
if (terrain == "Grassland" || terrain == "Tundra")
terrain = "Desert"
} else if (abs(getLatitude(tile.position)) > maxLatitude * 0.7) {
if (terrain == "Grassland" || terrain == "Plains" || terrain == "Desert" || terrain == "Ocean") {
if (terrain == "Grassland" || terrain == "Plains" || terrain == "Desert" || terrain == ocean) {
terrain = "Tundra"
}
} else {
@ -260,9 +262,9 @@ class PerlinNoiseRandomMapGenerator:SeedRandomMapGenerator(){
+ Perlin.noise(vector.x*ratio*2,vector.y*ratio*2,mapRandomSeed)/2
+ Perlin.noise(vector.x*ratio*4,vector.y*ratio*4,mapRandomSeed)/4
when {
height>0.8 -> tile.baseTerrain = "Mountain"
height>0.8 -> tile.baseTerrain = mountain
height>0 -> tile.baseTerrain = "" // we'll leave this to the area division
else -> tile.baseTerrain = "Ocean"
else -> tile.baseTerrain = ocean
}
return tile
}
@ -281,7 +283,6 @@ class AlexanderRandomMapGenerator:RandomMapGenerator(){
val sparkList = ArrayList<Vector2>()
val grassland = "Grassland"
val ocean = "Ocean"
for(i in 0..distance*distance/6){
val location = map.filter { it.value==null }.map { it.key }.random()
map[location] = TileInfo().apply { baseTerrain= grassland}
@ -362,7 +363,7 @@ open class SeedRandomMapGenerator : RandomMapGenerator() {
open fun divideIntoAreas(averageTilesPerArea: Int, waterPercent: Float, map: HashMap<Vector2, TileInfo>) {
val areas = ArrayList<Area>()
val terrains = GameBasics.Terrains.values.filter { it.type === TerrainType.Land && it.name != "Lakes" && it.name != "Mountain" }
val terrains = GameBasics.Terrains.values.filter { it.type === TerrainType.Land && it.name != "Lakes" && it.name != mountain }
while(map.values.any { it.baseTerrain=="" }) // the world could be split into lots off tiny islands, and every island deserves land types
{
@ -371,7 +372,7 @@ open class SeedRandomMapGenerator : RandomMapGenerator() {
for (i in 0 until numberOfSeeds) {
val terrain = if (Math.random() > waterPercent) terrains.random().name
else "Ocean"
else ocean
val area = Area(terrain)
val tile = emptyTiles.random()
emptyTiles -= tile
@ -384,7 +385,7 @@ open class SeedRandomMapGenerator : RandomMapGenerator() {
}
for (area in areas.filter { it.terrain == "Ocean" && it.locations.size <= 10 }) {
for (area in areas.filter { it.terrain == ocean && it.locations.size <= 10 }) {
// areas with 10 or less tiles are lakes.
for (location in area.locations)
map[location]!!.baseTerrain = "Lakes"
@ -496,7 +497,7 @@ open class RandomMapGenerator {
}
open fun setWaterTiles(map: HashMap<String, TileInfo>) {
for (tile in map.values.filter { it.baseTerrain == "Ocean" }) {
for (tile in map.values.filter { it.baseTerrain == ocean }) {
if (HexMath().getVectorsInDistance(tile.position,2).any { hasLandTile(map,it) }) {
tile.baseTerrain = "Coast"
tile.setTransients()
@ -506,7 +507,7 @@ open class RandomMapGenerator {
open fun randomizeTile(tileInfo: TileInfo, map: HashMap<String, TileInfo>){
if(tileInfo.getBaseTerrain().type==TerrainType.Land && Math.random()<0.05f){
tileInfo.baseTerrain = "Mountain"
tileInfo.baseTerrain = mountain
tileInfo.setTransients()
}
if(tileInfo.getBaseTerrain().type==TerrainType.Land && Math.random()<0.05f

View File

@ -1,6 +1,7 @@
package com.unciv.logic.map
import com.badlogic.gdx.math.Vector2
import com.unciv.Constants
import com.unciv.UnCivGame
import com.unciv.logic.city.CityInfo
import com.unciv.logic.civilization.CivilizationInfo
@ -18,6 +19,7 @@ open class TileInfo {
// These are for performance - checked with every tile movement and "canEnter" check, which makes them performance-critical
@Transient var isLand = false
@Transient var isWater = false
@Transient var isOcean = false
var militaryUnit:MapUnit?=null
var civilianUnit:MapUnit?=null
@ -91,9 +93,9 @@ open class TileInfo {
}
fun getHeight(): Int {
if (baseTerrain=="Mountain") return 4
if (baseTerrain==Constants.mountain) return 4
if (baseTerrain == "Hill") return 2
if (listOf("Forest", "Jungle").contains(terrainFeature)) return 1
if (baseTerrain=="Forest" || baseTerrain=="Jungle") return 1
return 0
}
@ -121,7 +123,7 @@ open class TileInfo {
fun getTileStats(city: CityInfo?, observingCiv: CivilizationInfo): Stats {
var stats = getBaseTerrain().clone()
if((baseTerrain=="Ocean"||baseTerrain=="Coast") && city!=null
if((baseTerrain== Constants.ocean||baseTerrain=="Coast") && city!=null
&& city.getBuildingUniques().contains("+1 food from Ocean and Coast tiles"))
stats.food += 1
@ -282,6 +284,7 @@ open class TileInfo {
baseTerrainObject = GameBasics.Terrains[baseTerrain]!!
isWater = getBaseTerrain().type==TerrainType.Water
isLand = getBaseTerrain().type==TerrainType.Land
isOcean = baseTerrain == Constants.ocean
if(militaryUnit!=null) militaryUnit!!.currentTile = this
if(civilianUnit!=null) civilianUnit!!.currentTile = this

View File

@ -70,7 +70,6 @@ class TileMap {
fun getTilesAtDistance(origin: Vector2, distance: Int): List<TileInfo> {
return HexMath().getVectorsAtDistance(origin, distance).asSequence()
.filter {contains(it)}.map { get(it) }.toList()
}
fun placeUnitNearTile(position: Vector2, unitName: String, civInfo: CivilizationInfo): MapUnit {

View File

@ -25,7 +25,7 @@ class UnitMovementAlgorithms(val unit:MapUnit) {
if (from.roadStatus !== RoadStatus.None && to.roadStatus !== RoadStatus.None) //Road
{
if (unit.civInfo.tech.getTechUniques().contains("Improves movement speed on roads")) return 1 / 3f
if (unit.civInfo.tech.movementSpeedOnRoadsImproved) return 1 / 3f
else return 1 / 2f
}
if (unit.ignoresTerrainCost) return 1f

View File

@ -36,3 +36,4 @@ class Counter<K> : LinkedHashMap<K, Int>() {
return newCounter
}
}

View File

@ -3,6 +3,7 @@ package com.unciv.models.gamebasics
import com.unciv.logic.city.CityConstructions
import com.unciv.logic.city.IConstruction
import com.unciv.logic.civilization.CivilizationInfo
import com.unciv.Constants
import com.unciv.models.gamebasics.tech.Technology
import com.unciv.models.stats.NamedStats
import com.unciv.models.stats.*
@ -295,8 +296,8 @@ class Building : NamedStats(), IConstruction{
civInfo.addGreatPerson("Great Scientist", construction.cityInfo)
}
"Provides 2 free workers" in uniques -> {
civInfo.placeUnitNearTile(construction.cityInfo.location, "Worker")
civInfo.placeUnitNearTile(construction.cityInfo.location, "Worker")
civInfo.placeUnitNearTile(construction.cityInfo.location, Constants.worker)
civInfo.placeUnitNearTile(construction.cityInfo.location, Constants.worker)
}
"Free Social Policy" in uniques -> civInfo.policies.freePolicies++
"Free Great Person" in uniques -> {

View File

@ -4,6 +4,7 @@ import com.unciv.logic.city.CityConstructions
import com.unciv.logic.city.IConstruction
import com.unciv.logic.civilization.CivilizationInfo
import com.unciv.logic.map.MapUnit
import com.unciv.Constants
import com.unciv.models.gamebasics.GameBasics
import com.unciv.models.gamebasics.ICivilopedia
import com.unciv.models.gamebasics.Translations
@ -131,7 +132,7 @@ class BaseUnit : INamed, IConstruction, ICivilopedia {
if (uniqueTo!=null && uniqueTo!=civInfo.civName) return "Unique to $uniqueTo"
if (GameBasics.Units.values.any { it.uniqueTo==civInfo.civName && it.replaces==name }) return "Our unique unit replaces this"
if (requiredResource!=null && !civInfo.hasResource(requiredResource!!)) return "Requires $requiredResource"
if (name == "Settler" && civInfo.isCityState()) return "No settler for city state"
if (name == Constants.settler && civInfo.isCityState()) return "No settler for city state"
return ""
}

View File

@ -10,6 +10,7 @@ import com.unciv.UnCivGame
import com.unciv.logic.GameSaver
import com.unciv.logic.civilization.CivilizationInfo
import com.unciv.logic.civilization.diplomacy.DiplomaticStatus
import com.unciv.Constants
import com.unciv.models.gamebasics.GameBasics
import com.unciv.models.gamebasics.tile.ResourceType
import com.unciv.models.gamebasics.tr
@ -137,7 +138,7 @@ class WorldScreen : CameraStageBaseScreen() {
if(gameClone.getCurrentPlayerCivilization().getCivUnits().any { it.health<100 })
displayTutorials("InjuredUnits")
if(gameClone.getCurrentPlayerCivilization().getCivUnits().any { it.name=="Worker" })
if(gameClone.getCurrentPlayerCivilization().getCivUnits().any { it.name== Constants.worker })
displayTutorials("WorkerTrained")
updateTechButton(cloneCivilization)

View File

@ -7,6 +7,7 @@ import com.badlogic.gdx.scenes.scene2d.ui.Label
import com.badlogic.gdx.scenes.scene2d.ui.Table
import com.unciv.UnCivGame
import com.unciv.logic.map.MapUnit
import com.unciv.Constants
import com.unciv.models.gamebasics.tr
import com.unciv.ui.utils.*
import com.unciv.ui.worldscreen.WorldScreen
@ -25,10 +26,10 @@ class UnitActionsTable(val worldScreen: WorldScreen) : Table(){
"Stop movement"-> return ImageGetter.getStatIcon("Movement").apply { color= Color.RED }
"Fortify" -> return ImageGetter.getImage("OtherIcons/Shield").apply { color= Color.BLACK }
"Promote" -> return ImageGetter.getImage("OtherIcons/Star").apply { color= Color.GOLD }
"Construct improvement" -> return ImageGetter.getUnitIcon("Worker")
"Construct improvement" -> return ImageGetter.getUnitIcon(Constants.worker)
"Automate" -> return ImageGetter.getUnitIcon("Great Engineer")
"Stop automation" -> return ImageGetter.getImage("OtherIcons/Stop")
"Found city" -> return ImageGetter.getUnitIcon("Settler")
"Found city" -> return ImageGetter.getUnitIcon(Constants.settler)
"Discover Technology" -> return ImageGetter.getUnitIcon("Great Scientist")
"Construct Academy" -> return ImageGetter.getImprovementIcon("Academy")
"Start Golden Age" -> return ImageGetter.getUnitIcon("Great Artist")