Enha: filter out some words
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@ -1,13 +1,9 @@
|
||||
{{define "main"}}
|
||||
Start of main temp
|
||||
{{ if not . }}
|
||||
login temp
|
||||
{{template "login"}}
|
||||
{{ else if ne .LinkLogin "" }}
|
||||
got to linklogin
|
||||
{{template "linklogin" .LinkLogin}}
|
||||
{{ else if eq .State.RoomID "" }}
|
||||
empty state roomid
|
||||
<div id="hello-user">
|
||||
<p>Hello {{.State.Username}}</p>
|
||||
</div>
|
||||
@ -18,7 +14,6 @@
|
||||
{{template "roomlist" .List}}
|
||||
</div>
|
||||
{{else}}
|
||||
else
|
||||
<div id="room">
|
||||
{{template "room" .}}
|
||||
</div>
|
||||
|
@ -3,7 +3,8 @@
|
||||
<div id="meta">
|
||||
<p>Hello {{.State.Username}};</p>
|
||||
<p>Room created by {{.Room.CreatorName}};</p>
|
||||
<p>Room link:</p><p><input id="roomlink" readonly="" onclick="copyText()" value="{{.Room.RoomLink}}"></input></p>
|
||||
<p>Room link:</p>
|
||||
<p><input id="roomlink" readonly="" onclick="copyText()" value="{{.Room.RoomLink}}" class="bg-amber-100 text-black px-1 py-1 rounded"></input></p>
|
||||
<p>Game is running: {{.Room.IsRunning}}</p>
|
||||
<p>
|
||||
{{if and (eq .State.Username .Room.CreatorName) (not .Room.IsRunning)}}
|
||||
@ -12,13 +13,6 @@
|
||||
</p>
|
||||
{{if .Room.IsOver}}
|
||||
<p>GAME OVER; team <span class="text-{{.Room.TeamWon}}-500">{{.Room.TeamWon}}</span> won! 🧚</p>
|
||||
{{else}}
|
||||
<p>Turn of the <span class="text-{{.Room.TeamTurn}}-500">{{.Room.TeamTurn}}</span> team</p>
|
||||
{{if .Room.MimeDone}}
|
||||
<p class="text-{{.Room.TeamTurn}}-500">Waiting for guessers</p>
|
||||
{{else}}
|
||||
<p class="text-{{.Room.TeamTurn}}-500">Waiting for mime</p>
|
||||
{{end}}
|
||||
{{end}}
|
||||
<p>
|
||||
{{if eq .State.Team ""}}
|
||||
@ -30,6 +24,12 @@
|
||||
</div>
|
||||
<hr />
|
||||
{{if .Room.IsRunning}}
|
||||
<p>Turn of the <span class="text-{{.Room.TeamTurn}}-500">{{.Room.TeamTurn}}</span> team</p>
|
||||
{{if .Room.MimeDone}}
|
||||
<p class="text-{{.Room.TeamTurn}}-500">Waiting for guessers</p>
|
||||
{{else}}
|
||||
<p class="text-{{.Room.TeamTurn}}-500">Waiting for mime</p>
|
||||
{{end}}
|
||||
{{template "cardcounter" .Room}}
|
||||
{{end}}
|
||||
<div id="addbot">
|
||||
@ -62,7 +62,7 @@
|
||||
</div>
|
||||
<div>
|
||||
{{if and (eq .State.Username .Room.CreatorName) (.Room.IsRunning)}}
|
||||
<button hx-get="/renotify-bot" class="bg-amber-100 text-black px-4 py-2 rounded">Btn in case llm call failed</button>
|
||||
<button hx-get="/renotify-bot" hx-swap="none" class="bg-gray-100 text-black px-1 py-1 rounded">Btn in case llm call failed</button>
|
||||
{{end}}
|
||||
</div>
|
||||
<div hx-get="/actionhistory" hx-trigger="sse:backlog_{{.Room.ID}}">
|
||||
|
@ -4,9 +4,9 @@
|
||||
<p>
|
||||
{{.ID}}
|
||||
</p>
|
||||
<div class="room-item mb-3 p-4 border rounded-lg hover:bg-gray-50 transition-colors">
|
||||
<div hx-get="/room-join?id={{.ID}}" hx-target="#ancestor" class="room-item mb-3 p-4 border rounded-lg hover:bg-gray-50 transition-colors">
|
||||
<div class="flex justify-between items-center">
|
||||
<div hx-get="/room-join?id={{.ID}}" hx-target="#ancestor" class="room-info">
|
||||
<div class="room-info">
|
||||
<div class="text-sm text-gray-500">
|
||||
Created {{.CreatedAt.Format "2 Jan 2006 15:04"}} by
|
||||
<span class="font-medium text-gray-700">{{.CreatorName}}</span>
|
||||
|
@ -301,7 +301,10 @@ func recoverBots() {
|
||||
}
|
||||
|
||||
func recoverBot(bm map[string]string) error {
|
||||
// TODO: check if room still exists
|
||||
// check if room still exists
|
||||
if _, err := getRoomByID(bm["room_id"]); err != nil {
|
||||
return fmt.Errorf("no such room: %s; err: %w", bm["room_id"], err)
|
||||
}
|
||||
log.Debug("recovering bot", "bot", bm)
|
||||
_, err := llmapi.NewBot(bm["role"], bm["team"], bm["bot_name"], bm["room_id"], cfg)
|
||||
if err != nil {
|
||||
|
@ -151,7 +151,7 @@ func makeCookie(username string, remote string) (*http.Cookie, error) {
|
||||
log.Info("check remote addr for cookie set",
|
||||
"remote", remote, "session", session)
|
||||
if strings.Contains(remote, "192.168.0") {
|
||||
cookie.Domain = "192.168.0.106"
|
||||
cookie.Domain = "192.168.0.100"
|
||||
cookie.SameSite = http.SameSiteLaxMode
|
||||
cookie.Secure = false
|
||||
log.Info("changing cookie domain", "domain", cookie.Domain)
|
||||
|
@ -85,12 +85,14 @@ func HandleShowColor(w http.ResponseWriter, r *http.Request) {
|
||||
// if opened card is of color of opp team, change turn
|
||||
oppositeColor := fi.Room.GetOppositeTeamColor()
|
||||
fi.Room.OpenedThisTurn++
|
||||
if fi.Room.ThisTurnLimit >= fi.Room.OpenedThisTurn {
|
||||
// end turn
|
||||
fi.Room.TeamTurn = oppositeColor
|
||||
fi.Room.MimeDone = false
|
||||
fi.Room.OpenedThisTurn = 0
|
||||
fi.Room.ThisTurnLimit = 0
|
||||
if fi.Room.ThisTurnLimit > 0 {
|
||||
if fi.Room.ThisTurnLimit >= fi.Room.OpenedThisTurn {
|
||||
// end turn
|
||||
fi.Room.TeamTurn = oppositeColor
|
||||
fi.Room.MimeDone = false
|
||||
fi.Room.OpenedThisTurn = 0
|
||||
fi.Room.ThisTurnLimit = 0
|
||||
}
|
||||
}
|
||||
switch string(color) {
|
||||
case "black":
|
||||
|
@ -262,6 +262,7 @@ func HandleGiveClue(w http.ResponseWriter, r *http.Request) {
|
||||
fi.Room.ActionHistory = append(fi.Room.ActionHistory, action)
|
||||
fi.Room.MimeDone = true
|
||||
fi.Room.ThisTurnLimit = uint8(guessLimitU64) + 1
|
||||
log.Debug("given clue", "clue", clue, "limit", guessLimitU64)
|
||||
notify(models.NotifyBacklogPrefix+fi.Room.ID, clue+num)
|
||||
notifyBotIfNeeded(fi)
|
||||
if err := saveFullInfo(fi); err != nil {
|
||||
|
@ -12,6 +12,7 @@ import (
|
||||
"log/slog"
|
||||
"net/http"
|
||||
"os"
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
|
||||
@ -93,6 +94,27 @@ type Bot struct {
|
||||
// DoneCh chan bool
|
||||
}
|
||||
|
||||
func convertToSliceOfStrings(value any) ([]string, error) {
|
||||
switch v := value.(type) {
|
||||
case []string:
|
||||
// Directly return if it's already []string
|
||||
return v, nil
|
||||
case []interface{}:
|
||||
// Convert each element to string
|
||||
result := make([]string, len(v))
|
||||
for i, item := range v {
|
||||
str, ok := item.(string)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("element at index %d is not a string (got %T)", i, item)
|
||||
}
|
||||
result[i] = str
|
||||
}
|
||||
return result, nil
|
||||
default:
|
||||
return nil, fmt.Errorf("unsupported type: %T", value)
|
||||
}
|
||||
}
|
||||
|
||||
// StartBot
|
||||
func (b *Bot) StartBot() {
|
||||
for {
|
||||
@ -138,8 +160,18 @@ func (b *Bot) StartBot() {
|
||||
room.ActionHistory = append(room.ActionHistory, action)
|
||||
room.MimeDone = true
|
||||
eventPayload = mimeResp.Clue + mimeResp.Number
|
||||
guessLimitU64, err := strconv.ParseUint(mimeResp.Number, 10, 8)
|
||||
if err != nil {
|
||||
b.log.Warn("failed to parse bot given limit", "mimeResp", mimeResp, "bot_name", b.BotName)
|
||||
}
|
||||
room.ThisTurnLimit = uint8(guessLimitU64)
|
||||
case models.UserRoleGuesser:
|
||||
for _, word := range tempMap["guesses"].([]string) {
|
||||
guesses, err := convertToSliceOfStrings(tempMap["guesses"])
|
||||
if err != nil {
|
||||
b.log.Warn("failed to parse bot given guesses", "mimeResp", tempMap, "bot_name", b.BotName)
|
||||
continue
|
||||
}
|
||||
for _, word := range guesses {
|
||||
color, exists := room.WCMap[word]
|
||||
b.log.Debug("bot trying to open card", "word", word, "color",
|
||||
color, "exists", exists)
|
||||
|
5
todos.md
5
todos.md
@ -5,7 +5,6 @@
|
||||
- mark cards (instead of opening them (right click?);
|
||||
- invite link; +
|
||||
- login with invite link; +
|
||||
- add html icons of whos turn it is (like an image of big ? when mime is thinking);
|
||||
- there three places for bot to check if its its move: start-game; end-turn, after mime gave clue; +
|
||||
- remove bot button (if game is not running, or bot already added); +
|
||||
- show in backlog (and with that in prompt to llm) how many cards are left to open, also additional comment: if guess was right;
|
||||
@ -16,6 +15,7 @@
|
||||
- autoscroll down backlog on update;
|
||||
- gameover to backlog;
|
||||
- ended turn action to backlog;
|
||||
- clear indication that model (llm) is thinking / answered;
|
||||
|
||||
#### sse points
|
||||
- clue sse update;
|
||||
@ -38,4 +38,5 @@
|
||||
- invite link gets cutoff;
|
||||
- mime rejoined the room: does not see colors; state save in store.json has empty role and team +
|
||||
- restart bot routines after server restart; +
|
||||
- guesser did not have same number of guesses (move ended after 1 guess); show how much guesses left on the page;
|
||||
- guesser did not have same number of guesses (move ended after 1 guess); show how much guesses left on the page (red after blue);
|
||||
- guesser bot no request after game restart;
|
||||
|
Reference in New Issue
Block a user