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}} |          style="text-shadow: 0 2px 4px rgba(0,0,0,0.9);"> {{.Word}} | ||||||
|     </div> |     </div> | ||||||
|   {{else}} |   {{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}} |          style="text-shadow: 0 2px 4px rgba(0,0,0,0.9);"> {{.Word}} | ||||||
|     </div> |     </div> | ||||||
|   {{end}} |   {{end}} | ||||||
| {{else}} | {{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);" |      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"> |      hx-get="/word/show-color?word={{.Word}}" hx-trigger="click" hx-swap="outerHTML transition:true swap:.05s"> | ||||||
|     {{.Word}} |     {{.Word}} | ||||||
|   | |||||||
| @@ -34,6 +34,10 @@ func saveRoom(room *models.Room) error { | |||||||
| 		return err | 		return err | ||||||
| 	} | 	} | ||||||
| 	memcache.Set(key, data) | 	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 | 	return nil | ||||||
| } | } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -65,12 +65,10 @@ type BotPlayer 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"` | 	CreatedAt      time.Time `json:"created_at" db:"created_at"` // limit? | ||||||
| 	// RoomName     string    `json:"room_name"` |  | ||||||
| 	RoomPass       string    `json:"room_pass"` | 	RoomPass       string    `json:"room_pass"` | ||||||
| 	RoomLink       string | 	RoomLink       string | ||||||
| 	CreatorName    string `json:"creator_name"` | 	CreatorName    string `json:"creator_name"` | ||||||
| 	// PlayerList     []string `json:"player_list"` |  | ||||||
| 	ActionHistory  []Action | 	ActionHistory  []Action | ||||||
| 	TeamTurn       UserTeam | 	TeamTurn       UserTeam | ||||||
| 	RedTeam        Team | 	RedTeam        Team | ||||||
| @@ -86,15 +84,14 @@ type Room struct { | |||||||
| 	RedTurn        bool // false is blue turn | 	RedTurn        bool // false is blue turn | ||||||
| 	MimeDone       bool | 	MimeDone       bool | ||||||
| 	IsPublic       bool | 	IsPublic       bool | ||||||
| 	// GameSettings *GameSettings `json:"settings"` |  | ||||||
| 	IsRunning      bool   `json:"is_running"` | 	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"` | 	RoundTime      int32  `json:"round_time"` | ||||||
| 	// ProgressPct uint32 `json:"progress_pct"` |  | ||||||
| 	IsOver         bool | 	IsOver         bool | ||||||
| 	TeamWon        UserTeam // blue | red | 	TeamWon        UserTeam // blue | red | ||||||
| 	// needed for debug | 	// needed for debug | ||||||
| 	LogJournal   []string | 	LogJournal   []string | ||||||
|  | 	LastActionTS time.Time | ||||||
| } | } | ||||||
|  |  | ||||||
| // FindBotByTeamRole returns bot name if found; otherwise empty string | // FindBotByTeamRole returns bot name if found; otherwise empty string | ||||||
|   | |||||||
							
								
								
									
										2
									
								
								todos.md
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								todos.md
									
									
									
									
									
								
							| @@ -1,5 +1,5 @@ | |||||||
| ### feats | ### 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; + | - words database (file) load and form random 25 words; + | ||||||
| - different files for each supported lang; | - different files for each supported lang; | ||||||
| - mark cards (instead of opening them (right click?); | - mark cards (instead of opening them (right click?); | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Grail Finder
					Grail Finder