Fix: limit 0 because of too early call of notifybot
This commit is contained in:
		| @@ -60,6 +60,12 @@ func (b *Bot) checkGuess(word string, room *models.Room) error { | ||||
| 		return fmt.Errorf("fn: checkGuess; %s does not exists", 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() | ||||
| 	action := models.Action{ | ||||
| 		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) | ||||
| 		return err | ||||
| 	} | ||||
|  | ||||
| 	if err := repo.RoomUpdate(ctx, room); err != nil { | ||||
| 		// nolint: errcheck | ||||
| 		tx.Rollback() | ||||
| @@ -288,7 +295,7 @@ func (b *Bot) BotMove() { | ||||
| 		if err != nil { | ||||
| 			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{ | ||||
| 			Entry:    entry, | ||||
| 			Username: b.BotName, | ||||
| @@ -306,9 +313,16 @@ func (b *Bot) BotMove() { | ||||
| 		b.log.Error("unexpected role", "role", b.Role, "resp-map", tempMap) | ||||
| 		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 != "" { | ||||
| 		b.log.Debug("notifying bot", "name", botName) | ||||
| 		SignalChanMap[botName] <- true | ||||
| 		b.log.Debug("after sending the signal", "name", botName) | ||||
| 	} | ||||
| } | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Grail Finder
					Grail Finder