mirror of
https://github.com/yairm210/Unciv.git
synced 2025-09-28 06:16:37 -04:00
Linting and deprecation corrections
This commit is contained in:
parent
c73891cbe7
commit
efe369ad19
@ -3,8 +3,8 @@ package com.unciv.build
|
|||||||
object BuildConfig {
|
object BuildConfig {
|
||||||
const val kotlinVersion = "1.4.30"
|
const val kotlinVersion = "1.4.30"
|
||||||
const val appName = "Unciv"
|
const val appName = "Unciv"
|
||||||
const val appCodeNumber = 571
|
const val appCodeNumber = 572
|
||||||
const val appVersion = "3.14.12"
|
const val appVersion = "3.14.13"
|
||||||
|
|
||||||
const val gdxVersion = "1.10.0"
|
const val gdxVersion = "1.10.0"
|
||||||
const val roboVMVersion = "2.3.1"
|
const val roboVMVersion = "2.3.1"
|
||||||
|
@ -58,8 +58,10 @@ object Automation {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun chooseMilitaryUnit(city: CityInfo): String? {
|
fun chooseMilitaryUnit(city: CityInfo): String? {
|
||||||
var militaryUnits = city.cityConstructions.getConstructableUnits().filter { !it.unitType.isCivilian() }
|
var militaryUnits =
|
||||||
if (militaryUnits.map { it.name }.contains(city.cityConstructions.currentConstructionFromQueue))
|
city.cityConstructions.getConstructableUnits().filter { !it.unitType.isCivilian() }
|
||||||
|
if (militaryUnits.map { it.name }
|
||||||
|
.contains(city.cityConstructions.currentConstructionFromQueue))
|
||||||
return city.cityConstructions.currentConstructionFromQueue
|
return city.cityConstructions.currentConstructionFromQueue
|
||||||
|
|
||||||
// This is so that the AI doesn't use all its aluminum on units and have none left for spaceship parts
|
// This is so that the AI doesn't use all its aluminum on units and have none left for spaceship parts
|
||||||
@ -67,36 +69,44 @@ object Automation {
|
|||||||
if (aluminum != null && aluminum < 2) // mods may have no aluminum
|
if (aluminum != null && aluminum < 2) // mods may have no aluminum
|
||||||
militaryUnits.filter { !it.getResourceRequirements().containsKey("Aluminum") }
|
militaryUnits.filter { !it.getResourceRequirements().containsKey("Aluminum") }
|
||||||
|
|
||||||
val findWaterConnectedCitiesAndEnemies = BFS(city.getCenterTile()) { it.isWater || it.isCityCenter() }
|
val findWaterConnectedCitiesAndEnemies =
|
||||||
|
BFS(city.getCenterTile()) { it.isWater || it.isCityCenter() }
|
||||||
findWaterConnectedCitiesAndEnemies.stepToEnd()
|
findWaterConnectedCitiesAndEnemies.stepToEnd()
|
||||||
if (findWaterConnectedCitiesAndEnemies.tilesReached.keys.none {
|
if (findWaterConnectedCitiesAndEnemies.tilesReached.keys.none {
|
||||||
(it.isCityCenter() && it.getOwner() != city.civInfo)
|
(it.isCityCenter() && it.getOwner() != city.civInfo)
|
||||||
|| (it.militaryUnit != null && it.militaryUnit!!.civInfo != city.civInfo)
|
|| (it.militaryUnit != null && it.militaryUnit!!.civInfo != city.civInfo)
|
||||||
}) // there is absolutely no reason for you to make water units on this body of water.
|
}) // there is absolutely no reason for you to make water units on this body of water.
|
||||||
militaryUnits = militaryUnits.filter { it.unitType.isLandUnit() || it.unitType.isAirUnit() }
|
militaryUnits =
|
||||||
|
militaryUnits.filter { it.unitType.isLandUnit() || it.unitType.isAirUnit() }
|
||||||
|
|
||||||
val chosenUnit: BaseUnit
|
val chosenUnit: BaseUnit
|
||||||
if (!city.civInfo.isAtWar() && city.civInfo.cities.any { it.getCenterTile().militaryUnit == null }
|
if (!city.civInfo.isAtWar() && city.civInfo.cities.any { it.getCenterTile().militaryUnit == null }
|
||||||
&& militaryUnits.any { it.unitType == UnitType.Ranged }) // this is for city defence so get an archery unit if we can
|
&& militaryUnits.any { it.unitType == UnitType.Ranged }) // this is for city defence so get an archery unit if we can
|
||||||
chosenUnit = militaryUnits.filter { it.unitType == UnitType.Ranged }.maxBy { it.cost }!!
|
chosenUnit = militaryUnits.filter { it.unitType == UnitType.Ranged }
|
||||||
|
.maxByOrNull { it.cost }!!
|
||||||
else { // randomize type of unit and take the most expensive of its kind
|
else { // randomize type of unit and take the most expensive of its kind
|
||||||
val availableTypes = militaryUnits.map { it.unitType }.distinct().filterNot { it == UnitType.Scout }.toList()
|
val availableTypes =
|
||||||
|
militaryUnits.map { it.unitType }.distinct().filterNot { it == UnitType.Scout }
|
||||||
|
.toList()
|
||||||
if (availableTypes.isEmpty()) return null
|
if (availableTypes.isEmpty()) return null
|
||||||
val randomType = availableTypes.random()
|
val randomType = availableTypes.random()
|
||||||
chosenUnit = militaryUnits.filter { it.unitType == randomType }.maxBy { it.cost }!!
|
chosenUnit = militaryUnits.filter { it.unitType == randomType }
|
||||||
|
.maxByOrNull { it.cost }!!
|
||||||
}
|
}
|
||||||
return chosenUnit.name
|
return chosenUnit.name
|
||||||
}
|
}
|
||||||
|
|
||||||
fun evaluteCombatStrength(civInfo: CivilizationInfo): Int {
|
fun evaluateCombatStrength(civInfo: CivilizationInfo): Int {
|
||||||
// Since units become exponentially stronger per combat strength increase, we square em all
|
// Since units become exponentially stronger per combat strength increase, we square em all
|
||||||
fun square(x: Int) = x * x
|
fun square(x: Int) = x * x
|
||||||
val unitStrength = civInfo.getCivUnits().map { square(max(it.baseUnit().strength, it.baseUnit().rangedStrength)) }.sum()
|
val unitStrength = civInfo.getCivUnits()
|
||||||
|
.map { square(max(it.baseUnit().strength, it.baseUnit().rangedStrength)) }.sum()
|
||||||
return sqrt(unitStrength.toDouble()).toInt() + 1 //avoid 0, because we divide by the result
|
return sqrt(unitStrength.toDouble()).toInt() + 1 //avoid 0, because we divide by the result
|
||||||
}
|
}
|
||||||
|
|
||||||
fun threatAssessment(assessor: CivilizationInfo, assessed: CivilizationInfo): ThreatLevel {
|
fun threatAssessment(assessor: CivilizationInfo, assessed: CivilizationInfo): ThreatLevel {
|
||||||
val powerLevelComparison = evaluteCombatStrength(assessed)/evaluteCombatStrength(assessor).toFloat()
|
val powerLevelComparison =
|
||||||
|
evaluateCombatStrength(assessed) / evaluateCombatStrength(assessor).toFloat()
|
||||||
return when {
|
return when {
|
||||||
powerLevelComparison > 2 -> ThreatLevel.VeryHigh
|
powerLevelComparison > 2 -> ThreatLevel.VeryHigh
|
||||||
powerLevelComparison > 1.5f -> ThreatLevel.High
|
powerLevelComparison > 1.5f -> ThreatLevel.High
|
||||||
@ -143,4 +153,3 @@ enum class ThreatLevel{
|
|||||||
High,
|
High,
|
||||||
VeryHigh
|
VeryHigh
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@ class ConstructionAutomation(val cityConstructions: CityConstructions){
|
|||||||
|
|
||||||
val buildableNotWonders = cityConstructions.getBuildableBuildings()
|
val buildableNotWonders = cityConstructions.getBuildableBuildings()
|
||||||
.filterNot { it.isWonder || it.isNationalWonder }
|
.filterNot { it.isWonder || it.isNationalWonder }
|
||||||
val buildableWonders = cityConstructions.getBuildableBuildings()
|
private val buildableWonders = cityConstructions.getBuildableBuildings()
|
||||||
.filter { it.isWonder || it.isNationalWonder }
|
.filter { it.isWonder || it.isNationalWonder }
|
||||||
|
|
||||||
val civUnits = civInfo.getCivUnits()
|
val civUnits = civInfo.getCivUnits()
|
||||||
@ -33,7 +33,7 @@ class ConstructionAutomation(val cityConstructions: CityConstructions){
|
|||||||
val isAtWar = civInfo.isAtWar()
|
val isAtWar = civInfo.isAtWar()
|
||||||
val preferredVictoryType = civInfo.victoryType()
|
val preferredVictoryType = civInfo.victoryType()
|
||||||
|
|
||||||
val averageProduction = civInfo.cities.map { it.cityStats.currentCityStats.production }.average()
|
private val averageProduction = civInfo.cities.map { it.cityStats.currentCityStats.production }.average()
|
||||||
val cityIsOverAverageProduction = cityInfo.cityStats.currentCityStats.production >= averageProduction
|
val cityIsOverAverageProduction = cityInfo.cityStats.currentCityStats.production >= averageProduction
|
||||||
|
|
||||||
val relativeCostEffectiveness = ArrayList<ConstructionChoice>()
|
val relativeCostEffectiveness = ArrayList<ConstructionChoice>()
|
||||||
@ -205,7 +205,7 @@ class ConstructionAutomation(val cityConstructions: CityConstructions){
|
|||||||
if (!buildableWonders.any()) return
|
if (!buildableWonders.any()) return
|
||||||
|
|
||||||
val highestPriorityWonder = buildableWonders
|
val highestPriorityWonder = buildableWonders
|
||||||
.maxBy { getWonderPriority(it) }!!
|
.maxByOrNull { getWonderPriority(it) }!!
|
||||||
val citiesBuildingWonders = civInfo.cities
|
val citiesBuildingWonders = civInfo.cities
|
||||||
.count { it.cityConstructions.isBuildingWonder() }
|
.count { it.cityConstructions.isBuildingWonder() }
|
||||||
|
|
||||||
|
@ -360,12 +360,12 @@ object NextTurnAutomation {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun motivationToAttack(civInfo: CivilizationInfo, otherCiv: CivilizationInfo): Int {
|
private fun motivationToAttack(civInfo: CivilizationInfo, otherCiv: CivilizationInfo): Int {
|
||||||
val ourCombatStrength = Automation.evaluteCombatStrength(civInfo).toFloat()
|
val ourCombatStrength = Automation.evaluateCombatStrength(civInfo).toFloat()
|
||||||
var theirCombatStrength = Automation.evaluteCombatStrength(otherCiv)
|
var theirCombatStrength = Automation.evaluateCombatStrength(otherCiv)
|
||||||
|
|
||||||
//for city-states, also consider there protectors
|
//for city-states, also consider there protectors
|
||||||
if(otherCiv.isCityState() and otherCiv.getProtectorCivs().isNotEmpty()) {
|
if(otherCiv.isCityState() and otherCiv.getProtectorCivs().isNotEmpty()) {
|
||||||
theirCombatStrength += otherCiv.getProtectorCivs().sumOf{Automation.evaluteCombatStrength(it)}
|
theirCombatStrength += otherCiv.getProtectorCivs().sumOf{Automation.evaluateCombatStrength(it)}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (theirCombatStrength > ourCombatStrength) return 0
|
if (theirCombatStrength > ourCombatStrength) return 0
|
||||||
|
@ -118,7 +118,6 @@ object BattleDamage {
|
|||||||
|
|
||||||
fun getAttackModifiers(
|
fun getAttackModifiers(
|
||||||
attacker: ICombatant,
|
attacker: ICombatant,
|
||||||
tileToAttackFrom: TileInfo?,
|
|
||||||
defender: ICombatant
|
defender: ICombatant
|
||||||
): Counter<String> {
|
): Counter<String> {
|
||||||
val modifiers = getGeneralModifiers(attacker, defender)
|
val modifiers = getGeneralModifiers(attacker, defender)
|
||||||
@ -280,7 +279,7 @@ object BattleDamage {
|
|||||||
defender: ICombatant
|
defender: ICombatant
|
||||||
): Float {
|
): Float {
|
||||||
val attackModifier =
|
val attackModifier =
|
||||||
modifiersToMultiplicationBonus(getAttackModifiers(attacker, tileToAttackFrom, defender))
|
modifiersToMultiplicationBonus(getAttackModifiers(attacker, defender))
|
||||||
return attacker.getAttackingStrength() * attackModifier
|
return attacker.getAttackingStrength() * attackModifier
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@ interface IConstruction : INamed {
|
|||||||
fun getGoldCost(civInfo: CivilizationInfo): Int
|
fun getGoldCost(civInfo: CivilizationInfo): Int
|
||||||
fun isBuildable(cityConstructions: CityConstructions): Boolean
|
fun isBuildable(cityConstructions: CityConstructions): Boolean
|
||||||
fun shouldBeDisplayed(cityConstructions: CityConstructions): Boolean
|
fun shouldBeDisplayed(cityConstructions: CityConstructions): Boolean
|
||||||
fun postBuildEvent(construction: CityConstructions, wasBought: Boolean = false): Boolean // Yes I'm hilarious.
|
fun postBuildEvent(cityConstructions: CityConstructions, wasBought: Boolean = false): Boolean // Yes I'm hilarious.
|
||||||
fun getResourceRequirements(): HashMap<String,Int>
|
fun getResourceRequirements(): HashMap<String,Int>
|
||||||
fun canBePurchased(): Boolean
|
fun canBePurchased(): Boolean
|
||||||
}
|
}
|
||||||
@ -59,7 +59,7 @@ open class PerpetualConstruction(override var name: String, val description: Str
|
|||||||
override fun isBuildable(cityConstructions: CityConstructions): Boolean =
|
override fun isBuildable(cityConstructions: CityConstructions): Boolean =
|
||||||
throw Exception("Impossible!")
|
throw Exception("Impossible!")
|
||||||
|
|
||||||
override fun postBuildEvent(construction: CityConstructions, wasBought: Boolean) =
|
override fun postBuildEvent(cityConstructions: CityConstructions, wasBought: Boolean) =
|
||||||
throw Exception("Impossible!")
|
throw Exception("Impossible!")
|
||||||
|
|
||||||
override fun getResourceRequirements(): HashMap<String, Int> = hashMapOf()
|
override fun getResourceRequirements(): HashMap<String, Int> = hashMapOf()
|
||||||
|
@ -51,7 +51,7 @@ class QuestManager {
|
|||||||
/** Number of turns left before this city state can start a new individual quest */
|
/** Number of turns left before this city state can start a new individual quest */
|
||||||
private var individualQuestCountdown: HashMap<String, Int> = HashMap()
|
private var individualQuestCountdown: HashMap<String, Int> = HashMap()
|
||||||
|
|
||||||
/** Returns [true] if [civInfo] have active quests for [challenger] */
|
/** Returns true if [civInfo] have active quests for [challenger] */
|
||||||
fun haveQuestsFor(challenger: CivilizationInfo): Boolean = assignedQuests.any { it.assignee == challenger.civName }
|
fun haveQuestsFor(challenger: CivilizationInfo): Boolean = assignedQuests.any { it.assignee == challenger.civName }
|
||||||
|
|
||||||
fun clone(): QuestManager {
|
fun clone(): QuestManager {
|
||||||
@ -195,7 +195,7 @@ class QuestManager {
|
|||||||
if (quests.isEmpty())
|
if (quests.isEmpty())
|
||||||
return
|
return
|
||||||
|
|
||||||
val topScore = quests.map { getScoreForQuest(it) }.max()!!
|
val topScore = quests.map { getScoreForQuest(it) }.maxOrNull()!!
|
||||||
|
|
||||||
for (quest in quests) {
|
for (quest in quests) {
|
||||||
if (getScoreForQuest(quest) >= topScore)
|
if (getScoreForQuest(quest) >= topScore)
|
||||||
@ -218,7 +218,7 @@ class QuestManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** If quest is complete, it gives the influence reward to the player.
|
/** If quest is complete, it gives the influence reward to the player.
|
||||||
* Returns [true] if the quest can be removed (is either complete, obsolete or expired) */
|
* Returns true if the quest can be removed (is either complete, obsolete or expired) */
|
||||||
private fun handleIndividualQuest(assignedQuest: AssignedQuest): Boolean {
|
private fun handleIndividualQuest(assignedQuest: AssignedQuest): Boolean {
|
||||||
val assignee = civInfo.gameInfo.getCivilization(assignedQuest.assignee)
|
val assignee = civInfo.gameInfo.getCivilization(assignedQuest.assignee)
|
||||||
|
|
||||||
@ -251,7 +251,7 @@ class QuestManager {
|
|||||||
|
|
||||||
when (quest.name) {
|
when (quest.name) {
|
||||||
QuestName.ClearBarbarianCamp.value -> {
|
QuestName.ClearBarbarianCamp.value -> {
|
||||||
val camp = getBarbarianEncampmentForQuest(assignee)!!
|
val camp = getBarbarianEncampmentForQuest()!!
|
||||||
data1 = camp.position.x.toInt().toString()
|
data1 = camp.position.x.toInt().toString()
|
||||||
data2 = camp.position.y.toInt().toString()
|
data2 = camp.position.y.toInt().toString()
|
||||||
}
|
}
|
||||||
@ -281,13 +281,13 @@ class QuestManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Returns [true] if [civInfo] can assign a quest to [challenger] */
|
/** Returns true if [civInfo] can assign a quest to [challenger] */
|
||||||
private fun canAssignAQuestTo(challenger: CivilizationInfo): Boolean {
|
private fun canAssignAQuestTo(challenger: CivilizationInfo): Boolean {
|
||||||
return !challenger.isDefeated() && challenger.isMajorCiv() &&
|
return !challenger.isDefeated() && challenger.isMajorCiv() &&
|
||||||
civInfo.knows(challenger) && !civInfo.isAtWarWith(challenger)
|
civInfo.knows(challenger) && !civInfo.isAtWarWith(challenger)
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Returns [true] if the [quest] can be assigned to [challenger] */
|
/** Returns true if the [quest] can be assigned to [challenger] */
|
||||||
private fun isQuestValid(quest: Quest, challenger: CivilizationInfo): Boolean {
|
private fun isQuestValid(quest: Quest, challenger: CivilizationInfo): Boolean {
|
||||||
if (!canAssignAQuestTo(challenger))
|
if (!canAssignAQuestTo(challenger))
|
||||||
return false
|
return false
|
||||||
@ -295,7 +295,7 @@ class QuestManager {
|
|||||||
return false
|
return false
|
||||||
|
|
||||||
return when (quest.name) {
|
return when (quest.name) {
|
||||||
QuestName.ClearBarbarianCamp.value -> getBarbarianEncampmentForQuest(challenger) != null
|
QuestName.ClearBarbarianCamp.value -> getBarbarianEncampmentForQuest() != null
|
||||||
QuestName.Route.value -> {
|
QuestName.Route.value -> {
|
||||||
if (challenger.cities.none() || !civInfo.hasEverBeenFriendWith(challenger)
|
if (challenger.cities.none() || !civInfo.hasEverBeenFriendWith(challenger)
|
||||||
|| civInfo.isCapitalConnectedToCity(challenger.getCapital())) return false
|
|| civInfo.isCapitalConnectedToCity(challenger.getCapital())) return false
|
||||||
@ -313,7 +313,7 @@ class QuestManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Returns [true] if the [assignedQuest] is successfully completed */
|
/** Returns true if the [assignedQuest] is successfully completed */
|
||||||
private fun isComplete(assignedQuest: AssignedQuest): Boolean {
|
private fun isComplete(assignedQuest: AssignedQuest): Boolean {
|
||||||
val assignee = civInfo.gameInfo.getCivilization(assignedQuest.assignee)
|
val assignee = civInfo.gameInfo.getCivilization(assignedQuest.assignee)
|
||||||
return when (assignedQuest.questName) {
|
return when (assignedQuest.questName) {
|
||||||
@ -327,7 +327,7 @@ class QuestManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Returns [true] if the [assignedQuest] request cannot be fulfilled anymore */
|
/** Returns true if the [assignedQuest] request cannot be fulfilled anymore */
|
||||||
private fun isObsolete(assignedQuest: AssignedQuest): Boolean {
|
private fun isObsolete(assignedQuest: AssignedQuest): Boolean {
|
||||||
val assignee = civInfo.gameInfo.getCivilization(assignedQuest.assignee)
|
val assignee = civInfo.gameInfo.getCivilization(assignedQuest.assignee)
|
||||||
return when (assignedQuest.questName) {
|
return when (assignedQuest.questName) {
|
||||||
@ -441,7 +441,7 @@ class QuestManager {
|
|||||||
* Returns a random [TileInfo] containing a Barbarian encampment within 8 tiles of [civInfo]
|
* Returns a random [TileInfo] containing a Barbarian encampment within 8 tiles of [civInfo]
|
||||||
* to be destroyed
|
* to be destroyed
|
||||||
*/
|
*/
|
||||||
private fun getBarbarianEncampmentForQuest(challenger: CivilizationInfo): TileInfo? {
|
private fun getBarbarianEncampmentForQuest(): TileInfo? {
|
||||||
val encampments = civInfo.getCapital().getCenterTile().getTilesInDistance(8)
|
val encampments = civInfo.getCapital().getCenterTile().getTilesInDistance(8)
|
||||||
.filter { it.improvement == Constants.barbarianEncampment }.toList()
|
.filter { it.improvement == Constants.barbarianEncampment }.toList()
|
||||||
|
|
||||||
@ -492,7 +492,7 @@ class QuestManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a random [NaturalWonder] not yet discovered by [challenger].
|
* Returns a random Natural Wonder not yet discovered by [challenger].
|
||||||
*/
|
*/
|
||||||
private fun getNaturalWonderToFindForQuest(challenger: CivilizationInfo): String? {
|
private fun getNaturalWonderToFindForQuest(challenger: CivilizationInfo): String? {
|
||||||
val naturalWondersToFind = civInfo.gameInfo.tileMap.naturalWonders.subtract(challenger.naturalWonders)
|
val naturalWondersToFind = civInfo.gameInfo.tileMap.naturalWonders.subtract(challenger.naturalWonders)
|
||||||
|
@ -132,8 +132,6 @@ class MapLandmassGenerator(val randomness: MapGenerationRandomness) {
|
|||||||
|
|
||||||
// region Cellular automata
|
// region Cellular automata
|
||||||
private fun generateLandCellularAutomata(tileMap: TileMap) {
|
private fun generateLandCellularAutomata(tileMap: TileMap) {
|
||||||
val mapRadius = tileMap.mapParameters.mapSize.radius
|
|
||||||
val mapType = tileMap.mapParameters.type
|
|
||||||
val numSmooth = 4
|
val numSmooth = 4
|
||||||
|
|
||||||
// init
|
// init
|
||||||
|
@ -59,7 +59,7 @@ class RiverGenerator(val randomness: MapGenerationRandomness) {
|
|||||||
getAdjacentTiles(it, map).map { it.aerialDistanceTo(endPosition) }
|
getAdjacentTiles(it, map).map { it.aerialDistanceTo(endPosition) }
|
||||||
.minOrNull()!!
|
.minOrNull()!!
|
||||||
}
|
}
|
||||||
.minBy { it.key }!!
|
.minByOrNull { it.key }!!
|
||||||
.component2().random(randomness.RNG)
|
.component2().random(randomness.RNG)
|
||||||
|
|
||||||
// set new rivers in place
|
// set new rivers in place
|
||||||
|
@ -237,8 +237,8 @@ class TradeEvaluation {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun evaluatePeaceCostForThem(ourCivilization: CivilizationInfo, otherCivilization: CivilizationInfo): Int {
|
fun evaluatePeaceCostForThem(ourCivilization: CivilizationInfo, otherCivilization: CivilizationInfo): Int {
|
||||||
val ourCombatStrength = Automation.evaluteCombatStrength(ourCivilization)
|
val ourCombatStrength = Automation.evaluateCombatStrength(ourCivilization)
|
||||||
val theirCombatStrength = Automation.evaluteCombatStrength(otherCivilization)
|
val theirCombatStrength = Automation.evaluateCombatStrength(otherCivilization)
|
||||||
if (ourCombatStrength*1.5f >= theirCombatStrength && theirCombatStrength * 1.5f >= ourCombatStrength)
|
if (ourCombatStrength*1.5f >= theirCombatStrength && theirCombatStrength * 1.5f >= ourCombatStrength)
|
||||||
return 0 // we're roughly equal, there's no huge power imbalance
|
return 0 // we're roughly equal, there's no huge power imbalance
|
||||||
if (ourCombatStrength == 0) return -1000
|
if (ourCombatStrength == 0) return -1000
|
||||||
|
@ -75,7 +75,7 @@ class Building : NamedStats(), IConstruction {
|
|||||||
val str = getStats(null).toString()
|
val str = getStats(null).toString()
|
||||||
if (str.isNotEmpty()) infoList += str
|
if (str.isNotEmpty()) infoList += str
|
||||||
for (stat in getStatPercentageBonuses(null).toHashMap())
|
for (stat in getStatPercentageBonuses(null).toHashMap())
|
||||||
if (stat.value != 0f) infoList += "+${stat.value.toInt()}% ${stat.key.toString().tr()}"
|
if (stat.value != 0f) infoList += "+${stat.value.toInt()}% ${stat.key.name.tr()}"
|
||||||
|
|
||||||
val improvedResources = ruleset.tileResources.values.asSequence().filter { it.building == name }.map { it.name.tr() }
|
val improvedResources = ruleset.tileResources.values.asSequence().filter { it.building == name }.map { it.name.tr() }
|
||||||
if (improvedResources.any()) {
|
if (improvedResources.any()) {
|
||||||
|
@ -184,9 +184,9 @@ class BaseUnit : INamed, IConstruction {
|
|||||||
return getRejectionReason(cityConstructions) == ""
|
return getRejectionReason(cityConstructions) == ""
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun postBuildEvent(construction: CityConstructions, wasBought: Boolean): Boolean {
|
override fun postBuildEvent(cityConstructions: CityConstructions, wasBought: Boolean): Boolean {
|
||||||
val civInfo = construction.cityInfo.civInfo
|
val civInfo = cityConstructions.cityInfo.civInfo
|
||||||
val unit = civInfo.placeUnitNearTile(construction.cityInfo.location, name)
|
val unit = civInfo.placeUnitNearTile(cityConstructions.cityInfo.location, name)
|
||||||
if (unit == null) return false // couldn't place the unit, so there's actually no unit =(
|
if (unit == null) return false // couldn't place the unit, so there's actually no unit =(
|
||||||
|
|
||||||
//movement penalty
|
//movement penalty
|
||||||
@ -195,10 +195,10 @@ class BaseUnit : INamed, IConstruction {
|
|||||||
|
|
||||||
if (this.unitType.isCivilian()) return true // tiny optimization makes save files a few bytes smaller
|
if (this.unitType.isCivilian()) return true // tiny optimization makes save files a few bytes smaller
|
||||||
|
|
||||||
var XP = construction.getBuiltBuildings().sumBy { it.xpForNewUnits }
|
var XP = cityConstructions.getBuiltBuildings().sumBy { it.xpForNewUnits }
|
||||||
|
|
||||||
|
|
||||||
for (unique in construction.cityInfo.cityConstructions.builtBuildingUniqueMap
|
for (unique in cityConstructions.cityInfo.cityConstructions.builtBuildingUniqueMap
|
||||||
.getUniques("New [] units start with [] Experience in this city")
|
.getUniques("New [] units start with [] Experience in this city")
|
||||||
+ civInfo.getMatchingUniques("New [] units start with [] Experience")) {
|
+ civInfo.getMatchingUniques("New [] units start with [] Experience")) {
|
||||||
if (unit.matchesFilter(unique.params[0]))
|
if (unit.matchesFilter(unique.params[0]))
|
||||||
@ -206,7 +206,7 @@ class BaseUnit : INamed, IConstruction {
|
|||||||
}
|
}
|
||||||
unit.promotions.XP = XP
|
unit.promotions.XP = XP
|
||||||
|
|
||||||
for (unique in construction.cityInfo.cityConstructions.builtBuildingUniqueMap
|
for (unique in cityConstructions.cityInfo.cityConstructions.builtBuildingUniqueMap
|
||||||
.getUniques("All newly-trained [] units in this city receive the [] promotion")) {
|
.getUniques("All newly-trained [] units in this city receive the [] promotion")) {
|
||||||
val filter = unique.params[0]
|
val filter = unique.params[0]
|
||||||
val promotion = unique.params[1]
|
val promotion = unique.params[1]
|
||||||
|
@ -119,7 +119,7 @@ class BattleTable(val worldScreen: WorldScreen): Table() {
|
|||||||
add(defender.getDefendingStrength().toString()+Fonts.strength).row()
|
add(defender.getDefendingStrength().toString()+Fonts.strength).row()
|
||||||
|
|
||||||
val attackerModifiers =
|
val attackerModifiers =
|
||||||
BattleDamage.getAttackModifiers(attacker,null,defender).map {
|
BattleDamage.getAttackModifiers(attacker, defender).map {
|
||||||
val description = if(it.key.startsWith("vs ")) ("vs ["+it.key.replace("vs ","")+"]").tr() else it.key.tr()
|
val description = if(it.key.startsWith("vs ")) ("vs ["+it.key.replace("vs ","")+"]").tr() else it.key.tr()
|
||||||
val percentage = (if(it.value>0)"+" else "")+ it.value +"%"
|
val percentage = (if(it.value>0)"+" else "")+ it.value +"%"
|
||||||
"$description: $percentage"
|
"$description: $percentage"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user