mirror of
https://github.com/nolen777/eagle0.git
synced 2026-07-28 20:55:44 +00:00
Skip incomplete text query during battles (#8717)
This commit is contained in:
@@ -90,11 +90,10 @@ object GameController {
|
||||
val otherPlayersHaveCommands = otherFactionIds.exists { fid =>
|
||||
engine.getAvailablePlayerCommands(fid).nonEmpty
|
||||
}
|
||||
val hasIncompleteTexts = clientTextStore.hasIncompleteTextsAccessibleTo(factionId)
|
||||
|
||||
if hasOutstandingBattles then Some(ServerGameStatus(status = ServerGameStatus.Status.BATTLE_IN_PROGRESS))
|
||||
else if hasCommands then Some(ServerGameStatus(status = ServerGameStatus.Status.YOUR_TURN))
|
||||
else if hasIncompleteTexts then Some(ServerGameStatus(status = ServerGameStatus.Status.GENERATING_TEXT))
|
||||
else if clientTextStore.hasIncompleteTextsAccessibleTo(factionId) then
|
||||
Some(ServerGameStatus(status = ServerGameStatus.Status.GENERATING_TEXT))
|
||||
else if otherPlayersHaveCommands then Some(ServerGameStatus(status = ServerGameStatus.Status.WAITING_FOR_PLAYERS))
|
||||
else None
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import scala.collection.immutable.SortedMap
|
||||
|
||||
import net.eagle0.common.{RandomState, SeededRandom}
|
||||
import net.eagle0.eagle.ai.AIClient
|
||||
import net.eagle0.eagle.api.eagle.ServerGameStatus
|
||||
import net.eagle0.eagle.api.eagle.UpdateStreamRequest.StreamGameRequest.StreamingTextStatus
|
||||
import net.eagle0.eagle.api.selected_command.{AttackDecisionSelectedCommand, ReturnSelectedCommand}
|
||||
import net.eagle0.eagle.client_text.{ClientTextStore, ClientTextStoreWithUpdate, CompleteClientText}
|
||||
@@ -22,6 +23,7 @@ import net.eagle0.eagle.model.state.game_state.GameState
|
||||
import net.eagle0.eagle.model.state.hero.concrete.HeroC
|
||||
import net.eagle0.eagle.model.state.province.concrete.ProvinceC
|
||||
import net.eagle0.eagle.model.state.run_status.RunStatus
|
||||
import net.eagle0.eagle.model.state.shardok_battle.{BattleType, ShardokBattle}
|
||||
import net.eagle0.eagle.service.{FullGameHistory, InMemoryHistory, PostResults, SyncResponseObserver}
|
||||
import net.eagle0.eagle.UserId
|
||||
import org.scalamock.scalatest.MockFactory
|
||||
@@ -88,6 +90,32 @@ class GameControllerTest extends AnyFlatSpec with MockFactory with Matchers with
|
||||
.returning(false)
|
||||
.anyNumberOfTimes(): Unit
|
||||
|
||||
"computeServerGameStatus" should "not query incomplete texts while a battle is in progress" in {
|
||||
val factionId = 1
|
||||
val engine = mock[Engine]
|
||||
val textStore = mock[ClientTextStore]
|
||||
val battle = ShardokBattle(
|
||||
hexMapName = "test-map",
|
||||
players = Vector.empty,
|
||||
roundStarted = 0,
|
||||
defenderProvince = 1,
|
||||
eagleGameId = eagleGameId,
|
||||
shardokGameId = "test-battle",
|
||||
battleIndex = 0,
|
||||
battleType = BattleType.AssaultProvince
|
||||
)
|
||||
|
||||
engine.getAvailablePlayerCommands.expects(factionId).returning(SortedMap.empty): Unit
|
||||
(() => engine.currentState).expects().returning(testGameState.copy(outstandingBattles = Vector(battle))): Unit
|
||||
|
||||
GameController.computeServerGameStatus(
|
||||
engine = engine,
|
||||
factionId = factionId,
|
||||
otherFactionIds = Vector.empty,
|
||||
clientTextStore = textStore
|
||||
) shouldBe Some(ServerGameStatus(status = ServerGameStatus.Status.BATTLE_IN_PROGRESS))
|
||||
}
|
||||
|
||||
"postStreamingLlmFailure" should "reset visible clients before retrying the request" in {
|
||||
val requestId = "chronicle"
|
||||
val mockObserver = mock[SyncResponseObserver]
|
||||
|
||||
Reference in New Issue
Block a user