mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-09 23:39:40 +07:00
Can now handle multiple civ-wide uniques of the same type!
This commit is contained in:
@ -139,6 +139,7 @@
|
|||||||
{
|
{
|
||||||
"name": "Professional Army",
|
"name": "Professional Army",
|
||||||
"effect": "Gold cost of upgrading military units reduced by 33%",
|
"effect": "Gold cost of upgrading military units reduced by 33%",
|
||||||
|
"uniques": ["Gold cost of upgrading military units reduced by 33%"],
|
||||||
"requires": ["Military Caste"],
|
"requires": ["Military Caste"],
|
||||||
"row": 3,
|
"row": 3,
|
||||||
"column": 4
|
"column": 4
|
||||||
@ -146,6 +147,7 @@
|
|||||||
{
|
{
|
||||||
"name": "Honor Complete",
|
"name": "Honor Complete",
|
||||||
"effect": "Gain gold for each unit killed"
|
"effect": "Gain gold for each unit killed"
|
||||||
|
"uniques": ["Gain gold for each unit killed"],
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},{
|
},{
|
||||||
|
@ -1290,13 +1290,13 @@
|
|||||||
{
|
{
|
||||||
"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]", "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]", "Unbuildable"],
|
||||||
"movement": 2
|
"movement": 2
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -1309,13 +1309,13 @@
|
|||||||
{
|
{
|
||||||
"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]", "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]", "Unbuildable"],
|
||||||
"movement": 2
|
"movement": 2
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -1324,7 +1324,7 @@
|
|||||||
"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%", "Unbuildable",
|
||||||
"Heal adjacent units for an additional 15 HP per turn", "Can build improvement: Citadel"],
|
"Heal adjacent units for an additional 15 HP per turn", "Can construct [Citadel]"],
|
||||||
"movement": 5
|
"movement": 5
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
@ -82,7 +82,7 @@ object Battle {
|
|||||||
tryGetCultureFromHonor(defender, attacker)
|
tryGetCultureFromHonor(defender, attacker)
|
||||||
|
|
||||||
if (defender.isDefeated() && defender is MapUnitCombatant && !defender.getUnitType().isCivilian()
|
if (defender.isDefeated() && defender is MapUnitCombatant && !defender.getUnitType().isCivilian()
|
||||||
&& attacker.getCivInfo().policies.isAdopted("Honor Complete"))
|
&& attacker.getCivInfo().hasUnique("Gain gold for each unit killed"))
|
||||||
attacker.getCivInfo().gold += defender.unit.baseUnit.getProductionCost(attacker.getCivInfo()) / 10
|
attacker.getCivInfo().gold += defender.unit.baseUnit.getProductionCost(attacker.getCivInfo()) / 10
|
||||||
|
|
||||||
if (attacker is MapUnitCombatant) {
|
if (attacker is MapUnitCombatant) {
|
||||||
|
@ -22,6 +22,7 @@ import com.unciv.models.ruleset.VictoryType
|
|||||||
import com.unciv.models.ruleset.tile.ResourceSupplyList
|
import com.unciv.models.ruleset.tile.ResourceSupplyList
|
||||||
import com.unciv.models.ruleset.unit.BaseUnit
|
import com.unciv.models.ruleset.unit.BaseUnit
|
||||||
import com.unciv.models.stats.Stats
|
import com.unciv.models.stats.Stats
|
||||||
|
import com.unciv.models.translations.equalsPlaceholderText
|
||||||
import com.unciv.models.translations.tr
|
import com.unciv.models.translations.tr
|
||||||
import com.unciv.ui.victoryscreen.RankingType
|
import com.unciv.ui.victoryscreen.RankingType
|
||||||
import java.util.*
|
import java.util.*
|
||||||
@ -177,9 +178,15 @@ class CivilizationInfo {
|
|||||||
|
|
||||||
fun hasResource(resourceName:String): Boolean = getCivResourcesByName()[resourceName]!!>0
|
fun hasResource(resourceName:String): Boolean = getCivResourcesByName()[resourceName]!!>0
|
||||||
|
|
||||||
fun hasUnique(unique:String) = policies.hasEffect(unique)
|
private fun getCivUniques() = policies.policyEffects.asSequence() + cities.asSequence().flatMap { it.getBuildingUniques() }
|
||||||
|| cities.any { it.containsBuildingUnique(unique) }
|
|
||||||
|
|
||||||
|
// This is
|
||||||
|
fun hasUnique(unique:String) = getCivUniques().contains(unique)
|
||||||
|
|
||||||
|
fun getMatchingUniques(uniqueTemplate: String) =
|
||||||
|
if (uniqueTemplate.contains('['))
|
||||||
|
getCivUniques().filter { it.equalsPlaceholderText(uniqueTemplate) }
|
||||||
|
else getCivUniques().filter { it==uniqueTemplate }
|
||||||
|
|
||||||
//region Units
|
//region Units
|
||||||
fun getCivUnits(): Sequence<MapUnit> = units.asSequence()
|
fun getCivUnits(): Sequence<MapUnit> = units.asSequence()
|
||||||
|
@ -263,9 +263,7 @@ class MapUnit {
|
|||||||
fun getCostOfUpgrade(): Int {
|
fun getCostOfUpgrade(): Int {
|
||||||
val unitToUpgradeTo = getUnitToUpgradeTo()
|
val unitToUpgradeTo = getUnitToUpgradeTo()
|
||||||
var goldCostOfUpgrade = (unitToUpgradeTo.cost - baseUnit().cost) * 2 + 10
|
var goldCostOfUpgrade = (unitToUpgradeTo.cost - baseUnit().cost) * 2 + 10
|
||||||
if (civInfo.policies.isAdopted("Professional Army"))
|
for(unique in civInfo.getMatchingUniques("Gold cost of upgrading military units reduced by 33%"))
|
||||||
goldCostOfUpgrade = (goldCostOfUpgrade * 0.66f).toInt()
|
|
||||||
if(civInfo.hasUnique("Gold cost of upgrading military units reduced by 33%"))
|
|
||||||
goldCostOfUpgrade = (goldCostOfUpgrade * 0.66f).toInt()
|
goldCostOfUpgrade = (goldCostOfUpgrade * 0.66f).toInt()
|
||||||
if(goldCostOfUpgrade<0) return 0 // For instance, Landsknecht costs less than Spearman, so upgrading would cost negative gold
|
if(goldCostOfUpgrade<0) return 0 // For instance, Landsknecht costs less than Spearman, so upgrading would cost negative gold
|
||||||
return goldCostOfUpgrade
|
return goldCostOfUpgrade
|
||||||
|
Reference in New Issue
Block a user