Feat: game setting fields
This commit is contained in:
@ -5,7 +5,7 @@
|
||||
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>
|
||||
<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/>
|
||||
<label For="language">Language:</label><br/>
|
||||
<input type="text" id="language" name="language" class="text-center text-white" value="en"/><br/>
|
||||
|
@ -57,7 +57,7 @@
|
||||
</ul>
|
||||
</div>
|
||||
<div sse-swap="journal_{{.Room.ID}}">
|
||||
sse div
|
||||
bot thoughts
|
||||
<div>
|
||||
<div id="cardtable">
|
||||
{{template "cardtable" .Room}}
|
||||
|
@ -12,10 +12,16 @@ import (
|
||||
)
|
||||
|
||||
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
|
||||
payload := &models.RoomReq{
|
||||
RoomPass: r.PostFormValue("room_pass"),
|
||||
RoomName: r.PostFormValue("room_name"),
|
||||
RoomPass: r.PostFormValue("room_pass"),
|
||||
Language: r.PostFormValue("language"),
|
||||
RoundTime: uint32(ttU64),
|
||||
}
|
||||
// create a room
|
||||
room, err := createRoom(r.Context(), payload)
|
||||
|
@ -71,7 +71,6 @@ type CardMark struct {
|
||||
type Room struct {
|
||||
ID string `json:"id" db:"id"`
|
||||
CreatedAt time.Time `json:"created_at" db:"created_at"` // limit?
|
||||
RoomPass string `json:"room_pass"`
|
||||
RoomLink string
|
||||
CreatorName string `json:"creator_name"`
|
||||
ActionHistory []Action
|
||||
@ -97,6 +96,7 @@ type Room struct {
|
||||
Mark CardMark // card is marked
|
||||
// needed for debug
|
||||
LogJournal []string
|
||||
Settings GameSettings
|
||||
}
|
||||
|
||||
func (r *Room) ClearMarks() {
|
||||
@ -325,11 +325,10 @@ type WordCard struct {
|
||||
}
|
||||
|
||||
type GameSettings struct {
|
||||
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
|
||||
RoomPass string `json:"room_pass"`
|
||||
TurnSeconds uint32
|
||||
RoundTime uint32
|
||||
}
|
||||
|
||||
// =====
|
||||
@ -337,20 +336,26 @@ type GameSettings struct {
|
||||
type RoomReq struct {
|
||||
// is not user or not unique
|
||||
RoomPass string `json:"room_pass" form:"room_pass"`
|
||||
RoomName string `json:"room_name" form:"room_name"`
|
||||
// GameSettings
|
||||
Language string `json:"language" form:"language"`
|
||||
RoundTime uint32
|
||||
}
|
||||
|
||||
func (rr *RoomReq) CreateRoom(creator string) *Room {
|
||||
roomID := xid.New().String()
|
||||
settings := GameSettings{
|
||||
Language: rr.Language,
|
||||
RoomPass: rr.RoomPass,
|
||||
RoundTime: rr.RoundTime,
|
||||
}
|
||||
return &Room{
|
||||
// RoomName: ,
|
||||
RoomPass: rr.RoomPass,
|
||||
ID: roomID,
|
||||
CreatedAt: time.Now(),
|
||||
// PlayerList: []string{creator},
|
||||
CreatorName: creator,
|
||||
BotMap: make(map[string]BotPlayer),
|
||||
Settings: settings,
|
||||
}
|
||||
}
|
||||
|
||||
|
9
todos.md
9
todos.md
@ -13,6 +13,10 @@
|
||||
- ways to remove bots from teams; +
|
||||
- mark cards (instead of opening them (right click?); +
|
||||
- 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;
|
||||
- common auth system between sites;
|
||||
===
|
||||
@ -22,11 +26,8 @@
|
||||
- ended turn action to backlog;
|
||||
===
|
||||
- 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?);
|
||||
- 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;
|
||||
- at game creation list languages and support them at backend;
|
||||
|
||||
#### sse points
|
||||
- clue sse update;
|
||||
|
Reference in New Issue
Block a user