Avoid resting in safe shallow provinces (#8694)

This commit is contained in:
2026-07-18 05:24:42 -07:00
committed by GitHub
parent 62fd16cec5
commit 3ad7c3e567
2 changed files with 22 additions and 8 deletions
@@ -563,7 +563,7 @@ object CommandChoiceHelpers {
val readyHeroCount = heroes.count(_.vigor >= DefenseReadyVigorForRest)
val allHeroesTired = tiredHeroCount == heroes.size
(readyHeroCount < FrontierReadyHeroesBeforeRest && tiredHeroCount >= 2) || allHeroesTired
} else heroes.exists(_.vigor < ShallowProvinceRestVigor)
} else false
}
end if
}
@@ -1079,20 +1079,17 @@ class CommandChoiceHelpersTest extends AnyFlatSpec with Matchers with BeforeAndA
.newValue shouldBe empty
}
it should "rest a shallow province when a hero is below the recovery threshold" in {
val chosen = CommandChoiceHelpers
it should "not rest a safe shallow province even when both heroes are tired" in {
CommandChoiceHelpers
.chosenUniversalCommand(
actingFactionId = 6,
gameState = universalRestGameState(
heroes = Vector(restedHero(1, vigor = 59), restedHero(2, vigor = 80))
heroes = Vector(restedHero(1, vigor = 40), restedHero(2, vigor = 40))
),
availableCommands = Vector(RestAvailable(actingProvinceId = 1)),
functionalRandom = functionalRandom
)
.newValue
.get
chosen.selected shouldBe RestSelected
.newValue shouldBe empty
}
it should "not rest a shallow province at the recovery threshold" in {
@@ -1108,6 +1105,23 @@ class CommandChoiceHelpersTest extends AnyFlatSpec with Matchers with BeforeAndA
.newValue shouldBe empty
}
it should "rest a hostile-border shallow province when defense readiness is at risk" in {
val chosen = CommandChoiceHelpers
.chosenUniversalCommand(
actingFactionId = 6,
gameState = universalRestGameState(
heroes = Vector(restedHero(1, vigor = 40), restedHero(2, vigor = 40)),
hasHostileNeighbor = true
),
availableCommands = Vector(RestAvailable(actingProvinceId = 1)),
functionalRandom = functionalRandom
)
.newValue
.get
chosen.selected shouldBe RestSelected
}
it should "not rest three mildly fatigued heroes in a safe province" in {
CommandChoiceHelpers
.chosenUniversalCommand(