Compare commits

..

14 Commits

13 changed files with 102 additions and 36 deletions

View File

@@ -297,3 +297,38 @@
### Features
* Add logging to Gateway for pod synchronization and startup events ([2615707](https://git.janis-eccarius.de/KnockOutWhist/KnockOutWhist-Web/commit/26157076d686a5dd3f8157ec2b2d1ae9d9e9eedf))
## (2026-01-07)
### Features
* Add Health and Login endpoints with updated Redis configuration ([4a5af36](https://git.janis-eccarius.de/KnockOutWhist/KnockOutWhist-Web/commit/4a5af36ae0dcb540e02b7a1cd042e54cc6342c78))
## (2026-01-07)
### Features
* Update Gateway to use ArrayList for game IDs and bound users ([2f89951](https://git.janis-eccarius.de/KnockOutWhist/KnockOutWhist-Web/commit/2f89951c25484d6bc412536a83019ee6d0b7f780))
## (2026-01-07)
### Features
* Update joinGame endpoint to accept gameId as a path parameter ([cf18549](https://git.janis-eccarius.de/KnockOutWhist/KnockOutWhist-Web/commit/cf1854976a51eb4931d50cf93640498ed18686fc))
## (2026-01-07)
### Features
* Enhance user state management with polling and WebSocket connection handling ([b4bf2ce](https://git.janis-eccarius.de/KnockOutWhist/KnockOutWhist-Web/commit/b4bf2ceb4dc76ac388124b9705a1aa9e577582af))
### Bug Fixes
* Update knockoutwhistfrontend hash for consistency ([0e555cd](https://git.janis-eccarius.de/KnockOutWhist/KnockOutWhist-Web/commit/0e555cdfeb114464c9438bfd5dc397201a073867))
## (2026-01-07)
### Features
* Implement PlayDogCard functionality in user session and update Vue component ([859dfce](https://git.janis-eccarius.de/KnockOutWhist/KnockOutWhist-Web/commit/859dfce521b193b9208d0c70fca88016f8fe08f4))
* Implement PlayDogCard functionality in user session and update Vue component ([61ae9b5](https://git.janis-eccarius.de/KnockOutWhist/KnockOutWhist-Web/commit/61ae9b5a5e7cd9fd82b77e9159814b0066874c2d))
## (2026-01-13)
### Features
* **ui:** Tie selection ([#111](https://git.janis-eccarius.de/KnockOutWhist/KnockOutWhist-Web/issues/111)) ([dc3da9a](https://git.janis-eccarius.de/KnockOutWhist/KnockOutWhist-Web/commit/dc3da9a75c75597ce81ce4d023af5390197012c9))

View File

@@ -1,6 +1,6 @@
meta {
name: Game
seq: 3
seq: 2
}
auth {

View File

@@ -0,0 +1,16 @@
meta {
name: Health
type: http
seq: 3
}
get {
url: {{host}}/health/simple
body: none
auth: inherit
}
settings {
encodeUrl: true
timeout: 0
}

View File

@@ -0,0 +1,3 @@
vars {
host: https://st.knockout.janis-eccarius.de/api
}

View File

@@ -55,13 +55,8 @@ class MainMenuController @Inject()(
}
def joinGame(): Action[AnyContent] = authAction { implicit request: AuthenticatedRequest[AnyContent] =>
val jsonBody = request.body.asJson
val gameId: Option[String] = jsonBody.flatMap { jsValue =>
(jsValue \ "gameId").asOpt[String]
}
if (gameId.isDefined) {
val game = PodManager.getGame(gameId.get)
def joinGame(gameId: String): Action[AnyContent] = authAction { implicit request: AuthenticatedRequest[AnyContent] =>
val game = PodManager.getGame(gameId)
game match {
case Some(g) =>
g.addUser(request.user)
@@ -76,12 +71,6 @@ class MainMenuController @Inject()(
"errorMessage" -> "No Game found"
))
}
} else {
BadRequest(Json.obj(
"status" -> "failure",
"errorMessage" -> "Invalid form submission"
))
}
}
def rules(): Action[AnyContent] = authAction { implicit request: AuthenticatedRequest[AnyContent] =>

View File

@@ -34,6 +34,7 @@ class StatusController @Inject()(
Json.obj(
"status" -> "authenticated",
"username" -> user.name,
"userId" -> user.id,
"inGame" -> false
)
)
@@ -43,6 +44,7 @@ class StatusController @Inject()(
Json.obj(
"status" -> "authenticated",
"username" -> user.name,
"userId" -> user.id,
"inGame" -> true,
"gameId" -> game.id
)

View File

@@ -7,6 +7,7 @@ import org.redisson.config.Config
import play.api.Logger
import play.api.inject.ApplicationLifecycle
import java.util
import java.util.UUID
import javax.inject.*
import scala.concurrent.ExecutionContext
@@ -22,14 +23,14 @@ class Gateway @Inject()(
val redis: RedisManager = {
val config: Config = Config()
val url = "valkey://" + sys.env.getOrElse("VALKEY_HOST", "localhost") + ":" + sys.env.getOrElse("VALKEY_PORT", "6379")
logger.info(s"Connecting to Valkey at $url")
val url = "redis://" + sys.env.getOrElse("REDIS_HOST", "localhost") + ":" + sys.env.getOrElse("REDIS_PORT", "6379")
logger.info(s"Connecting to Redis at $url")
config.useSingleServer.setAddress(url)
RedisManager(config)
}
redis.continuousSyncPod(() => {
logger.info("Syncing pod with Valkey")
logger.info("Syncing pod with Redis")
createPod()
})
@@ -45,8 +46,8 @@ class Gateway @Inject()(
PodManager.podName,
PodManager.podIp,
9000,
PodManager.getAllGameIds().asJava,
PodManager.allBoundUsers().asJava
new util.ArrayList[String](PodManager.getAllGameIds().asJava),
new util.ArrayList[String](PodManager.allBoundUsers().asJava)
)
}

View File

@@ -54,6 +54,16 @@ class UserSession(val user: User, val host: Boolean, val gameLobby: GameLobby) e
case None =>
println("Card Index not found or is not a number." + data)
}
case "PlayDogCard" =>
val maybeCardIndex: Option[Int] = (data \ "cardindex").asOpt[Int]
maybeCardIndex match {
case Some(index) =>
val session = gameLobby.getUserSession(user.id)
gameLobby.playDogCard(session, index)
case None =>
val session = gameLobby.getUserSession(user.id)
gameLobby.playDogCard(session, -1)
}
case "PickTrumpsuit" =>
val maybeSuitIndex: Option[Int] = (data \ "suitIndex").asOpt[Int]
maybeSuitIndex match {
@@ -63,6 +73,15 @@ class UserSession(val user: User, val host: Boolean, val gameLobby: GameLobby) e
case None =>
println("Card Index not found or is not a number.")
}
case "PickTie" =>
val maybeCardIndex: Option[Int] = (data \ "cardIndex").asOpt[Int]
maybeCardIndex match {
case Some(index) =>
val session = gameLobby.getUserSession(user.id)
gameLobby.selectTie(session, index)
case None =>
println("Card Index not found or is not a number.")
}
case "KickPlayer" =>
val maybePlayerId: Option[String] = (data \ "playerId").asOpt[String]
maybePlayerId match {

View File

@@ -36,7 +36,7 @@ object WebsocketEventMapper {
// Register all custom mappers here
registerCustomMapper(ReceivedHandEventMapper)
registerCustomMapper(GameStateEventMapper)
//registerCustomMapper(GameStateEventMapper)
registerCustomMapper(CardPlayedEventMapper)
registerCustomMapper(NewRoundEventMapper)
registerCustomMapper(NewTrickEventMapper)
@@ -54,6 +54,7 @@ object WebsocketEventMapper {
}else {
None
}
//println(s"This is getting sent to client: EVENT: ${obj.id}, STATE: ${session.gameLobby.getLogic.getCurrentState.toString}, STATEDATA: ${stateToJson(session)}, DATA: ${data}")
Json.obj(
"id" -> ("request-" + java.util.UUID.randomUUID().toString),
"event" -> obj.id,

View File

@@ -15,7 +15,7 @@ GET /rules controllers.MainMenuController.rules()
GET /navSPA/:pType controllers.MainMenuController.navSPA(pType)
POST /createGame controllers.MainMenuController.createGame()
POST /joinGame controllers.MainMenuController.joinGame()
POST /joinGame/:gameId controllers.MainMenuController.joinGame(gameId: String)
# User authentication routes
POST /login controllers.UserController.login_Post()

View File

@@ -1,3 +1,3 @@
MAJOR=4
MINOR=22
MINOR=28
PATCH=0