diff options
-rw-r--r-- | sw-bot/build.gradle.kts | 2 | ||||
-rw-r--r-- | sw-bot/src/main/kotlin/org/luxons/sevenwonders/bot/SevenWondersBot.kt | 7 |
2 files changed, 8 insertions, 1 deletions
diff --git a/sw-bot/build.gradle.kts b/sw-bot/build.gradle.kts index c4cd1eaa..64a03734 100644 --- a/sw-bot/build.gradle.kts +++ b/sw-bot/build.gradle.kts @@ -7,6 +7,8 @@ dependencies { implementation(kotlin("stdlib-jdk8")) implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.4.1") + implementation("org.slf4j:slf4j-api:1.7.30") + testImplementation(kotlin("test")) testImplementation(kotlin("test-junit")) } 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) } } |