diff --git a/android/build.gradle b/android/build.gradle index 0ba9ef2128..ed628be1d8 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -21,8 +21,8 @@ android { applicationId "com.unciv.app" minSdkVersion 14 targetSdkVersion 28 - versionCode 264 - versionName "2.17.11" + versionCode 266 + versionName "2.17.12-patch1" } // Had to add this crap for Travis to build, it wanted to sign the app diff --git a/core/src/com/unciv/logic/automation/Automation.kt b/core/src/com/unciv/logic/automation/Automation.kt index 7cbc12827d..4dbbd08844 100644 --- a/core/src/com/unciv/logic/automation/Automation.kt +++ b/core/src/com/unciv/logic/automation/Automation.kt @@ -261,7 +261,7 @@ class Automation { fun square(x:Int) = x*x val unitStrength = civInfo.getCivUnits().map { square(max(it.baseUnit().strength, it.baseUnit().rangedStrength)) }.sum() val cityStrength = civInfo.cities.map { square(CityCombatant(it).getCityStrength()) }.sum() - return (sqrt(unitStrength.toDouble()) /*+ sqrt(cityStrength.toDouble())*/).toInt() + 1 //avoid 0 + return (sqrt(unitStrength.toDouble()) /*+ sqrt(cityStrength.toDouble())*/).toInt() + 1 //avoid 0, becaus we divide by the result } fun threatAssessment(assessor:CivilizationInfo, assessed: CivilizationInfo): ThreatLevel { diff --git a/core/src/com/unciv/logic/automation/NextTurnAutomation.kt b/core/src/com/unciv/logic/automation/NextTurnAutomation.kt index d7eaa4fb03..09908fe232 100644 --- a/core/src/com/unciv/logic/automation/NextTurnAutomation.kt +++ b/core/src/com/unciv/logic/automation/NextTurnAutomation.kt @@ -329,30 +329,36 @@ class NextTurnAutomation{ private fun declareWar(civInfo: CivilizationInfo) { if (civInfo.isCityState()) return - if (civInfo.victoryType()==VictoryType.Cultural) - return + if (civInfo.victoryType() == VictoryType.Cultural) return + if (civInfo.cities.isEmpty() || civInfo.diplomacy.isEmpty()) return + if (civInfo.isAtWar() || civInfo.getHappiness() <= 0) return - if (civInfo.cities.isNotEmpty() && civInfo.diplomacy.isNotEmpty()) { - val ourMilitaryUnits = civInfo.getCivUnits().filter { !it.type.isCivilian() }.size - if (!civInfo.isAtWar() && civInfo.getHappiness() > 0 - && ourMilitaryUnits >= civInfo.cities.size) { //evaluate war - val ourCombatStrength = Automation().evaluteCombatStrength(civInfo) - val enemyCivsByDistanceToOurs = civInfo.getKnownCivs() - .filterNot { it == civInfo || it.cities.isEmpty() || !civInfo.getDiplomacyManager(it).canDeclareWar() } - .groupBy { getMinDistanceBetweenCities(civInfo, it) } - .toSortedMap() + val ourMilitaryUnits = civInfo.getCivUnits().filter { !it.type.isCivilian() }.size + if (ourMilitaryUnits < civInfo.cities.size) return - for (group in enemyCivsByDistanceToOurs) { - if (group.key > 7) break - for (otherCiv in group.value) { - if (Automation().evaluteCombatStrength(otherCiv) * 2 < ourCombatStrength) { - civInfo.getDiplomacyManager(otherCiv).declareWar() - return - } - } - } - } + //evaluate war + val enemyCivs = civInfo.getKnownCivs() + .filterNot { it == civInfo || it.cities.isEmpty() || !civInfo.getDiplomacyManager(it).canDeclareWar() } + if (enemyCivs.isEmpty()) return + + var enemyCivsToEvaluate = enemyCivs.filter { getMinDistanceBetweenCities(civInfo, it) <= 7 } + + var isFightingFarAway = false + if (enemyCivsToEvaluate.isEmpty()) { // so, there ARE civs we can declare war on, just not close by + if (civInfo.victoryType() != VictoryType.Domination) return // No point in attacking civs that are too far away + enemyCivsToEvaluate = enemyCivs + isFightingFarAway = true } + + val weakestCloseCiv = enemyCivsToEvaluate.minBy { Automation().evaluteCombatStrength(it) }!! + val weakestCloseCivCombatStrength = Automation().evaluteCombatStrength(weakestCloseCiv) + val ourCombatStrength = Automation().evaluteCombatStrength(civInfo) + + val amountWeNeedToBeStronger = + if (civInfo.victoryType() == VictoryType.Domination && !isFightingFarAway) 1.5f else 2f + + if (weakestCloseCivCombatStrength * amountWeNeedToBeStronger < ourCombatStrength) + civInfo.getDiplomacyManager(weakestCloseCiv).declareWar() } private fun automateUnits(civInfo: CivilizationInfo) { diff --git a/core/src/com/unciv/ui/utils/Tutorials.kt b/core/src/com/unciv/ui/utils/Tutorials.kt index eb86a24b82..d4ed6bd7d4 100644 --- a/core/src/com/unciv/ui/utils/Tutorials.kt +++ b/core/src/com/unciv/ui/utils/Tutorials.kt @@ -11,7 +11,7 @@ import com.badlogic.gdx.utils.Array import com.unciv.UnCivGame import com.unciv.models.gamebasics.GameBasics import com.unciv.models.gamebasics.tr -import java.util.LinkedHashMap +import java.util.* import kotlin.collections.ArrayList import kotlin.collections.HashMap import kotlin.collections.set @@ -26,7 +26,7 @@ class Tutorials{ fun displayTutorials(name: String, stage: Stage) { - if (UnCivGame.Current.settings.showTutorials) return + if (!UnCivGame.Current.settings.showTutorials) return if (UnCivGame.Current.settings.tutorialsShown.contains(name)) return val texts = getTutorials(name, UnCivGame.Current.settings.language) tutorialTexts.add(Tutorial(name,texts))