diff --git a/core/src/com/unciv/logic/automation/NextTurnAutomation.kt b/core/src/com/unciv/logic/automation/NextTurnAutomation.kt index 3745840486..7082e9d446 100644 --- a/core/src/com/unciv/logic/automation/NextTurnAutomation.kt +++ b/core/src/com/unciv/logic/automation/NextTurnAutomation.kt @@ -293,7 +293,7 @@ object NextTurnAutomation { // Default setting is 5, this will be changed according to different civ. if ((1..10).random() > 5) continue val tradeLogic = TradeLogic(civInfo, otherCiv) - val cost = civInfo.getResearchAgreementCost(otherCiv) + val cost = civInfo.getResearchAgreementCost() tradeLogic.currentTrade.ourOffers.add(TradeOffer(Constants.researchAgreement, TradeType.Treaty, cost)) tradeLogic.currentTrade.theirOffers.add(TradeOffer(Constants.researchAgreement, TradeType.Treaty, cost)) diff --git a/core/src/com/unciv/logic/civilization/CivilizationInfo.kt b/core/src/com/unciv/logic/civilization/CivilizationInfo.kt index 3f9e129ab5..875617a9ba 100644 --- a/core/src/com/unciv/logic/civilization/CivilizationInfo.kt +++ b/core/src/com/unciv/logic/civilization/CivilizationInfo.kt @@ -118,7 +118,7 @@ class CivilizationInfo { toReturn.victoryManager = victoryManager.clone() toReturn.allyCivName = allyCivName for (diplomacyManager in diplomacy.values.map { it.clone() }) - toReturn.diplomacy.put(diplomacyManager.otherCivName, diplomacyManager) + toReturn.diplomacy[diplomacyManager.otherCivName] = diplomacyManager toReturn.cities = cities.map { it.clone() } // This is the only thing that is NOT switched out, which makes it a source of ConcurrentModification errors. @@ -165,7 +165,7 @@ class CivilizationInfo { fun isAlive(): Boolean = !isDefeated() fun hasEverBeenFriendWith(otherCiv: CivilizationInfo): Boolean = getDiplomacyManager(otherCiv).everBeenFriends() fun hasMetCivTerritory(otherCiv: CivilizationInfo): Boolean = otherCiv.getCivTerritory().any { it in exploredTiles } - fun getCivTerritory() = cities.asSequence().flatMap { it.tiles.asSequence() } + private fun getCivTerritory() = cities.asSequence().flatMap { it.tiles.asSequence() } fun victoryType(): VictoryType { if (gameInfo.gameParameters.victoryTypes.size == 1) @@ -267,7 +267,7 @@ class CivilizationInfo { fun getIdleUnits() = getCivUnits().filter { it.isIdle() } - fun getDueUnits() = getCivUnits().filter { it.due && it.isIdle() } + private fun getDueUnits() = getCivUnits().filter { it.due && it.isIdle() } fun shouldGoToDueUnit() = UncivGame.Current.settings.checkForDueUnits && getDueUnits().any() @@ -334,8 +334,8 @@ class CivilizationInfo { /** Returns true if the civ was fully initialized and has no cities remaining */ fun isDefeated(): Boolean { // Dirty hack: exploredTiles are empty only before starting units are placed - if (exploredTiles.isEmpty() || isBarbarian() || isSpectator()) return false - else return cities.isEmpty() // No cities + return if (exploredTiles.isEmpty() || isBarbarian() || isSpectator()) false + else cities.isEmpty() // No cities && (citiesCreated > 0 || !getCivUnits().any { it.hasUnique(Constants.settlerUnique) }) } @@ -343,12 +343,11 @@ class CivilizationInfo { if (gameInfo.ruleSet.technologies.isEmpty()) return "None" if (tech.researchedTechnologies.isEmpty()) return gameInfo.ruleSet.getEras().first() - val maxEraOfTech = tech.researchedTechnologies + return tech.researchedTechnologies .asSequence() .map { it.column!! } .maxByOrNull { it.columnNumber }!! .era - return maxEraOfTech } fun getEraNumber(): Int = gameInfo.ruleSet.getEraNumber(getEra()) @@ -383,7 +382,7 @@ class CivilizationInfo { fun canSignResearchAgreementsWith(otherCiv: CivilizationInfo): Boolean { val diplomacyManager = getDiplomacyManager(otherCiv) - val cost = getResearchAgreementCost(otherCiv) + val cost = getResearchAgreementCost() return canSignResearchAgreement() && otherCiv.canSignResearchAgreement() && diplomacyManager.hasFlag(DiplomacyFlags.DeclarationOfFriendship) && !diplomacyManager.hasFlag(DiplomacyFlags.ResearchAgreement) @@ -619,7 +618,7 @@ class CivilizationInfo { updateStatsForNextTurn() } - fun getResearchAgreementCost(otherCiv: CivilizationInfo): Int { + fun getResearchAgreementCost(): Int { // https://forums.civfanatics.com/resources/research-agreements-bnw.25568/ val basicGoldCostOfSignResearchAgreement = when (getEra()) { Constants.medievalEra, Constants.renaissanceEra -> 250 diff --git a/core/src/com/unciv/logic/civilization/TechManager.kt b/core/src/com/unciv/logic/civilization/TechManager.kt index a1e65e9904..ec64181f9d 100644 --- a/core/src/com/unciv/logic/civilization/TechManager.kt +++ b/core/src/com/unciv/logic/civilization/TechManager.kt @@ -1,7 +1,5 @@ package com.unciv.logic.civilization - -import com.badlogic.gdx.graphics.Color import com.unciv.logic.map.MapSize import com.unciv.logic.map.RoadStatus import com.unciv.models.ruleset.Unique @@ -70,7 +68,7 @@ class TechManager { fun getNumberOfTechsResearched(): Int = techsResearched.size - fun getRuleset() = civInfo.gameInfo.ruleSet + private fun getRuleset() = civInfo.gameInfo.ruleSet fun costOfTech(techName: String): Int { var techCost = getRuleset().technologies[techName]!!.cost.toFloat() @@ -156,7 +154,7 @@ class TechManager { return (scienceOfLast8Turns.sum() * civInfo.gameInfo.gameParameters.gameSpeed.modifier).toInt() } - fun addCurrentScienceToScienceOfLast8Turns() { + private fun addCurrentScienceToScienceOfLast8Turns() { // The Science the Great Scientist generates does not include Science from Policies, Trade routes and City-States. var allCitiesScience = 0f civInfo.cities.forEach { it -> @@ -167,11 +165,11 @@ class TechManager { scienceOfLast8Turns[civInfo.gameInfo.turns % 8] = allCitiesScience.toInt() } - fun limitOverflowScience(overflowscience: Int): Int { + private fun limitOverflowScience(overflowScience: Int): Int { // http://www.civclub.net/bbs/forum.php?mod=viewthread&tid=123976 // Apparently yes, we care about the absolute tech cost, not the actual calculated-for-this-player tech cost, // so don't change to costOfTech() - return min(overflowscience, max(civInfo.statsForNextTurn.science.toInt() * 5, + return min(overflowScience, max(civInfo.statsForNextTurn.science.toInt() * 5, getRuleset().technologies[currentTechnologyName()]!!.cost)) } @@ -280,11 +278,10 @@ class TechManager { val oldQueue = city.cityConstructions.constructionQueue.toList() // copy, since we're changing the queue city.cityConstructions.constructionQueue.clear() for (constructionName in oldQueue) { - val newConstructionName = constructionName if (constructionName in obsoleteUnits) { val text = "[$constructionName] has been obsolete and will be removed from construction queue in [${city.name}]!" civInfo.addNotification(text, city.location, NotificationIcon.Construction) - } else city.cityConstructions.constructionQueue.add(newConstructionName) + } else city.cityConstructions.constructionQueue.add(constructionName) } } @@ -300,7 +297,7 @@ class TechManager { updateTransientBooleans() } - fun updateTransientBooleans() { + private fun updateTransientBooleans() { wayfinding = civInfo.hasUnique("Can embark and move over Coasts and Oceans immediately") unitsCanEmbark = wayfinding || civInfo.hasUnique("Enables embarkation for land units") diff --git a/core/src/com/unciv/ui/trade/DiplomacyScreen.kt b/core/src/com/unciv/ui/trade/DiplomacyScreen.kt index 9496ca9ed2..cdd51d8ead 100644 --- a/core/src/com/unciv/ui/trade/DiplomacyScreen.kt +++ b/core/src/com/unciv/ui/trade/DiplomacyScreen.kt @@ -26,10 +26,10 @@ import com.unciv.ui.utils.AutoScrollPane as ScrollPane class DiplomacyScreen(val viewingCiv:CivilizationInfo):CameraStageBaseScreen() { - val leftSideTable = Table().apply { defaults().pad(10f) } - val rightSideTable = Table() + private val leftSideTable = Table().apply { defaults().pad(10f) } + private val rightSideTable = Table() - fun isNotPlayersTurn() = !UncivGame.Current.worldScreen.isPlayersTurn + private fun isNotPlayersTurn() = !UncivGame.Current.worldScreen.isPlayersTurn init { onBackButtonClicked { UncivGame.Current.setWorldScreen() } @@ -285,7 +285,7 @@ class DiplomacyScreen(val viewingCiv:CivilizationInfo):CameraStageBaseScreen() { if (viewingCiv.canSignResearchAgreementsWith(otherCiv)) { val researchAgreementButton = "Research Agreement".toTextButton() - val requiredGold = viewingCiv.getResearchAgreementCost(otherCiv) + val requiredGold = viewingCiv.getResearchAgreementCost() researchAgreementButton.onClick { val tradeTable = setTrade(otherCiv) val researchAgreement = TradeOffer(Constants.researchAgreement, TradeType.Treaty, requiredGold) @@ -390,7 +390,7 @@ class DiplomacyScreen(val viewingCiv:CivilizationInfo):CameraStageBaseScreen() { return demandsTable } - fun getRelationshipTable(otherCivDiplomacyManager: DiplomacyManager): Table { + private fun getRelationshipTable(otherCivDiplomacyManager: DiplomacyManager): Table { val relationshipTable = Table() val opinionOfUs = if (otherCivDiplomacyManager.civInfo.isCityState()) otherCivDiplomacyManager.influence.toInt()