diff --git a/handlers/actions.go b/handlers/actions.go index 81a09ea..4e86ac2 100644 --- a/handlers/actions.go +++ b/handlers/actions.go @@ -59,7 +59,7 @@ func getFullInfoByCtx(ctx context.Context) (*models.FullInfo, error) { } resp.State = state if state.RoomID == nil || *state.RoomID == "" { - log.Debug("returning state without room", "username", state.Username) + // log.Debug("returning state without room", "username", state.Username) return resp, nil } // room, err := getRoomByID(state.RoomID) diff --git a/handlers/elements.go b/handlers/elements.go index 12f1c75..9373713 100644 --- a/handlers/elements.go +++ b/handlers/elements.go @@ -293,7 +293,6 @@ func HandleAddBot(w http.ResponseWriter, r *http.Request) { // get team; // get role; make up a name team := r.URL.Query().Get("team") role := r.URL.Query().Get("role") - log.Debug("got add-bot request", "team", team, "role", role) fi, err := getFullInfoByCtx(r.Context()) if err != nil { abortWithError(w, err.Error()) @@ -307,6 +306,7 @@ func HandleAddBot(w http.ResponseWriter, r *http.Request) { } else { botname = fmt.Sprintf("bot_%d", maxID+1) // what if many rooms? } + log.Debug("got add-bot request", "team", team, "role", role, "max_id", maxID, "botname", botname, "error", err) _, err = llmapi.NewBot(role, team, botname, fi.Room.ID, cfg, false) if err != nil { abortWithError(w, err.Error()) diff --git a/handlers/middleware.go b/handlers/middleware.go index ba34d0f..76eb5d2 100644 --- a/handlers/middleware.go +++ b/handlers/middleware.go @@ -62,7 +62,7 @@ func GetSession(next http.Handler) http.Handler { } userSession, err := repo.SessionByToken(r.Context(), sessionToken) if err != nil { - msg := "auth failed; session does not exists" + msg := "auth failed; session does not exist" log.Debug(msg, "error", err, "key", sessionToken) next.ServeHTTP(w, r) return diff --git a/llmapi/main.go b/llmapi/main.go index fd3b3f9..78a8c1f 100644 --- a/llmapi/main.go +++ b/llmapi/main.go @@ -23,8 +23,8 @@ var ( SignalChanMap = make(map[string]chan bool) DoneChanMap = make(map[string]chan bool) // got prompt: control character (\\u0000-\\u001F) found while parsing a string at line 4 column 0 - MimePrompt = `we are playing alias;\nyou are a mime (player who gives a clue of one noun word and number of cards you expect them to open) of the %s team (people who would guess by your clue want open the %s cards);\nplease return your clue, number of cards to open and what words you mean them to find using that clue in json like:\n{\n\"clue\": \"one-word-noun\",\n\"number\": \"number-from-0-to-9\",\n\"words_I_mean_my_team_to_open\": [\"this\", \"that\", ...]\n}\nthe team who openes all their cards first wins.\nplease return json only.\nunopen Blue cards left: %d;\nunopen Red cards left: %d;\nhere is the game info in json:\n%s` - GuesserPrompt = `we are playing alias;\nyou are to guess words of the %s team (you want open %s cards) by given clue and a number of meant guesses;\nplease return your guesses and words that could be meant by the clue, but you do not wish to open yet, in json like:\n{\n\"guesses\": [\"word1\", \"word2\", ...],\n\"could_be\": [\"this\", \"that\", ...]\n}\nthe team who openes all their cards first wins.\nplease return json only.\nunopen Blue cards left: %d;\nunopen Red cards left: %d;\nhere is the cards (and other info), you need to choose revealed==false words:\n%s` + // MimePrompt = `we are playing alias;\nyou are a mime (player who gives a clue of one noun word and number of cards you expect them to open) of the %s team (people who would guess by your clue want open the %s cards);\nplease return your clue, number of cards to open and what words you mean them to find using that clue in json like:\n{\n\"clue\": \"one-word-noun\",\n\"number\": \"number-from-0-to-9\",\n\"words_I_mean_my_team_to_open\": [\"this\", \"that\", ...]\n}\nthe team who openes all their cards first wins.\nplease return json only.\nunopen Blue cards left: %d;\nunopen Red cards left: %d;\nhere is the game info in json:\n%s` + // GuesserPrompt = `we are playing alias;\nyou are to guess words of the %s team (you want open %s cards) by given clue and a number of meant guesses;\nplease return your guesses and words that could be meant by the clue, but you do not wish to open yet, in json like:\n{\n\"guesses\": [\"word1\", \"word2\", ...],\n\"could_be\": [\"this\", \"that\", ...]\n}\nthe team who openes all their cards first wins.\nplease return json only.\nunopen Blue cards left: %d;\nunopen Red cards left: %d;\nhere is the cards (and other info), you need to choose revealed==false words:\n%s` GuesserSimplePrompt = `we are playing game of alias;\n you were given a clue: \"%s\";\nplease return your guess and words that could be meant by the clue, but you do not wish to open yet, in json like:\n{\n\"guess\": \"most_relevant_word_to_the_clue\",\n\"could_be\": [\"this\", \"that\", ...]\n}\nhere is the words that you can choose from:\n%v` MimeSimplePrompt = `we are playing alias;\nyou are to give one word clue and a number of words you mean your team to open; your team words: %v;\nhere are the words of opposite team you want to avoid: %v;\nand here is a black word that is critical not to pick: %s;\nplease return your clue, number of cards to open and what words you mean them to find using that clue in json like:\n{\n\"clue\": \"one-word-noun\",\n\"number\": \"number-from-0-to-9-as-string\",\n\"words_I_mean_my_team_to_open\": [\"this\", \"that\", ...]\n}\nplease return json only.\nunopen Blue cards left: %d;\nunopen Red cards left: %d;` ) @@ -447,9 +447,11 @@ func NewBot(role, team, name, roomID string, cfg *config.Config, recovery bool) return nil, err } } + bot.log.Debug("before adding to ch map", "name", bot.BotName) // buffered channel to send to it in the same goroutine SignalChanMap[bot.BotName] = make(chan bool, 1) DoneChanMap[bot.BotName] = make(chan bool, 1) + bot.log.Debug("after adding to ch map", "name", bot.BotName) go bot.StartBot() // run bot routine return bot, nil } diff --git a/todos.md b/todos.md index bab7c47..ff511c6 100644 --- a/todos.md +++ b/todos.md @@ -89,3 +89,5 @@ - mime sees the clue input out of turn; (eh) - there is a problem of two timers, they both could switch turn, but it is not easy to stop them from llmapi or handlers. + - journal still does not work; + +- lose/win game; then exit room (while being the creator), then press to stats -> cannot find session in db, although cookie in place and session in db; +- player got deleted from db;