mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-10 15:59:33 +07:00
Resolved #9249 - Solved AI Great Scientist crash
This commit is contained in:
@ -274,11 +274,13 @@ object UnitAutomation {
|
|||||||
|
|
||||||
val isLateGame = isLateGame(unit.civ)
|
val isLateGame = isLateGame(unit.civ)
|
||||||
// Great scientist -> Hurry research if late game
|
// Great scientist -> Hurry research if late game
|
||||||
if (UnitActions.getUnitActions(unit).any { it.type == UnitActionType.HurryResearch }
|
if (isLateGame) {
|
||||||
&& isLateGame) {
|
val hurryResearch = UnitActions.getUnitActions(unit)
|
||||||
UnitActions.getUnitActions(unit)
|
.firstOrNull { it.type == UnitActionType.HurryResearch }?.action
|
||||||
.first { it.type == UnitActionType.HurryResearch }.action!!.invoke()
|
if (hurryResearch != null) {
|
||||||
return
|
hurryResearch()
|
||||||
|
return
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Great merchant -> Conduct trade mission if late game and if not at war.
|
// Great merchant -> Conduct trade mission if late game and if not at war.
|
||||||
@ -286,8 +288,7 @@ object UnitAutomation {
|
|||||||
// also have more influence.
|
// also have more influence.
|
||||||
if (unit.hasUnique(UniqueType.CanTradeWithCityStateForGoldAndInfluence)
|
if (unit.hasUnique(UniqueType.CanTradeWithCityStateForGoldAndInfluence)
|
||||||
// Don't wander around with the great merchant when at war. Barbs might also be a
|
// Don't wander around with the great merchant when at war. Barbs might also be a
|
||||||
// problem, but hopefully by the time we have a great merchant, they're under
|
// problem, but hopefully by the time we have a great merchant, they're under control.
|
||||||
// control.
|
|
||||||
&& !unit.civ.isAtWar()
|
&& !unit.civ.isAtWar()
|
||||||
&& isLateGame
|
&& isLateGame
|
||||||
) {
|
) {
|
||||||
|
@ -18,6 +18,7 @@ data class UnitAction(
|
|||||||
val title: String = type.value,
|
val title: String = type.value,
|
||||||
val isCurrentAction: Boolean = false,
|
val isCurrentAction: Boolean = false,
|
||||||
val uncivSound: UncivSound = type.uncivSound,
|
val uncivSound: UncivSound = type.uncivSound,
|
||||||
|
/** Action is Null is this unit *can* execute the action but *not right now* - it's embarked, out of moves, etc */
|
||||||
val action: (() -> Unit)? = null
|
val action: (() -> Unit)? = null
|
||||||
) {
|
) {
|
||||||
fun getIcon(): Actor {
|
fun getIcon(): Actor {
|
||||||
|
Reference in New Issue
Block a user