Feat: add models/cache/config
This commit is contained in:
69
models/main.go
Normal file
69
models/main.go
Normal file
@ -0,0 +1,69 @@
|
||||
package models
|
||||
|
||||
import "time"
|
||||
|
||||
type WordColor string
|
||||
|
||||
const (
|
||||
WordColorWhite = "white"
|
||||
WordColorBlue = "blue"
|
||||
WordColorRed = "red"
|
||||
WordColorBlack = "black"
|
||||
)
|
||||
|
||||
type Room struct {
|
||||
ID string `json:"id" db:"id"`
|
||||
CreatedAt time.Time `json:"created_at" db:"created_at"`
|
||||
RoomName string `json:"room_name"`
|
||||
RoomPass string `json:"room_pass"`
|
||||
RoomLink string
|
||||
CreatorName string `json:"creator_name"`
|
||||
PlayerList []string `json:"player_list"`
|
||||
RedMime string
|
||||
BlueMime string
|
||||
RedGuessers []string
|
||||
BlueGuessers []string
|
||||
Cards []WordCard
|
||||
GameSettings *GameSettings `json:"settings"`
|
||||
Result uint8 // 0 for unknown; 1 is win for red; 2 if for blue;
|
||||
}
|
||||
|
||||
type WordCard struct {
|
||||
Word string
|
||||
Color WordColor
|
||||
Revealed bool
|
||||
}
|
||||
|
||||
type RoomPublic struct {
|
||||
ID string `json:"id" db:"id"`
|
||||
CreatedAt time.Time `json:"created_at" db:"created_at"`
|
||||
PlayerList []string `json:"player_list"`
|
||||
CreatorName string `json:"creator_name"`
|
||||
GameSettings *GameSettings `json:"settings"`
|
||||
RedMime string
|
||||
BlueMime string
|
||||
RedGuessers []string
|
||||
BlueGuessers []string
|
||||
}
|
||||
|
||||
func (r Room) ToPublic() RoomPublic {
|
||||
return RoomPublic{
|
||||
ID: r.ID,
|
||||
CreatedAt: r.CreatedAt,
|
||||
PlayerList: r.PlayerList,
|
||||
GameSettings: r.GameSettings,
|
||||
CreatorName: r.CreatorName,
|
||||
RedMime: r.RedMime,
|
||||
BlueMime: r.BlueMime,
|
||||
RedGuessers: r.RedGuessers,
|
||||
BlueGuessers: r.BlueGuessers,
|
||||
}
|
||||
}
|
||||
|
||||
type GameSettings struct {
|
||||
IsRunning bool `json:"is_running"`
|
||||
Language string `json:"language" example:"en" form:"language"`
|
||||
RoundTime int32 `json:"round_time"`
|
||||
ProgressPct uint32 `json:"progress_pct"`
|
||||
IsOver bool
|
||||
}
|
Reference in New Issue
Block a user