Updated Honor branch to G&K (#4118)

* Updated Honor policies to G&K

* Simplified another unique

* Implemented requested changes
This commit is contained in:
Xander Lenstra
2021-06-13 07:11:14 +02:00
committed by GitHub
parent 60809db065
commit da991b5f66
3 changed files with 42 additions and 17 deletions

View File

@ -75,12 +75,17 @@ object BattleDamage {
}
}
if (civInfo.hasUnique("+15% combat strength for melee units which have another military unit in an adjacent tile")
&& combatant.isMelee()
&& combatant.getTile().neighbors.flatMap { it.getUnits() }
.any { it.civInfo == civInfo && !it.type.isCivilian() && !it.type.isAirUnit() }
)
modifiers["Discipline"] = 15
var adjacentUnitBonus = 0;
for (unique in civInfo.getMatchingUniques("+[]% Strength for [] units which have another [] unit in an adjacent tile")) {
if (combatant.matchesCategory(unique.params[1])
&& combatant.getTile().neighbors.flatMap { it.getUnits() }
.any { it.civInfo == civInfo && it.matchesFilter(unique.params[2]) }
) {
adjacentUnitBonus += unique.params[0].toInt()
}
}
if (adjacentUnitBonus != 0)
modifiers["Adjacent unit"] = adjacentUnitBonus
val civResources = civInfo.getCivResourcesByName()
for (resource in combatant.unit.baseUnit.getResourceRequirements().keys)
@ -103,14 +108,24 @@ object BattleDamage {
.isCityState() && civInfo.hasUnique("+30% Strength when fighting City-State units and cities")
)
modifiers["vs [City-States]"] = 30
// Deprecated since 3.14.17
if (civInfo.hasUnique("+15% combat strength for melee units which have another military unit in an adjacent tile")
&& combatant.isMelee()
&& combatant.getTile().neighbors.flatMap { it.getUnits() }
.any { it.civInfo == civInfo && !it.type.isCivilian() && !it.type.isAirUnit() }
)
modifiers["Discipline"] = 15
}
if (enemy.getCivInfo().isBarbarian()) {
modifiers["Difficulty"] =
(civInfo.gameInfo.getDifficulty().barbarianBonus * 100).toInt()
if (civInfo.hasUnique("+25% bonus vs Barbarians"))
modifiers["vs Barbarians"] = 25
// Deprecated since 3.14.17
if (civInfo.hasUnique("+25% bonus vs Barbarians")) {
modifiers["vs Barbarians (deprecated)"] = 25
}
}
return modifiers

View File

@ -319,11 +319,19 @@ class MapUnit {
fun getCostOfUpgrade(): Int {
val unitToUpgradeTo = getUnitToUpgradeTo()
var goldCostOfUpgrade = (unitToUpgradeTo.cost - baseUnit().cost) * 2 + 10
for (unique in civInfo.getMatchingUniques("Gold cost of upgrading military units reduced by 33%"))
goldCostOfUpgrade = (goldCostOfUpgrade * 0.66f).toInt()
var goldCostOfUpgrade = (unitToUpgradeTo.cost - baseUnit().cost) * 2f + 10f
for (unique in civInfo.getMatchingUniques("Gold cost of upgrading [] units reduced by []%")) {
if (matchesFilter(unique.params[0]))
goldCostOfUpgrade *= (1 - unique.params[1].toFloat() / 100f)
}
// Deprecated since 3.14.17
if (civInfo.hasUnique("Gold cost of upgrading military units reduced by 33%")) {
goldCostOfUpgrade *= 0.67f
}
//
if (goldCostOfUpgrade < 0) return 0 // For instance, Landsknecht costs less than Spearman, so upgrading would cost negative gold
return goldCostOfUpgrade
return goldCostOfUpgrade.toInt()
}