Skip to content

Commit

Permalink
Example for automating golden age triggers
Browse files Browse the repository at this point in the history
  • Loading branch information
yairm210 committed Nov 3, 2024
1 parent ab15058 commit 8a0e8bb
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions core/src/com/unciv/logic/automation/unit/CivilianUnitAutomation.kt
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,8 @@ object CivilianUnitAutomation {
}

// Great engineer -> Try to speed up wonder construction
if ((unit.hasUnique(UniqueType.CanSpeedupConstruction)
|| unit.hasUnique(UniqueType.CanSpeedupWonderConstruction))) {
if (unit.hasUnique(UniqueType.CanSpeedupConstruction)
|| unit.hasUnique(UniqueType.CanSpeedupWonderConstruction)) {
val wonderCanBeSpedUpEventually = SpecificUnitAutomation.speedupWonderConstruction(unit)
if (wonderCanBeSpedUpEventually)
return
Expand Down Expand Up @@ -139,6 +139,14 @@ object CivilianUnitAutomation {
// ages?

if (SpecificUnitAutomation.automateImprovementPlacer(unit)) return

val goldenAgeAction = UnitActions.getUnitActions(unit, UnitActionType.TriggerUnique)
.filter { it.action != null && it.associatedUnique?.type in listOf(UniqueType.OneTimeEnterGoldenAge,
UniqueType.OneTimeEnterGoldenAgeTurns) }.firstOrNull()
if (goldenAgeAction != null) {
goldenAgeAction.action?.invoke()
return
}

return // The AI doesn't know how to handle unknown civilian units
}
Expand Down

0 comments on commit 8a0e8bb

Please sign in to comment.