Free buildings part 2 - works for Carthage too (#5471)

* free buildings works for Carthage too
unify "provides a free [] []" and "gain a free [] []"

* re-check at start of turn

* reviews
This commit is contained in:
SimonCeder 2021-10-13 18:21:27 +02:00 committed by GitHub
parent 734fba8f30
commit ff67e66348
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 32 additions and 23 deletions

View File

@ -115,7 +115,7 @@
"greatPersonPoints": {"Great Scientist": 1},
"isWonder": true,
"requiredTech": "Writing",
"uniques": ["Free Technology", "Provides a free [Library] [in this city]"],
"uniques": ["Free Technology", "Gain a free [Library] [in this city]"],
"quote": "'Libraries are as the shrine where all the relics of the ancient saints, full of true virtue, and all that without delusion or imposture are preserved and reposed.' - Sir Francis Bacon"
},
{
@ -230,7 +230,7 @@
"greatPersonPoints": {"Great Merchant": 1},
"isWonder": true,
"uniques": ["Must be next to [Coast]", "[+1] Movement <for [{Military} {Water}] units>",
"[+1] Sight <for [{Military} {Water}] units>", "Provides a free [Lighthouse] [in this city]"],
"[+1] Sight <for [{Military} {Water}] units>", "Gain a free [Lighthouse] [in this city]"],
"requiredTech": "Optics",
"quote": "'They that go down to the sea in ships, that do business in great waters; these see the works of the Lord, and his wonders in the deep.' - The Bible, Psalms 107:23-24"
},
@ -269,7 +269,7 @@
"culture": 1,
"isWonder": true,
"requiredTech": "Mathematics",
"uniques": ["Provides a free [Garden] [in this city]"],
"uniques": ["Gain a free [Garden] [in this city]"],
"quote": "'I think that if ever a mortal heard the word of God it would be in a garden at the cool of the day.' - F. Frankfort Moore"
},
{
@ -390,7 +390,7 @@
"culture": 1,
"isWonder": true,
"greatPersonPoints": {"Great Engineer": 1},
"uniques": ["Must be next to [Desert]", "[+1 Food, +1 Production, +1 Gold] from [Desert] tiles without [Flood plains] [in this city]", "Provides a free [Amphitheater] [in this city]", "[+6 Culture] once [Archaeology] is discovered"],
"uniques": ["Must be next to [Desert]", "[+1 Food, +1 Production, +1 Gold] from [Desert] tiles without [Flood plains] [in this city]", "Gain a free [Amphitheater] [in this city]", "[+6 Culture] once [Archaeology] is discovered"],
"requiredTech": "Currency",
"quote": "'...who drinks the water I shall give him, says the Lord, will have a spring inside him welling up for eternal life. Let them bring me to your holy mountain in the place where you dwell. Across the desert and through the mountain to the Canyon of the Crescent Moon...' - Indiana Jones"
},
@ -407,7 +407,7 @@
"greatPersonPoints": {"Great Engineer": 1},
"isWonder": true,
"uniques": ["Enemy land units must spend 1 extra movement point when inside your territory (obsolete upon Dynamite)",
"Provides a free [Walls] [in this city]"],
"Gain a free [Walls] [in this city]"],
"requiredTech": "Engineering",
"quote": "'The art of war teaches us to rely not on the likelihood of the enemy's not attacking, but rather on the fact that we have made our position unassailable.' - Sun Tzu"
},
@ -446,7 +446,7 @@
"name": "Hagia Sophia",
"faith": 3,
"isWonder": true,
"uniques": ["Provides a free [Temple] [in this city]", "Free [Great Prophet] appears"],
"uniques": ["Gain a free [Temple] [in this city]", "Free [Great Prophet] appears"],
"requiredTech": "Theology",
"quote": "'For it soars to a height to match the sky, and as if surging up from among the other buildings it stands on high and looks down upon the remainder of the city, adorning it, because it is a part of it, but glorying in its own beauty' - Procopius, De Aedificis"
},
@ -456,7 +456,7 @@
"faith": 3,
"greatPersonPoints": {"Great Engineer": 1},
"isWonder": true,
"uniques": ["Provides a free [Mosque] [in this city]", "Hidden when religion is disabled",
"uniques": ["Gain a free [Mosque] [in this city]", "Hidden when religion is disabled",
"[Missionary] units built [in this city] can [Spread Religion] [1] extra times", "[Great Prophet] units built [in this city] can [Spread Religion] [1] extra times"],
"requiredTech": "Theology",
"quote": "'With the magnificence of eternity before us, let time, with all its fluctuations, dwindle into its own littleness.' - Thomas Chalmers"
@ -613,7 +613,7 @@
"isWonder": true,
"percentStatBonus": {"culture": 20},
"uniques": ["All newly-trained [relevant] units [in this city] receive the [Drill I] promotion",
"Provides a free [Castle] [in this city]"],
"Gain a free [Castle] [in this city]"],
"requiredTech": "Chivalry",
"quote": "'Justice is an unassailable fortress, built on the brow of a mountain which cannot be overthrown by the violence of torrents, nor demolished by the force of armies.' - Joseph Addison"
},
@ -754,7 +754,7 @@
"isWonder": true,
"greatPersonPoints": {"Great Engineer": 2},
"uniques": ["[+15]% Strength <for [All] units> <when fighting in [Friendly Land] tiles>",
"Provides a free [Castle] [in this city]"],
"Gain a free [Castle] [in this city]"],
"requiredTech": "Gunpowder",
"quote": "'Bushido is realized in the presence of death. This means choosing death whenever there is a choice between life and death. There is no other reasoning.' - Yamamoto Tsunetomo"
},
@ -1085,7 +1085,7 @@
"isWonder": true,
"culture": 1,
"greatPersonPoints": {"Great Merchant": 1},
"uniques": ["[+1] population [in all cities]", "[+1 Happiness] [in all cities]", "Provides a free [Broadcast Tower] [in all cities]"],
"uniques": ["[+1] population [in all cities]", "[+1 Happiness] [in all cities]", "Gain a free [Broadcast Tower] [in all cities]"],
"requiredTech": "Telecommunications",
"quote": "'Nothing travels faster than light with the possible exception of bad news, which obeys its own special rules.' - Douglas Adams"
},
@ -1110,7 +1110,7 @@
// "+[25]% Production when constructing [Spaceship part] units [in this city]"
"uniques": ["[2] free [Great Scientist] units appear",
"+[25]% Production when constructing [Spaceship part] [in this city]",
"Provides a free [Spaceship Factory] [in this city]"],
"Gain a free [Spaceship Factory] [in this city]"],
"requiredTech": "Satellites",
"quote": "'The wonder is, not that the field of stars is so vast, but that man has measured it.' - Anatole France"
},

View File

@ -162,8 +162,11 @@ class CityConstructions {
}
fun addFreeBuildings() {
// "Provides a free [buildingName] [cityFilter]"
for (unique in cityInfo.getLocalMatchingUniques(UniqueType.ProvidesFreeBuildings, StateForConditionals(cityInfo.civInfo, cityInfo))) {
// "Gain a free [buildingName] [cityFilter]"
val uniqueList = cityInfo.getLocalMatchingUniques(UniqueType.GainFreeBuildings, StateForConditionals(cityInfo.civInfo, cityInfo)).toMutableList()
// Deprecated - "Provides a free [buildingName] [cityFilter]"
uniqueList.addAll(cityInfo.getLocalMatchingUniques(UniqueType.ProvidesFreeBuildings, StateForConditionals(cityInfo.civInfo, cityInfo)))
for (unique in uniqueList) {
val freeBuildingName = cityInfo.civInfo.getEquivalentBuilding(unique.params[0]).name
val citiesThatApply = when (unique.params[1]) {
"in this city" -> listOf(cityInfo)
@ -180,6 +183,18 @@ class CityConstructions {
freeBuildingsProvidedFromThisCity[city.id]!!.add(freeBuildingName)
}
}
// Civ-level uniques - for these only add free buildings from each city to itself to avoid weirdness on city conquest
for (unique in cityInfo.civInfo.getMatchingUniques(UniqueType.GainFreeBuildings, stateForConditionals = StateForConditionals(cityInfo.civInfo, cityInfo))) {
val freeBuildingName = unique.params[0]
if (cityInfo.matchesFilter(unique.params[1])) {
if (cityInfo.id !in freeBuildingsProvidedFromThisCity)
freeBuildingsProvidedFromThisCity[cityInfo.id] = hashSetOf()
freeBuildingsProvidedFromThisCity[cityInfo.id]!!.add(freeBuildingName)
if (!isBuilt(freeBuildingName))
addBuilding(freeBuildingName)
}
}
}
/** @constructionName needs to be a non-perpetual construction, else an empty string is returned */

View File

@ -160,14 +160,7 @@ class CityInfo {
}
civInfo.civConstructions.tryAddFreeBuildings()
for (unique in getMatchingUniques(UniqueType.GainFreeBuildings, stateForConditionals = StateForConditionals(civInfo, this))) {
val freeBuildingName = unique.params[0]
if (matchesFilter(unique.params[1])) {
if (!cityConstructions.isBuilt(freeBuildingName))
cityConstructions.addBuilding(freeBuildingName)
}
}
cityConstructions.addFreeBuildings()
}
private fun setNewCityName(civInfo: CivilizationInfo) {
@ -489,6 +482,7 @@ class CityInfo {
// so they won't be generated out in the open and vulnerable to enemy attacks before you can control them
cityConstructions.constructIfEnough()
cityConstructions.addFreeBuildings()
cityStats.update()
tryUpdateRoadStatus()
attackedThisTurn = false

View File

@ -115,9 +115,9 @@ enum class UniqueType(val text:String, vararg targets: UniqueTarget) {
@Deprecated("As of 3.16.14", ReplaceWith("[amount]% growth [cityFilter] <when not at war>"), DeprecationLevel.WARNING)
GrowthPercentBonusWhenNotAtWar("+[amount]% growth [cityFilter] when not at war", UniqueTarget.Global),
// TODO: Unify these (I'm in favor of "gain a free" above "provides" because it fits more cases)
ProvidesFreeBuildings("Provides a free [buildingName] [cityFilter]", UniqueTarget.Global),
GainFreeBuildings("Gain a free [buildingName] [cityFilter]", UniqueTarget.Global),
@Deprecated("As of 3.17.7", ReplaceWith("Gain a free [buildingName] [cityFilter]"), DeprecationLevel.WARNING)
ProvidesFreeBuildings("Provides a free [buildingName] [cityFilter]", UniqueTarget.Global),
FreeExtraBeliefs("May choose [amount] additional [beliefType] beliefs when [foundingOrEnhancing] a religion", UniqueTarget.Global),
FreeExtraAnyBeliefs("May choose [amount] additional belief(s) of any type when [foundingOrEnhancing] a religion", UniqueTarget.Global),