From 1bd037d96992c2469a68fd9a46b6811b4fb36958 Mon Sep 17 00:00:00 2001 From: "Z. Cliffe Schreuders" Date: Sat, 1 Nov 2025 10:42:37 +0000 Subject: [PATCH] feat(npc): Enhance message handling by adding metadata support in addMessage method --- js/systems/npc-manager.js | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/js/systems/npc-manager.js b/js/systems/npc-manager.js index 2f612ea..8dc5cb3 100644 --- a/js/systems/npc-manager.js +++ b/js/systems/npc-manager.js @@ -104,7 +104,7 @@ export default class NPCManager { this.barkSystem = barkSystem; } - // Add a message to conversation history + // Add a message to conversation history (internal method) addMessageToHistory(npcId, type, text) { if (!this.conversationHistory.has(npcId)) { this.conversationHistory.set(npcId, []); @@ -118,6 +118,21 @@ export default class NPCManager { this._log('debug', `Added ${type} message to ${npcId} history:`, text); } + // Public API: Add a message with full metadata (used by external systems) + addMessage(npcId, type, text, metadata = {}) { + if (!this.conversationHistory.has(npcId)) { + this.conversationHistory.set(npcId, []); + } + this.conversationHistory.get(npcId).push({ + type, + text, + timestamp: Date.now(), + read: type === 'player', // Player messages are automatically marked as read + ...metadata + }); + this._log('debug', `Added ${type} message to ${npcId}:`, text); + } + // Get conversation history for an NPC getConversationHistory(npcId) { return this.conversationHistory.get(npcId) || [];