From c5ab4aff9f70d7bd12e00d9b54faf14e9e4658da Mon Sep 17 00:00:00 2001 From: joffrey-bion Date: Sun, 13 Dec 2020 01:08:31 +0100 Subject: Add logging of BOT status Related: https://github.com/joffrey-bion/seven-wonders/issues/71 --- .../src/main/kotlin/org/luxons/sevenwonders/bot/SevenWondersBot.kt | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'sw-bot/src/main/kotlin') diff --git a/sw-bot/src/main/kotlin/org/luxons/sevenwonders/bot/SevenWondersBot.kt b/sw-bot/src/main/kotlin/org/luxons/sevenwonders/bot/SevenWondersBot.kt index 6170acb8..d0331c15 100644 --- a/sw-bot/src/main/kotlin/org/luxons/sevenwonders/bot/SevenWondersBot.kt +++ b/sw-bot/src/main/kotlin/org/luxons/sevenwonders/bot/SevenWondersBot.kt @@ -13,6 +13,7 @@ import org.luxons.sevenwonders.model.PlayerMove import org.luxons.sevenwonders.model.PlayerTurnInfo import org.luxons.sevenwonders.model.api.actions.Icon import org.luxons.sevenwonders.model.resources.noTransactions +import org.slf4j.LoggerFactory import kotlin.random.Random import kotlin.time.Duration import kotlin.time.ExperimentalTime @@ -25,6 +26,8 @@ data class BotConfig( val globalTimeout: Duration = 10.hours, ) +private val logger = LoggerFactory.getLogger(SevenWondersBot::class.simpleName) + @OptIn(ExperimentalTime::class, ExperimentalCoroutinesApi::class) class SevenWondersBot( private val displayName: String, @@ -34,7 +37,7 @@ class SevenWondersBot( suspend fun play(serverUrl: String, gameId: Long) = withTimeout(botConfig.globalTimeout) { val session = client.connect(serverUrl) - session.chooseName(displayName, Icon("desktop")) + val player = session.chooseName(displayName, Icon("desktop")) val gameStartedEvents = session.watchGameStarted() session.joinGameAndWaitLobby(gameId) val firstTurn = gameStartedEvents.first() @@ -48,6 +51,8 @@ class SevenWondersBot( } .collect { turn -> botDelay() + val shortTurnDescription = "action ${turn.action}, ${turn.hand?.size ?: 0} cards in hand" + logger.info("BOT $player: playing turn ($shortTurnDescription)") session.playTurn(turn) } } -- cgit