From 85a6b4c2915fbfb42978fd7d2e3f7bd67e650314 Mon Sep 17 00:00:00 2001 From: Santo Cariotti Date: Sun, 27 Apr 2025 11:15:11 +0200 Subject: Co-op mode with next player randomly --- internal/api/database/models.go | 46 ++++++++++++++++++++++++----------------- 1 file changed, 27 insertions(+), 19 deletions(-) (limited to 'internal/api/database/models.go') diff --git a/internal/api/database/models.go b/internal/api/database/models.go index f065a8c..82a2649 100644 --- a/internal/api/database/models.go +++ b/internal/api/database/models.go @@ -17,24 +17,32 @@ const ( PairGameType GameType = "pair" ) +type MoveChooseType string + +const ( + SequentialChooseType MoveChooseType = "sequential" + RandomChooseType MoveChooseType = "random" +) + type Game struct { - ID int `json:"id"` - Type GameType `json:"type"` - Player1ID int `json:"-"` - Player1 User `gorm:"foreignKey:Player1ID" json:"player1"` - Player2ID *int `json:"-"` - Player2 *User `gorm:"foreignKey:Player2ID;null" json:"player2"` - Player3ID *int `json:"-"` - Player3 *User `gorm:"foreignKey:Player3ID;null" json:"player3"` - Player4ID *int `json:"-"` - Player4 *User `gorm:"foreignKey:Player4ID;null" json:"player4"` - Name string `json:"name"` - IP1 string `json:"ip1"` - IP2 string `json:"ip2"` - IP3 string `json:"ip3"` - IP4 string `json:"ip4"` - Outcome string `json:"outcome"` - LastPlayer int `json:"last_player"` // Last player entered in game - CreatedAt time.Time `json:"created_at"` - UpdatedAt time.Time `json:"updated_at"` + ID int `json:"id"` + Type GameType `json:"type"` + MoveChoose MoveChooseType `json:"move_choose_type"` + Player1ID int `json:"-"` + Player1 User `gorm:"foreignKey:Player1ID" json:"player1"` + Player2ID *int `json:"-"` + Player2 *User `gorm:"foreignKey:Player2ID;null" json:"player2"` + Player3ID *int `json:"-"` + Player3 *User `gorm:"foreignKey:Player3ID;null" json:"player3"` + Player4ID *int `json:"-"` + Player4 *User `gorm:"foreignKey:Player4ID;null" json:"player4"` + Name string `json:"name"` + IP1 string `json:"ip1"` + IP2 string `json:"ip2"` + IP3 string `json:"ip3"` + IP4 string `json:"ip4"` + Outcome string `json:"outcome"` + LastPlayer int `json:"last_player"` // Last player entered in game + CreatedAt time.Time `json:"created_at"` + UpdatedAt time.Time `json:"updated_at"` } -- cgit v1.2.3-18-g5258