Feat: room expiry
This commit is contained in:
@ -5,12 +5,12 @@
|
||||
style="text-shadow: 0 2px 4px rgba(0,0,0,0.9);"> {{.Word}}
|
||||
</div>
|
||||
{{else}}
|
||||
<div id="card-{{.Word}}" class="bg-{{.Color}}-600 border border-gray-500 p-4 rounded-lg min-w-[100px] text-center text-white cursor-pointer"
|
||||
<div id="card-{{.Word}}" class="bg-{{.Color}}-400 border border-gray-500 p-4 rounded-lg min-w-[100px] text-center text-white cursor-pointer"
|
||||
style="text-shadow: 0 2px 4px rgba(0,0,0,0.9);"> {{.Word}}
|
||||
</div>
|
||||
{{end}}
|
||||
{{else}}
|
||||
<div id="card-{{.Word}}" class="bg-stone-600 border border-gray-500 p-4 rounded-lg min-w-[100px] text-center text-white cursor-pointer"
|
||||
<div id="card-{{.Word}}" class="bg-stone-400 border border-gray-500 p-4 rounded-lg min-w-[100px] text-center text-white cursor-pointer"
|
||||
style="text-shadow: 0 2px 4px rgba(0,0,0,0.8);"
|
||||
hx-get="/word/show-color?word={{.Word}}" hx-trigger="click" hx-swap="outerHTML transition:true swap:.05s">
|
||||
{{.Word}}
|
||||
|
@ -34,6 +34,10 @@ func saveRoom(room *models.Room) error {
|
||||
return err
|
||||
}
|
||||
memcache.Set(key, data)
|
||||
// do I need last action here? since room save is kind of an action on itself
|
||||
// time.Now().Add(time.Hour).Sub(room.LastActionTS)
|
||||
anHour := int64(216000) // 60 * 60 * 60
|
||||
memcache.Expire(key, anHour)
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -64,13 +64,11 @@ type BotPlayer struct {
|
||||
}
|
||||
|
||||
type Room struct {
|
||||
ID string `json:"id" db:"id"`
|
||||
CreatedAt time.Time `json:"created_at" db:"created_at"`
|
||||
// RoomName string `json:"room_name"`
|
||||
RoomPass string `json:"room_pass"`
|
||||
RoomLink string
|
||||
CreatorName string `json:"creator_name"`
|
||||
// PlayerList []string `json:"player_list"`
|
||||
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
|
||||
TeamTurn UserTeam
|
||||
RedTeam Team
|
||||
@ -86,15 +84,14 @@ type Room struct {
|
||||
RedTurn bool // false is blue turn
|
||||
MimeDone bool
|
||||
IsPublic bool
|
||||
// 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
|
||||
TeamWon UserTeam // blue | red
|
||||
IsRunning bool `json:"is_running"`
|
||||
Language string `json:"language" example:"en" form:"language"`
|
||||
RoundTime int32 `json:"round_time"`
|
||||
IsOver bool
|
||||
TeamWon UserTeam // blue | red
|
||||
// needed for debug
|
||||
LogJournal []string
|
||||
LogJournal []string
|
||||
LastActionTS time.Time
|
||||
}
|
||||
|
||||
// FindBotByTeamRole returns bot name if found; otherwise empty string
|
||||
|
2
todos.md
2
todos.md
@ -1,5 +1,5 @@
|
||||
### feats
|
||||
- auto close room if nothing is going on there (hmm) for ~1h;
|
||||
- auto close room if nothing is going on there (hmm) for ~1h; +
|
||||
- words database (file) load and form random 25 words; +
|
||||
- different files for each supported lang;
|
||||
- mark cards (instead of opening them (right click?);
|
||||
|
Reference in New Issue
Block a user