Changed all hardcoded Great General references to unique-based

This commit is contained in:
Yair Morgenstern
2020-12-22 23:03:41 +02:00
parent a4e93d89f1
commit 12b844d917
4 changed files with 8 additions and 6 deletions

View File

@ -5,7 +5,6 @@ object Constants {
const val workerUnique = "Can build improvements on tiles"
const val settler = "Settler"
const val settlerUnique = "Founds a new city"
const val greatGeneral = "Great General"
const val impassable = "Impassable"
const val ocean = "Ocean"

View File

@ -451,7 +451,7 @@ object NextTurnAutomation {
when {
unit.type.isRanged() -> rangedUnits.add(unit)
unit.type.isMelee() -> meleeUnits.add(unit)
unit.name == Constants.greatGeneral || unit.baseUnit.replaces == Constants.greatGeneral
unit.hasUnique("Bonus for units in 2 tile radius 15%")
-> generals.add(unit) //generals move after military units
else -> civilianUnits.add(unit)
}

View File

@ -97,7 +97,7 @@ object UnitAutomation {
if (unit.name == "Work Boats")
return SpecificUnitAutomation.automateWorkBoats(unit)
if (unit.name == Constants.greatGeneral || unit.baseUnit.replaces == Constants.greatGeneral)
if (unit.hasUnique("Bonus for units in 2 tile radius 15%"))
return SpecificUnitAutomation.automateGreatGeneral(unit)
if (unit.hasUnique("Can construct []"))

View File

@ -269,10 +269,13 @@ object Battle {
if(thisCombatant.getCivInfo().isMajorCiv()) {
var greatGeneralPointsModifier = 1f
val unitUniques = thisCombatant.unit.getMatchingUniques("[] is earned []% faster")
val civUniques = thisCombatant.unit.civInfo.getMatchingUniques("[] is earned []% faster")
for (unique in unitUniques + civUniques)
if (unique.params[0] == Constants.greatGeneral)
val civUniques = thisCombatant.getCivInfo().getMatchingUniques("[] is earned []% faster")
for (unique in unitUniques + civUniques) {
val unitName = unique.params[0]
val unit = thisCombatant.getCivInfo().gameInfo.ruleSet.units[unitName]
if (unit != null && unit.uniques.contains("Great Person - [War]"))
greatGeneralPointsModifier += unique.params[1].toFloat() / 100
}
val greatGeneralPointsGained = (XPGained * greatGeneralPointsModifier).toInt()
thisCombatant.getCivInfo().greatPeople.greatGeneralPoints += greatGeneralPointsGained