Feat: start game btn; add todos.md
This commit is contained in:
@ -1,6 +1,13 @@
|
|||||||
{{define "room"}}
|
{{define "room"}}
|
||||||
<div id="hello-user">
|
<div id="hello-user">
|
||||||
<p>Hello {{.State.Username}};</p>
|
<p>Hello {{.State.Username}};</p>
|
||||||
|
<p>Room created by {{.Room.CreatorName}};</p>
|
||||||
|
<p>Game is running: {{.Room.IsRunning}}</p>
|
||||||
|
<p>
|
||||||
|
{{if eq .State.Username .Room.CreatorName}}
|
||||||
|
<button hx-get="/start-game" hx-target="#room" class="bg-amber-100 text-black px-4 py-2 rounded">Start Game</button>
|
||||||
|
{{end}}
|
||||||
|
</p>
|
||||||
<p>Turn of the {{.Room.TeamTurn}} team</p>
|
<p>Turn of the {{.Room.TeamTurn}} team</p>
|
||||||
<p>
|
<p>
|
||||||
{{if eq .State.Team ""}}
|
{{if eq .State.Team ""}}
|
||||||
|
@ -72,7 +72,7 @@ func HandleFrontLogin(w http.ResponseWriter, r *http.Request) {
|
|||||||
abortWithError(w, err.Error())
|
abortWithError(w, err.Error())
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
state := models.MakeTestState()
|
state := models.MakeTestState(cleanName)
|
||||||
state.State.Username = cleanName
|
state.State.Username = cleanName
|
||||||
// save state to cache
|
// save state to cache
|
||||||
// if err := saveState(cleanName, state.State); err != nil {
|
// if err := saveState(cleanName, state.State); err != nil {
|
||||||
|
@ -47,16 +47,17 @@ type Room struct {
|
|||||||
TeamTurn string
|
TeamTurn string
|
||||||
RedTeam Team
|
RedTeam Team
|
||||||
BlueTeam Team
|
BlueTeam Team
|
||||||
// RedMime string
|
|
||||||
// BlueMime string
|
|
||||||
// RedGuessers []string
|
|
||||||
// BlueGuessers []string
|
|
||||||
Cards []WordCard
|
Cards []WordCard
|
||||||
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
|
BlueCounter uint8
|
||||||
RedCounter uint8
|
RedCounter uint8
|
||||||
RedTurn bool // false is blue turn
|
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() {
|
func (r *Room) ChangeTurn() {
|
||||||
|
@ -47,7 +47,7 @@ type UserState struct {
|
|||||||
Role UserRole
|
Role UserRole
|
||||||
}
|
}
|
||||||
|
|
||||||
func MakeTestState() *FullInfo {
|
func MakeTestState(creatorName string) *FullInfo {
|
||||||
cards := []WordCard{
|
cards := []WordCard{
|
||||||
{Word: "hamster", Color: "blue"},
|
{Word: "hamster", Color: "blue"},
|
||||||
{Word: "child", Color: "red"},
|
{Word: "child", Color: "red"},
|
||||||
@ -80,14 +80,14 @@ func MakeTestState() *FullInfo {
|
|||||||
room := &Room{
|
room := &Room{
|
||||||
ID: "test-id",
|
ID: "test-id",
|
||||||
CreatedAt: time.Now(),
|
CreatedAt: time.Now(),
|
||||||
CreatorName: "test-name",
|
CreatorName: creatorName,
|
||||||
Cards: cards,
|
Cards: cards,
|
||||||
RedTeam: redTeam,
|
RedTeam: redTeam,
|
||||||
BlueTeam: blueTeam,
|
BlueTeam: blueTeam,
|
||||||
TeamTurn: "blue",
|
TeamTurn: "blue",
|
||||||
}
|
}
|
||||||
us := &UserState{
|
us := &UserState{
|
||||||
Username: "test-name",
|
Username: creatorName,
|
||||||
Team: UserTeamNone,
|
Team: UserTeamNone,
|
||||||
Role: UserRoleNone,
|
Role: UserRoleNone,
|
||||||
RoomID: "test-id",
|
RoomID: "test-id",
|
||||||
|
20
todos.md
Normal file
20
todos.md
Normal file
@ -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);
|
Reference in New Issue
Block a user