mirror of
https://github.com/yairm210/Unciv.git
synced 2025-09-25 12:54:06 -04:00
chore(purity): minor
This commit is contained in:
parent
8db6383e58
commit
064ba90990
@ -26,6 +26,7 @@ import com.unciv.models.ruleset.unit.BaseUnit
|
||||
import com.unciv.models.stats.Stat
|
||||
import com.unciv.ui.screens.victoryscreen.RankingType
|
||||
import com.unciv.utils.randomWeighted
|
||||
import yairm210.purity.annotations.Readonly
|
||||
import kotlin.random.Random
|
||||
|
||||
object NextTurnAutomation {
|
||||
@ -582,13 +583,14 @@ object NextTurnAutomation {
|
||||
diplomacyManager.removeFlag(demand.violationOccurred)
|
||||
}
|
||||
|
||||
|
||||
@Readonly
|
||||
fun getMinDistanceBetweenCities(civ1: Civilization, civ2: Civilization): Int {
|
||||
return getClosestCities(civ1, civ2)?.aerialDistance ?: Int.MAX_VALUE
|
||||
}
|
||||
|
||||
data class CityDistance(val city1: City, val city2: City, val aerialDistance: Int)
|
||||
|
||||
@Readonly
|
||||
fun getClosestCities(civ1: Civilization, civ2: Civilization): CityDistance? {
|
||||
if (civ1.cities.isEmpty() || civ2.cities.isEmpty())
|
||||
return null
|
||||
|
@ -25,6 +25,7 @@ import com.unciv.models.stats.Stats
|
||||
import com.unciv.ui.screens.worldscreen.unit.actions.UnitActions
|
||||
import com.unciv.ui.screens.worldscreen.unit.actions.UnitActionsFromUniques
|
||||
import com.unciv.utils.debug
|
||||
import yairm210.purity.annotations.Readonly
|
||||
import kotlin.math.abs
|
||||
|
||||
/**
|
||||
@ -679,6 +680,7 @@ class WorkerAutomation(
|
||||
* Can return `true` if there is an improvement that does not match the resource (for future modding abilities).
|
||||
* Does not check tile ownership - caller [automateWorkBoats] already did, other callers need to ensure this explicitly.
|
||||
*/
|
||||
@Readonly
|
||||
fun hasWorkableSeaResource(tile: Tile, civInfo: Civilization) = when {
|
||||
!tile.isWater -> false
|
||||
tile.resource == null -> false
|
||||
@ -695,6 +697,7 @@ class WorkerAutomation(
|
||||
* Only tests resource type and city range, not any improvement requirements.
|
||||
* @throws NullPointerException on tiles without a resource
|
||||
*/
|
||||
@Readonly
|
||||
fun isNotBonusResourceOrWorkable(tile: Tile, civInfo: Civilization): Boolean =
|
||||
tile.tileResource.resourceType != ResourceType.Bonus // Improve Oil even if no City reaps the yields
|
||||
|| civInfo.cities.any { it.tilesInRange.contains(tile) } // Improve Fish only if any of our Cities reaps the yields
|
||||
|
Loading…
x
Reference in New Issue
Block a user