feat: add message feature

This commit is contained in:
2026-06-25 01:11:34 +03:30
parent e8cde8e1f7
commit fa45ef0737
6 changed files with 274 additions and 8 deletions
@@ -47,6 +47,15 @@ class TableLobby {
'${players.map((p) => '${p.name}${p.host ? '*' : ''}@${p.seat}').join(',')}';
}
/// حبابِ پیام/شکلکِ یک بازیکن که کنارِ آواتارش نشان داده می‌شود.
/// id برای انقضای دقیق (پاک‌کردنِ همین حباب و نه حبابِ جدیدتر) به‌کار می‌رود.
class ChatBubble {
final String? text;
final String? emoji;
final int id;
const ChatBubble({this.text, this.emoji, required this.id});
}
class GameUiState extends Equatable {
final WsStatus connection;
final GameState? state;
@@ -56,6 +65,7 @@ class GameUiState extends Equatable {
final TableLobby? lobby;
final int? countdown;
final bool tableClosed;
final Map<int, ChatBubble> chatBubbles; // جایگاه ⇒ حبابِ پیامِ فعال
const GameUiState({
this.connection = WsStatus.connecting,
@@ -66,6 +76,7 @@ class GameUiState extends Equatable {
this.lobby,
this.countdown,
this.tableClosed = false,
this.chatBubbles = const {},
});
GameUiState copyWith({
@@ -77,6 +88,7 @@ class GameUiState extends Equatable {
TableLobby? lobby,
int? countdown,
bool? tableClosed,
Map<int, ChatBubble>? chatBubbles,
bool clearHandResult = false,
bool clearNotice = false,
}) =>
@@ -89,6 +101,7 @@ class GameUiState extends Equatable {
lobby: lobby ?? this.lobby,
countdown: countdown ?? this.countdown,
tableClosed: tableClosed ?? this.tableClosed,
chatBubbles: chatBubbles ?? this.chatBubbles,
);
@override
@@ -101,5 +114,8 @@ class GameUiState extends Equatable {
lobby?.sig,
countdown,
tableClosed,
chatBubbles.entries
.map((e) => '${e.key}:${e.value.id}')
.join(','),
];
}