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
run:
make migrate-up
run: migrate-up
go build
./gralias start

View File

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

View File

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

View File

@ -78,3 +78,10 @@
- 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;
- 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;