diff options
author | joffrey-bion <joffrey.bion@gmail.com> | 2020-12-13 01:08:31 +0100 |
---|---|---|
committer | joffrey-bion <joffrey.bion@gmail.com> | 2020-12-13 01:09:31 +0100 |
commit | c5ab4aff9f70d7bd12e00d9b54faf14e9e4658da (patch) | |
tree | f97bf9d16b4c385fb994db1bd730f05a7780b387 /sw-bot/src/main/kotlin | |
parent | Improve synchronization in GameController (diff) | |
download | seven-wonders-c5ab4aff9f70d7bd12e00d9b54faf14e9e4658da.tar.gz seven-wonders-c5ab4aff9f70d7bd12e00d9b54faf14e9e4658da.tar.bz2 seven-wonders-c5ab4aff9f70d7bd12e00d9b54faf14e9e4658da.zip |
Add logging of BOT status
Related:
https://github.com/joffrey-bion/seven-wonders/issues/71
Diffstat (limited to 'sw-bot/src/main/kotlin')
-rw-r--r-- | sw-bot/src/main/kotlin/org/luxons/sevenwonders/bot/SevenWondersBot.kt | 7 |
1 files changed, 6 insertions, 1 deletions
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) } } |