chore: upgrade versions and rename folders

This commit is contained in:
2026-07-20 19:54:58 +02:00
parent 7fb488ab56
commit 78956ce84e
113 changed files with 471 additions and 470 deletions
@@ -0,0 +1,36 @@
package eventDemo.domain.command.action
import eventDemo.domain.command.CommandException
import eventDemo.domain.command.command.IamReadyToPlayCommand
import eventDemo.domain.event.event.PlayerReadyEvent
import eventDemo.domain.event.projection.GameStateRepository
/**
* A command to set as ready to play
*/
class IamReadyToPlay(
private val gameStateRepository: GameStateRepository,
) : CommandAction<IamReadyToPlayCommand, PlayerReadyEvent> {
@Throws(CommandException::class)
override fun run(command: IamReadyToPlayCommand): (version: Int) -> PlayerReadyEvent {
val state = gameStateRepository.get(command.payload.aggregateId)
val playerExist: Boolean = state.players.contains(command.payload.player)
val playerIsAlreadyReady: Boolean = state.readyPlayers.contains(command.payload.player)
if (state.isStarted) {
throw CommandException("The game is already started")
} else if (!playerExist) {
throw CommandException("You are not in the game")
} else if (playerIsAlreadyReady) {
throw CommandException("You are already ready")
} else {
return { version: Int ->
PlayerReadyEvent(
aggregateId = command.payload.aggregateId,
player = command.payload.player,
version = version,
)
}
}
}
}