mirror of
https://github.com/yairm210/Unciv.git
synced 2025-09-26 13:27:22 -04:00
Kotlin 1.5 new warnings - partial (#5120)
This commit is contained in:
parent
8b6881c76b
commit
ab5083173d
@ -182,7 +182,7 @@ class MapUnit {
|
|||||||
if (isEmbarked()) 2
|
if (isEmbarked()) 2
|
||||||
else baseUnit.movement
|
else baseUnit.movement
|
||||||
|
|
||||||
movement += getMatchingUniques("[] Movement").sumBy { it.params[0].toInt() }
|
movement += getMatchingUniques("[] Movement").sumOf { it.params[0].toInt() }
|
||||||
|
|
||||||
for (unique in civInfo.getMatchingUniques("+[] Movement for all [] units"))
|
for (unique in civInfo.getMatchingUniques("+[] Movement for all [] units"))
|
||||||
if (matchesFilter(unique.params[1]))
|
if (matchesFilter(unique.params[1]))
|
||||||
@ -277,7 +277,7 @@ class MapUnit {
|
|||||||
visibilityRange += unique.params[0].toInt()
|
visibilityRange += unique.params[0].toInt()
|
||||||
|
|
||||||
// TODO: This should be replaced with "Sight" like others, for naming consistency
|
// TODO: This should be replaced with "Sight" like others, for naming consistency
|
||||||
visibilityRange += getMatchingUniques("[] Visibility Range").sumBy { it.params[0].toInt() }
|
visibilityRange += getMatchingUniques("[] Visibility Range").sumOf { it.params[0].toInt() }
|
||||||
|
|
||||||
if (hasUnique("Limited Visibility")) visibilityRange -= 1
|
if (hasUnique("Limited Visibility")) visibilityRange -= 1
|
||||||
|
|
||||||
@ -344,7 +344,7 @@ class MapUnit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun maxAttacksPerTurn(): Int {
|
fun maxAttacksPerTurn(): Int {
|
||||||
var maxAttacksPerTurn = 1 + getMatchingUniques("[] additional attacks per turn").sumBy { it.params[0].toInt() }
|
var maxAttacksPerTurn = 1 + getMatchingUniques("[] additional attacks per turn").sumOf { it.params[0].toInt() }
|
||||||
return maxAttacksPerTurn
|
return maxAttacksPerTurn
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -356,7 +356,7 @@ class MapUnit {
|
|||||||
fun getRange(): Int {
|
fun getRange(): Int {
|
||||||
if (baseUnit.isMelee()) return 1
|
if (baseUnit.isMelee()) return 1
|
||||||
var range = baseUnit().range
|
var range = baseUnit().range
|
||||||
range += getMatchingUniques("[] Range").sumBy { it.params[0].toInt() }
|
range += getMatchingUniques("[] Range").sumOf { it.params[0].toInt() }
|
||||||
return range
|
return range
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -440,7 +440,7 @@ class MapUnit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun adjacentHealingBonus(): Int {
|
private fun adjacentHealingBonus(): Int {
|
||||||
return getMatchingUniques("All adjacent units heal [] HP when healing").sumBy { it.params[0].toInt() }
|
return getMatchingUniques("All adjacent units heal [] HP when healing").sumOf { it.params[0].toInt() }
|
||||||
}
|
}
|
||||||
|
|
||||||
fun canGarrison() = baseUnit.isMilitary() && baseUnit.isLandUnit()
|
fun canGarrison() = baseUnit.isMilitary() && baseUnit.isLandUnit()
|
||||||
@ -469,7 +469,7 @@ class MapUnit {
|
|||||||
for (ability in abilityUsedCount) {
|
for (ability in abilityUsedCount) {
|
||||||
val maxUsesOfThisAbility = getMatchingUniques("Can [] [] times")
|
val maxUsesOfThisAbility = getMatchingUniques("Can [] [] times")
|
||||||
.filter { it.params[0] == ability.key }
|
.filter { it.params[0] == ability.key }
|
||||||
.sumBy { it.params[1].toInt() }
|
.sumOf { it.params[1].toInt() }
|
||||||
abilityUsesLeft[ability.key] = maxUsesOfThisAbility - ability.value
|
abilityUsesLeft[ability.key] = maxUsesOfThisAbility - ability.value
|
||||||
maxAbilityUses[ability.key] = maxUsesOfThisAbility
|
maxAbilityUses[ability.key] = maxUsesOfThisAbility
|
||||||
}
|
}
|
||||||
@ -595,7 +595,7 @@ class MapUnit {
|
|||||||
var amountToHealBy = rankTileForHealing(getTile())
|
var amountToHealBy = rankTileForHealing(getTile())
|
||||||
if (amountToHealBy == 0 && !(hasUnique("May heal outside of friendly territory") && !getTile().isFriendlyTerritory(civInfo))) return
|
if (amountToHealBy == 0 && !(hasUnique("May heal outside of friendly territory") && !getTile().isFriendlyTerritory(civInfo))) return
|
||||||
|
|
||||||
amountToHealBy += getMatchingUniques("[] HP when healing").sumBy { it.params[0].toInt() }
|
amountToHealBy += getMatchingUniques("[] HP when healing").sumOf { it.params[0].toInt() }
|
||||||
|
|
||||||
val maxAdjacentHealingBonus = currentTile.getTilesInDistance(1)
|
val maxAdjacentHealingBonus = currentTile.getTilesInDistance(1)
|
||||||
.flatMap { it.getUnits().asSequence() }.map { it.adjacentHealingBonus() }.maxOrNull()
|
.flatMap { it.getUnits().asSequence() }.map { it.adjacentHealingBonus() }.maxOrNull()
|
||||||
@ -858,13 +858,13 @@ class MapUnit {
|
|||||||
fun canIntercept(): Boolean {
|
fun canIntercept(): Boolean {
|
||||||
if (interceptChance() == 0) return false
|
if (interceptChance() == 0) return false
|
||||||
val maxAttacksPerTurn = 1 +
|
val maxAttacksPerTurn = 1 +
|
||||||
getMatchingUniques("[] extra interceptions may be made per turn").sumBy { it.params[0].toInt() }
|
getMatchingUniques("[] extra interceptions may be made per turn").sumOf { it.params[0].toInt() }
|
||||||
if (attacksThisTurn >= maxAttacksPerTurn) return false
|
if (attacksThisTurn >= maxAttacksPerTurn) return false
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
fun interceptChance(): Int {
|
fun interceptChance(): Int {
|
||||||
return getMatchingUniques("[]% chance to intercept air attacks").sumBy { it.params[0].toInt() }
|
return getMatchingUniques("[]% chance to intercept air attacks").sumOf { it.params[0].toInt() }
|
||||||
}
|
}
|
||||||
|
|
||||||
fun isTransportTypeOf(mapUnit: MapUnit): Boolean {
|
fun isTransportTypeOf(mapUnit: MapUnit): Boolean {
|
||||||
@ -872,13 +872,12 @@ class MapUnit {
|
|||||||
if (!mapUnit.baseUnit.movesLikeAirUnits()) return false
|
if (!mapUnit.baseUnit.movesLikeAirUnits()) return false
|
||||||
return getMatchingUniques("Can carry [] [] units").any { mapUnit.matchesFilter(it.params[1]) }
|
return getMatchingUniques("Can carry [] [] units").any { mapUnit.matchesFilter(it.params[1]) }
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun carryCapacity(unit: MapUnit): Int {
|
private fun carryCapacity(unit: MapUnit): Int {
|
||||||
var capacity = getMatchingUniques("Can carry [] [] units").filter { unit.matchesFilter(it.params[1]) }
|
return (getMatchingUniques("Can carry [] [] units")
|
||||||
.sumBy { it.params[0].toInt() }
|
+ getMatchingUniques("Can carry [] extra [] units"))
|
||||||
capacity += getMatchingUniques("Can carry [] extra [] units").filter { unit.matchesFilter(it.params[1]) }
|
.filter { unit.matchesFilter(it.params[1]) }
|
||||||
.sumBy { it.params[0].toInt() }
|
.sumOf { it.params[0].toInt() }
|
||||||
return capacity
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun canTransport(unit: MapUnit): Boolean {
|
fun canTransport(unit: MapUnit): Boolean {
|
||||||
@ -891,7 +890,7 @@ class MapUnit {
|
|||||||
|
|
||||||
fun interceptDamagePercentBonus(): Int {
|
fun interceptDamagePercentBonus(): Int {
|
||||||
return getUniques().filter { it.placeholderText == "[]% Damage when intercepting"}
|
return getUniques().filter { it.placeholderText == "[]% Damage when intercepting"}
|
||||||
.sumBy { it.params[0].toInt() }
|
.sumOf { it.params[0].toInt() }
|
||||||
}
|
}
|
||||||
|
|
||||||
fun receivedInterceptDamageFactor(): Float {
|
fun receivedInterceptDamageFactor(): Float {
|
||||||
@ -999,9 +998,9 @@ class MapUnit {
|
|||||||
fun getBaseMaxActionUses(action: String): Int {
|
fun getBaseMaxActionUses(action: String): Int {
|
||||||
return getMatchingUniques("Can [] [] times")
|
return getMatchingUniques("Can [] [] times")
|
||||||
.filter { it.params[0] == action }
|
.filter { it.params[0] == action }
|
||||||
.sumBy { it.params[1].toInt() }
|
.sumOf { it.params[1].toInt() }
|
||||||
}
|
}
|
||||||
|
|
||||||
fun setupAbilityUses(buildCity: CityInfo? = null) {
|
fun setupAbilityUses(buildCity: CityInfo? = null) {
|
||||||
for (action in religiousActionsUnitCanDo()) {
|
for (action in religiousActionsUnitCanDo()) {
|
||||||
val baseAmount = getBaseMaxActionUses(action)
|
val baseAmount = getBaseMaxActionUses(action)
|
||||||
@ -1009,15 +1008,14 @@ class MapUnit {
|
|||||||
if (buildCity == null) 0
|
if (buildCity == null) 0
|
||||||
else buildCity.getMatchingUniques("[] units built [] can [] [] extra times")
|
else buildCity.getMatchingUniques("[] units built [] can [] [] extra times")
|
||||||
.filter { matchesFilter(it.params[0]) && buildCity.matchesFilter(it.params[1]) && it.params[2] == action }
|
.filter { matchesFilter(it.params[0]) && buildCity.matchesFilter(it.params[1]) && it.params[2] == action }
|
||||||
.sumBy { println("Addition ability found: ${it.params[1]}"); it.params[3].toInt() }
|
.sumOf { it.params[3].toInt() }
|
||||||
|
|
||||||
maxAbilityUses[action] = baseAmount + additional
|
maxAbilityUses[action] = baseAmount + additional
|
||||||
|
abilityUsesLeft[action] = baseAmount + additional
|
||||||
abilityUsesLeft[action] = maxAbilityUses[action]!!
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
fun getPressureAddedFromSpread(): Int {
|
fun getPressureAddedFromSpread(): Int {
|
||||||
var pressureAdded = baseUnit.religiousStrength.toFloat()
|
var pressureAdded = baseUnit.religiousStrength.toFloat()
|
||||||
for (unique in civInfo.getMatchingUniques("[]% Spread Religion Strength for [] units"))
|
for (unique in civInfo.getMatchingUniques("[]% Spread Religion Strength for [] units"))
|
||||||
|
@ -482,8 +482,8 @@ class BaseUnit : INamed, INonPerpetualConstruction, ICivilopediaText {
|
|||||||
if (getType().matchesFilter(filter)) return true
|
if (getType().matchesFilter(filter)) return true
|
||||||
if (
|
if (
|
||||||
filter.endsWith(" units")
|
filter.endsWith(" units")
|
||||||
// "military units" --> "Military"
|
// "military units" --> "Military", using invariant locale
|
||||||
&& matchesFilter(filter.removeSuffix(" units").toLowerCase(Locale.ENGLISH).capitalize(Locale.ENGLISH))
|
&& matchesFilter(filter.removeSuffix(" units").lowercase().replaceFirstChar { it.uppercaseChar() })
|
||||||
) return true
|
) return true
|
||||||
return uniques.contains(filter)
|
return uniques.contains(filter)
|
||||||
}
|
}
|
||||||
|
@ -58,7 +58,6 @@ class CityScreenCityPickerTable(private val cityScreen: CityScreen) : Table() {
|
|||||||
actionOnOk = { text ->
|
actionOnOk = { text ->
|
||||||
city.name = text
|
city.name = text
|
||||||
cityScreen.game.setScreen(CityScreen(city))
|
cityScreen.game.setScreen(CityScreen(city))
|
||||||
true
|
|
||||||
}
|
}
|
||||||
).open()
|
).open()
|
||||||
}
|
}
|
||||||
|
@ -173,7 +173,6 @@ class CivilopediaScreen(
|
|||||||
onBackButtonClicked { UncivGame.Current.setWorldScreen() }
|
onBackButtonClicked { UncivGame.Current.setWorldScreen() }
|
||||||
|
|
||||||
val hideReligionItems = !game.gameInfo.hasReligionEnabled()
|
val hideReligionItems = !game.gameInfo.hasReligionEnabled()
|
||||||
val noCulturalVictory = VictoryType.Cultural !in game.gameInfo.gameParameters.victoryTypes
|
|
||||||
|
|
||||||
fun shouldBeDisplayed(uniqueObjects: List<Unique>): Boolean {
|
fun shouldBeDisplayed(uniqueObjects: List<Unique>): Boolean {
|
||||||
val uniques = uniqueObjects.map { it.placeholderText }
|
val uniques = uniqueObjects.map { it.placeholderText }
|
||||||
|
@ -13,8 +13,7 @@ import com.badlogic.gdx.scenes.scene2d.ui.TextField
|
|||||||
* @param maxLength The maximal amount of characters the user may input
|
* @param maxLength The maximal amount of characters the user may input
|
||||||
* @param validate Function that should return `true` when a valid input is entered, false otherwise
|
* @param validate Function that should return `true` when a valid input is entered, false otherwise
|
||||||
* @param actionOnOk Lambda that will be executed after pressing 'OK'.
|
* @param actionOnOk Lambda that will be executed after pressing 'OK'.
|
||||||
* Gets the text the user inputted as a parameter. Should return `true` if ready to close,
|
* Gets the text the user inputted as a parameter.
|
||||||
* `false` if `errorText` is to be displayed
|
|
||||||
*/
|
*/
|
||||||
class AskTextPopup(
|
class AskTextPopup(
|
||||||
screen: CameraStageBaseScreen,
|
screen: CameraStageBaseScreen,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user