Unified regular unit and great person unit additions

First playaround with nation uniques!
This commit is contained in:
Yair Morgenstern 2020-08-01 23:04:33 +03:00
parent 9ade890ad4
commit b4708b05b3
13 changed files with 56 additions and 52 deletions

View file

@ -30,6 +30,7 @@
"outerColor": [27,53,63], "outerColor": [27,53,63],
"innerColor": [213,249,255], "innerColor": [213,249,255],
"unique": "INGENUITY", "unique": "INGENUITY",
"uniques": ["Receive free [Great Scientist] when you discover [Writing]", "Earn Great Scientists 50% faster"]
"cities": ["Babylon","Akkad","Dur-Kurigalzu","Nippur","Borsippa","Sippar","Opis","Mari","Shushan","Eshnunna", "cities": ["Babylon","Akkad","Dur-Kurigalzu","Nippur","Borsippa","Sippar","Opis","Mari","Shushan","Eshnunna",
"Ellasar","Erech","Kutha","Sirpurla","Neribtum","Ashur","Ninveh","Nimrud","Arbela","Nuzi", "Ellasar","Erech","Kutha","Sirpurla","Neribtum","Ashur","Ninveh","Nimrud","Arbela","Nuzi",
"Arrapkha","Tutub","Shaduppum","Rapiqum","Mashkan Shapir","Tuttul","Ramad","Ana","Haradum","Agrab", "Arrapkha","Tutub","Shaduppum","Rapiqum","Mashkan Shapir","Tuttul","Ramad","Ana","Haradum","Agrab",

View file

@ -72,7 +72,7 @@
{ {
"name": "Republic", "name": "Republic",
"effect": "+1 production in every city, +5% production when constructing buildings", "effect": "+1 production in every city, +5% production when constructing buildings",
"uniques": ["[+1 Production] in all cities", "+5% production when constructing buildings"], "uniques": ["[+1 Production] in all cities", "+[5]% Production when constructing [Buildings]"],
"requires": ["Collective Rule"], "requires": ["Collective Rule"],
"row": 2, "row": 2,
"column": 1 "column": 1

View file

@ -1290,32 +1290,33 @@
{ {
"name": "Great Artist", "name": "Great Artist",
"unitType": "Civilian", "unitType": "Civilian",
"uniques": ["Can start an 8-turn golden age", "Can construct [Landmark]", "Unbuildable"], "uniques": ["Can start an 8-turn golden age", "Can construct [Landmark]", "Great Person", "Unbuildable"],
"movement": 2 "movement": 2
}, },
{ {
"name": "Great Scientist", "name": "Great Scientist",
"unitType": "Civilian", "unitType": "Civilian",
"uniques": ["Can hurry technology research", "Can construct [Academy]", "Unbuildable"], "uniques": ["Can hurry technology research", "Can construct [Academy]", "Great Person", "Unbuildable"],
"movement": 2 "movement": 2
}, },
{ {
"name": "Great Merchant", "name": "Great Merchant",
"unitType": "Civilian", "unitType": "Civilian",
"uniques": ["Can undertake a trade mission with City-State, giving a large sum of gold and [30] Influence", "uniques": ["Can undertake a trade mission with City-State, giving a large sum of gold and [30] Influence",
"Can construct [Customs house]", "Unbuildable"], "Can construct [Customs house]", "Great Person", "Unbuildable"],
"movement": 2 "movement": 2
}, },
{ {
"name": "Great Engineer", "name": "Great Engineer",
"unitType": "Civilian", "unitType": "Civilian",
"uniques": ["Can speed up construction of a wonder", "Can construct [Manufactory]", "Unbuildable"], "uniques": ["Can speed up construction of a wonder", "Can construct [Manufactory]", "Great Person", "Unbuildable"],
"movement": 2 "movement": 2
}, },
{ {
"name": "Great General", "name": "Great General",
"unitType": "Civilian", "unitType": "Civilian",
"uniques": ["Can start an 8-turn golden age", "Bonus for units in 2 tile radius 15%", "Can construct [Citadel]", "Unbuildable"], "uniques": ["Can start an 8-turn golden age", "Bonus for units in 2 tile radius 15%", "Can construct [Citadel]",
"Great Person", "Unbuildable"],
"movement": 2 "movement": 2
}, },
{ {
@ -1323,8 +1324,8 @@
"unitType": "Civilian", "unitType": "Civilian",
"uniqueTo": "Mongolia", "uniqueTo": "Mongolia",
"replaces": "Great General", "replaces": "Great General",
"uniques": ["Can start an 8-turn golden age","Bonus for units in 2 tile radius 15%", "Unbuildable", "uniques": ["Can start an 8-turn golden age","Bonus for units in 2 tile radius 15%",
"Heal adjacent units for an additional 15 HP per turn", "Can construct [Citadel]"], "Heal adjacent units for an additional 15 HP per turn", "Can construct [Citadel]", "Great Person", "Unbuildable"],
"movement": 5 "movement": 5
} }
] ]

View file

@ -676,6 +676,8 @@ Policies =
Base happiness = Base happiness =
Occupied City = Occupied City =
Buildings = Buildings =
# For the "when constructing [military units]" translation
military units =
Wonders = Wonders =
Base values = Base values =
Bonuses = Bonuses =

View file

@ -16,13 +16,10 @@ Resolved #2907 - University unique registers properly
Added civ-wide per-building stat bonus Added civ-wide per-building stat bonus
By lishaoxia1985: New Diplomacy Overview UI - By lishaoxia1985
- New Diplomacy Overview UI Fog of war implementation - By alkorolyov
By alkorolyov:
- Fog of war implementation
## 3.9.16 ## 3.9.16

View file

@ -330,15 +330,13 @@ class CityStats {
return stats return stats
} }
private fun getStatPercentBonusesFromPolicies(policies: HashSet<String>, cityConstructions: CityConstructions): Stats { private fun getStatPercentBonusesFromPolicies(cityConstructions: CityConstructions): Stats {
val stats = Stats() val stats = Stats()
val currentConstruction = cityConstructions.getCurrentConstruction() val currentConstruction = cityConstructions.getCurrentConstruction()
if (policies.contains("Collective Rule") && cityInfo.isCapital() if (currentConstruction.name == Constants.settler && cityInfo.isCapital()
&& currentConstruction.name == Constants.settler) && cityInfo.civInfo.hasUnique("Training of settlers increased +50% in capital"))
stats.production += 50f stats.production += 50f
if (policies.contains("Republic") && currentConstruction is Building)
stats.production += 5f
if (cityInfo.civInfo.hasUnique("+20% production when training melee units") if (cityInfo.civInfo.hasUnique("+20% production when training melee units")
&& currentConstruction is BaseUnit && currentConstruction.unitType.isMelee()) && currentConstruction is BaseUnit && currentConstruction.unitType.isMelee())
stats.production += 20 stats.production += 20
@ -355,7 +353,8 @@ class CityStats {
val placeholderParams = unique.getPlaceholderParameters() val placeholderParams = unique.getPlaceholderParameters()
val filter = placeholderParams[1] val filter = placeholderParams[1]
if (currentConstruction.name == filter if (currentConstruction.name == filter
|| (filter=="military units" && currentConstruction is BaseUnit && !currentConstruction.unitType.isCivilian())) || (filter=="military units" && currentConstruction is BaseUnit && !currentConstruction.unitType.isCivilian())
|| (filter=="Buildings" && currentConstruction is Building && !currentConstruction.isWonder))
stats.production += placeholderParams[0].toInt() stats.production += placeholderParams[0].toInt()
} }
@ -407,7 +406,7 @@ class CityStats {
fun updateStatPercentBonusList() { fun updateStatPercentBonusList() {
val newStatPercentBonusList = LinkedHashMap<String, Stats>() val newStatPercentBonusList = LinkedHashMap<String, Stats>()
newStatPercentBonusList["Golden Age"] = getStatPercentBonusesFromGoldenAge(cityInfo.civInfo.goldenAges.isGoldenAge()) newStatPercentBonusList["Golden Age"] = getStatPercentBonusesFromGoldenAge(cityInfo.civInfo.goldenAges.isGoldenAge())
newStatPercentBonusList["Policies"] = getStatPercentBonusesFromPolicies(cityInfo.civInfo.policies.adoptedPolicies, cityInfo.cityConstructions) newStatPercentBonusList["Policies"] = getStatPercentBonusesFromPolicies(cityInfo.cityConstructions)
newStatPercentBonusList["Buildings"] = getStatPercentBonusesFromBuildings() newStatPercentBonusList["Buildings"] = getStatPercentBonusesFromBuildings()
newStatPercentBonusList["Railroad"] = getStatPercentBonusesFromRailroad() newStatPercentBonusList["Railroad"] = getStatPercentBonusesFromRailroad()
newStatPercentBonusList["Marble"] = getStatPercentBonusesFromMarble() newStatPercentBonusList["Marble"] = getStatPercentBonusesFromMarble()

View file

@ -178,9 +178,9 @@ class CivilizationInfo {
fun hasResource(resourceName:String): Boolean = getCivResourcesByName()[resourceName]!!>0 fun hasResource(resourceName:String): Boolean = getCivResourcesByName()[resourceName]!!>0
private fun getCivUniques() = policies.policyEffects.asSequence() + cities.asSequence().flatMap { it.getBuildingUniques() } private fun getCivUniques() = nation.uniques.asSequence() + policies.policyEffects.asSequence() +
cities.asSequence().flatMap { it.getBuildingUniques() }
// This is
fun hasUnique(unique:String) = getCivUniques().contains(unique) fun hasUnique(unique:String) = getCivUniques().contains(unique)
fun getMatchingUniques(uniqueTemplate: String) = fun getMatchingUniques(uniqueTemplate: String) =
@ -407,7 +407,7 @@ class CivilizationInfo {
// so they won't be generated out in the open and vulnerable to enemy attacks before you can control them // so they won't be generated out in the open and vulnerable to enemy attacks before you can control them
if (cities.isNotEmpty()) { //if no city available, addGreatPerson will throw exception if (cities.isNotEmpty()) { //if no city available, addGreatPerson will throw exception
val greatPerson = greatPeople.getNewGreatPerson() val greatPerson = greatPeople.getNewGreatPerson()
if (greatPerson != null) addGreatPerson(greatPerson) if (greatPerson != null) addUnit(greatPerson)
} }
updateViewableTiles() // adds explored tiles so that the units will be able to perform automated actions better updateViewableTiles() // adds explored tiles so that the units will be able to perform automated actions better
@ -492,15 +492,13 @@ class CivilizationInfo {
notifications.add(Notification(text, color, action)) notifications.add(Notification(text, color, action))
} }
fun addGreatPerson(greatPerson: String){ fun addUnit(unitName:String, city: CityInfo?=null) {
if (cities.isEmpty()) return if (cities.isEmpty()) return
addGreatPerson(greatPerson, cities.random()) val cityToAddTo = city ?: cities.random()
} val unit = getEquivalentUnit(unitName)
placeUnitNearTile(cityToAddTo.location, unit.name)
fun addGreatPerson(greatPerson: String, city:CityInfo) { if ("Great Person" in unit.uniques)
val greatPersonName = getEquivalentUnit(greatPerson).name addNotification("A [${unit.name}] has been born in [${cityToAddTo.name}]!", cityToAddTo.location, Color.GOLD)
placeUnitNearTile(city.location, greatPersonName)
addNotification("A [$greatPersonName] has been born in [${city.name}]!", city.location, Color.GOLD)
} }
fun placeUnitNearTile(location: Vector2, unitName: String): MapUnit? { fun placeUnitNearTile(location: Vector2, unitName: String): MapUnit? {

View file

@ -148,7 +148,7 @@ class PolicyManager {
VictoryType.Domination, VictoryType.Neutral -> VictoryType.Domination, VictoryType.Neutral ->
civInfo.gameInfo.ruleSet.units.keys.filter { it.startsWith("Great") }.random() civInfo.gameInfo.ruleSet.units.keys.filter { it.startsWith("Great") }.random()
} }
civInfo.addGreatPerson(greatPerson) civInfo.addUnit(greatPerson)
} }
} }
"Quantity of strategic resources produced by the empire increased by 100%" -> civInfo.updateDetailedCivResources() "Quantity of strategic resources produced by the empire increased by 100%" -> civInfo.updateDetailedCivResources()

View file

@ -8,6 +8,7 @@ import com.unciv.UniqueAbility
import com.unciv.logic.map.MapSize import com.unciv.logic.map.MapSize
import com.unciv.logic.map.RoadStatus import com.unciv.logic.map.RoadStatus
import com.unciv.models.ruleset.tech.Technology import com.unciv.models.ruleset.tech.Technology
import com.unciv.models.translations.getPlaceholderParameters
import com.unciv.ui.utils.withItem import com.unciv.ui.utils.withItem
import java.util.* import java.util.*
import kotlin.collections.ArrayList import kotlin.collections.ArrayList
@ -271,9 +272,11 @@ class TechManager {
} }
} }
if (techName == "Writing" && civInfo.nation.unique == UniqueAbility.INGENUITY for(unique in civInfo.getMatchingUniques("Receive free [] when you discover []")){
&& civInfo.cities.any()) val params = unique.getPlaceholderParameters()
civInfo.addGreatPerson("Great Scientist") if(params[1]!=techName) continue
civInfo.addUnit(params[0])
}
} }
fun setTransients() { fun setTransients() {

View file

@ -361,24 +361,24 @@ class Building : NamedStats(), IConstruction{
if ("Empire enters golden age" in uniques) civInfo.goldenAges.enterGoldenAge() if ("Empire enters golden age" in uniques) civInfo.goldenAges.enterGoldenAge()
for(unique in uniques) if(unique.equalsPlaceholderText("Free [] appears")){ for(unique in uniques) if(unique.equalsPlaceholderText("Free [] appears")){
val unitName = unique.getPlaceholderParameters()[0] val unitName = unique.getPlaceholderParameters()[0]
civInfo.addGreatPerson(unitName, cityConstructions.cityInfo) civInfo.addUnit(unitName, cityConstructions.cityInfo)
} }
if ("2 free Great Artists appear" in uniques) { if ("2 free Great Artists appear" in uniques) {
civInfo.addGreatPerson("Great Artist", cityConstructions.cityInfo) civInfo.addUnit("Great Artist", cityConstructions.cityInfo)
civInfo.addGreatPerson("Great Artist", cityConstructions.cityInfo) civInfo.addUnit("Great Artist", cityConstructions.cityInfo)
} }
if ("2 free great scientists appear" in uniques) { if ("2 free great scientists appear" in uniques) {
civInfo.addGreatPerson("Great Scientist", cityConstructions.cityInfo) civInfo.addUnit("Great Scientist", cityConstructions.cityInfo)
civInfo.addGreatPerson("Great Scientist", cityConstructions.cityInfo) civInfo.addUnit("Great Scientist", cityConstructions.cityInfo)
} }
if ("Provides 2 free workers" in uniques) { if ("Provides 2 free workers" in uniques) {
civInfo.placeUnitNearTile(cityConstructions.cityInfo.location, Constants.worker) civInfo.addUnit(Constants.worker, cityConstructions.cityInfo)
civInfo.placeUnitNearTile(cityConstructions.cityInfo.location, Constants.worker) civInfo.addUnit(Constants.worker, cityConstructions.cityInfo)
} }
if ("Free Social Policy" in uniques) civInfo.policies.freePolicies++ if ("Free Social Policy" in uniques) civInfo.policies.freePolicies++
if ("Free Great Person" in uniques) { if ("Free Great Person" in uniques) {
if (civInfo.isPlayerCivilization()) civInfo.greatPeople.freeGreatPeople++ if (civInfo.isPlayerCivilization()) civInfo.greatPeople.freeGreatPeople++
else civInfo.addGreatPerson(civInfo.gameInfo.ruleSet.units.keys.filter { it.startsWith("Great") }.random()) else civInfo.addUnit(civInfo.gameInfo.ruleSet.units.keys.filter { it.startsWith("Great") }.random())
} }
if ("+1 population in each city" in uniques) { if ("+1 population in each city" in uniques) {
for(city in civInfo.cities){ for(city in civInfo.cities){

View file

@ -36,6 +36,7 @@ class Nation : INamed {
lateinit var outerColor: List<Int> lateinit var outerColor: List<Int>
var unique: UniqueAbility? = null var unique: UniqueAbility? = null
val uniques = ArrayList<String>()
var innerColor: List<Int>? = null var innerColor: List<Int>? = null
var startBias = ArrayList<String>() var startBias = ArrayList<String>()

View file

@ -12,8 +12,6 @@ open class Policy : INamed {
var column: Int = 0 var column: Int = 0
var requires: ArrayList<String>? = null var requires: ArrayList<String>? = null
override fun toString(): String { override fun toString() = name
return name
}
} }

View file

@ -93,14 +93,18 @@ class PolicyPickerScreen(val worldScreen: WorldScreen, civInfo: CivilizationInfo
rightSideButton.enable() rightSideButton.enable()
} }
pickedPolicy = policy pickedPolicy = policy
var policyText = policy.name.tr() + "\r\n" + policy.effect.tr() + "\r\n" val policyText = mutableListOf<String>()
policyText += policy.name
// policyText += policy.effect
policyText += policy.uniques
if (!policy.name.endsWith("Complete")) { if (!policy.name.endsWith("Complete")) {
if (policy.requires!!.isNotEmpty()) if (policy.requires!!.isNotEmpty())
policyText += "{Requires} ".tr() + policy.requires!!.joinToString { it.tr() } policyText += "{Requires} ".tr() + policy.requires!!.joinToString { it.tr() }
else else
policyText += ("{Unlocked at} {" + policy.branch.era + "}").tr() policyText += ("{Unlocked at} {" + policy.branch.era + "}").tr()
} }
descriptionLabel.setText(policyText) descriptionLabel.setText(policyText.joinToString("\r\n") { it.tr() })
} }
private fun getPolicyButton(policy: Policy, image: Boolean): Button { private fun getPolicyButton(policy: Policy, image: Boolean): Button {