aboutsummaryrefslogtreecommitdiffhomepage
path: root/backend/api/handlers.go
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2024-08-01 01:19:09 +0900
committernsfisis <nsfisis@gmail.com>2024-08-01 01:19:09 +0900
commit222ed4e77c3564c95450361fdeca40a733ce65c9 (patch)
treebe7fe2a9b1a66553f7cda5a462afef801b6cf438 /backend/api/handlers.go
parent5fc739292bdd65da2d33f1e9a4c2b1b33576fdf6 (diff)
parentf5b6c2f14d3521e9763ba7a356b8e87ebc6d7cd9 (diff)
downloadiosdc-japan-2024-albatross-222ed4e77c3564c95450361fdeca40a733ce65c9.tar.gz
iosdc-japan-2024-albatross-222ed4e77c3564c95450361fdeca40a733ce65c9.tar.zst
iosdc-japan-2024-albatross-222ed4e77c3564c95450361fdeca40a733ce65c9.zip
Merge branch 'feat/game-starting'
Diffstat (limited to 'backend/api/handlers.go')
-rw-r--r--backend/api/handlers.go16
1 files changed, 13 insertions, 3 deletions
diff --git a/backend/api/handlers.go b/backend/api/handlers.go
index cc16972..c96cd2a 100644
--- a/backend/api/handlers.go
+++ b/backend/api/handlers.go
@@ -18,12 +18,18 @@ import (
var _ StrictServerInterface = (*ApiHandler)(nil)
type ApiHandler struct {
- q *db.Queries
+ q *db.Queries
+ hubs GameHubsInterface
}
-func NewHandler(queries *db.Queries) *ApiHandler {
+type GameHubsInterface interface {
+ StartGame(gameID int) error
+}
+
+func NewHandler(queries *db.Queries, hubs GameHubsInterface) *ApiHandler {
return &ApiHandler{
- q: queries,
+ q: queries,
+ hubs: hubs,
}
}
@@ -145,6 +151,10 @@ func (h *ApiHandler) PutAdminGamesGameId(ctx context.Context, request PutAdminGa
var changedState string
if state != nil {
changedState = string(*state)
+ // TODO:
+ if changedState != game.State && changedState == "prepare" {
+ h.hubs.StartGame(int(gameID))
+ }
} else {
changedState = game.State
}