Skip to content

Commit

Permalink
Added follower beliefs for buying religious buildings (#4793)
Browse files Browse the repository at this point in the history
* Added follower beliefs for buying religious buildings

* Implemented recommended changes
  • Loading branch information
xlenstra authored Aug 8, 2021
1 parent eab42c0 commit 55d32e1
Show file tree
Hide file tree
Showing 13 changed files with 227 additions and 127 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
217 changes: 119 additions & 98 deletions android/assets/BuildingIcons.atlas

Large diffs are not rendered by default.

Binary file modified android/assets/BuildingIcons.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
24 changes: 20 additions & 4 deletions android/assets/jsons/Civ V - Vanilla/Beliefs.json
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,11 @@
///////////////////////////////////////// Follower beliefs /////////////////////////////////////////

// Missing: asceticism (requires followers)
// Missing: cathedrals (requires purchasing with faith)
{
"name": "Cathedrals",
"type": "Follower",
"uniques": ["May buy [Cathedral] buildings for [200] [Faith] [in cities following this religion]"]
},
// Missing: choral music (requires followers)
{
"name": "Divine inspiration",
Expand All @@ -140,9 +144,21 @@
},
// Missing: Holy Warriors (requires purchasing with faith)
// Missing: Liturgical drama (requires followers)
// Missing: Monasteries (requires purchasing with faith)
// Missing: Mosques (requires purchasing with faith)
// Missing: Pagodas (requires purchasing with faith)
{
"name": "Monasteries",
"type": "Follower",
"uniques": ["May buy [Monastery] buildings for [200] [Faith] [in cities following this religion]"]
},
{
"name": "Mosques",
"type": "Follower",
"uniques": ["May buy [Mosque] buildings for [200] [Faith] [in cities following this religion]"]
},
{
"name": "Pagodas",
"type": "Follower",
"uniques": ["May buy [Pagoda] buildings for [200] [Faith] [in cities following this religion]"]
},
{
"name": "Peace Gardens",
"type": "Follower",
Expand Down
46 changes: 37 additions & 9 deletions android/assets/jsons/Civ V - Vanilla/Buildings.json
Original file line number Diff line number Diff line change
Expand Up @@ -442,14 +442,6 @@
"maintenance": 1,
"requiredTech": "Theology"
},
{
"name": "Monastery",
"maintenance": 0,
"requiredNearbyImprovedResources": ["Wine","Incense"],
"uniques": ["[+2 Culture] from [Wine] tiles [in this city]", "[+2 Culture] from [Incense] tiles [in this city]"],
"hurryCostModifier": 25,
"requiredTech": "Theology"
},
{
"name": "Hagia Sophia",
"culture": 1,
Expand Down Expand Up @@ -1122,5 +1114,41 @@
"isNationalWonder": true,
"uniques": ["Hidden until [5] social policy branches have been completed", "Triggers a global alert upon build start",
"Triggers a Cultural Victory upon completion", "Hidden when [Cultural] Victory is disabled"]
}
},

// Religious buildings

{
"name": "Cathedral",
"cost": 0,
"faith": 1,
"culture": 3,
"happiness": 1,
"specialistSlots": {"Artist": 1},
"uniques": ["Unbuildable"]
},
{
"name": "Monastery",
"cost": 0,
"culture": 2,
"faith": 2,
"uniques": ["[+1 Culture, +1 Faith] from [Wine] tiles [in this city]",
"[+1 Culture, +1 Faith] from [Incense] tiles [in this city]","Unbuildable"]
},
{
"name": "Mosque",
"cost": 0,
"culture": 2,
"faith": 3,
"happiness": 1,
"uniques": ["Unbuildable"]
},
{
"name": "Pagoda",
"cost": 0,
"culture": 2,
"faith": 2,
"happiness": 2,
"uniques": ["Unbuildable"]
},
]
4 changes: 4 additions & 0 deletions core/src/com/unciv/logic/city/CityInfo.kt
Original file line number Diff line number Diff line change
Expand Up @@ -595,6 +595,10 @@ class CityInfo {
"in all cities in which the majority religion is a major religion" ->
religion.getMajorityReligion() != null
&& civInfo.gameInfo.religions[religion.getMajorityReligion()]!!.isMajorReligion()
// This is only used in communication to the user indicating that only in cities with this
// religion a unique is active. However, since religion uniques only come from the city itself,
// this will always be true when checked.
"in cities following this religion" -> true
else -> false
}
}
Expand Down
3 changes: 1 addition & 2 deletions core/src/com/unciv/logic/city/IConstruction.kt
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ interface INonPerpetualConstruction : IConstruction, INamed, IHasUniques {
fun getStatBuyCost(cityInfo: CityInfo, stat: Stat): Int?
fun getRejectionReason(cityConstructions: CityConstructions): String

private fun getMatchingUniques(uniqueTemplate: String): Sequence<Unique> {
fun getMatchingUniques(uniqueTemplate: String): Sequence<Unique> {
return uniqueObjects.asSequence().filter { it.placeholderText == uniqueTemplate }
}

Expand Down Expand Up @@ -58,7 +58,6 @@ interface INonPerpetualConstruction : IConstruction, INamed, IHasUniques {
return (30.0 * getProductionCost(civInfo)).pow(0.75) * (1 + hurryCostModifier / 100f)
}

// I can't make this function protected or private :(
fun getBaseBuyCost(cityInfo: CityInfo, stat: Stat): Int? {
if (stat == Stat.Gold) return getBaseGoldCost(cityInfo.civInfo).toInt()

Expand Down
27 changes: 27 additions & 0 deletions core/src/com/unciv/models/ruleset/Building.kt
Original file line number Diff line number Diff line change
Expand Up @@ -202,9 +202,36 @@ class Building : NamedStats(), INonPerpetualConstruction, ICivilopediaText {

override fun canBePurchasedWithStat(cityInfo: CityInfo, stat: Stat, ignoreCityRequirements: Boolean): Boolean {
if (stat == Stat.Gold && isAnyWonder()) return false
// May buy [buildingFilter] buildings for [amount] [Stat] [cityFilter]
if (cityInfo.getMatchingUniques("May buy [] buildings for [] [] []")
.any { it.params[2] == stat.name && matchesFilter(it.params[0]) && cityInfo.matchesFilter(it.params[3]) }
) return true
return super.canBePurchasedWithStat(cityInfo, stat, ignoreCityRequirements)
}

override fun getBaseBuyCost(cityInfo: CityInfo, stat: Stat): Int? {
if (stat == Stat.Gold) return getBaseGoldCost(cityInfo.civInfo).toInt()

val lowestCostFromUnique =
(
// Can be purchased for [amount] [Stat] [cityFilter]
getMatchingUniques("Can be purchased for [] [] []")
.filter { it.params[1] == stat.name && cityInfo.matchesFilter(it.params[2]) }
.map { it.params[0].toInt() }
// May buy [buildingFilter] buildings for [amount] [Stat] [cityFilter]
+ cityInfo.getMatchingUniques("May buy [] buildings for [] [] []")
.filter { it.params[2] == stat.name && matchesFilter(it.params[0]) && cityInfo.matchesFilter(it.params[3])}
.map { it.params[1].toInt() }
).minOrNull()
if (lowestCostFromUnique != null) return lowestCostFromUnique

// Can be purchased with [Stat] [cityFilter]
if (getMatchingUniques("Can be purchased with [] []")
.any { it.params[0] == stat.name && cityInfo.matchesFilter(it.params[1])}
) return cityInfo.civInfo.gameInfo.ruleSet.eras[cityInfo.civInfo.getEra()]!!.baseUnitBuyCost
return null
}

override fun getCivilopediaTextHeader() = FormattedLine(name, header=2, icon=makeLink())
override fun makeLink() = if (isAnyWonder()) "Wonder/$name" else "Building/$name"
override fun hasCivilopediaTextLines() = true
Expand Down
8 changes: 4 additions & 4 deletions core/src/com/unciv/models/ruleset/Ruleset.kt
Original file line number Diff line number Diff line change
Expand Up @@ -237,9 +237,9 @@ class Ruleset {
* */
fun updateBuildingCosts() {
for (building in buildings.values) {
if (building.cost == 0) {
if (building.cost == 0 && !building.uniques.contains("Unbuildable")) {
val column = technologies[building.requiredTech]?.column
?: throw UncivShowableException("Building (${building.name}) must either have an explicit cost or reference an existing tech")
?: throw UncivShowableException("Building (${building.name}) is buildable and therefore must either have an explicit cost or reference an existing tech")
building.cost = if (building.isAnyWonder()) column.wonderCost else column.buildingCost
}
}
Expand Down Expand Up @@ -311,8 +311,8 @@ class Ruleset {
}

for (building in buildings.values) {
if (building.requiredTech == null && building.cost == 0)
lines += "${building.name} must either have an explicit cost or reference an existing tech!"
if (building.requiredTech == null && building.cost == 0 && !building.uniques.contains("Unbuildable"))
lines += "${building.name} is buildable and therefore must either have an explicit cost or reference an existing tech!"
}

for (nation in nations.values) {
Expand Down
19 changes: 10 additions & 9 deletions core/src/com/unciv/models/translations/TranslationFileWriter.kt
Original file line number Diff line number Diff line change
Expand Up @@ -213,19 +213,20 @@ object TranslationFileWriter {
"water units",
"air units",
"military units",
"submarine units"
"submarine units",
// Note: this can't handle combinations of parameters (e.g. [{Military} {Water}])
)) }
val cityFilterMap = setOf(
"in this city",
"in all cities",
"in all coastal cities",
"in capital",
"in all non-occupied cities",
"in all cities with a world wonder",
"in all cities connected to capital",
"in all cities with a garrison",
"in all cities in which the majority religion is a major religion"
"in all cities",
"in all coastal cities",
"in capital",
"in all non-occupied cities",
"in all cities with a world wonder",
"in all cities connected to capital",
"in all cities with a garrison",
"in all cities in which the majority religion is a major religion",
"in cities following this religion",
)

val startMillis = System.currentTimeMillis()
Expand Down
6 changes: 5 additions & 1 deletion docs/Credits.md
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,6 @@ Unless otherwise specified, all the following are from [the Noun Project](https:
* [Wat Arun Ratchawararam Ratchawaramahawihan](https://thenounproject.com/term/wat-arun-ratchawararam-ratchawaramahawihan/320664/) By József Balázs-Hegedüs for Wat
* [College](https://thenounproject.com/term/college/1203703/) By Vectors Market for National College
* [Chichen Itza](https://thenounproject.com/term/chichen-itza/668065/) By Hea Poh Lin
* [Christian Church](https://thenounproject.com/term/christian-church/1174183/) By Andrejs Kirma for Monastery
* [Castle](https://thenounproject.com/search/?q=castle&i=390189) By Mint Shirt
* [Red Fort](https://thenounproject.com/arunabh.jain.0fficial/collection/famous-indian-monuments/?i=2092466), [Gateway of India](https://thenounproject.com/arunabh.jain.0fficial/collection/famous-indian-monuments/?i=2092468) By Arunabh Jain, IN for Mughal Fort
* [Angkor Wat](https://thenounproject.com/search/?q=angkor%20wat&i=2412873) By Phạm Thanh Lộc for Angkor Wat
Expand Down Expand Up @@ -312,6 +311,11 @@ Unless otherwise specified, all the following are from [the Noun Project](https:

### All Era's
* [Illuminati](https://thenounproject.com/term/illuminati/1617812) by emilegraphics for the Utopia Project
* [Christian Church](https://thenounproject.com/term/christian-church/1174183/) by Andrejs Kirma for Monastery
* [cathedral](https://thenounproject.com/search/?q=Cathedral&i=4136407) by Pixel Bazaar for Cathedral
* [Mosque](https://thenounproject.com/search/?q=mosque&i=4139519) by Ahmad Roaayala for Mosque
* [Pagoda](https://thenounproject.com/search/?q=pagoda&i=446665) by Xinh Studio for Pagoda


## Social Policies

Expand Down

0 comments on commit 55d32e1

Please sign in to comment.