Replaced "Building.providesFreeBuilding" field with generic unique

This commit is contained in:
Yair Morgenstern 2021-07-26 14:29:43 +03:00
parent 8a1c728438
commit c5ffec9ade
2 changed files with 27 additions and 23 deletions

View File

@ -91,9 +91,8 @@
"culture": 1,
"greatPersonPoints": {"Great Scientist": 1},
"isWonder": true,
"providesFreeBuilding": "Library",
"requiredTech": "Writing",
"uniques": ["Free Technology"],
"uniques": ["Free Technology", "Provides 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"
},
{
@ -205,9 +204,8 @@
"culture": 1,
"greatPersonPoints": {"Great Merchant": 1},
"isWonder": true,
"providesFreeBuilding": "Lighthouse",
"uniques": ["Must be next to [Coast]", "+[1] Movement for all [{Military} {Water}] units",
"+[1] Sight for all [{Military} {Water}] units"],
"+[1] Sight for all [{Military} {Water}] units", "Provides 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"
},
@ -245,8 +243,8 @@
"food": 6,
"culture": 1,
"isWonder": true,
"providesFreeBuilding": "Garden",
"requiredTech": "Mathematics",
"uniques": ["Provides 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"
},
{
@ -408,8 +406,8 @@
"culture": 3,
"greatPersonPoints": {"Great Engineer": 1},
"isWonder": true,
"providesFreeBuilding": "Walls",
"uniques": ["Enemy land units must spend 1 extra movement point when inside your territory (obsolete upon Dynamite)"],
"uniques": ["Enemy land units must spend 1 extra movement point when inside your territory (obsolete upon Dynamite)",
"Provides 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"
},
@ -601,9 +599,9 @@
"culture": 1,
"greatPersonPoints": {"Great Artist": 1},
"isWonder": true,
"providesFreeBuilding": "Castle",
"percentStatBonus": {"culture": 20},
"uniques": ["All newly-trained [relevant] units [in this city] receive the [Drill I] promotion"],
"uniques": ["All newly-trained [relevant] units [in this city] receive the [Drill I] promotion",
"Provides 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"
},
@ -729,8 +727,8 @@
"culture": 3,
"isWonder": true,
"greatPersonPoints": {"Great Engineer": 2},
"providesFreeBuilding": "Castle",
"uniques": ["+[15]% Strength for units fighting in [Friendly Land]"],
"uniques": ["+[15]% Strength for units fighting in [Friendly Land]",
"Provides 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"
},
@ -1049,8 +1047,7 @@
"isWonder": true,
"culture": 1,
"greatPersonPoints": {"Great Merchant": 1},
"providesFreeBuilding": "Broadcast Tower",
"uniques": ["[+1] population [in all cities]", "[+1 Happiness] [in all cities]"],
"uniques": ["[+1] population [in all cities]", "[+1 Happiness] [in all cities]", "Provides a free [Broadcast Tower] [in this city]"],
"requiredTech": "Telecommunications",
"quote": "'Nothing travels faster than light with the possible exception of bad news, which obeys its own special rules.' - Douglas Adams"
},
@ -1071,11 +1068,11 @@
"name": "Hubble Space Telescope",
"isWonder": true,
"greatPersonPoints": {"Great Scientist": 1},
"providesFreeBuilding": "Spaceship Factory",
// If spaceship parts are changed into units, the spaceship part unique should be changed to
// "+[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]"],
"+[25]% Production when constructing [Spaceship part] [in this city]",
"Provides 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

@ -63,6 +63,7 @@ class Building : NamedStats(), IConstruction, ICivilopediaText {
var replaces: String? = null
var uniqueTo: String? = null
var quote: String = ""
@Deprecated("As of 3.15.16 - replaced with 'Provides a free [buildingName] [cityFilter]'")
var providesFreeBuilding: String? = null
var uniques = ArrayList<String>()
var replacementTextForUniques = ""
@ -549,14 +550,21 @@ class Building : NamedStats(), IConstruction, ICivilopediaText {
}
}
if (providesFreeBuilding != null && !cityConstructions.containsBuildingOrEquivalent(providesFreeBuilding!!)) {
var buildingToAdd = providesFreeBuilding!!
// "Provides a free [buildingName] [cityFilter]"
var freeBuildingUniques = uniqueObjects.asSequence().filter { it.placeholderText=="Provides a free [] []" }
if (providesFreeBuilding!=null) freeBuildingUniques += sequenceOf(Unique("Provides a free [$providesFreeBuilding] [in this city]"))
for (building in civInfo.gameInfo.ruleSet.buildings.values)
if (building.replaces == buildingToAdd && building.uniqueTo == civInfo.civName)
buildingToAdd = building.name
for(unique in freeBuildingUniques) {
val affectedCities =
if (unique.params[1] == "in this city") sequenceOf(cityConstructions.cityInfo)
else civInfo.cities.asSequence().filter { it.matchesFilter(unique.params[1]) }
cityConstructions.addBuilding(buildingToAdd)
val freeBuildingName = civInfo.getEquivalentBuilding(unique.params[0]).name
for (city in affectedCities) {
if (cityConstructions.containsBuildingOrEquivalent(freeBuildingName)) continue
cityConstructions.addBuilding(freeBuildingName)
}
}
for (unique in uniqueObjects)
@ -598,8 +606,7 @@ class Building : NamedStats(), IConstruction, ICivilopediaText {
}
fun getBaseBuilding(ruleset: Ruleset): Building {
return if (replaces == null) this
else ruleset.buildings[replaces!!]!!
return if (replaces == null) this else ruleset.buildings[replaces!!]!!
}
fun getImprovement(ruleset: Ruleset): TileImprovement? {