Skip to content

Commit

Permalink
feat: Add bot test mode
Browse files Browse the repository at this point in the history
Currently only allow you to select specific
Trung cards for the Bots.
In future, I may add selecting Bot die rolls, etc.
  • Loading branch information
sellmerfud committed Feb 20, 2024
1 parent eb7f8d1 commit d5a926e
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 12 deletions.
46 changes: 34 additions & 12 deletions src/main/scala/fitl/FireInTheLake.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2125,6 +2125,7 @@ object FireInTheLake {
gameOver: Boolean = false,
peaceTalks: Boolean = false,
botDebug: Boolean = false,
botTest: Boolean = false,
logTrung: Boolean = true, // Log Trung decisions
botIntents: BotIntents = BotIntentsVerbose,
history: Vector[GameSegment] = Vector.empty,
Expand Down Expand Up @@ -4133,19 +4134,31 @@ object FireInTheLake {
// The game state is updated and the topmost card
// is returned.
def drawTrungCard(faction: Faction): TrungCard = {
var trungDeck = game.trungDeck

// First the topmost card is place on the bottom
// Then continue drawing until we get a card for the
// given faction.
do {
trungDeck = trungDeck.tail :+ trungDeck.head
} while (trungDeck.head.faction != faction)

game = game.copy(trungDeck = trungDeck)
trungDeck.head
// In bot test mode prompt the user for the Trung card
if (game.botTest) {
val candidates = (game.trungDeck
.filter(_.faction == faction)
.sortBy(_.id))

val choices = candidates.map(c => (c, c.toString))
askMenu(choices, "\nChoose Trung card:", allowAbort = false).head
}
else {
var trungDeck = game.trungDeck

// First the topmost card is place on the bottom
// Then continue drawing until we get a card for the
// given faction.
do {
trungDeck = trungDeck.tail :+ trungDeck.head
} while (trungDeck.head.faction != faction)

game = game.copy(trungDeck = trungDeck)
trungDeck.head
}
}


def factionPasses(faction: Faction): Unit = {
log(s"\n$faction faction passes")
log(separator())
Expand Down Expand Up @@ -5987,7 +6000,7 @@ object FireInTheLake {
val options = (
List("resources", "aid", "patronage", "econ", "trail", "uspolicy", "casualties",
"on deck card", "out of play", "capabilities", "momentum", "rvnLeaders", "pivotal",
"eligibility", "trung deck", "bot log", "trung log", "human win", "bot intents") ::: agitate
"eligibility", "trung deck", "bot log", "bot test", "trung log", "human win", "bot intents") ::: agitate
).sorted ::: SpaceNames

val choice = askOneOf("[Adjust] (? for list): ", options, param, allowNone = true, allowAbort = false)
Expand All @@ -6009,6 +6022,7 @@ object FireInTheLake {
case "eligibility" => adjustEligibility()
case "trung" => adjustTrungDeck()
case "bot log" => adjustBotDebug()
case "bot test" => adjustBotTest()
case "trung log" => adjustLogTrung()
case "human win" => adjustHumanWinInVictoryPhase()
case "bot intents" => adjustBotIntentDisplay()
Expand Down Expand Up @@ -6568,6 +6582,14 @@ object FireInTheLake {
saveGameState("Bot Debug Logging")
}

def adjustBotTest(): Unit = {
val newValue = !game.botTest
val desc = adjustmentDesc("Bot Test mode", game.botTest, newValue)
game = game.copy(botTest = newValue)
log(desc)
saveGameState("Bot Test mode")
}

// Whether or not to log dice rolls in Trung decisions
def adjustLogTrung(): Unit = {
val newValue = !game.logTrung
Expand Down
2 changes: 2 additions & 0 deletions src/main/scala/fitl/SavedGame.scala
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,7 @@ object SavedGame {
"gameOver" -> gameState.gameOver,
"peaceTalks" -> gameState.peaceTalks,
"botDebug" -> gameState.botDebug,
"botTest" -> gameState.botTest,
"logTrung" -> gameState.logTrung,
"botIntents" -> gameState.botIntents.toString,
"history" -> (gameState.history map gameSegmentToMap)
Expand Down Expand Up @@ -288,6 +289,7 @@ object SavedGame {
asBoolean(data("gameOver")),
asBoolean(data("peaceTalks")),
asBoolean(data("botDebug")),
asBoolean(data.get("botTest") getOrElse false),
asBoolean(data.get("logTrung") getOrElse true),
BotIntents(asString(data.get("botIntents") getOrElse BotIntentsVerbose.toString)),
(asList(data("history")) map (s => gameSegmentFromMap(asMap(s)))).toVector
Expand Down

0 comments on commit d5a926e

Please sign in to comment.