mirror of
https://github.com/cliffe/BreakEscape.git
synced 2026-02-21 11:18:08 +00:00
feat(npc): Enhance message handling by adding metadata support in addMessage method
This commit is contained in:
@@ -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) || [];
|
||||
|
||||
Reference in New Issue
Block a user