Feat: game setting fields

This commit is contained in:
Grail Finder
2025-06-30 17:39:07 +03:00
parent 87a0f870e8
commit a51668e321
5 changed files with 27 additions and 15 deletions

View File

@ -5,7 +5,7 @@
or<br/> or<br/>
<button button class="justify-center rounded-md bg-indigo-600 px-3 py-1.5 text-sm font-semibold leading-6 text-white shadow-sm hover:bg-indigo-500 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-indigo-600" hx-get="/room/hideform" hx-target=".create-room-div" >Hide Form</button> <button button class="justify-center rounded-md bg-indigo-600 px-3 py-1.5 text-sm font-semibold leading-6 text-white shadow-sm hover:bg-indigo-500 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-indigo-600" hx-get="/room/hideform" hx-target=".create-room-div" >Hide Form</button>
<form hx-post="/room-create" hx-target="#ancestor"> <form hx-post="/room-create" hx-target="#ancestor">
<label For="game_time">Game Time:</label><br/> <label For="game_time">Turn Seconds:</label><br/>
<input type="number" id="game_time" name="game_time" class="text-center text-white" value="300"/><br/> <input type="number" id="game_time" name="game_time" class="text-center text-white" value="300"/><br/>
<label For="language">Language:</label><br/> <label For="language">Language:</label><br/>
<input type="text" id="language" name="language" class="text-center text-white" value="en"/><br/> <input type="text" id="language" name="language" class="text-center text-white" value="en"/><br/>

View File

@ -57,7 +57,7 @@
</ul> </ul>
</div> </div>
<div sse-swap="journal_{{.Room.ID}}"> <div sse-swap="journal_{{.Room.ID}}">
sse div bot thoughts
<div> <div>
<div id="cardtable"> <div id="cardtable">
{{template "cardtable" .Room}} {{template "cardtable" .Room}}

View File

@ -12,10 +12,16 @@ import (
) )
func HandleCreateRoom(w http.ResponseWriter, r *http.Request) { func HandleCreateRoom(w http.ResponseWriter, r *http.Request) {
turnTimeStr := r.PostFormValue("game_time")
ttU64, err := strconv.ParseUint(turnTimeStr, 10, 64)
if err != nil {
log.Warn("failed to parse turn time", "game_time", turnTimeStr)
}
// parse payload // parse payload
payload := &models.RoomReq{ payload := &models.RoomReq{
RoomPass: r.PostFormValue("room_pass"), RoomPass: r.PostFormValue("room_pass"),
RoomName: r.PostFormValue("room_name"), Language: r.PostFormValue("language"),
RoundTime: uint32(ttU64),
} }
// create a room // create a room
room, err := createRoom(r.Context(), payload) room, err := createRoom(r.Context(), payload)

View File

@ -71,7 +71,6 @@ type CardMark struct {
type Room struct { type Room struct {
ID string `json:"id" db:"id"` ID string `json:"id" db:"id"`
CreatedAt time.Time `json:"created_at" db:"created_at"` // limit? CreatedAt time.Time `json:"created_at" db:"created_at"` // limit?
RoomPass string `json:"room_pass"`
RoomLink string RoomLink string
CreatorName string `json:"creator_name"` CreatorName string `json:"creator_name"`
ActionHistory []Action ActionHistory []Action
@ -97,6 +96,7 @@ type Room struct {
Mark CardMark // card is marked Mark CardMark // card is marked
// needed for debug // needed for debug
LogJournal []string LogJournal []string
Settings GameSettings
} }
func (r *Room) ClearMarks() { func (r *Room) ClearMarks() {
@ -325,11 +325,10 @@ type WordCard struct {
} }
type GameSettings struct { type GameSettings struct {
IsRunning bool `json:"is_running"`
Language string `json:"language" example:"en" form:"language"` Language string `json:"language" example:"en" form:"language"`
RoundTime int32 `json:"round_time"` RoomPass string `json:"room_pass"`
ProgressPct uint32 `json:"progress_pct"` TurnSeconds uint32
IsOver bool RoundTime uint32
} }
// ===== // =====
@ -337,20 +336,26 @@ type GameSettings struct {
type RoomReq struct { type RoomReq struct {
// is not user or not unique // is not user or not unique
RoomPass string `json:"room_pass" form:"room_pass"` RoomPass string `json:"room_pass" form:"room_pass"`
RoomName string `json:"room_name" form:"room_name"`
// GameSettings // GameSettings
Language string `json:"language" form:"language"`
RoundTime uint32
} }
func (rr *RoomReq) CreateRoom(creator string) *Room { func (rr *RoomReq) CreateRoom(creator string) *Room {
roomID := xid.New().String() roomID := xid.New().String()
settings := GameSettings{
Language: rr.Language,
RoomPass: rr.RoomPass,
RoundTime: rr.RoundTime,
}
return &Room{ return &Room{
// RoomName: , // RoomName: ,
RoomPass: rr.RoomPass,
ID: roomID, ID: roomID,
CreatedAt: time.Now(), CreatedAt: time.Now(),
// PlayerList: []string{creator}, // PlayerList: []string{creator},
CreatorName: creator, CreatorName: creator,
BotMap: make(map[string]BotPlayer), BotMap: make(map[string]BotPlayer),
Settings: settings,
} }
} }

View File

@ -13,6 +13,10 @@
- ways to remove bots from teams; + - ways to remove bots from teams; +
- mark cards (instead of opening them (right click?); + - mark cards (instead of opening them (right click?); +
- on end of turn clear all the marks; + - on end of turn clear all the marks; +
- different files for each supported lang; +
- sse div to bot thinking; +
- simplify mime prompt; +
- redo card .revealed use: it should mean that card is revealed for everybody, while mime should be able to see cards as is; +
- better styles and fluff; - better styles and fluff;
- common auth system between sites; - common auth system between sites;
=== ===
@ -22,11 +26,8 @@
- ended turn action to backlog; - ended turn action to backlog;
=== ===
- clear indication that model (llm) is thinking / answered; - clear indication that model (llm) is thinking / answered;
- different files for each supported lang;
- possibly turn markings into parts of names of users (first three letters?); - possibly turn markings into parts of names of users (first three letters?);
- sse div to bot thinking; - at game creation list languages and support them at backend;
- simplify mime prompt;
- redo card .revealed use: it should mean that card is revealed for everybody, while mime should be able to see cards as is;
#### sse points #### sse points
- clue sse update; - clue sse update;