feat: interactive oracle session chat and dynamic draw additional d10 cards for context refinement

This commit is contained in:
Alma Alexyz
2026-08-31 15:31:51 +05:00
parent 95c64ce1cd
commit 10c3fee083
3 changed files with 734 additions and 224 deletions
+43 -1
View File
@@ -48,6 +48,40 @@ class SessionWord {
);
}
class SessionChatMessage {
final String id;
final String sender; // 'user' | 'oracle' | 'system'
final String text;
final DateTime timestamp;
final SessionWord? attachedWord;
const SessionChatMessage({
required this.id,
required this.sender,
required this.text,
required this.timestamp,
this.attachedWord,
});
Map<String, dynamic> toMap() => {
'id': id,
'sender': sender,
'text': text,
'timestamp': timestamp.toIso8601String(),
if (attachedWord != null) 'attachedWord': attachedWord!.toMap(),
};
factory SessionChatMessage.fromMap(Map<String, dynamic> map) => SessionChatMessage(
id: map['id'] as String? ?? '',
sender: map['sender'] as String? ?? 'oracle',
text: map['text'] as String? ?? '',
timestamp: DateTime.tryParse(map['timestamp'] as String? ?? '') ?? DateTime.now(),
attachedWord: map['attachedWord'] != null
? SessionWord.fromMap(map['attachedWord'] as Map<String, dynamic>)
: null,
);
}
class OracleSession {
final String id;
final DateTime timestamp;
@@ -55,6 +89,7 @@ class OracleSession {
final int wordsCount;
final List<SessionWord> words;
final String? aiInterpretation;
final List<SessionChatMessage> messages;
const OracleSession({
required this.id,
@@ -63,6 +98,7 @@ class OracleSession {
required this.wordsCount,
required this.words,
this.aiInterpretation,
this.messages = const [],
});
OracleSession copyWith({
@@ -72,6 +108,7 @@ class OracleSession {
int? wordsCount,
List<SessionWord>? words,
String? aiInterpretation,
List<SessionChatMessage>? messages,
}) {
return OracleSession(
id: id ?? this.id,
@@ -80,6 +117,7 @@ class OracleSession {
wordsCount: wordsCount ?? this.wordsCount,
words: words ?? this.words,
aiInterpretation: aiInterpretation ?? this.aiInterpretation,
messages: messages ?? this.messages,
);
}
@@ -100,6 +138,7 @@ class OracleSession {
'wordsCount': wordsCount,
'words': words.map((w) => w.toMap()).toList(),
if (aiInterpretation != null) 'aiInterpretation': aiInterpretation,
'messages': messages.map((m) => m.toMap()).toList(),
};
factory OracleSession.fromMap(Map<String, dynamic> map) {
@@ -113,6 +152,10 @@ class OracleSession {
.toList() ??
[],
aiInterpretation: map['aiInterpretation'] as String?,
messages: (map['messages'] as List<dynamic>?)
?.map((item) => SessionChatMessage.fromMap(item as Map<String, dynamic>))
.toList() ??
[],
);
}
@@ -120,5 +163,4 @@ class OracleSession {
factory OracleSession.fromJson(String source) => OracleSession.fromMap(jsonDecode(source));
}
// Backward compatibility alias
typedef HistoryEntry = OracleSession;