Add Comments

This commit is contained in:
2025-03-03 21:08:21 +01:00
parent ae5c229e4b
commit de3d4a1021
18 changed files with 111 additions and 12 deletions

View File

@@ -31,6 +31,9 @@ class GameRoute(
)
}
/**
* API route to send a request to play card.
*/
fun Routing.playNewCard() {
val commandStream by inject<GameCommandStream>()

View File

@@ -7,6 +7,9 @@ import eventDemo.shared.entity.Game
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
/**
* A command to perform an action to play a new card
*/
@Serializable
@SerialName("PlayCard")
data class PlayCardCommand(

View File

@@ -9,13 +9,17 @@ import kotlinx.coroutines.launch
/**
* Listen [PlayCardCommand] on [GameCommandStream], check the validity and execute the action.
*
* This action produces a new [CardIsPlayedEvent]
*/
class PlayCardCommandHandler(
private val commandStream: GameCommandStream,
private val eventStream: GameEventStream,
) {
operator fun invoke() {
/**
* Init the handler
*/
fun init() {
CoroutineScope(Dispatchers.IO).launch {
commandStream.process {
// TODO check the command can be executed

View File

@@ -27,6 +27,9 @@ class Game(
)
}
/**
* API route to read the last card played.
*/
fun Routing.readLastPlayedCard() {
val eventStream by inject<GameEventStream>()