From 7c2371766b940742f3986d7904d4c20a4127ea70 Mon Sep 17 00:00:00 2001 From: joffrey-bion Date: Wed, 3 Feb 2021 02:37:38 +0100 Subject: Add auto-game with bots only Resolves: https://github.com/joffrey-bion/seven-wonders/issues/82 --- .../org/luxons/sevenwonders/model/api/AutoGame.kt | 27 ++++++++++++++++++++++ .../org/luxons/sevenwonders/model/api/Player.kt | 4 +++- .../sevenwonders/model/api/actions/Actions.kt | 10 ++++++++ 3 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 sw-common-model/src/commonMain/kotlin/org/luxons/sevenwonders/model/api/AutoGame.kt (limited to 'sw-common-model/src/commonMain/kotlin/org') diff --git a/sw-common-model/src/commonMain/kotlin/org/luxons/sevenwonders/model/api/AutoGame.kt b/sw-common-model/src/commonMain/kotlin/org/luxons/sevenwonders/model/api/AutoGame.kt new file mode 100644 index 00000000..9822b303 --- /dev/null +++ b/sw-common-model/src/commonMain/kotlin/org/luxons/sevenwonders/model/api/AutoGame.kt @@ -0,0 +1,27 @@ +package org.luxons.sevenwonders.model.api + +import kotlinx.serialization.Serializable +import org.luxons.sevenwonders.model.Settings +import org.luxons.sevenwonders.model.TableState +import org.luxons.sevenwonders.model.api.actions.BotConfig +import org.luxons.sevenwonders.model.score.ScoreBoard +import org.luxons.sevenwonders.model.wonders.AssignedWonder +import kotlin.random.Random + +@Serializable +data class AutoGameAction( + val nbPlayers: Int = 3, + val gameName: String = "AutoGame-${Random.nextInt().toString(16)}", + val customSettings: Settings? = null, + val customWonders: List? = null, + /** + * The configuration of the bots that will play the game. + */ + val config: BotConfig = BotConfig(0, 0), +) + +@Serializable +data class AutoGameResult( + val scoreBoard: ScoreBoard, + val table: TableState, +) diff --git a/sw-common-model/src/commonMain/kotlin/org/luxons/sevenwonders/model/api/Player.kt b/sw-common-model/src/commonMain/kotlin/org/luxons/sevenwonders/model/api/Player.kt index 3963112a..8ed15f24 100644 --- a/sw-common-model/src/commonMain/kotlin/org/luxons/sevenwonders/model/api/Player.kt +++ b/sw-common-model/src/commonMain/kotlin/org/luxons/sevenwonders/model/api/Player.kt @@ -17,7 +17,9 @@ data class ConnectedPlayer( override val displayName: String, override val isHuman: Boolean, override val icon: Icon?, -) : BasicPlayerInfo +) : BasicPlayerInfo { + override fun toString(): String = "'$displayName' ($username)" +} @Serializable data class PlayerDTO( diff --git a/sw-common-model/src/commonMain/kotlin/org/luxons/sevenwonders/model/api/actions/Actions.kt b/sw-common-model/src/commonMain/kotlin/org/luxons/sevenwonders/model/api/actions/Actions.kt index b0be3ae0..8d352402 100644 --- a/sw-common-model/src/commonMain/kotlin/org/luxons/sevenwonders/model/api/actions/Actions.kt +++ b/sw-common-model/src/commonMain/kotlin/org/luxons/sevenwonders/model/api/actions/Actions.kt @@ -106,4 +106,14 @@ class AddBotAction( * The display name for the bot to add. */ val botDisplayName: String, + /** + * The configuration of the bot to add. + */ + val config: BotConfig = BotConfig(), +) + +@Serializable +data class BotConfig( + val minActionDelayMillis: Long = 50, + val maxActionDelayMillis: Long = 500, ) -- cgit