Enha: leave one room model for now
This commit is contained in:
@ -5,7 +5,7 @@ import (
|
|||||||
"golias/models"
|
"golias/models"
|
||||||
)
|
)
|
||||||
|
|
||||||
func createRoom(ctx context.Context, req *models.RoomReq) (*models.RoomPublic, error) {
|
func createRoom(ctx context.Context, req *models.RoomReq) (*models.Room, error) {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,11 +26,16 @@ func init() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var roundWords = map[string]string{
|
var roundWords = map[string]string{
|
||||||
"hamster": "blue",
|
"hamster": "blue",
|
||||||
"child": "red",
|
"child": "red",
|
||||||
"wheel": "white",
|
"wheel": "white",
|
||||||
"condition": "black",
|
"condition": "black",
|
||||||
"test": "white",
|
"test": "white",
|
||||||
|
"ball": "blue",
|
||||||
|
"violin": "red",
|
||||||
|
"rat": "white",
|
||||||
|
"perplexity": "blue",
|
||||||
|
"notion": "red",
|
||||||
}
|
}
|
||||||
|
|
||||||
func HandlePing(w http.ResponseWriter, r *http.Request) {
|
func HandlePing(w http.ResponseWriter, r *http.Request) {
|
||||||
|
@ -43,6 +43,9 @@ type Room struct {
|
|||||||
Cards []WordCard
|
Cards []WordCard
|
||||||
GameSettings *GameSettings `json:"settings"`
|
GameSettings *GameSettings `json:"settings"`
|
||||||
Result uint8 // 0 for unknown; 1 is win for red; 2 if for blue;
|
Result uint8 // 0 for unknown; 1 is win for red; 2 if for blue;
|
||||||
|
BlueCounter uint8
|
||||||
|
RedCounter uint8
|
||||||
|
RedTurn bool // false is blue turn
|
||||||
}
|
}
|
||||||
|
|
||||||
type WordCard struct {
|
type WordCard struct {
|
||||||
@ -51,34 +54,6 @@ type WordCard struct {
|
|||||||
Revealed bool
|
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
|
|
||||||
TeamTurn string
|
|
||||||
BlueMime string
|
|
||||||
RedGuessers []string
|
|
||||||
BlueGuessers []string
|
|
||||||
Cards []WordCard
|
|
||||||
}
|
|
||||||
|
|
||||||
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 {
|
type GameSettings struct {
|
||||||
IsRunning bool `json:"is_running"`
|
IsRunning bool `json:"is_running"`
|
||||||
Language string `json:"language" example:"en" form:"language"`
|
Language string `json:"language" example:"en" form:"language"`
|
||||||
|
@ -42,7 +42,7 @@ func StrToUserRole(s string) UserRole {
|
|||||||
|
|
||||||
type UserState struct {
|
type UserState struct {
|
||||||
Username string
|
Username string
|
||||||
Room RoomPublic
|
Room Room
|
||||||
Team UserTeam
|
Team UserTeam
|
||||||
Role UserRole
|
Role UserRole
|
||||||
}
|
}
|
||||||
@ -54,8 +54,13 @@ func MakeTestState() *UserState {
|
|||||||
{Word: "wheel", Color: "white"},
|
{Word: "wheel", Color: "white"},
|
||||||
{Word: "condition", Color: "black"},
|
{Word: "condition", Color: "black"},
|
||||||
{Word: "test", Color: "white"},
|
{Word: "test", Color: "white"},
|
||||||
|
{Word: "ball", Color: "blue"},
|
||||||
|
{Word: "violin", Color: "red"},
|
||||||
|
{Word: "rat", Color: "white"},
|
||||||
|
{Word: "perplexity", Color: "blue"},
|
||||||
|
{Word: "notion", Color: "red"},
|
||||||
}
|
}
|
||||||
room := RoomPublic{
|
room := Room{
|
||||||
ID: "test-id",
|
ID: "test-id",
|
||||||
CreatedAt: time.Now(),
|
CreatedAt: time.Now(),
|
||||||
CreatorName: "test-name",
|
CreatorName: "test-name",
|
||||||
|
Reference in New Issue
Block a user