diff --git a/core/src/com/unciv/logic/HexMath.kt b/core/src/com/unciv/logic/HexMath.kt index f9a8db369e..729876a6c0 100644 --- a/core/src/com/unciv/logic/HexMath.kt +++ b/core/src/com/unciv/logic/HexMath.kt @@ -227,19 +227,17 @@ object HexMath { return minOf(left, right, top, bottom) } else { val radius = mapParameters.mapSize.radius - if (mapParameters.worldWrap) { - // The non-wrapping method holds in the upper two and lower two 'triangles' of the hexagon - // but needs special casing for left and right 'wedges', where only distance from the - // 'choke points' counts (upper and lower hex at the 'seam' where height is smallest). - // These are at (radius,0) and (0,-radius) - if (x.sign == y.sign) return radius - getDistance(vector, Vector2.Zero) - // left wedge - the 'choke points' are not wrapped relative to us - if (x > 0) return min(getDistance(vector, Vector2(radius.toFloat(),0f)), getDistance(vector, Vector2(0f, -radius.toFloat()))) - // right wedge - compensate wrap by using a hex 1 off along the edge - same result - return min(getDistance(vector, Vector2(1f, radius.toFloat())), getDistance(vector, Vector2(-radius.toFloat(), -1f))) - } else { - return radius - getDistance(vector, Vector2.Zero) - } + if (!mapParameters.worldWrap) return radius - getDistance(vector, Vector2.Zero) + + // The non-wrapping method holds in the upper two and lower two 'triangles' of the hexagon + // but needs special casing for left and right 'wedges', where only distance from the + // 'choke points' counts (upper and lower hex at the 'seam' where height is smallest). + // These are at (radius,0) and (0,-radius) + if (x.sign == y.sign) return radius - getDistance(vector, Vector2.Zero) + // left wedge - the 'choke points' are not wrapped relative to us + if (x > 0) return min(getDistance(vector, Vector2(radius.toFloat(),0f)), getDistance(vector, Vector2(0f, -radius.toFloat()))) + // right wedge - compensate wrap by using a hex 1 off along the edge - same result + return min(getDistance(vector, Vector2(1f, radius.toFloat())), getDistance(vector, Vector2(-radius.toFloat(), -1f))) } } } diff --git a/core/src/com/unciv/logic/city/CityInfo.kt b/core/src/com/unciv/logic/city/CityInfo.kt index faaeef8966..daab0b8d40 100644 --- a/core/src/com/unciv/logic/city/CityInfo.kt +++ b/core/src/com/unciv/logic/city/CityInfo.kt @@ -282,7 +282,7 @@ class CityInfo { if (tileInfo.improvement == null) continue val tileImprovement = tileInfo.getTileImprovement() for (unique in tileImprovement!!.uniqueObjects) { - if (unique.matches(UniqueType.ProvidesResources, getRuleset())) { + if (unique.isOfType(UniqueType.ProvidesResources)) { if (!unique.conditionalsApply(civInfo, this)) continue val resource = getRuleset().tileResources[unique.params[1]] ?: continue cityResources.add( @@ -291,7 +291,7 @@ class CityInfo { "Improvements" ) } - if (unique.matches(UniqueType.ConsumesResources, getRuleset())) { + if (unique.isOfType(UniqueType.ConsumesResources)) { val resource = getRuleset().tileResources[unique.params[1]] ?: continue cityResources.add( resource, diff --git a/core/src/com/unciv/logic/city/CityStats.kt b/core/src/com/unciv/logic/city/CityStats.kt index cd5e294dc5..edccc57b0f 100644 --- a/core/src/com/unciv/logic/city/CityStats.kt +++ b/core/src/com/unciv/logic/city/CityStats.kt @@ -244,14 +244,6 @@ class CityStats(val cityInfo: CityInfo) { // "[stats] in cities on [tileFilter] tiles" if (unique.placeholderText == "[] in cities on [] tiles" && cityInfo.getCenterTile().matchesTerrainFilter(unique.params[1])) stats.add(unique.stats) - - // Deprecated since 3.16.16 - // "[stats] if this city has at least [amount] specialists" - if (unique.matches(UniqueType.StatBonusForNumberOfSpecialists, cityInfo.getRuleset()) - && cityInfo.population.getNumberOfSpecialists() >= unique.params[1].toInt() - ) - stats.add(unique.stats) - // if (unique.placeholderText == "[] per turn from cities before []" && !cityInfo.civInfo.hasTechOrPolicy(unique.params[1])) stats.add(unique.stats) diff --git a/core/src/com/unciv/logic/civilization/CivilizationInfo.kt b/core/src/com/unciv/logic/civilization/CivilizationInfo.kt index 2fcf3dc835..a3ee092a1e 100644 --- a/core/src/com/unciv/logic/civilization/CivilizationInfo.kt +++ b/core/src/com/unciv/logic/civilization/CivilizationInfo.kt @@ -352,8 +352,7 @@ class CivilizationInfo { // Does not return local uniques, only global ones. /** Destined to replace getMatchingUniques, gradually, as we fill the enum */ fun getMatchingUniques(uniqueType: UniqueType, stateForConditionals: StateForConditionals? = null, cityToIgnore: CityInfo? = null) = sequence { - val ruleset = gameInfo.ruleSet - yieldAll(nation.uniqueObjects.asSequence().filter {it.matches(uniqueType, ruleset) }) + yieldAll(nation.uniqueObjects.asSequence().filter {it.isOfType(uniqueType) }) yieldAll(cities.asSequence() .filter { it != cityToIgnore } .flatMap { city -> city.getMatchingUniquesWithNonLocalEffects(uniqueType) } @@ -362,7 +361,7 @@ class CivilizationInfo { yieldAll(tech.techUniques.getUniques(uniqueType)) yieldAll(temporaryUniques.asSequence() .map { it.first } - .filter { it.matches(uniqueType, ruleset) } + .filter { it.isOfType(uniqueType) } ) yieldAll(getEra().getMatchingUniques(uniqueType)) if (religionManager.religion != null) diff --git a/core/src/com/unciv/logic/map/TileInfo.kt b/core/src/com/unciv/logic/map/TileInfo.kt index 8be4d19cb5..d47f203a7b 100644 --- a/core/src/com/unciv/logic/map/TileInfo.kt +++ b/core/src/com/unciv/logic/map/TileInfo.kt @@ -413,7 +413,7 @@ open class TileInfo { matchesTerrainFilter(it.params[0]) && !civInfo.tech.isResearched(it.params[1]) } -> false improvement.uniqueObjects.any { - it.matches(UniqueType.ConsumesResources, ruleset) + it.isOfType(UniqueType.ConsumesResources) && civInfo.getCivResourcesByName()[it.params[1]]!! < it.params[0].toInt() } -> false else -> canImprovementBeBuiltHere(improvement, hasViewableResource(civInfo)) diff --git a/core/src/com/unciv/models/ruleset/unique/Unique.kt b/core/src/com/unciv/models/ruleset/unique/Unique.kt index 8d0efb72e8..ba4f893deb 100644 --- a/core/src/com/unciv/models/ruleset/unique/Unique.kt +++ b/core/src/com/unciv/models/ruleset/unique/Unique.kt @@ -24,10 +24,6 @@ class Unique(val text: String, val sourceObjectType: UniqueTarget? = null, val s fun isOfType(uniqueType: UniqueType) = uniqueType == type - /** We can't save compliance errors in the unique, since it's ruleset-dependant */ - fun matches(uniqueType: UniqueType, ruleset: Ruleset) = isOfType(uniqueType) - && uniqueType.getComplianceErrors(this, ruleset).isEmpty() - fun conditionalsApply(civInfo: CivilizationInfo? = null, city: CityInfo? = null): Boolean { return conditionalsApply(StateForConditionals(civInfo, city)) } @@ -112,3 +108,4 @@ class UniqueMap: HashMap>() { fun getAllUniques() = this.asSequence().flatMap { it.value.asSequence() } } + diff --git a/core/src/com/unciv/models/ruleset/unique/UniqueType.kt b/core/src/com/unciv/models/ruleset/unique/UniqueType.kt index dbff14e5c0..5f35d56724 100644 --- a/core/src/com/unciv/models/ruleset/unique/UniqueType.kt +++ b/core/src/com/unciv/models/ruleset/unique/UniqueType.kt @@ -64,7 +64,7 @@ enum class UniqueType(val text:String, vararg targets: UniqueTarget) { Stats("[stats]", UniqueTarget.Global, UniqueTarget.FollowerBelief), StatsPerCity("[stats] [cityFilter]", UniqueTarget.Global), - @Deprecated("As of 3.16.16", ReplaceWith("[stats] "), DeprecationLevel.WARNING) + @Deprecated("As of 3.16.16", ReplaceWith("[stats] "), DeprecationLevel.ERROR) StatBonusForNumberOfSpecialists("[stats] if this city has at least [amount] specialists", UniqueTarget.Global), StatPercentBonus("[amount]% [stat]", UniqueTarget.Global), diff --git a/core/src/com/unciv/ui/worldscreen/unit/UnitActions.kt b/core/src/com/unciv/ui/worldscreen/unit/UnitActions.kt index ad258921a1..d2481fc606 100644 --- a/core/src/com/unciv/ui/worldscreen/unit/UnitActions.kt +++ b/core/src/com/unciv/ui/worldscreen/unit/UnitActions.kt @@ -595,7 +595,7 @@ object UnitActions { var resourcesAvailable = true if (improvement.uniqueObjects.any { - it.matches(UniqueType.ConsumesResources, tile.ruleset) && civResources[unique.params[1]] ?: 0 < unique.params[0].toInt() + it.isOfType(UniqueType.ConsumesResources, tile.ruleset) && civResources[unique.params[1]] ?: 0 < unique.params[0].toInt() }) resourcesAvailable = false