Fix: limit 0 because of too early call of notifybot
This commit is contained in:
@ -345,12 +345,13 @@ func HandleGiveClue(w http.ResponseWriter, r *http.Request) {
|
|||||||
fi.Room.OpenedThisTurn = 0
|
fi.Room.OpenedThisTurn = 0
|
||||||
StartTurnTimer(fi.Room.ID, fi.Room.Settings.RoundTime)
|
StartTurnTimer(fi.Room.ID, fi.Room.Settings.RoundTime)
|
||||||
log.Debug("given clue", "clue", clue, "limit", fi.Room.ThisTurnLimit)
|
log.Debug("given clue", "clue", clue, "limit", fi.Room.ThisTurnLimit)
|
||||||
notify(models.NotifyBacklogPrefix+fi.Room.ID, clue+num)
|
// notify(models.NotifyBacklogPrefix+fi.Room.ID, clue+num)
|
||||||
notifyBotIfNeeded(fi.Room)
|
notify(models.NotifyRoomUpdatePrefix+fi.Room.ID, clue+num)
|
||||||
if err := saveFullInfo(r.Context(), fi); err != nil {
|
if err := saveFullInfo(r.Context(), fi); err != nil {
|
||||||
abortWithError(w, err.Error())
|
abortWithError(w, err.Error())
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
notifyBotIfNeeded(fi.Room)
|
||||||
}
|
}
|
||||||
|
|
||||||
func HandleRenotifyBot(w http.ResponseWriter, r *http.Request) {
|
func HandleRenotifyBot(w http.ResponseWriter, r *http.Request) {
|
||||||
|
@ -60,6 +60,12 @@ func (b *Bot) checkGuess(word string, room *models.Room) error {
|
|||||||
return fmt.Errorf("fn: checkGuess; %s does not exists", word)
|
return fmt.Errorf("fn: checkGuess; %s does not exists", word)
|
||||||
}
|
}
|
||||||
room.RevealSpecificWord(word)
|
room.RevealSpecificWord(word)
|
||||||
|
if err := repo.WordCardReveal(context.Background(), word, room.ID); err != nil {
|
||||||
|
b.log.Error("failed to reveal word in db", "word", word, "color",
|
||||||
|
color, "exists", exists, "limit", room.ThisTurnLimit,
|
||||||
|
"opened", room.OpenedThisTurn)
|
||||||
|
return err
|
||||||
|
}
|
||||||
room.UpdateCounter()
|
room.UpdateCounter()
|
||||||
action := models.Action{
|
action := models.Action{
|
||||||
RoomID: room.ID,
|
RoomID: room.ID,
|
||||||
@ -156,6 +162,7 @@ func (b *Bot) checkGuess(word string, room *models.Room) error {
|
|||||||
b.log.Error("failed to create action", "error", err, "action", action)
|
b.log.Error("failed to create action", "error", err, "action", action)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := repo.RoomUpdate(ctx, room); err != nil {
|
if err := repo.RoomUpdate(ctx, room); err != nil {
|
||||||
// nolint: errcheck
|
// nolint: errcheck
|
||||||
tx.Rollback()
|
tx.Rollback()
|
||||||
@ -288,7 +295,7 @@ func (b *Bot) BotMove() {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
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("%s guessed: %s; also considered this: %v", b.BotName, guess, couldBe)
|
||||||
lj := models.Journal{
|
lj := models.Journal{
|
||||||
Entry: entry,
|
Entry: entry,
|
||||||
Username: b.BotName,
|
Username: b.BotName,
|
||||||
@ -306,9 +313,16 @@ func (b *Bot) BotMove() {
|
|||||||
b.log.Error("unexpected role", "role", b.Role, "resp-map", tempMap)
|
b.log.Error("unexpected role", "role", b.Role, "resp-map", tempMap)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
// just incase, get the room once more
|
||||||
|
room, err = repo.RoomGetExtended(context.Background(), b.RoomID)
|
||||||
|
if err != nil {
|
||||||
|
b.log.Error("bot loop", "error", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
if botName := room.WhichBotToMove(); botName != "" {
|
if botName := room.WhichBotToMove(); botName != "" {
|
||||||
b.log.Debug("notifying bot", "name", botName)
|
b.log.Debug("notifying bot", "name", botName)
|
||||||
SignalChanMap[botName] <- true
|
SignalChanMap[botName] <- true
|
||||||
|
b.log.Debug("after sending the signal", "name", botName)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -294,7 +294,7 @@ func getGuesser(m map[string]BotPlayer, team UserTeam) string {
|
|||||||
func (r *Room) WhichBotToMove() string {
|
func (r *Room) WhichBotToMove() string {
|
||||||
fmt.Println("looking for bot to move", "team-turn:", r.TeamTurn,
|
fmt.Println("looking for bot to move", "team-turn:", r.TeamTurn,
|
||||||
"mime-done:", r.MimeDone, "bot-map:", r.BotMap, "is_running:", r.IsRunning,
|
"mime-done:", r.MimeDone, "bot-map:", r.BotMap, "is_running:", r.IsRunning,
|
||||||
"blueMime:", r.BlueTeam.Mime, "redMime:", r.RedTeam.Mime)
|
"blueMime:", r.BlueTeam.Mime, "redMime:", r.RedTeam.Mime, "card-limit:", r.ThisTurnLimit, "opened:", r.OpenedThisTurn)
|
||||||
if !r.IsRunning {
|
if !r.IsRunning {
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
1
todos.md
1
todos.md
@ -86,3 +86,4 @@
|
|||||||
- start new game satrted timer for a mime; (feature? in other cases mime has no timer);
|
- start new game satrted timer for a mime; (feature? in other cases mime has no timer);
|
||||||
- timer ended and went to 300;
|
- timer ended and went to 300;
|
||||||
- mime sees the clue input out of turn;
|
- mime sees the clue input out of turn;
|
||||||
|
- there is a problem of two timers, they both could switch turn, but it is not easy to stop them from llmapi or handlers.
|
||||||
|
Reference in New Issue
Block a user