From 18ad0f5f42e3bc723e7941b8e085913c9b00577c Mon Sep 17 00:00:00 2001 From: "Grail Finder (aider)" Date: Fri, 21 Mar 2025 18:30:39 +0300 Subject: feat: add Cluedo game mode with turn-based card reminders --- bot.go | 20 +++++++++++++++++++- config/config.go | 2 ++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/bot.go b/bot.go index e7cedc5..4fc037c 100644 --- a/bot.go +++ b/bot.go @@ -50,6 +50,8 @@ func createClient(connectTimeout time.Duration) *http.Client { } var ( + cluedoState *extra.CluedoRoundInfo // Current game state + playerOrder []string // Turn order tracking cfg *config.Config logger *slog.Logger logLevel = new(slog.LevelVar) @@ -290,6 +292,22 @@ func chatRound(userMsg, role string, tv *tview.TextView, regen, resume bool) { } go sendMsgToLLM(reader) logger.Debug("looking at vars in chatRound", "msg", userMsg, "regen", regen, "resume", resume) + + // Handle Cluedo game flow + if cfg.EnableCluedo && cluedoState != nil && !resume { + currentPlayer := playerOrder[0] + playerOrder = append(playerOrder[1:], currentPlayer) // Rotate turns + if role == cfg.UserRole { + userMsg = fmt.Sprintf("Your cards: %s\n%s", + cluedoState.GetPlayerCards(currentPlayer), userMsg) + } else { + chatBody.Messages = append(chatBody.Messages, models.RoleMsg{ + Role: cfg.ToolRole, + Content: cluedoState.GetPlayerCards(currentPlayer), + }) + } + } + if !resume { fmt.Fprintf(tv, "[-:-:b](%d) ", len(chatBody.Messages)) fmt.Fprint(tv, roleToIcon(cfg.AssistantRole)) @@ -378,7 +396,7 @@ func chatToText(showSys bool) string { func removeThinking(chatBody *models.ChatBody) { msgs := []models.RoleMsg{} for _, msg := range chatBody.Messages { - rm := models.RoleMsg{} + // Filter out tool messages and thinking markers if msg.Role == cfg.ToolRole { continue } diff --git a/config/config.go b/config/config.go index cf7685b..b48d657 100644 --- a/config/config.go +++ b/config/config.go @@ -7,6 +7,8 @@ import ( ) type Config struct { + EnableCluedo bool `toml:"EnableCluedo"` // Cluedo game mode toggle + CluedoRole2 string `toml:"CluedoRole2"` // Secondary AI role name ChatAPI string `toml:"ChatAPI"` CompletionAPI string `toml:"CompletionAPI"` CurrentAPI string -- cgit v1.2.3