diff --git a/core/src/com/unciv/logic/battle/BattleDamage.kt b/core/src/com/unciv/logic/battle/BattleDamage.kt index ba5bb758..5cb46c5b 100644 --- a/core/src/com/unciv/logic/battle/BattleDamage.kt +++ b/core/src/com/unciv/logic/battle/BattleDamage.kt @@ -151,7 +151,7 @@ object BattleDamage { modifiers["Autocracy Complete"] = 0.2f if (defender is CityCombatant && - attacker.getCivInfo().containsBuildingUnique("+15% Combat Strength for all units when attacking Cities")) + attacker.getCivInfo().hasUnique("+15% Combat Strength for all units when attacking Cities")) modifiers["Statue of Zeus"] = 0.15f } else if (attacker is CityCombatant) { if (policies.hasEffect("Units in cities cost no Maintenance, garrisoned city +50% attacking strength") @@ -207,7 +207,7 @@ object BattleDamage { private fun getTileSpecificModifiers(unit: MapUnitCombatant, tile: TileInfo): HashMap { val modifiers = HashMap() - if(tile.isFriendlyTerritory(unit.getCivInfo()) && unit.getCivInfo().containsBuildingUnique("+15% combat strength for units fighting in friendly territory")) + if(tile.isFriendlyTerritory(unit.getCivInfo()) && unit.getCivInfo().hasUnique("+15% combat strength for units fighting in friendly territory")) modifiers["Himeji Castle"] = 0.15f if(!tile.isFriendlyTerritory(unit.getCivInfo()) && unit.unit.hasUnique("+20% bonus outside friendly territory")) modifiers["Foreign Land"] = 0.2f diff --git a/core/src/com/unciv/logic/battle/CityCombatant.kt b/core/src/com/unciv/logic/battle/CityCombatant.kt index dcb3a840..1573198c 100644 --- a/core/src/com/unciv/logic/battle/CityCombatant.kt +++ b/core/src/com/unciv/logic/battle/CityCombatant.kt @@ -55,7 +55,7 @@ class CityCombatant(val city: CityInfo) : ICombatant { strength += cityTile.militaryUnit!!.baseUnit().strength * (cityTile.militaryUnit!!.health / 100f) * 0.2f var buildingsStrength = city.cityConstructions.getBuiltBuildings().sumBy{ it.cityStrength }.toFloat() - if(getCivInfo().containsBuildingUnique("Defensive buildings in all cities are 25% more effective")) + if(getCivInfo().hasUnique("Defensive buildings in all cities are 25% more effective")) buildingsStrength*=1.25f strength += buildingsStrength diff --git a/core/src/com/unciv/logic/city/CityExpansionManager.kt b/core/src/com/unciv/logic/city/CityExpansionManager.kt index 57db73ca..e228db93 100644 --- a/core/src/com/unciv/logic/city/CityExpansionManager.kt +++ b/core/src/com/unciv/logic/city/CityExpansionManager.kt @@ -34,7 +34,7 @@ class CityExpansionManager { // The second seems to be more based, so I'll go with that fun getCultureToNextTile(): Int { var cultureToNextTile = 6 * (max(0, tilesClaimed()) + 1.4813).pow(1.3) - if (cityInfo.civInfo.containsBuildingUnique("Cost of acquiring new tiles reduced by 25%")) + if (cityInfo.civInfo.hasUnique("Cost of acquiring new tiles reduced by 25%")) cultureToNextTile *= 0.75 //Speciality of Angkor Wat if (cityInfo.containsBuildingUnique("Culture and Gold costs of acquiring new tiles reduced by 25% in this city")) cultureToNextTile *= 0.75 // Specialty of Krepost @@ -56,7 +56,7 @@ class CityExpansionManager { val distanceFromCenter = tileInfo.aerialDistanceTo(cityInfo.getCenterTile()) var cost = baseCost * (distanceFromCenter - 1) + tilesClaimed() * 5.0 - if (cityInfo.civInfo.containsBuildingUnique("Cost of acquiring new tiles reduced by 25%")) + if (cityInfo.civInfo.hasUnique("Cost of acquiring new tiles reduced by 25%")) cost *= 0.75 //Speciality of Angkor Wat if (cityInfo.containsBuildingUnique("Culture and Gold costs of acquiring new tiles reduced by 25% in this city")) cost *= 0.75 // Specialty of Krepost diff --git a/core/src/com/unciv/logic/city/CityInfo.kt b/core/src/com/unciv/logic/city/CityInfo.kt index 686bd973..7acca31e 100644 --- a/core/src/com/unciv/logic/city/CityInfo.kt +++ b/core/src/com/unciv/logic/city/CityInfo.kt @@ -263,7 +263,7 @@ class CityInfo { if (civInfo.policies.hasEffect("Great Merchants are earned 25% faster, +1 Science from every Mint, Market, Bank and Stock Exchange.")) entry.value.gold *= 1.25f - if (civInfo.containsBuildingUnique("+33% great person generation in all cities")) + if (civInfo.hasUnique("+33% great person generation in all cities")) stats[entry.key] = stats[entry.key]!!.times(1.33f) if (civInfo.policies.hasEffect("+25% great people rate")) stats[entry.key] = stats[entry.key]!!.times(1.25f) diff --git a/core/src/com/unciv/logic/city/CityStats.kt b/core/src/com/unciv/logic/city/CityStats.kt index 00ab3b0b..c42c4384 100644 --- a/core/src/com/unciv/logic/city/CityStats.kt +++ b/core/src/com/unciv/logic/city/CityStats.kt @@ -51,7 +51,7 @@ class CityStats { var goldFromTradeRoute = civInfo.getCapital().population.population * 0.15 + cityInfo.population.population * 1.1 - 1 // Calculated by http://civilization.wikia.com/wiki/Trade_route_(Civ5) if (civInfo.nation.unique == UniqueAbility.TRADE_CARAVANS) goldFromTradeRoute += 1 if (civInfo.policies.hasEffect("Maintenance on roads & railroads reduced by 33%, +2 gold from all trade routes")) goldFromTradeRoute += 2 - if (civInfo.containsBuildingUnique("Gold from all trade routes +25%")) goldFromTradeRoute *= 1.25 // Machu Pichu speciality + if (civInfo.hasUnique("Gold from all trade routes +25%")) goldFromTradeRoute *= 1.25 // Machu Pichu speciality stats.gold += goldFromTradeRoute.toFloat() } return stats @@ -195,7 +195,7 @@ class CityStats { unhappinessFromCitizens *= 1.5f else if (hasExtraAnnexUnhappiness()) unhappinessFromCitizens *= 2f - if (civInfo.containsBuildingUnique("Unhappiness from population decreased by 10%")) + if (civInfo.hasUnique("Unhappiness from population decreased by 10%")) unhappinessFromCitizens *= 0.9f if (civInfo.policies.hasEffect("+1 happiness for every city connected to capital, -5% unhappiness from citizens")) unhappinessFromCitizens *= 0.95f @@ -224,7 +224,7 @@ class CityStats { val happinessFromBuildings = cityInfo.cityConstructions.getStats().happiness.toInt().toFloat() newHappinessList["Buildings"] = happinessFromBuildings - if (civInfo.containsBuildingUnique("+1 happiness in each city")) + if (civInfo.hasUnique("+1 happiness in each city")) newHappinessList["Wonders"] = 1f newHappinessList["Tile yields"] = getStatsFromTiles().happiness @@ -246,7 +246,7 @@ class CityStats { else stats.add(stat, 2f) // science and gold specialists if (policies.contains("Secularism")) stats.science += 2 - if (cityInfo.civInfo.containsBuildingUnique("+1 Production from specialists")) + if (cityInfo.civInfo.hasUnique("+1 Production from specialists")) stats.production += 1 if(cityInfo.civInfo.nation.unique == UniqueAbility.SCHOLARS_OF_THE_JADE_HALL) stats.science+=2 @@ -297,13 +297,13 @@ class CityStats { val stats = cityInfo.cityConstructions.getStatPercentBonuses() val currentConstruction = cityInfo.cityConstructions.getCurrentConstruction() - if (cityInfo.civInfo.containsBuildingUnique("Culture in all cities increased by 25%")) + if (cityInfo.civInfo.hasUnique("Culture in all cities increased by 25%")) stats.culture += 25f if (currentConstruction is Building && currentConstruction.uniques.contains("Spaceship part")) { if (cityInfo.containsBuildingUnique("Increases production of spaceship parts by 15%")) stats.production += 15 - if (cityInfo.civInfo.containsBuildingUnique("Increases production of spaceship parts by 25%")) + if (cityInfo.civInfo.hasUnique("Increases production of spaceship parts by 25%")) stats.production += 25 if (cityInfo.containsBuildingUnique("Increases production of spaceship parts by 50%")) stats.production += 50 diff --git a/core/src/com/unciv/logic/civilization/CivInfoStats.kt b/core/src/com/unciv/logic/civilization/CivInfoStats.kt index cbe6f6c7..11b50b49 100644 --- a/core/src/com/unciv/logic/civilization/CivInfoStats.kt +++ b/core/src/com/unciv/logic/civilization/CivInfoStats.kt @@ -131,7 +131,7 @@ class CivInfoStats(val civInfo: CivilizationInfo){ } } - if (civInfo.containsBuildingUnique("Provides 1 happiness per 2 additional social policies adopted")) { + if (civInfo.hasUnique("Provides 1 happiness per 2 additional social policies adopted")) { if(!statMap.containsKey("Policies")) statMap["Policies"]=0f statMap["Policies"] = statMap["Policies"]!! + civInfo.policies.getAdoptedPolicies().count { !it.endsWith("Complete") } / 2 diff --git a/core/src/com/unciv/logic/civilization/CivInfoTransientUpdater.kt b/core/src/com/unciv/logic/civilization/CivInfoTransientUpdater.kt index 63c62951..80d0adf2 100644 --- a/core/src/com/unciv/logic/civilization/CivInfoTransientUpdater.kt +++ b/core/src/com/unciv/logic/civilization/CivInfoTransientUpdater.kt @@ -118,7 +118,7 @@ class CivInfoTransientUpdater(val civInfo: CivilizationInfo) { fun updateHasActiveGreatWall() { civInfo.hasActiveGreatWall = !civInfo.tech.isResearched("Dynamite") && - civInfo.containsBuildingUnique("Enemy land units must spend 1 extra movement point when inside your territory (obsolete upon Dynamite)") + civInfo.hasUnique("Enemy land units must spend 1 extra movement point when inside your territory (obsolete upon Dynamite)") } diff --git a/core/src/com/unciv/logic/civilization/CivilizationInfo.kt b/core/src/com/unciv/logic/civilization/CivilizationInfo.kt index 04dbb605..a3b2785e 100644 --- a/core/src/com/unciv/logic/civilization/CivilizationInfo.kt +++ b/core/src/com/unciv/logic/civilization/CivilizationInfo.kt @@ -177,7 +177,8 @@ class CivilizationInfo { fun hasResource(resourceName:String): Boolean = getCivResourcesByName()[resourceName]!!>0 - fun containsBuildingUnique(unique:String) = cities.any { it.containsBuildingUnique(unique) } + fun hasUnique(unique:String) = policies.hasEffect(unique) + || cities.any { it.containsBuildingUnique(unique) } //region Units diff --git a/core/src/com/unciv/logic/civilization/GoldenAgeManager.kt b/core/src/com/unciv/logic/civilization/GoldenAgeManager.kt index 6f1a79b9..f5ef5c83 100644 --- a/core/src/com/unciv/logic/civilization/GoldenAgeManager.kt +++ b/core/src/com/unciv/logic/civilization/GoldenAgeManager.kt @@ -27,7 +27,7 @@ class GoldenAgeManager{ fun enterGoldenAge() { var turnsToGoldenAge = 10.0 - if (civInfo.containsBuildingUnique("Golden Age length increases +50%")) turnsToGoldenAge *= 1.5 + if (civInfo.hasUnique("Golden Age length increases +50%")) turnsToGoldenAge *= 1.5 if(civInfo.nation.unique == UniqueAbility.ACHAEMENID_LEGACY ) turnsToGoldenAge*=1.5 if (civInfo.policies.isAdopted("Freedom Complete")) turnsToGoldenAge *= 1.5 diff --git a/core/src/com/unciv/logic/civilization/PolicyManager.kt b/core/src/com/unciv/logic/civilization/PolicyManager.kt index ae2d3438..c4b4b97d 100644 --- a/core/src/com/unciv/logic/civilization/PolicyManager.kt +++ b/core/src/com/unciv/logic/civilization/PolicyManager.kt @@ -67,7 +67,7 @@ class PolicyManager { if (hasEffect("Each city founded increases culture cost of policies 33% less than normal. Starts a golden age.")) cityModifier *= (2 / 3f) if (isAdopted("Piety Complete")) policyCultureCost *= 0.9 - if (civInfo.containsBuildingUnique("Culture cost of adopting new Policies reduced by 10%")) + if (civInfo.hasUnique("Culture cost of adopting new Policies reduced by 10%")) policyCultureCost *= 0.9 if (civInfo.isPlayerCivilization()) policyCultureCost *= civInfo.getDifficulty().policyCostModifier diff --git a/core/src/com/unciv/logic/civilization/TechManager.kt b/core/src/com/unciv/logic/civilization/TechManager.kt index 7453338e..c9571ce6 100644 --- a/core/src/com/unciv/logic/civilization/TechManager.kt +++ b/core/src/com/unciv/logic/civilization/TechManager.kt @@ -8,7 +8,6 @@ import com.unciv.UniqueAbility import com.unciv.logic.map.MapSize import com.unciv.logic.map.RoadStatus import com.unciv.models.ruleset.tech.Technology -import com.unciv.models.ruleset.unit.BaseUnit import com.unciv.ui.utils.withItem import java.util.* import kotlin.collections.ArrayList @@ -172,7 +171,7 @@ class TechManager { var researchAgreementModifier = 0.5f if (civInfo.policies.isAdopted("Scientific Revolution")) researchAgreementModifier += 0.25f - if (civInfo.containsBuildingUnique("Science gained from research agreements +50%")) + if (civInfo.hasUnique("Science gained from research agreements +50%")) researchAgreementModifier += 0.25f return (scienceFromResearchAgreements / 3 * researchAgreementModifier).toInt() } diff --git a/core/src/com/unciv/logic/map/MapUnit.kt b/core/src/com/unciv/logic/map/MapUnit.kt index e057358d..fbf6fe2f 100644 --- a/core/src/com/unciv/logic/map/MapUnit.kt +++ b/core/src/com/unciv/logic/map/MapUnit.kt @@ -11,7 +11,6 @@ import com.unciv.logic.civilization.CivilizationInfo import com.unciv.logic.map.action.MapUnitAction import com.unciv.logic.map.action.StringAction import com.unciv.models.ruleset.Ruleset -import com.unciv.models.ruleset.tile.TerrainType import com.unciv.models.ruleset.unit.BaseUnit import com.unciv.models.ruleset.unit.UnitType import java.text.DecimalFormat @@ -104,7 +103,7 @@ class MapUnit { movement += getUniques().count { it == "+1 Movement" } if (type.isWaterUnit() && !type.isCivilian() - && civInfo.containsBuildingUnique("All military naval units receive +1 movement and +1 sight")) + && civInfo.hasUnique("All military naval units receive +1 movement and +1 sight")) movement += 1 if (type.isWaterUnit() && civInfo.nation.unique == UniqueAbility.SUN_NEVER_SETS) @@ -164,7 +163,7 @@ class MapUnit { if (civInfo.nation.unique == UniqueAbility.MANIFEST_DESTINY) visibilityRange += 1 if (type.isWaterUnit() && !type.isCivilian() - && civInfo.containsBuildingUnique("All military naval units receive +1 movement and +1 sight")) + && civInfo.hasUnique("All military naval units receive +1 movement and +1 sight")) visibilityRange += 1 if (isEmbarked() && civInfo.nation.unique == UniqueAbility.WAYFINDING) visibilityRange += 1 @@ -266,7 +265,7 @@ class MapUnit { var goldCostOfUpgrade = (unitToUpgradeTo.cost - baseUnit().cost) * 2 + 10 if (civInfo.policies.isAdopted("Professional Army")) goldCostOfUpgrade = (goldCostOfUpgrade * 0.66f).toInt() - if(civInfo.containsBuildingUnique("Gold cost of upgrading military units reduced by 33%")) + if(civInfo.hasUnique("Gold cost of upgrading military units reduced by 33%")) goldCostOfUpgrade = (goldCostOfUpgrade * 0.66f).toInt() if(goldCostOfUpgrade<0) return 0 // For instance, Landsknecht costs less than Spearman, so upgrading would cost negative gold return goldCostOfUpgrade diff --git a/core/src/com/unciv/logic/map/TileInfo.kt b/core/src/com/unciv/logic/map/TileInfo.kt index d0b1d0ea..f9eeea8a 100644 --- a/core/src/com/unciv/logic/map/TileInfo.kt +++ b/core/src/com/unciv/logic/map/TileInfo.kt @@ -176,7 +176,7 @@ open class TileInfo { if (unique.equalsPlaceholderText("[] from [] tiles")) { val placeholderParams = unique.getPlaceholderParameters() val tileType = placeholderParams[1] - if (baseTerrain == tileType || terrainFeature == tileType || resource == tileType) + if (baseTerrain == tileType || terrainFeature == tileType || resource == tileType || improvement == tileType) stats.add(Stats.parse(placeholderParams[0])) } } diff --git a/core/src/com/unciv/models/ruleset/Building.kt b/core/src/com/unciv/models/ruleset/Building.kt index 89fe51ef..4c2d31bf 100644 --- a/core/src/com/unciv/models/ruleset/Building.kt +++ b/core/src/com/unciv/models/ruleset/Building.kt @@ -156,7 +156,7 @@ class Building : NamedStats(), IConstruction{ stats.culture += 2f if (baseBuildingName == "Castle" - && civInfo.containsBuildingUnique("+1 happiness, +2 culture and +3 gold from every Castle")){ + && civInfo.hasUnique("+1 happiness, +2 culture and +3 gold from every Castle")){ stats.happiness+=1 stats.culture+=2 stats.gold+=3 @@ -220,7 +220,7 @@ class Building : NamedStats(), IConstruction{ // https://forums.civfanatics.com/threads/rush-buying-formula.393892/ var cost = (30 * getProductionCost(civInfo)).toDouble().pow(0.75) * (1 + hurryCostModifier / 100) if (civInfo.policies.hasEffect("-25% to purchasing items in cities")) cost *= 0.75 - if (civInfo.containsBuildingUnique("-15% to purchasing items in cities")) cost *= 0.85 + if (civInfo.hasUnique("-15% to purchasing items in cities")) cost *= 0.85 if (civInfo.policies.hasEffect( "Cost of purchasing culture buildings reduced by 50%") && culture !=0f && !isWonder) cost *= 0.5 @@ -331,7 +331,7 @@ class Building : NamedStats(), IConstruction{ } if ("Spaceship part" in uniques) { - if (!civInfo.containsBuildingUnique("Enables construction of Spaceship parts")) return "Apollo project not built!" + if (!civInfo.hasUnique("Enables construction of Spaceship parts")) return "Apollo project not built!" if (civInfo.victoryManager.unconstructedSpaceshipParts()[name] == 0) return "Don't need to build any more of these!" } diff --git a/core/src/com/unciv/models/ruleset/tile/TileImprovement.kt b/core/src/com/unciv/models/ruleset/tile/TileImprovement.kt index 812668e3..8a250854 100644 --- a/core/src/com/unciv/models/ruleset/tile/TileImprovement.kt +++ b/core/src/com/unciv/models/ruleset/tile/TileImprovement.kt @@ -27,7 +27,7 @@ class TileImprovement : NamedStats() { fun getTurnsToBuild(civInfo: CivilizationInfo): Int { var realTurnsToBuild = turnsToBuild.toFloat() * civInfo.gameInfo.gameParameters.gameSpeed.modifier - if (civInfo.containsBuildingUnique("Worker construction increased 25%")) + if (civInfo.hasUnique("Worker construction increased 25%")) realTurnsToBuild *= 0.75f if (civInfo.policies.isAdopted("Citizenship")) realTurnsToBuild *= 0.75f diff --git a/core/src/com/unciv/models/ruleset/unit/BaseUnit.kt b/core/src/com/unciv/models/ruleset/unit/BaseUnit.kt index 004a5cfe..28ff1714 100644 --- a/core/src/com/unciv/models/ruleset/unit/BaseUnit.kt +++ b/core/src/com/unciv/models/ruleset/unit/BaseUnit.kt @@ -104,7 +104,7 @@ class BaseUnit : INamed, IConstruction { var cost = getBaseGoldCost() if (civInfo.policies.adoptedPolicies.contains("Mercantilism")) cost *= 0.75 if (civInfo.policies.adoptedPolicies.contains("Militarism")) cost *= 0.66f - if (civInfo.containsBuildingUnique("-15% to purchasing items in cities")) cost *= 0.85 + if (civInfo.hasUnique("-15% to purchasing items in cities")) cost *= 0.85 return (cost / 10).toInt() * 10 // rounded down o nearest ten } @@ -133,7 +133,7 @@ class BaseUnit : INamed, IConstruction { if (civInfo.gameInfo.ruleSet.units.values.any { it.uniqueTo==civInfo.civName && it.replaces==name }) return "Our unique unit replaces this" if (!civInfo.gameInfo.gameParameters.nuclearWeaponsEnabled && uniques.contains("Requires Manhattan Project")) return "Disabled by setting" - if (uniques.contains("Requires Manhattan Project") && !civInfo.containsBuildingUnique("Enables nuclear weapon")) + if (uniques.contains("Requires Manhattan Project") && !civInfo.hasUnique("Enables nuclear weapon")) return "Requires Manhattan Project" if (requiredResource!=null && !civInfo.hasResource(requiredResource!!)) return "Consumes 1 [$requiredResource]" if (name == Constants.settler && civInfo.isCityState()) return "No settler for city-states" diff --git a/core/src/com/unciv/ui/victoryscreen/VictoryScreen.kt b/core/src/com/unciv/ui/victoryscreen/VictoryScreen.kt index dcc0ff18..fe0c3f4a 100644 --- a/core/src/com/unciv/ui/victoryscreen/VictoryScreen.kt +++ b/core/src/com/unciv/ui/victoryscreen/VictoryScreen.kt @@ -128,7 +128,7 @@ class VictoryScreen(val worldScreen: WorldScreen) : PickerScreen() { val t = Table() t.defaults().pad(5f) t.add(getMilestone("Built Apollo Program", - playerCivInfo.containsBuildingUnique("Enables construction of Spaceship parts"))).row() + playerCivInfo.hasUnique("Enables construction of Spaceship parts"))).row() val victoryManager= playerCivInfo.victoryManager diff --git a/core/src/com/unciv/ui/worldscreen/WorldScreen.kt b/core/src/com/unciv/ui/worldscreen/WorldScreen.kt index 3e864715..89840be2 100644 --- a/core/src/com/unciv/ui/worldscreen/WorldScreen.kt +++ b/core/src/com/unciv/ui/worldscreen/WorldScreen.kt @@ -642,7 +642,7 @@ class WorldScreen(val viewingCiv:CivilizationInfo) : CameraStageBaseScreen() { viewingCiv.getKnownCivs().asSequence().filter { viewingCiv.isAtWarWith(it) } .flatMap { it.cities.asSequence() }.any { viewingCiv.exploredTiles.contains(it.location) } } - displayTutorial(Tutorial.ApolloProgram) { viewingCiv.containsBuildingUnique("Enables construction of Spaceship parts") } + displayTutorial(Tutorial.ApolloProgram) { viewingCiv.hasUnique("Enables construction of Spaceship parts") } displayTutorial(Tutorial.SiegeUnits) { viewingCiv.getCivUnits().any { it.type == UnitType.Siege } } displayTutorial(Tutorial.Embarking) { viewingCiv.tech.getTechUniques().contains("Enables embarkation for land units") } displayTutorial(Tutorial.NaturalWonders) { viewingCiv.naturalWonders.size > 0 }