More uniquetyping

This commit is contained in:
Yair Morgenstern 2022-02-18 13:42:23 +02:00
parent 0171ad168f
commit 82236fe2c8
8 changed files with 37 additions and 9 deletions

View File

@ -88,7 +88,7 @@ object BattleDamage {
.flatMap { it.getUnits() }.filter { it.civInfo == combatant.unit.civInfo } .flatMap { it.getUnits() }.filter { it.civInfo == combatant.unit.civInfo }
if (nearbyCivUnits.any { it.hasUnique("Bonus for units in 2 tile radius 15%") }) { if (nearbyCivUnits.any { it.hasUnique("Bonus for units in 2 tile radius 15%") }) {
val greatGeneralModifier = val greatGeneralModifier =
if (combatant.unit.civInfo.hasUnique("Great General provides double combat bonus")) 30 else 15 if (combatant.unit.civInfo.hasUnique(UniqueType.GreatGeneralProvidesDoubleCombatBonus)) 30 else 15
modifiers["Great General"] = greatGeneralModifier modifiers["Great General"] = greatGeneralModifier
} }
@ -253,7 +253,7 @@ object BattleDamage {
private fun getHealthDependantDamageRatio(combatant: ICombatant): Float { private fun getHealthDependantDamageRatio(combatant: ICombatant): Float {
return if (combatant !is MapUnitCombatant // is city return if (combatant !is MapUnitCombatant // is city
|| (combatant.getCivInfo().hasUnique("Units fight as though they were at full strength even when damaged") || (combatant.getCivInfo().hasUnique(UniqueType.UnitsFightFullStrengthWhenDamaged)
&& !combatant.unit.baseUnit.movesLikeAirUnits() && !combatant.unit.baseUnit.movesLikeAirUnits()
) )
) { ) {

View File

@ -181,7 +181,7 @@ class CityInfo {
val cityName = nationCities[cityNameIndex] val cityName = nationCities[cityNameIndex]
val cityNameRounds = civInfo.citiesCreated / nationCities.size val cityNameRounds = civInfo.citiesCreated / nationCities.size
if (cityNameRounds > 0 && civInfo.hasUnique("\"Borrows\" city names from other civilizations in the game")) { if (cityNameRounds > 0 && civInfo.hasUnique(UniqueType.BorrowsCityNames)) {
name = borrowCityName() name = borrowCityName()
return return
} }

View File

@ -399,7 +399,7 @@ class CityStats(val cityInfo: CityInfo) {
unhappinessModifier *= civInfo.gameInfo.getDifficulty().aiUnhappinessModifier unhappinessModifier *= civInfo.gameInfo.getDifficulty().aiUnhappinessModifier
var unhappinessFromCity = -3f // -3 happiness per city var unhappinessFromCity = -3f // -3 happiness per city
if (civInfo.hasUnique("Unhappiness from number of Cities doubled")) if (civInfo.hasUnique(UniqueType.UnhappinessFromCitiesDoubled))
unhappinessFromCity *= 2f //doubled for the Indian unhappinessFromCity *= 2f //doubled for the Indian
newHappinessList["Cities"] = unhappinessFromCity * unhappinessModifier newHappinessList["Cities"] = unhappinessFromCity * unhappinessModifier

View File

@ -127,7 +127,7 @@ class CivInfoTransientUpdater(val civInfo: CivilizationInfo) {
goldGained += 500 goldGained += 500
} }
if (civInfo.hasUnique("100 Gold for discovering a Natural Wonder (bonus enhanced to 500 Gold if first to discover it)")) { if (civInfo.hasUnique(UniqueType.GoldWhenDiscoveringNaturalWonder)) {
goldGained += if (discoveredNaturalWonders.contains(tile.naturalWonder!!)) 100 else 500 goldGained += if (discoveredNaturalWonders.contains(tile.naturalWonder!!)) 100 else 500
} }

View File

@ -289,7 +289,7 @@ class DiplomacyManager() {
var modifierPercent = 0f var modifierPercent = 0f
if (otherCiv().hasUnique("City-State Influence recovers at twice the normal rate")) if (otherCiv().hasUnique(UniqueType.CityStateInfluenceRecoversTwiceNormalRate))
modifierPercent += 100f modifierPercent += 100f
val religion = if (civInfo.cities.isEmpty()) null val religion = if (civInfo.cities.isEmpty()) null
@ -355,7 +355,7 @@ class DiplomacyManager() {
*/ */
fun isConsideredFriendlyTerritory(): Boolean { fun isConsideredFriendlyTerritory(): Boolean {
if (civInfo.isCityState() && if (civInfo.isCityState() &&
(relationshipLevel() >= RelationshipLevel.Friend || otherCiv().hasUnique("City-State territory always counts as friendly territory"))) (relationshipLevel() >= RelationshipLevel.Friend || otherCiv().hasUnique(UniqueType.CityStateTerritoryAlwaysFriendly)))
return true return true
return hasOpenBorders return hasOpenBorders
} }

View File

@ -735,7 +735,7 @@ class Building : RulesetStatsObject(), INonPerpetualConstruction {
civInfo.updateHasActiveGreatWall() civInfo.updateHasActiveGreatWall()
// Korean unique - apparently gives the same as the research agreement // Korean unique - apparently gives the same as the research agreement
if (science > 0 && civInfo.hasUnique("Receive a tech boost when scientific buildings/wonders are built in capital")) if (science > 0 && civInfo.hasUnique(UniqueType.TechBoostWhenScientificBuildingsBuiltInCapital))
civInfo.tech.addScience(civInfo.tech.scienceOfLast8Turns.sum() / 8) civInfo.tech.addScience(civInfo.tech.scienceOfLast8Turns.sum() / 8)
cityConstructions.cityInfo.cityStats.update() // new building, new stats cityConstructions.cityInfo.cityStats.update() // new building, new stats

View File

@ -144,7 +144,7 @@ enum class UniqueType(val text: String, vararg targets: UniqueTarget, val flags:
CityStateLuxuryHappiness("[amount]% Happiness from luxury resources gifted by City-States", UniqueTarget.Global), CityStateLuxuryHappiness("[amount]% Happiness from luxury resources gifted by City-States", UniqueTarget.Global),
@Deprecated("as of 3.18.17", ReplaceWith("[+amount]% Happiness from luxury resources gifted by City-States")) @Deprecated("as of 3.18.17", ReplaceWith("[+amount]% Happiness from luxury resources gifted by City-States"))
CityStateLuxuryHappinessDeprecated("Happiness from Luxury Resources gifted by City-States increased by [amount]%", UniqueTarget.Global), CityStateLuxuryHappinessDeprecated("Happiness from Luxury Resources gifted by City-States increased by [amount]%", UniqueTarget.Global),
CityStateInfluenceRecoversTwiceNormalRate("City-State Influence recovers at twice the normal rate", UniqueTarget.Global),
// endregion // endregion
/////// region Other global uniques /////// region Other global uniques
@ -241,7 +241,14 @@ enum class UniqueType(val text: String, vararg targets: UniqueTarget, val flags:
EnablesConstructionOfSpaceshipParts("Enables construction of Spaceship parts", UniqueTarget.Global), EnablesConstructionOfSpaceshipParts("Enables construction of Spaceship parts", UniqueTarget.Global),
// Misc national uniques
NotifiedOfBarbarianEncampments("Notified of new Barbarian encampments", UniqueTarget.Global), NotifiedOfBarbarianEncampments("Notified of new Barbarian encampments", UniqueTarget.Global),
BorrowsCityNames("\"Borrows\" city names from other civilizations in the game", UniqueTarget.Global),
UnitsFightFullStrengthWhenDamaged("Units fight as though they were at full strength even when damaged", UniqueTarget.Global),
GoldWhenDiscoveringNaturalWonder("100 Gold for discovering a Natural Wonder (bonus enhanced to 500 Gold if first to discover it)", UniqueTarget.Global),
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),
EnablesOpenBorders("Enables Open Borders agreements", UniqueTarget.Global), EnablesOpenBorders("Enables Open Borders agreements", UniqueTarget.Global),
// Should the 'R' in 'Research agreements' be capitalized? // Should the 'R' in 'Research agreements' be capitalized?

View File

@ -185,6 +185,9 @@ Example: "[20]% Happiness from luxury resources gifted by City-States"
Applicable to: Global Applicable to: Global
#### City-State Influence recovers at twice the normal rate
Applicable to: Global
#### [amount] units cost no maintenance #### [amount] units cost no maintenance
Example: "[20] units cost no maintenance" Example: "[20] units cost no maintenance"
@ -384,6 +387,24 @@ Applicable to: Global
#### Notified of new Barbarian encampments #### Notified of new Barbarian encampments
Applicable to: Global Applicable to: Global
#### "Borrows" city names from other civilizations in the game
Applicable to: Global
#### Units fight as though they were at full strength even when damaged
Applicable to: Global
#### 100 Gold for discovering a Natural Wonder (bonus enhanced to 500 Gold if first to discover it)
Applicable to: Global
#### Unhappiness from number of Cities doubled
Applicable to: Global
#### Great General provides double combat bonus
Applicable to: Global
#### Receive a tech boost when scientific buildings/wonders are built in capital
Applicable to: Global
#### Enables Open Borders agreements #### Enables Open Borders agreements
Applicable to: Global Applicable to: Global