feat(game): add GameWritebackEventDto and update related services for game state management
Build & Test (NowChessSystems) TeamCity build failed
Build & Test (NowChessSystems) TeamCity build failed
This commit is contained in:
@@ -31,6 +31,7 @@ val quarkusPlatformArtifactId: String by project
|
||||
val quarkusPlatformVersion: String by project
|
||||
|
||||
dependencies {
|
||||
implementation(project(":modules:api"))
|
||||
|
||||
runtimeOnly("io.quarkus:quarkus-jdbc-h2")
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package de.nowchess.store.config
|
||||
|
||||
import de.nowchess.api.dto.{GameWritebackEventDto}
|
||||
import de.nowchess.store.domain.GameRecord
|
||||
import de.nowchess.store.redis.GameWritebackEventDto
|
||||
import io.quarkus.runtime.annotations.RegisterForReflection
|
||||
|
||||
@RegisterForReflection(
|
||||
|
||||
@@ -86,6 +86,9 @@ class GameRecord extends PanacheEntityBase:
|
||||
@Column
|
||||
var pendingDrawOffer: String = uninitialized
|
||||
|
||||
@Column
|
||||
var pendingTakebackOffer: String = uninitialized
|
||||
|
||||
// Game result
|
||||
@Column
|
||||
var result: String = uninitialized
|
||||
|
||||
@@ -1,26 +0,0 @@
|
||||
package de.nowchess.store.redis
|
||||
|
||||
case class GameWritebackEventDto(
|
||||
gameId: String,
|
||||
fen: String,
|
||||
pgn: String,
|
||||
moveCount: Int,
|
||||
whiteId: String,
|
||||
whiteName: String,
|
||||
blackId: String,
|
||||
blackName: String,
|
||||
mode: String,
|
||||
resigned: Boolean,
|
||||
limitSeconds: Option[Int],
|
||||
incrementSeconds: Option[Int],
|
||||
daysPerMove: Option[Int],
|
||||
whiteRemainingMs: Option[Long],
|
||||
blackRemainingMs: Option[Long],
|
||||
incrementMs: Option[Long],
|
||||
clockLastTickAt: Option[Long],
|
||||
clockMoveDeadline: Option[Long],
|
||||
clockActiveColor: Option[String],
|
||||
pendingDrawOffer: Option[String],
|
||||
result: Option[String] = None,
|
||||
terminationReason: Option[String] = None,
|
||||
)
|
||||
@@ -1,6 +1,7 @@
|
||||
package de.nowchess.store.redis
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper
|
||||
import de.nowchess.api.dto.GameWritebackEventDto
|
||||
import de.nowchess.store.service.GameWritebackService
|
||||
import io.quarkus.redis.datasource.RedisDataSource
|
||||
import jakarta.annotation.PostConstruct
|
||||
|
||||
+1
-1
@@ -25,7 +25,7 @@ class GameRecordRepository:
|
||||
|
||||
def findByPlayerId(playerId: String, offset: Int, limit: Int): List[GameRecord] =
|
||||
em.createQuery(
|
||||
"SELECT g FROM GameRecord g WHERE g.whiteId = :id OR g.blackId = :id ORDER BY g.updatedAt DESC",
|
||||
"SELECT g FROM GameRecord g WHERE g.whiteId = :id OR g.blackId = :id AND g.result != null ORDER BY g.updatedAt DESC",
|
||||
classOf[GameRecord],
|
||||
).setParameter("id", playerId)
|
||||
.setFirstResult(offset)
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
package de.nowchess.store.service
|
||||
|
||||
import de.nowchess.api.dto.GameWritebackEventDto
|
||||
import de.nowchess.store.domain.GameRecord
|
||||
import de.nowchess.store.redis.GameWritebackEventDto
|
||||
import de.nowchess.store.repository.GameRecordRepository
|
||||
import jakarta.enterprise.context.ApplicationScoped
|
||||
import jakarta.inject.Inject
|
||||
import jakarta.transaction.Transactional
|
||||
|
||||
import scala.compiletime.uninitialized
|
||||
import java.time.Instant
|
||||
|
||||
@@ -66,6 +67,7 @@ class GameWritebackService:
|
||||
r.clockMoveDeadline = event.clockMoveDeadline.map(java.lang.Long.valueOf).orNull
|
||||
r.clockActiveColor = event.clockActiveColor.orNull
|
||||
r.pendingDrawOffer = event.pendingDrawOffer.orNull
|
||||
r.pendingTakebackOffer = event.pendingTakebackRequest.orNull
|
||||
r.result = event.result.orNull
|
||||
r.terminationReason = event.terminationReason.orNull
|
||||
r.updatedAt = Instant.now()
|
||||
|
||||
Reference in New Issue
Block a user