Kotlin 1.5 new warnings - partial (#5121)

This commit is contained in:
SomeTroglodyte 2021-09-08 20:15:32 +02:00 committed by GitHub
parent 1785c1f78e
commit 366ce4b89b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 38 additions and 34 deletions

View File

@ -64,7 +64,7 @@ class PopulationManager {
var percentOfFoodCarriedOver = cityInfo var percentOfFoodCarriedOver = cityInfo
.getMatchingUniques("[]% of food is carried over [] after population increases") .getMatchingUniques("[]% of food is carried over [] after population increases")
.filter { cityInfo.matchesFilter(it.params[1]) } .filter { cityInfo.matchesFilter(it.params[1]) }
.sumBy { it.params[0].toInt() } .sumOf { it.params[0].toInt() }
// Try to avoid runaway food gain in mods, just in case // Try to avoid runaway food gain in mods, just in case
if (percentOfFoodCarriedOver > 95) percentOfFoodCarriedOver = 95 if (percentOfFoodCarriedOver > 95) percentOfFoodCarriedOver = 95
foodStored += (getFoodToNextPopulation() * percentOfFoodCarriedOver / 100f).toInt() foodStored += (getFoodToNextPopulation() * percentOfFoodCarriedOver / 100f).toInt()

View File

@ -199,7 +199,7 @@ class PolicyManager {
// If we have "create a free aqueduct in first 3 cities" and "create free aqueduct in first 4 cities", we do: "create free aqueduct in first 3+4=7 cities" // If we have "create a free aqueduct in first 3 cities" and "create free aqueduct in first 4 cities", we do: "create free aqueduct in first 3+4=7 cities"
val sortedUniques = matchingUniques.groupBy {it.params[0]} val sortedUniques = matchingUniques.groupBy {it.params[0]}
for (unique in sortedUniques) { for (unique in sortedUniques) {
tryAddSpecificBuilding(unique.key, unique.value.sumBy {it.params[1].toInt()}) tryAddSpecificBuilding(unique.key, unique.value.sumOf {it.params[1].toInt()})
} }
} }

View File

@ -17,6 +17,7 @@ import com.unciv.ui.utils.randomWeighted
import kotlin.math.max import kotlin.math.max
import kotlin.random.Random import kotlin.random.Random
@Suppress("NON_EXHAUSTIVE_WHEN") // Many when uses in here are much clearer this way
class QuestManager { class QuestManager {
companion object { companion object {
@ -338,7 +339,7 @@ class QuestManager {
} }
} }
/** Increments [assignedQuest.assignee] influence on [civInfo] and adds a [Notification] */ /** Increments [assignedQuest.assignee][AssignedQuest.assignee] influence on [civInfo] and adds a [Notification] */
private fun giveReward(assignedQuest: AssignedQuest) { private fun giveReward(assignedQuest: AssignedQuest) {
val rewardInfluence = civInfo.gameInfo.ruleSet.quests[assignedQuest.questName]!!.influece val rewardInfluence = civInfo.gameInfo.ruleSet.quests[assignedQuest.questName]!!.influece
val assignee = civInfo.gameInfo.getCivilization(assignedQuest.assignee) val assignee = civInfo.gameInfo.getCivilization(assignedQuest.assignee)
@ -357,6 +358,7 @@ class QuestManager {
/** Returns the score for the [assignedQuest] */ /** Returns the score for the [assignedQuest] */
private fun getScoreForQuest(assignedQuest: AssignedQuest): Int { private fun getScoreForQuest(assignedQuest: AssignedQuest): Int {
@Suppress("UNUSED_VARIABLE") // This is a work in progress
val assignee = civInfo.gameInfo.getCivilization(assignedQuest.assignee) val assignee = civInfo.gameInfo.getCivilization(assignedQuest.assignee)
return when (assignedQuest.questName) { return when (assignedQuest.questName) {
// Waiting for contest quests // Waiting for contest quests

View File

@ -287,7 +287,7 @@ class ReligionManager {
if (religion == null) return 0 if (religion == null) return 0
return civInfo.gameInfo.getCities() return civInfo.gameInfo.getCities()
.filter { it.matchesFilter(cityFilter, civInfo) } .filter { it.matchesFilter(cityFilter, civInfo) }
.sumBy { it.religion.getFollowersOf(religion!!.name)!! } .sumOf { it.religion.getFollowersOf(religion!!.name)!! }
} }
} }

View File

@ -25,7 +25,7 @@ enum class RelationshipLevel(val color: Color) {
Ally(Color.CHARTREUSE) // HSV(90,100,100) Ally(Color.CHARTREUSE) // HSV(90,100,100)
} }
enum class DiplomacyFlags{ enum class DiplomacyFlags {
DeclinedLuxExchange, DeclinedLuxExchange,
DeclinedPeace, DeclinedPeace,
DeclinedResearchAgreement, DeclinedResearchAgreement,
@ -46,7 +46,7 @@ enum class DiplomacyFlags{
AngerFreeIntrusion AngerFreeIntrusion
} }
enum class DiplomaticModifiers{ enum class DiplomaticModifiers {
DeclaredWarOnUs, DeclaredWarOnUs,
WarMongerer, WarMongerer,
CapturedOurCities, CapturedOurCities,
@ -743,6 +743,7 @@ class DiplomacyManager() {
for (thirdCiv in getCommonKnownCivs() for (thirdCiv in getCommonKnownCivs()
.filter { it.getDiplomacyManager(civInfo).hasFlag(DiplomacyFlags.DeclarationOfFriendship) }) { .filter { it.getDiplomacyManager(civInfo).hasFlag(DiplomacyFlags.DeclarationOfFriendship) }) {
val otherCivRelationshipWithThirdCiv = otherCiv().getDiplomacyManager(thirdCiv).relationshipLevel() val otherCivRelationshipWithThirdCiv = otherCiv().getDiplomacyManager(thirdCiv).relationshipLevel()
@Suppress("NON_EXHAUSTIVE_WHEN") // Better readability
when (otherCivRelationshipWithThirdCiv) { when (otherCivRelationshipWithThirdCiv) {
RelationshipLevel.Unforgivable -> addModifier(DiplomaticModifiers.DeclaredFriendshipWithOurEnemies, -15f) RelationshipLevel.Unforgivable -> addModifier(DiplomaticModifiers.DeclaredFriendshipWithOurEnemies, -15f)
RelationshipLevel.Enemy -> addModifier(DiplomaticModifiers.DeclaredFriendshipWithOurEnemies, -5f) RelationshipLevel.Enemy -> addModifier(DiplomaticModifiers.DeclaredFriendshipWithOurEnemies, -5f)
@ -765,6 +766,7 @@ class DiplomacyManager() {
thirdCiv.addNotification("[${civInfo.civName}] has denounced [$otherCivName]!", civInfo.civName, NotificationIcon.Diplomacy, otherCivName) thirdCiv.addNotification("[${civInfo.civName}] has denounced [$otherCivName]!", civInfo.civName, NotificationIcon.Diplomacy, otherCivName)
val thirdCivRelationshipWithOtherCiv = thirdCiv.getDiplomacyManager(otherCiv()).relationshipLevel() val thirdCivRelationshipWithOtherCiv = thirdCiv.getDiplomacyManager(otherCiv()).relationshipLevel()
val thirdCivDiplomacyManager = thirdCiv.getDiplomacyManager(civInfo) val thirdCivDiplomacyManager = thirdCiv.getDiplomacyManager(civInfo)
@Suppress("NON_EXHAUSTIVE_WHEN") // Better readability
when (thirdCivRelationshipWithOtherCiv) { when (thirdCivRelationshipWithOtherCiv) {
RelationshipLevel.Unforgivable -> thirdCivDiplomacyManager.addModifier(DiplomaticModifiers.DenouncedOurEnemies, 15f) RelationshipLevel.Unforgivable -> thirdCivDiplomacyManager.addModifier(DiplomaticModifiers.DenouncedOurEnemies, 15f)
RelationshipLevel.Enemy -> thirdCivDiplomacyManager.addModifier(DiplomaticModifiers.DenouncedOurEnemies, 5f) RelationshipLevel.Enemy -> thirdCivDiplomacyManager.addModifier(DiplomaticModifiers.DenouncedOurEnemies, 5f)