mirror of
https://github.com/yairm210/Unciv.git
synced 2025-09-26 21:35:14 -04:00
Kotlin 1.5 new warnings - partial (#5121)
This commit is contained in:
parent
1785c1f78e
commit
366ce4b89b
@ -64,7 +64,7 @@ class PopulationManager {
|
||||
var percentOfFoodCarriedOver = cityInfo
|
||||
.getMatchingUniques("[]% of food is carried over [] after population increases")
|
||||
.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
|
||||
if (percentOfFoodCarriedOver > 95) percentOfFoodCarriedOver = 95
|
||||
foodStored += (getFoodToNextPopulation() * percentOfFoodCarriedOver / 100f).toInt()
|
||||
|
@ -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"
|
||||
val sortedUniques = matchingUniques.groupBy {it.params[0]}
|
||||
for (unique in sortedUniques) {
|
||||
tryAddSpecificBuilding(unique.key, unique.value.sumBy {it.params[1].toInt()})
|
||||
tryAddSpecificBuilding(unique.key, unique.value.sumOf {it.params[1].toInt()})
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -17,6 +17,7 @@ import com.unciv.ui.utils.randomWeighted
|
||||
import kotlin.math.max
|
||||
import kotlin.random.Random
|
||||
|
||||
@Suppress("NON_EXHAUSTIVE_WHEN") // Many when uses in here are much clearer this way
|
||||
class QuestManager {
|
||||
|
||||
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) {
|
||||
val rewardInfluence = civInfo.gameInfo.ruleSet.quests[assignedQuest.questName]!!.influece
|
||||
val assignee = civInfo.gameInfo.getCivilization(assignedQuest.assignee)
|
||||
@ -357,6 +358,7 @@ class QuestManager {
|
||||
|
||||
/** Returns the score for the [assignedQuest] */
|
||||
private fun getScoreForQuest(assignedQuest: AssignedQuest): Int {
|
||||
@Suppress("UNUSED_VARIABLE") // This is a work in progress
|
||||
val assignee = civInfo.gameInfo.getCivilization(assignedQuest.assignee)
|
||||
return when (assignedQuest.questName) {
|
||||
// Waiting for contest quests
|
||||
|
@ -287,7 +287,7 @@ class ReligionManager {
|
||||
if (religion == null) return 0
|
||||
return civInfo.gameInfo.getCities()
|
||||
.filter { it.matchesFilter(cityFilter, civInfo) }
|
||||
.sumBy { it.religion.getFollowersOf(religion!!.name)!! }
|
||||
.sumOf { it.religion.getFollowersOf(religion!!.name)!! }
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -25,7 +25,7 @@ enum class RelationshipLevel(val color: Color) {
|
||||
Ally(Color.CHARTREUSE) // HSV(90,100,100)
|
||||
}
|
||||
|
||||
enum class DiplomacyFlags{
|
||||
enum class DiplomacyFlags {
|
||||
DeclinedLuxExchange,
|
||||
DeclinedPeace,
|
||||
DeclinedResearchAgreement,
|
||||
@ -46,7 +46,7 @@ enum class DiplomacyFlags{
|
||||
AngerFreeIntrusion
|
||||
}
|
||||
|
||||
enum class DiplomaticModifiers{
|
||||
enum class DiplomaticModifiers {
|
||||
DeclaredWarOnUs,
|
||||
WarMongerer,
|
||||
CapturedOurCities,
|
||||
@ -743,6 +743,7 @@ class DiplomacyManager() {
|
||||
for (thirdCiv in getCommonKnownCivs()
|
||||
.filter { it.getDiplomacyManager(civInfo).hasFlag(DiplomacyFlags.DeclarationOfFriendship) }) {
|
||||
val otherCivRelationshipWithThirdCiv = otherCiv().getDiplomacyManager(thirdCiv).relationshipLevel()
|
||||
@Suppress("NON_EXHAUSTIVE_WHEN") // Better readability
|
||||
when (otherCivRelationshipWithThirdCiv) {
|
||||
RelationshipLevel.Unforgivable -> addModifier(DiplomaticModifiers.DeclaredFriendshipWithOurEnemies, -15f)
|
||||
RelationshipLevel.Enemy -> addModifier(DiplomaticModifiers.DeclaredFriendshipWithOurEnemies, -5f)
|
||||
@ -765,6 +766,7 @@ class DiplomacyManager() {
|
||||
thirdCiv.addNotification("[${civInfo.civName}] has denounced [$otherCivName]!", civInfo.civName, NotificationIcon.Diplomacy, otherCivName)
|
||||
val thirdCivRelationshipWithOtherCiv = thirdCiv.getDiplomacyManager(otherCiv()).relationshipLevel()
|
||||
val thirdCivDiplomacyManager = thirdCiv.getDiplomacyManager(civInfo)
|
||||
@Suppress("NON_EXHAUSTIVE_WHEN") // Better readability
|
||||
when (thirdCivRelationshipWithOtherCiv) {
|
||||
RelationshipLevel.Unforgivable -> thirdCivDiplomacyManager.addModifier(DiplomaticModifiers.DenouncedOurEnemies, 15f)
|
||||
RelationshipLevel.Enemy -> thirdCivDiplomacyManager.addModifier(DiplomaticModifiers.DenouncedOurEnemies, 5f)
|
||||
|
Loading…
x
Reference in New Issue
Block a user