diff --git a/components/room.html b/components/room.html index 696e429..0e20c35 100644 --- a/components/room.html +++ b/components/room.html @@ -1,6 +1,13 @@ {{define "room"}}
Hello {{.State.Username}};
+Room created by {{.Room.CreatorName}};
+Game is running: {{.Room.IsRunning}}
++ {{if eq .State.Username .Room.CreatorName}} + + {{end}} +
Turn of the {{.Room.TeamTurn}} team
{{if eq .State.Team ""}} diff --git a/handlers/auth.go b/handlers/auth.go index 0a3ac6d..bc4f2ae 100644 --- a/handlers/auth.go +++ b/handlers/auth.go @@ -72,7 +72,7 @@ func HandleFrontLogin(w http.ResponseWriter, r *http.Request) { abortWithError(w, err.Error()) return } - state := models.MakeTestState() + state := models.MakeTestState(cleanName) state.State.Username = cleanName // save state to cache // if err := saveState(cleanName, state.State); err != nil { diff --git a/models/main.go b/models/main.go index 8185330..4cae2e3 100644 --- a/models/main.go +++ b/models/main.go @@ -47,16 +47,17 @@ type Room struct { TeamTurn string RedTeam Team BlueTeam Team - // 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; - BlueCounter uint8 - RedCounter uint8 - RedTurn bool // false is blue turn + Cards []WordCard + Result uint8 // 0 for unknown; 1 is win for red; 2 if for blue; + BlueCounter uint8 + RedCounter uint8 + RedTurn bool // false is blue turn + // GameSettings *GameSettings `json:"settings"` + 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 } func (r *Room) ChangeTurn() { diff --git a/models/state.go b/models/state.go index f455675..4c4bc5c 100644 --- a/models/state.go +++ b/models/state.go @@ -47,7 +47,7 @@ type UserState struct { Role UserRole } -func MakeTestState() *FullInfo { +func MakeTestState(creatorName string) *FullInfo { cards := []WordCard{ {Word: "hamster", Color: "blue"}, {Word: "child", Color: "red"}, @@ -80,14 +80,14 @@ func MakeTestState() *FullInfo { room := &Room{ ID: "test-id", CreatedAt: time.Now(), - CreatorName: "test-name", + CreatorName: creatorName, Cards: cards, RedTeam: redTeam, BlueTeam: blueTeam, TeamTurn: "blue", } us := &UserState{ - Username: "test-name", + Username: creatorName, Team: UserTeamNone, Role: UserRoleNone, RoomID: "test-id", diff --git a/todos.md b/todos.md new file mode 100644 index 0000000..db60698 --- /dev/null +++ b/todos.md @@ -0,0 +1,20 @@ +### feats +- game state (running/not); +- start game: btn, endpoint; +- mime: clue + number; +- game log: what clues were given, who opened what cards; +- end game: who won. +- end game: two reasons (black word; all words); + +#### sse points +- clue sse update; +- join team; +- start game; +- end turn; +- open card; +- game over; +- timer per turn (when added); + + +### issues +- new client login rewrites room creator (test room issue);