Fix: bot mime give clue -> update page

This commit is contained in:
Grail Finder
2025-07-06 08:39:58 +03:00
parent f97d91ac74
commit 9900ebd3dd
4 changed files with 26 additions and 10 deletions

View File

@ -1,7 +1,6 @@
.PHONY: all init deps install test lint run stop .PHONY: all init deps install test lint run stop
run: run: migrate-up
make migrate-up
go build go build
./gralias start ./gralias start

View File

@ -53,7 +53,7 @@
Server says: <br> Server says: <br>
<ul> <ul>
{{range .Room.LogJournal}} {{range .Room.LogJournal}}
<li>{{.}}</li> <li>{{.Username}}: {{.Entry}}</li>
{{end}} {{end}}
</ul> </ul>
</div> </div>

View File

@ -188,7 +188,8 @@ func (b *Bot) BotMove() {
b.log.Error("bot loop", "error", err) b.log.Error("bot loop", "error", err)
return return
} }
eventName := models.NotifyBacklogPrefix + room.ID // eventName := models.NotifyBacklogPrefix + room.ID
eventName := models.NotifyRoomUpdatePrefix + room.ID
eventPayload := "" eventPayload := ""
defer func() { // save room defer func() { // save room
if err := saveRoom(room); err != nil { if err := saveRoom(room); err != nil {
@ -247,11 +248,15 @@ func (b *Bot) BotMove() {
room.ActionHistory = append(room.ActionHistory, action) room.ActionHistory = append(room.ActionHistory, action)
room.MimeDone = true room.MimeDone = true
entry := fmt.Sprintf("meant to open: %v", tempMap["words_I_mean_my_team_to_open"]) entry := fmt.Sprintf("meant to open: %v", tempMap["words_I_mean_my_team_to_open"])
room.LogJournal = append(room.LogJournal, models.Journal{ lj := models.Journal{
Entry: entry, Entry: entry,
Username: b.BotName, Username: b.BotName,
RoomID: room.ID, RoomID: room.ID,
}) }
room.LogJournal = append(room.LogJournal, lj)
if err := repo.JournalCreate(context.Background(), &lj); err != nil {
b.log.Warn("failed to write to journal", "entry", lj)
}
eventPayload = mimeResp.Clue + mimeResp.Number eventPayload = mimeResp.Clue + mimeResp.Number
guessLimitU64, err := strconv.ParseUint(mimeResp.Number, 10, 8) guessLimitU64, err := strconv.ParseUint(mimeResp.Number, 10, 8)
if err != nil { if err != nil {
@ -267,6 +272,7 @@ func (b *Bot) BotMove() {
b.log.Error("failed to create action", "error", err) b.log.Error("failed to create action", "error", err)
return return
} }
// StartTurnTimer(fi.Room.ID, fi.Room.Settings.RoundTime)
if err := saveRoom(room); err != nil { if err := saveRoom(room); err != nil {
b.log.Error("failed to save room", "error", err) b.log.Error("failed to save room", "error", err)
return return
@ -291,13 +297,17 @@ func (b *Bot) BotMove() {
b.log.Warn("failed to parse could_be", "bot_resp", tempMap, "bot_name", b.BotName) b.log.Warn("failed to parse could_be", "bot_resp", tempMap, "bot_name", b.BotName)
} }
entry := fmt.Sprintf("also considered this: %v", couldBe) entry := fmt.Sprintf("also considered this: %v", couldBe)
room.LogJournal = append(room.LogJournal, models.Journal{ lj := models.Journal{
Entry: entry, Entry: entry,
Username: b.BotName, Username: b.BotName,
RoomID: room.ID, RoomID: room.ID,
}) }
eventName = models.NotifyRoomUpdatePrefix + room.ID room.LogJournal = append(room.LogJournal, lj)
eventPayload = "" if err := repo.JournalCreate(context.Background(), &lj); err != nil {
b.log.Warn("failed to write to journal", "entry", lj)
}
// eventName = models.NotifyRoomUpdatePrefix + room.ID
// eventPayload = ""
// TODO: needs to decide if it wants to open the next cardword or end turn // TODO: needs to decide if it wants to open the next cardword or end turn
// or end turn on limit // or end turn on limit
default: default:

View File

@ -78,3 +78,10 @@
- bot mime makes a clue -> no update in the room for players; - bot mime makes a clue -> no update in the room for players;
- red moves after bot gave (metal - 3) ended after two guesses (showed in logs, that opened 3. double click on the same card? or somewhere counter is not dropped?); the first guess moved counter to 2, in logs only two requests as expected; - red moves after bot gave (metal - 3) ended after two guesses (showed in logs, that opened 3. double click on the same card? or somewhere counter is not dropped?); the first guess moved counter to 2, in logs only two requests as expected;
- bot mime gve a blue -> timer did not start; timer should be in third package, maybe in crons;
- log journal is not shown on the page;
- marks did not clear after end of the turn (feature?)
- start new game satrted timer for a mime; (feature? in other cases mime has no timer);
- old cards are still around;
- timer ended and went to 300;