From fc0c5edc3829b806c5fa2f9a14213b369e66bedc Mon Sep 17 00:00:00 2001 From: tolelom <98kimsungmin@naver.com> Date: Wed, 25 Mar 2026 14:05:04 +0900 Subject: [PATCH] feat: add chat emote system (/hi, /gg, /go, /wait, /help) Co-Authored-By: Claude Opus 4.6 (1M context) --- game/emote.go | 17 +++++++++++++++++ game/emote_test.go | 31 +++++++++++++++++++++++++++++++ game/session.go | 6 +++++- 3 files changed, 53 insertions(+), 1 deletion(-) create mode 100644 game/emote.go create mode 100644 game/emote_test.go diff --git a/game/emote.go b/game/emote.go new file mode 100644 index 0000000..5535d03 --- /dev/null +++ b/game/emote.go @@ -0,0 +1,17 @@ +package game + +var emotes = map[string]string{ + "/hi": "👋 waves hello!", + "/gg": "🎉 says GG!", + "/go": "⚔️ says Let's go!", + "/wait": "✋ says Wait!", + "/help": "🆘 calls for help!", +} + +func ParseEmote(input string) (string, bool) { + if input == "" { + return "", false + } + text, ok := emotes[input] + return text, ok +} diff --git a/game/emote_test.go b/game/emote_test.go new file mode 100644 index 0000000..bc21243 --- /dev/null +++ b/game/emote_test.go @@ -0,0 +1,31 @@ +package game + +import "testing" + +func TestParseEmote(t *testing.T) { + tests := []struct { + input string + isEmote bool + expected string + }{ + {"/hi", true, "👋 waves hello!"}, + {"/gg", true, "🎉 says GG!"}, + {"/go", true, "⚔️ says Let's go!"}, + {"/wait", true, "✋ says Wait!"}, + {"/help", true, "🆘 calls for help!"}, + {"/unknown", false, ""}, + {"hello", false, ""}, + {"", false, ""}, + } + for _, tt := range tests { + t.Run(tt.input, func(t *testing.T) { + result, ok := ParseEmote(tt.input) + if ok != tt.isEmote { + t.Errorf("ParseEmote(%q) isEmote = %v, want %v", tt.input, ok, tt.isEmote) + } + if ok && result != tt.expected { + t.Errorf("ParseEmote(%q) = %q, want %q", tt.input, result, tt.expected) + } + }) + } +} diff --git a/game/session.go b/game/session.go index 0deb957..f48b692 100644 --- a/game/session.go +++ b/game/session.go @@ -361,7 +361,11 @@ func (s *GameSession) BuyItem(playerID string, itemIdx int) bool { func (s *GameSession) SendChat(playerName, message string) { s.mu.Lock() defer s.mu.Unlock() - s.addLog(fmt.Sprintf("[%s] %s", playerName, message)) + if emoteText, ok := ParseEmote(message); ok { + s.addLog(fmt.Sprintf("✨ %s %s", playerName, emoteText)) + } else { + s.addLog(fmt.Sprintf("[%s] %s", playerName, message)) + } } // LeaveShop exits the shop phase