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],
"innerColor": [213,249,255],
"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",
"Ellasar","Erech","Kutha","Sirpurla","Neribtum","Ashur","Ninveh","Nimrud","Arbela","Nuzi",
"Arrapkha","Tutub","Shaduppum","Rapiqum","Mashkan Shapir","Tuttul","Ramad","Ana","Haradum","Agrab",

View file

@ -72,7 +72,7 @@
{
"name": "Republic",
"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"],
"row": 2,
"column": 1

View file

@ -1290,32 +1290,33 @@
{
"name": "Great Artist",
"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
},
{
"name": "Great Scientist",
"unitType": "Civilian",
"uniques": ["Can hurry technology research", "Can construct [Academy]", "Unbuildable"],
"uniques": ["Can hurry technology research", "Can construct [Academy]", "Great Person", "Unbuildable"],
"movement": 2
},
{
"name": "Great Merchant",
"unitType": "Civilian",
"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
},
{
"name": "Great Engineer",
"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
},
{
"name": "Great General",
"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
},
{
@ -1323,8 +1324,8 @@
"unitType": "Civilian",
"uniqueTo": "Mongolia",
"replaces": "Great General",
"uniques": ["Can start an 8-turn golden age","Bonus for units in 2 tile radius 15%", "Unbuildable",
"Heal adjacent units for an additional 15 HP per turn", "Can construct [Citadel]"],
"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]", "Great Person", "Unbuildable"],
"movement": 5
}
]

View file

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

View file

@ -16,13 +16,10 @@ Resolved #2907 - University unique registers properly
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

View file

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

View file

@ -178,9 +178,9 @@ class CivilizationInfo {
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 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
if (cities.isNotEmpty()) { //if no city available, addGreatPerson will throw exception
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
@ -492,15 +492,13 @@ class CivilizationInfo {
notifications.add(Notification(text, color, action))
}
fun addGreatPerson(greatPerson: String){
if(cities.isEmpty()) return
addGreatPerson(greatPerson, cities.random())
}
fun addGreatPerson(greatPerson: String, city:CityInfo) {
val greatPersonName = getEquivalentUnit(greatPerson).name
placeUnitNearTile(city.location, greatPersonName)
addNotification("A [$greatPersonName] has been born in [${city.name}]!", city.location, Color.GOLD)
fun addUnit(unitName:String, city: CityInfo?=null) {
if (cities.isEmpty()) return
val cityToAddTo = city ?: cities.random()
val unit = getEquivalentUnit(unitName)
placeUnitNearTile(cityToAddTo.location, unit.name)
if ("Great Person" in unit.uniques)
addNotification("A [${unit.name}] has been born in [${cityToAddTo.name}]!", cityToAddTo.location, Color.GOLD)
}
fun placeUnitNearTile(location: Vector2, unitName: String): MapUnit? {

View file

@ -148,7 +148,7 @@ class PolicyManager {
VictoryType.Domination, VictoryType.Neutral ->
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()

View file

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

View file

@ -361,24 +361,24 @@ class Building : NamedStats(), IConstruction{
if ("Empire enters golden age" in uniques) civInfo.goldenAges.enterGoldenAge()
for(unique in uniques) if(unique.equalsPlaceholderText("Free [] appears")){
val unitName = unique.getPlaceholderParameters()[0]
civInfo.addGreatPerson(unitName, cityConstructions.cityInfo)
civInfo.addUnit(unitName, cityConstructions.cityInfo)
}
if ("2 free Great Artists appear" in uniques) {
civInfo.addGreatPerson("Great Artist", cityConstructions.cityInfo)
civInfo.addGreatPerson("Great Artist", cityConstructions.cityInfo)
civInfo.addUnit("Great Artist", cityConstructions.cityInfo)
civInfo.addUnit("Great Artist", cityConstructions.cityInfo)
}
if ("2 free great scientists appear" in uniques) {
civInfo.addGreatPerson("Great Scientist", cityConstructions.cityInfo)
civInfo.addGreatPerson("Great Scientist", cityConstructions.cityInfo)
civInfo.addUnit("Great Scientist", cityConstructions.cityInfo)
civInfo.addUnit("Great Scientist", cityConstructions.cityInfo)
}
if ("Provides 2 free workers" in uniques) {
civInfo.placeUnitNearTile(cityConstructions.cityInfo.location, Constants.worker)
civInfo.placeUnitNearTile(cityConstructions.cityInfo.location, Constants.worker)
civInfo.addUnit(Constants.worker, cityConstructions.cityInfo)
civInfo.addUnit(Constants.worker, cityConstructions.cityInfo)
}
if ("Free Social Policy" in uniques) civInfo.policies.freePolicies++
if ("Free Great Person" in uniques) {
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) {
for(city in civInfo.cities){

View file

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

View file

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

View file

@ -93,14 +93,18 @@ class PolicyPickerScreen(val worldScreen: WorldScreen, civInfo: CivilizationInfo
rightSideButton.enable()
}
pickedPolicy = policy
var policyText = policy.name.tr() + "\r\n" + policy.effect.tr() + "\r\n"
if (!policy.name.endsWith("Complete")){
if(policy.requires!!.isNotEmpty())
val policyText = mutableListOf<String>()
policyText += policy.name
// policyText += policy.effect
policyText += policy.uniques
if (!policy.name.endsWith("Complete")) {
if (policy.requires!!.isNotEmpty())
policyText += "{Requires} ".tr() + policy.requires!!.joinToString { it.tr() }
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 {