mirror of
https://github.com/yairm210/Unciv.git
synced 2025-09-27 22:06:05 -04:00
units get promotions and xp bonuses from CS buildings (#5012)
* units get promotions and xp bonuses from CS buildings * fix siam
This commit is contained in:
parent
a01a6270fc
commit
7e0b7f0007
@ -892,10 +892,16 @@ class CivilizationInfo {
|
|||||||
.toList().random()
|
.toList().random()
|
||||||
// placing the unit may fail - in that case stay quiet
|
// placing the unit may fail - in that case stay quiet
|
||||||
val placedUnit = placeUnitNearTile(city.location, militaryUnit.name) ?: return
|
val placedUnit = placeUnitNearTile(city.location, militaryUnit.name) ?: return
|
||||||
|
|
||||||
|
// The unit should have bonuses from Barracks, Alhambra etc as if it was built in the CS capital
|
||||||
|
militaryUnit.addConstructionBonuses(placedUnit, otherCiv.getCapital().cityConstructions)
|
||||||
|
|
||||||
// Siam gets +10 XP for all CS units
|
// Siam gets +10 XP for all CS units
|
||||||
for (unique in getMatchingUniques("Military Units gifted from City-States start with [] XP")) {
|
for (unique in getMatchingUniques("Military Units gifted from City-States start with [] XP")) {
|
||||||
placedUnit.promotions.XP += unique.params[0].toInt()
|
placedUnit.promotions.XP += unique.params[0].toInt()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Point to the places mentioned in the message _in that order_ (debatable)
|
// Point to the places mentioned in the message _in that order_ (debatable)
|
||||||
val placedLocation = placedUnit.getTile().position
|
val placedLocation = placedUnit.getTile().position
|
||||||
val locations = LocationAction(listOf(placedLocation, cities.city2.location, city.location))
|
val locations = LocationAction(listOf(placedLocation, cities.city2.location, city.location))
|
||||||
|
@ -331,16 +331,22 @@ class BaseUnit : INamed, INonPerpetualConstruction, ICivilopediaText {
|
|||||||
|
|
||||||
if (this.isCivilian()) return true // tiny optimization makes save files a few bytes smaller
|
if (this.isCivilian()) return true // tiny optimization makes save files a few bytes smaller
|
||||||
|
|
||||||
|
addConstructionBonuses(unit, cityConstructions)
|
||||||
|
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
fun addConstructionBonuses(unit: MapUnit, cityConstructions: CityConstructions) {
|
||||||
|
val civInfo = cityConstructions.cityInfo.civInfo
|
||||||
var XP = cityConstructions.getBuiltBuildings().sumBy { it.xpForNewUnits }
|
var XP = cityConstructions.getBuiltBuildings().sumBy { it.xpForNewUnits }
|
||||||
|
|
||||||
|
|
||||||
for (unique in
|
for (unique in
|
||||||
cityConstructions.cityInfo.getMatchingUniques("New [] units start with [] Experience []")
|
cityConstructions.cityInfo.getMatchingUniques("New [] units start with [] Experience []")
|
||||||
.filter { cityConstructions.cityInfo.matchesFilter(it.params[2]) } +
|
.filter { cityConstructions.cityInfo.matchesFilter(it.params[2]) } +
|
||||||
// Deprecated since 3.15.9
|
// Deprecated since 3.15.9
|
||||||
cityConstructions.cityInfo.getMatchingUniques("New [] units start with [] Experience") +
|
cityConstructions.cityInfo.getMatchingUniques("New [] units start with [] Experience") +
|
||||||
cityConstructions.cityInfo.getLocalMatchingUniques("New [] units start with [] Experience in this city")
|
cityConstructions.cityInfo.getLocalMatchingUniques("New [] units start with [] Experience in this city")
|
||||||
//
|
//
|
||||||
) {
|
) {
|
||||||
if (unit.matchesFilter(unique.params[0]))
|
if (unit.matchesFilter(unique.params[0]))
|
||||||
XP += unique.params[1].toInt()
|
XP += unique.params[1].toInt()
|
||||||
@ -348,30 +354,28 @@ class BaseUnit : INamed, INonPerpetualConstruction, ICivilopediaText {
|
|||||||
unit.promotions.XP = XP
|
unit.promotions.XP = XP
|
||||||
|
|
||||||
for (unique in
|
for (unique in
|
||||||
cityConstructions.cityInfo.getMatchingUniques("All newly-trained [] units [] receive the [] promotion")
|
cityConstructions.cityInfo.getMatchingUniques("All newly-trained [] units [] receive the [] promotion")
|
||||||
.filter { cityConstructions.cityInfo.matchesFilter(it.params[1]) } +
|
.filter { cityConstructions.cityInfo.matchesFilter(it.params[1]) } +
|
||||||
// Deprecated since 3.15.9
|
// Deprecated since 3.15.9
|
||||||
cityConstructions.cityInfo.getLocalMatchingUniques("All newly-trained [] units in this city receive the [] promotion")
|
cityConstructions.cityInfo.getLocalMatchingUniques("All newly-trained [] units in this city receive the [] promotion")
|
||||||
//
|
//
|
||||||
) {
|
) {
|
||||||
val filter = unique.params[0]
|
val filter = unique.params[0]
|
||||||
val promotion = unique.params.last()
|
val promotion = unique.params.last()
|
||||||
|
|
||||||
if (unit.matchesFilter(filter) ||
|
if (unit.matchesFilter(filter) ||
|
||||||
(
|
(
|
||||||
filter == "relevant" &&
|
filter == "relevant" &&
|
||||||
civInfo.gameInfo.ruleSet.unitPromotions.values
|
civInfo.gameInfo.ruleSet.unitPromotions.values
|
||||||
.any {
|
.any {
|
||||||
it.name == promotion
|
it.name == promotion
|
||||||
&& unit.type.name in it.unitTypes
|
&& unit.type.name in it.unitTypes
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
unit.promotions.addPromotion(promotion, isFree = true)
|
unit.promotions.addPromotion(promotion, isFree = true)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user