mirror of
https://github.com/yairm210/Unciv.git
synced 2025-09-26 13:27:22 -04:00
Finished unique typing for CivInfo.hasUnique() and removed string version!
Damn but there are a LOT of uniques that have accumulated over time
This commit is contained in:
parent
cd92f66c3a
commit
9595247d3b
@ -338,7 +338,7 @@ object Battle {
|
||||
|
||||
// German unique - needs to be checked before we try to move to the enemy tile, since the encampment disappears after we move in
|
||||
if (defender.isDefeated()
|
||||
&& attacker.getCivInfo().hasUnique("67% chance to earn 25 Gold and recruit a Barbarian unit from a conquered encampment")
|
||||
&& attacker.getCivInfo().hasUnique(UniqueType.ChanceToRecruitBarbarianFromEncampment)
|
||||
&& Random().nextDouble() < 0.67) {
|
||||
attacker.getCivInfo().placeUnitNearTile(attackedTile.position, defender.getName())
|
||||
attacker.getCivInfo().addGold(25)
|
||||
@ -350,7 +350,7 @@ object Battle {
|
||||
}
|
||||
|
||||
// Similarly, Ottoman unique
|
||||
if (attacker.getCivInfo().hasUnique("50% chance of capturing defeated Barbarian naval units and earning 25 Gold")
|
||||
if (attacker.getCivInfo().hasUnique(UniqueType.ChanceToRecruitNavalBarbarian)
|
||||
&& defender.isDefeated()
|
||||
&& defender is MapUnitCombatant
|
||||
&& defender.unit.baseUnit.isWaterUnit()
|
||||
|
@ -26,7 +26,7 @@ class CityInfoConquestFunctions(val city: CityInfo){
|
||||
val baseGold = 20 + 10 * city.population.population + tileBasedRandom.nextInt(40)
|
||||
val turnModifier = max(0, min(50, city.civInfo.gameInfo.turns - city.turnAcquired)) / 50f
|
||||
val cityModifier = if (city.containsBuildingUnique("Doubles Gold given to enemy if city is captured")) 2f else 1f
|
||||
val conqueringCivModifier = if (conqueringCiv.hasUnique("Receive triple Gold from Barbarian encampments and pillaging Cities")) 3f else 1f
|
||||
val conqueringCivModifier = if (conqueringCiv.hasUnique(UniqueType.TripleGoldFromEncampmentsAndCities)) 3f else 1f
|
||||
|
||||
val goldPlundered = baseGold * turnModifier * cityModifier * conqueringCivModifier
|
||||
return goldPlundered.toInt()
|
||||
|
@ -90,7 +90,7 @@ class CityStats(val cityInfo: CityInfo) {
|
||||
stats.gold = civInfo.getCapital().population.population * 0.15f + cityInfo.population.population * 1.1f - 1 // Calculated by http://civilization.wikia.com/wiki/Trade_route_(Civ5)
|
||||
for (unique in cityInfo.getMatchingUniques(UniqueType.StatsFromTradeRoute))
|
||||
stats.add(unique.stats)
|
||||
if (civInfo.hasUnique("Gold from all trade routes +25%")) stats.gold *= 1.25f // Machu Picchu speciality
|
||||
if (civInfo.hasUnique(UniqueType.GoldBonusFromTradeRouts)) stats.gold *= 1.25f // Machu Picchu speciality
|
||||
}
|
||||
return stats
|
||||
}
|
||||
@ -107,7 +107,7 @@ class CityStats(val cityInfo: CityInfo) {
|
||||
|
||||
fun getScienceConversionRate(): Float {
|
||||
var conversionRate = 1 / 4f
|
||||
if (cityInfo.civInfo.hasUnique("Production to science conversion in cities increased by 33%"))
|
||||
if (cityInfo.civInfo.hasUnique(UniqueType.ProductionToScienceConversionBonus))
|
||||
conversionRate *= 1.33f
|
||||
return conversionRate
|
||||
}
|
||||
|
@ -291,7 +291,7 @@ class CivInfoStats(val civInfo: CivilizationInfo) {
|
||||
}
|
||||
}
|
||||
|
||||
if (civInfo.hasUnique("Provides 1 happiness per 2 additional social policies adopted")) {
|
||||
if (civInfo.hasUnique(UniqueType.HappinessPer2Policies)) {
|
||||
if (!statMap.containsKey("Policies")) statMap["Policies"] = 0f
|
||||
statMap["Policies"] = statMap["Policies"]!! +
|
||||
civInfo.policies.getAdoptedPolicies()
|
||||
|
@ -117,7 +117,7 @@ class CivInfoTransientUpdater(val civInfo: CivilizationInfo) {
|
||||
if (civInfo.naturalWonders.contains(tile.naturalWonder))
|
||||
continue
|
||||
civInfo.discoverNaturalWonder(tile.naturalWonder!!)
|
||||
civInfo.addNotification("We have discovered [" + tile.naturalWonder + "]!", tile.position, "StatIcons/Happiness")
|
||||
civInfo.addNotification("We have discovered [${tile.naturalWonder}]!", tile.position, "StatIcons/Happiness")
|
||||
|
||||
var goldGained = 0
|
||||
val discoveredNaturalWonders = civInfo.gameInfo.civilizations.filter { it != civInfo && it.isMajorCiv() }
|
||||
@ -133,7 +133,7 @@ class CivInfoTransientUpdater(val civInfo: CivilizationInfo) {
|
||||
|
||||
if (goldGained > 0) {
|
||||
civInfo.addGold(goldGained)
|
||||
civInfo.addNotification("We have received [" + goldGained + "] Gold for discovering [" + tile.naturalWonder + "]", NotificationIcon.Gold)
|
||||
civInfo.addNotification("We have received [$goldGained] Gold for discovering [${tile.naturalWonder}]", NotificationIcon.Gold)
|
||||
}
|
||||
|
||||
}
|
||||
@ -141,7 +141,7 @@ class CivInfoTransientUpdater(val civInfo: CivilizationInfo) {
|
||||
|
||||
fun updateHasActiveGreatWall() {
|
||||
civInfo.hasActiveGreatWall = !civInfo.tech.isResearched("Dynamite") &&
|
||||
civInfo.hasUnique("Enemy land units must spend 1 extra movement point when inside your territory (obsolete upon Dynamite)")
|
||||
civInfo.hasUnique(UniqueType.EnemyLandUnitsSpendExtraMovement)
|
||||
}
|
||||
|
||||
|
||||
|
@ -375,7 +375,6 @@ class CivilizationInfo {
|
||||
|
||||
fun hasUnique(uniqueType: UniqueType, stateForConditionals: StateForConditionals =
|
||||
StateForConditionals(this)) = getMatchingUniques(uniqueType, stateForConditionals).any()
|
||||
fun hasUnique(unique: String) = getMatchingUniques(unique).any()
|
||||
|
||||
// Does not return local uniques, only global ones.
|
||||
/** Destined to replace getMatchingUniques, gradually, as we fill the enum */
|
||||
|
@ -121,7 +121,7 @@ class ReligionManager {
|
||||
if (getGreatProphetEquivalent() == null) return false
|
||||
if (storedFaith < faithForNextGreatProphet()) return false
|
||||
if (!civInfo.isMajorCiv()) return false
|
||||
if (civInfo.hasUnique("May not generate great prophet equivalents naturally")) return false
|
||||
if (civInfo.hasUnique(UniqueType.MAyNotGenerateGreatProphet)) return false
|
||||
return true
|
||||
}
|
||||
|
||||
|
@ -904,7 +904,7 @@ class MapUnit {
|
||||
|
||||
var goldGained =
|
||||
civInfo.getDifficulty().clearBarbarianCampReward * civInfo.gameInfo.gameParameters.gameSpeed.modifier
|
||||
if (civInfo.hasUnique("Receive triple Gold from Barbarian encampments and pillaging Cities"))
|
||||
if (civInfo.hasUnique(UniqueType.TripleGoldFromEncampmentsAndCities))
|
||||
goldGained *= 3f
|
||||
|
||||
civInfo.addGold(goldGained.toInt())
|
||||
|
@ -96,6 +96,7 @@ enum class UniqueType(val text: String, vararg targets: UniqueTarget, val flags:
|
||||
AllStatsPercentFromObject("[amount]% Yield from every [tileFilter]", UniqueTarget.FollowerBelief, UniqueTarget.Global),
|
||||
StatPercentFromReligionFollowers("[amount]% [stat] from every follower, up to [amount]%", UniqueTarget.FollowerBelief),
|
||||
BonusStatsFromCityStates("[amount]% [stat] from City-States", UniqueTarget.Global),
|
||||
GoldBonusFromTradeRouts("Gold from all trade routes +25%", UniqueTarget.Global),
|
||||
|
||||
NullifiesStat("Nullifies [stat] [cityFilter]", UniqueTarget.Global),
|
||||
NullifiesGrowth("Nullifies Growth [cityFilter]", UniqueTarget.Global),
|
||||
@ -165,7 +166,7 @@ enum class UniqueType(val text: String, vararg targets: UniqueTarget, val flags:
|
||||
UnhappinessFromPopulationPercentageChange("[amount]% unhappiness from population [cityFilter]", UniqueTarget.Global, UniqueTarget.FollowerBelief),
|
||||
UnhappinessFromSpecialistsPercentageChange("[amount]% unhappiness from specialists [cityFilter]", UniqueTarget.Global, UniqueTarget.FollowerBelief),
|
||||
FoodConsumptionBySpecialists("[amount]% Food consumption by specialists [cityFilter]", UniqueTarget.Global, UniqueTarget.FollowerBelief),
|
||||
|
||||
HappinessPer2Policies("Provides 1 happiness per 2 additional social policies adopted", UniqueTarget.Global),
|
||||
ExcessHappinessToGlobalStat("[amount]% of excess happiness converted to [stat]", UniqueTarget.Global),
|
||||
|
||||
BorderGrowthPercentage("[amount]% Culture cost of natural border growth [cityFilter]", UniqueTarget.Global, UniqueTarget.FollowerBelief),
|
||||
@ -224,6 +225,9 @@ enum class UniqueType(val text: String, vararg targets: UniqueTarget, val flags:
|
||||
DoubleHappinessFromNaturalWonders("Double Happiness from Natural Wonders", UniqueTarget.Global),
|
||||
|
||||
EnablesConstructionOfSpaceshipParts("Enables construction of Spaceship parts", UniqueTarget.Global),
|
||||
EnemyLandUnitsSpendExtraMovement("Enemy land units must spend 1 extra movement point when inside your territory (obsolete upon Dynamite)", UniqueTarget.Global),
|
||||
|
||||
ProductionToScienceConversionBonus("Production to science conversion in cities increased by 33%", UniqueTarget.Global),
|
||||
|
||||
// Misc national uniques
|
||||
NotifiedOfBarbarianEncampments("Notified of new Barbarian encampments", UniqueTarget.Global),
|
||||
@ -233,6 +237,10 @@ enum class UniqueType(val text: String, vararg targets: UniqueTarget, val flags:
|
||||
UnhappinessFromCitiesDoubled("Unhappiness from number of Cities doubled", UniqueTarget.Global),
|
||||
GreatGeneralProvidesDoubleCombatBonus("Great General provides double combat bonus", UniqueTarget.Global),
|
||||
TechBoostWhenScientificBuildingsBuiltInCapital("Receive a tech boost when scientific buildings/wonders are built in capital", UniqueTarget.Global),
|
||||
MAyNotGenerateGreatProphet("May not generate great prophet equivalents naturally", UniqueTarget.Global),
|
||||
ChanceToRecruitBarbarianFromEncampment("67% chance to earn 25 Gold and recruit a Barbarian unit from a conquered encampment", UniqueTarget.Global),
|
||||
ChanceToRecruitNavalBarbarian("50% chance of capturing defeated Barbarian naval units and earning 25 Gold", UniqueTarget.Global),
|
||||
TripleGoldFromEncampmentsAndCities("Receive triple Gold from Barbarian encampments and pillaging Cities", UniqueTarget.Global),
|
||||
|
||||
EnablesOpenBorders("Enables Open Borders agreements", UniqueTarget.Global),
|
||||
// Should the 'R' in 'Research agreements' be capitalized?
|
||||
|
Loading…
x
Reference in New Issue
Block a user