mirror of
https://github.com/nolen777/eagle0.git
synced 2026-07-28 20:55:44 +00:00
Require Rest for RestProvince quests (#8695)
* Require rest commands for RestProvince quests * Centralize Rest command selection
This commit is contained in:
+15
-4
@@ -23,15 +23,26 @@ object RestCommandSelector {
|
||||
restCommand = restCommand,
|
||||
reason = reason
|
||||
).getOrElse(
|
||||
CommandSelection(
|
||||
chosenRestWithoutFeastCommand(
|
||||
actingFactionId = actingFactionId,
|
||||
actingProvinceId = restCommand.actingProvinceId,
|
||||
available = restCommand,
|
||||
selected = RestSelected,
|
||||
restCommand = restCommand,
|
||||
reason = reason
|
||||
)
|
||||
)
|
||||
|
||||
def chosenRestWithoutFeastCommand(
|
||||
actingFactionId: FactionId,
|
||||
restCommand: RestAvailable,
|
||||
reason: String
|
||||
): CommandSelection =
|
||||
CommandSelection(
|
||||
actingFactionId = actingFactionId,
|
||||
actingProvinceId = restCommand.actingProvinceId,
|
||||
available = restCommand,
|
||||
selected = RestSelected,
|
||||
reason = reason
|
||||
)
|
||||
|
||||
private def preferredFeastInsteadOfRest(
|
||||
actingFactionId: FactionId,
|
||||
gameState: GameState,
|
||||
|
||||
+1
-3
@@ -25,10 +25,8 @@ object RestProvinceQuestCommandChooser extends DeterministicQuestCommandChooser
|
||||
availableCommands.collect { case ra: RestAvailable => ra }
|
||||
.find(ra => targetProvinceIds.contains(ra.actingProvinceId))
|
||||
.map { restAvailable =>
|
||||
RestCommandSelector.chosenRestOrPreferredFeastCommand(
|
||||
RestCommandSelector.chosenRestWithoutFeastCommand(
|
||||
actingFactionId = actingFactionId,
|
||||
gameState = gameState,
|
||||
availableCommands = availableCommands,
|
||||
restCommand = restAvailable,
|
||||
reason = "fulfill RestProvince quest"
|
||||
)
|
||||
|
||||
+5
-5
@@ -4,7 +4,7 @@ import net.eagle0.eagle.{FactionId, HeroId, ProvinceId}
|
||||
import net.eagle0.eagle.library.settings.{DesiredLoyaltyOverThreshold, LoyaltyThreshold}
|
||||
import net.eagle0.eagle.model.state.{GameType, RoundPhase}
|
||||
import net.eagle0.eagle.model.state.command.available.AvailableCommand.{FeastAvailable, RestAvailable}
|
||||
import net.eagle0.eagle.model.state.command.selected.SelectedCommand.{FeastSelected, RestSelected}
|
||||
import net.eagle0.eagle.model.state.command.selected.SelectedCommand.RestSelected
|
||||
import net.eagle0.eagle.model.state.date.Date
|
||||
import net.eagle0.eagle.model.state.date.Date.Month.June
|
||||
import net.eagle0.eagle.model.state.faction.concrete.FactionC
|
||||
@@ -112,7 +112,7 @@ class RestProvinceQuestCommandChooserTest extends AnyFlatSpec with Matchers {
|
||||
selectedCommand.map(_.reason).shouldBe(Some("fulfill RestProvince quest"))
|
||||
}
|
||||
|
||||
it should "prefer feast when it is better than resting for a RestProvince quest" in {
|
||||
it should "rest even when a feast would otherwise be preferred" in {
|
||||
LoyaltyThreshold.setDoubleValue(40)
|
||||
DesiredLoyaltyOverThreshold.setDoubleValue(30)
|
||||
|
||||
@@ -124,8 +124,8 @@ class RestProvinceQuestCommandChooserTest extends AnyFlatSpec with Matchers {
|
||||
uhsWithQuests = Vector(questHeroWithRestQuest)
|
||||
)
|
||||
|
||||
selectedCommand.map(_.selected).shouldBe(Some(FeastSelected))
|
||||
selectedCommand.map(_.available).shouldBe(Some(feastCommand))
|
||||
selectedCommand.map(_.reason).shouldBe(Some("fulfill RestProvince quest: feast instead of rest"))
|
||||
selectedCommand.map(_.selected).shouldBe(Some(RestSelected))
|
||||
selectedCommand.map(_.available).shouldBe(Some(restCommand))
|
||||
selectedCommand.map(_.reason).shouldBe(Some("fulfill RestProvince quest"))
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user