mirror of
https://github.com/nolen777/eagle0.git
synced 2026-07-28 21:55:42 +00:00
Prioritize duel tutorial before melee (#8662)
This commit is contained in:
+1
-5
@@ -263,11 +263,7 @@ object TacticalTutorialDialogueSelector {
|
||||
)
|
||||
.map(command => Content.startFire(heroes.marek, command.actor))
|
||||
|
||||
val hasNonTarnDuel = duels.exists(command => targetUnit(command, snapshot).flatMap(heroId).exists(_ != heroes.tarn))
|
||||
val ordered =
|
||||
if hasNonTarnDuel then Vector(archery, duel, melee, charge, startFire)
|
||||
else Vector(archery, melee, charge, duel, startFire)
|
||||
ordered.flatten
|
||||
Vector(archery, duel, melee, charge, startFire).flatten
|
||||
}
|
||||
|
||||
private def applyResult(snapshot: Snapshot, result: ActionResultView): Snapshot =
|
||||
|
||||
@@ -74,6 +74,7 @@ scala_test(
|
||||
srcs = ["TacticalTutorialDialogueSelectorTest.scala"],
|
||||
deps = [
|
||||
"//src/main/protobuf/net/eagle0/shardok/api:action_result_view_scala_proto",
|
||||
"//src/main/protobuf/net/eagle0/shardok/api:command_descriptor_scala_proto",
|
||||
"//src/main/protobuf/net/eagle0/shardok/api:game_state_view_scala_proto",
|
||||
"//src/main/scala/net/eagle0/eagle/model/state:game_type",
|
||||
"//src/main/scala/net/eagle0/eagle/model/state:round_phase",
|
||||
|
||||
+31
@@ -7,9 +7,11 @@ import net.eagle0.eagle.model.state.hero.concrete.HeroC
|
||||
import net.eagle0.eagle.model.state.run_status.RunStatus
|
||||
import net.eagle0.eagle.model.view.action_result.TutorialFocus
|
||||
import net.eagle0.shardok.api.action_result_view.ActionResultView
|
||||
import net.eagle0.shardok.api.command_descriptor.{AvailableCommands, CommandDescriptor}
|
||||
import net.eagle0.shardok.api.game_state_view.GameStateViewDiff
|
||||
import net.eagle0.shardok.api.unit_view.{BattalionView, HeroView, UnitView}
|
||||
import net.eagle0.shardok.common.action_type.ActionType
|
||||
import net.eagle0.shardok.common.command_type.CommandType
|
||||
import net.eagle0.shardok.common.hostility.Hostility
|
||||
import net.eagle0.util.hero_generation.LoadedHero
|
||||
import org.scalatest.flatspec.AnyFlatSpec
|
||||
@@ -18,6 +20,7 @@ import org.scalatest.matchers.should.Matchers
|
||||
class TacticalTutorialDialogueSelectorTest extends AnyFlatSpec with Matchers {
|
||||
private val MarekId = 10
|
||||
private val SadarId = 11
|
||||
private val TarnId = 15
|
||||
|
||||
private val gameState = {
|
||||
val heroNames = Vector(
|
||||
@@ -174,6 +177,34 @@ class TacticalTutorialDialogueSelectorTest extends AnyFlatSpec with Matchers {
|
||||
dialogue.steps.head.dialogueTextId.shouldBe("tutorial_duel_lost_dialogue")
|
||||
}
|
||||
|
||||
it should "recommend the duel tutorial before melee when both are available" in {
|
||||
val initial = ActionResultView(
|
||||
gameStateViewDiff = Some(
|
||||
GameStateViewDiff(changedUnits = Vector(unit(101, SadarId, 100), unit(102, TarnId, 100)))
|
||||
)
|
||||
)
|
||||
val availableCommands = AvailableCommands(
|
||||
currentCommand = Vector(
|
||||
CommandDescriptor(
|
||||
`type` = CommandType.MELEE_COMMAND,
|
||||
actor = Some(101),
|
||||
targetUnit = Some(102)
|
||||
),
|
||||
CommandDescriptor(
|
||||
`type` = CommandType.CHALLENGE_DUEL_COMMAND,
|
||||
actor = Some(101),
|
||||
targetUnit = Some(102)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
val dialogueIds = TacticalTutorialDialogueSelector
|
||||
.candidates(gameState, Vector(initial), newResultViewCount = 1, availableCommands = Some(availableCommands))
|
||||
.map(_.id)
|
||||
|
||||
dialogueIds.indexOf("tutorial_duel") should be < dialogueIds.indexOf("tutorial_melee")
|
||||
}
|
||||
|
||||
it should "name the newly warned tutorial heroes before ending the turn" in {
|
||||
val cases = Vector(
|
||||
Vector(13) -> ("tutorial_end_turn_unused_elena", "tutorial_end_turn_unused_elena_dialogue"),
|
||||
|
||||
Reference in New Issue
Block a user