mirror of
https://github.com/yairm210/Unciv.git
synced 2025-09-24 03:53:12 -04:00
chore(purity): Removed suppressions
This commit is contained in:
parent
714fc6cfa6
commit
3af195fe11
@ -54,6 +54,13 @@ allprojects {
|
||||
"com.badlogic.gdx.math.Vector2.len",
|
||||
"com.badlogic.gdx.math.Vector2.cpy",
|
||||
"com.badlogic.gdx.math.Vector2.hashCode",
|
||||
|
||||
"com.badlogic.gdx.files.FileHandle.child",
|
||||
"com.badlogic.gdx.files.FileHandle.list",
|
||||
"com.badlogic.gdx.files.FileHandle.exists",
|
||||
"com.badlogic.gdx.files.FileHandle.isDirectory",
|
||||
"com.badlogic.gdx.files.FileHandle.isFile",
|
||||
"com.badlogic.gdx.files.FileHandle.name",
|
||||
)
|
||||
wellKnownPureClasses = setOf(
|
||||
)
|
||||
|
@ -16,13 +16,14 @@ import com.unciv.models.ruleset.nation.PersonalityValue
|
||||
import com.unciv.models.ruleset.unique.UniqueType
|
||||
import com.unciv.models.ruleset.unit.BaseUnit
|
||||
import com.unciv.ui.screens.victoryscreen.RankingType
|
||||
import yairm210.purity.annotations.Pure
|
||||
import yairm210.purity.annotations.Readonly
|
||||
|
||||
object MotivationToAttackAutomation {
|
||||
|
||||
/** Will return the motivation to attack, but might short circuit if the value is guaranteed to
|
||||
* be lower than `atLeast`. So any values below `atLeast` should not be used for comparison. */
|
||||
@Readonly @Suppress("purity")
|
||||
@Readonly @Suppress("purity") // requires changing dependents from mutating to readonly
|
||||
fun hasAtLeastMotivationToAttack(civInfo: Civilization, targetCiv: Civilization, atLeast: Float): Float {
|
||||
val diplomacyManager = civInfo.getDiplomacyManager(targetCiv)!!
|
||||
val personality = civInfo.getPersonality()
|
||||
@ -156,6 +157,19 @@ object MotivationToAttackAutomation {
|
||||
if (civInfo.getCapital() != null) ourCombatStrength += CityCombatant(civInfo.getCapital()!!).getCityStrength()
|
||||
return ourCombatStrength
|
||||
}
|
||||
|
||||
@Pure
|
||||
fun addHelloWorld(@Pure add: (String) -> Unit){
|
||||
add("Hello")
|
||||
add("World")
|
||||
}
|
||||
|
||||
@Pure
|
||||
fun a(): MutableList<String> {
|
||||
val myList = mutableListOf<String>()
|
||||
addHelloWorld{myList.add(it)}
|
||||
return myList
|
||||
}
|
||||
|
||||
private fun addWonderBasedMotivations(otherCiv: Civilization, modifiers: MutableList<Pair<String, Float>>) {
|
||||
var wonderCount = 0
|
||||
|
@ -605,7 +605,7 @@ class MapUnit : IsPartOfGameInfoSerialization {
|
||||
}
|
||||
|
||||
/** Implements [UniqueParameterType.MapUnitFilter][com.unciv.models.ruleset.unique.UniqueParameterType.MapUnitFilter] */
|
||||
@Readonly @Suppress("purity") // allow passing functions like this
|
||||
@Readonly
|
||||
fun matchesFilter(filter: String, multiFilter: Boolean = true): Boolean {
|
||||
return if (multiFilter) MultiFilter.multiFilter(filter, ::matchesSingleFilter) else matchesSingleFilter(filter)
|
||||
}
|
||||
|
@ -36,7 +36,6 @@ import com.unciv.utils.Log
|
||||
import org.jetbrains.annotations.VisibleForTesting
|
||||
import yairm210.purity.annotations.Readonly
|
||||
import kotlin.collections.set
|
||||
|
||||
enum class RulesetFile(
|
||||
val filename: String,
|
||||
@Readonly val getRulesetObjects: Ruleset.() -> Sequence<IRulesetObject> = { emptySequence() },
|
||||
@ -292,9 +291,9 @@ class Ruleset {
|
||||
events.clear()
|
||||
}
|
||||
|
||||
@Readonly @Suppress("purity")
|
||||
@Readonly
|
||||
fun allRulesetObjects(): Sequence<IRulesetObject> = RulesetFile.entries.asSequence().flatMap { it.getRulesetObjects(this) }
|
||||
@Readonly @Suppress("purity")
|
||||
@Readonly
|
||||
fun allUniques(): Sequence<Unique> = RulesetFile.entries.asSequence().flatMap { it.getUniques(this) }
|
||||
@Readonly fun allICivilopediaText(): Sequence<ICivilopediaText> = allRulesetObjects() + events.values.flatMap { it.choices }
|
||||
|
||||
@ -546,6 +545,7 @@ class Ruleset {
|
||||
else -> "Combined RuleSet ($mods)"
|
||||
}
|
||||
|
||||
@Readonly
|
||||
fun getSummary(): String {
|
||||
val stringList = ArrayList<String>()
|
||||
if (modOptions.isBaseRuleset) stringList += "Base Ruleset"
|
||||
|
@ -30,7 +30,6 @@ internal sealed interface Node {
|
||||
}
|
||||
|
||||
class BinaryOperation(private val operator: Operator.Binary, private val left: Node, private val right: Node): Node {
|
||||
@Suppress("purity")
|
||||
override fun eval(context: GameContext): Double = operator.implementation(left.eval(context), right.eval(context))
|
||||
override fun toString() = "($left $operator $right)"
|
||||
override fun getErrors(ruleset: Ruleset): List<String> {
|
||||
|
@ -40,9 +40,10 @@ object ModCompatibility {
|
||||
}
|
||||
|
||||
// If there's media (audio folders or any atlas), show the PAV choice...
|
||||
@Readonly @Suppress("purity") // requies marking file functions
|
||||
@Readonly
|
||||
private fun isAudioVisualGuessed(mod: Ruleset): Boolean {
|
||||
val folder = mod.folderLocation ?: return false // Also catches isBuiltin
|
||||
@Readonly
|
||||
fun isSubFolderNotEmpty(modFolder: FileHandle, name: String): Boolean {
|
||||
val file = modFolder.child(name)
|
||||
if (!file.exists()) return false
|
||||
@ -62,7 +63,6 @@ object ModCompatibility {
|
||||
&& !mod.modOptions.hasUnique(UniqueType.ModIsAudioVisualOnly)
|
||||
|
||||
@Readonly
|
||||
@Suppress("purity") // requies marking file functions
|
||||
fun isConstantsOnly(mod: Ruleset): Boolean {
|
||||
val folder = mod.folderLocation ?: return false
|
||||
if (folder.list("atlas").isNotEmpty()) return false
|
||||
|
Loading…
x
Reference in New Issue
Block a user