Chore: some logs
This commit is contained in:
@ -68,7 +68,8 @@ func (b *Bot) checkGuesses(tempMap map[string]any, room *models.Room) error {
|
|||||||
func (b *Bot) checkGuess(word string, room *models.Room) error {
|
func (b *Bot) checkGuess(word string, room *models.Room) error {
|
||||||
color, exists := room.WCMap[word]
|
color, exists := room.WCMap[word]
|
||||||
b.log.Debug("bot trying to open card", "word", word, "color",
|
b.log.Debug("bot trying to open card", "word", word, "color",
|
||||||
color, "exists", exists)
|
color, "exists", exists, "limit", room.ThisTurnLimit,
|
||||||
|
"opened", room.OpenedThisTurn)
|
||||||
if !exists {
|
if !exists {
|
||||||
return fmt.Errorf("fn: checkGuess; %s does not exists", word)
|
return fmt.Errorf("fn: checkGuess; %s does not exists", word)
|
||||||
}
|
}
|
||||||
@ -86,6 +87,9 @@ func (b *Bot) checkGuess(word string, room *models.Room) error {
|
|||||||
oppositeColor := room.GetOppositeTeamColor()
|
oppositeColor := room.GetOppositeTeamColor()
|
||||||
room.OpenedThisTurn++
|
room.OpenedThisTurn++
|
||||||
if room.OpenedThisTurn >= room.ThisTurnLimit {
|
if room.OpenedThisTurn >= room.ThisTurnLimit {
|
||||||
|
b.log.Debug("ending turn on limit", "word", word, "color",
|
||||||
|
color, "exists", exists, "limit", room.ThisTurnLimit,
|
||||||
|
"opened", room.OpenedThisTurn)
|
||||||
// end turn
|
// end turn
|
||||||
room.TeamTurn = oppositeColor
|
room.TeamTurn = oppositeColor
|
||||||
room.MimeDone = false
|
room.MimeDone = false
|
||||||
@ -219,6 +223,14 @@ func (b *Bot) BotMove() {
|
|||||||
b.log.Warn("failed to parse bot given limit", "mimeResp", mimeResp, "bot_name", b.BotName)
|
b.log.Warn("failed to parse bot given limit", "mimeResp", mimeResp, "bot_name", b.BotName)
|
||||||
}
|
}
|
||||||
room.ThisTurnLimit = uint8(guessLimitU64)
|
room.ThisTurnLimit = uint8(guessLimitU64)
|
||||||
|
if room.ThisTurnLimit == 0 {
|
||||||
|
b.log.Warn("turn limit is 0", "mimeResp", mimeResp)
|
||||||
|
room.ThisTurnLimit = 9
|
||||||
|
}
|
||||||
|
if err := saveRoom(room); err != nil {
|
||||||
|
b.log.Error("failed to save room", "error", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
case models.UserRoleGuesser:
|
case models.UserRoleGuesser:
|
||||||
// // deprecated
|
// // deprecated
|
||||||
// if err := b.checkGuesses(tempMap, room); err != nil {
|
// if err := b.checkGuesses(tempMap, room); err != nil {
|
||||||
@ -234,7 +246,7 @@ func (b *Bot) BotMove() {
|
|||||||
msg := fmt.Sprintf("failed to check guess; mimeResp: %v; bot_name: %s; guess: %s; error: %v", tempMap, b.BotName, guess, err)
|
msg := fmt.Sprintf("failed to check guess; mimeResp: %v; bot_name: %s; guess: %s; error: %v", tempMap, b.BotName, guess, err)
|
||||||
room.LogJournal = append(room.LogJournal, msg)
|
room.LogJournal = append(room.LogJournal, msg)
|
||||||
}
|
}
|
||||||
b.log.Info("mime resp log", "guesserResp", tempMap)
|
b.log.Info("guesser resp log", "guesserResp", tempMap)
|
||||||
couldBe, err := convertToSliceOfStrings(tempMap["could_be"])
|
couldBe, err := convertToSliceOfStrings(tempMap["could_be"])
|
||||||
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)
|
||||||
|
2
todos.md
2
todos.md
@ -63,3 +63,5 @@
|
|||||||
- name check does not work;
|
- name check does not work;
|
||||||
- game did not end when all blue cards were open;
|
- game did not end when all blue cards were open;
|
||||||
- bot ends a turn after guessing one word only;
|
- bot ends a turn after guessing one word only;
|
||||||
|
|
||||||
|
- sync writing to json cache; what happens now: timer (or other side routine) overwrites old room, while mime making clue;
|
||||||
|
Reference in New Issue
Block a user