summaryrefslogtreecommitdiff
path: root/sw-common-model
diff options
context:
space:
mode:
authorJoffrey Bion <joffrey.bion@gmail.com>2021-03-08 01:31:26 +0100
committerJoffrey Bion <joffrey.bion@gmail.com>2021-03-08 01:31:59 +0100
commit3f8a672dcfefdd9304ba8b489865cb12153a75e3 (patch)
tree3b5e091d37b9f821e189ec26791db7a4eec177b4 /sw-common-model
parentMake SayReady action an object (diff)
downloadseven-wonders-3f8a672dcfefdd9304ba8b489865cb12153a75e3.tar.gz
seven-wonders-3f8a672dcfefdd9304ba8b489865cb12153a75e3.tar.bz2
seven-wonders-3f8a672dcfefdd9304ba8b489865cb12153a75e3.zip
Make turnInfo generic in its action type
Diffstat (limited to 'sw-common-model')
-rw-r--r--sw-common-model/src/commonMain/kotlin/org/luxons/sevenwonders/model/PlayerState.kt12
1 files changed, 9 insertions, 3 deletions
diff --git a/sw-common-model/src/commonMain/kotlin/org/luxons/sevenwonders/model/PlayerState.kt b/sw-common-model/src/commonMain/kotlin/org/luxons/sevenwonders/model/PlayerState.kt
index 1e483a56..db0a2eb6 100644
--- a/sw-common-model/src/commonMain/kotlin/org/luxons/sevenwonders/model/PlayerState.kt
+++ b/sw-common-model/src/commonMain/kotlin/org/luxons/sevenwonders/model/PlayerState.kt
@@ -4,14 +4,20 @@ import kotlinx.serialization.Serializable
import org.luxons.sevenwonders.model.wonders.WonderBuildability
@Serializable
-data class PlayerTurnInfo(
+data class PlayerTurnInfo<out A : TurnAction>(
val playerIndex: Int,
val table: TableState,
- val action: TurnAction,
+ val action: A,
) {
val currentAge: Int = table.currentAge
val wonderBuildability: WonderBuildability = table.boards[playerIndex].wonder.buildability
}
// TODO move to server code
-fun Collection<PlayerTurnInfo>.hideHandsAndWaitForReadiness() = map { it.copy(action = TurnAction.SayReady) }
+fun Collection<PlayerTurnInfo<*>>.hideHandsAndWaitForReadiness() = map {
+ PlayerTurnInfo(
+ playerIndex = it.playerIndex,
+ table = it.table,
+ action = TurnAction.SayReady,
+ )
+}
bgstack15