70 lines
1.7 KiB
Go
70 lines
1.7 KiB
Go
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
|
|
}
|