Enha: leave one room model for now
This commit is contained in:
@ -5,7 +5,7 @@ import (
|
||||
"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
|
||||
}
|
||||
|
||||
|
@ -26,11 +26,16 @@ func init() {
|
||||
}
|
||||
|
||||
var roundWords = map[string]string{
|
||||
"hamster": "blue",
|
||||
"child": "red",
|
||||
"wheel": "white",
|
||||
"condition": "black",
|
||||
"test": "white",
|
||||
"hamster": "blue",
|
||||
"child": "red",
|
||||
"wheel": "white",
|
||||
"condition": "black",
|
||||
"test": "white",
|
||||
"ball": "blue",
|
||||
"violin": "red",
|
||||
"rat": "white",
|
||||
"perplexity": "blue",
|
||||
"notion": "red",
|
||||
}
|
||||
|
||||
func HandlePing(w http.ResponseWriter, r *http.Request) {
|
||||
|
@ -43,6 +43,9 @@ type Room struct {
|
||||
Cards []WordCard
|
||||
GameSettings *GameSettings `json:"settings"`
|
||||
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 {
|
||||
@ -51,34 +54,6 @@ type WordCard struct {
|
||||
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 {
|
||||
IsRunning bool `json:"is_running"`
|
||||
Language string `json:"language" example:"en" form:"language"`
|
||||
|
@ -42,7 +42,7 @@ func StrToUserRole(s string) UserRole {
|
||||
|
||||
type UserState struct {
|
||||
Username string
|
||||
Room RoomPublic
|
||||
Room Room
|
||||
Team UserTeam
|
||||
Role UserRole
|
||||
}
|
||||
@ -54,8 +54,13 @@ func MakeTestState() *UserState {
|
||||
{Word: "wheel", Color: "white"},
|
||||
{Word: "condition", Color: "black"},
|
||||
{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",
|
||||
CreatedAt: time.Now(),
|
||||
CreatorName: "test-name",
|
||||
|
Reference in New Issue
Block a user