feat: rotate table players

This commit is contained in:
2026-06-19 23:18:51 +03:30
parent 04b97ca163
commit 0c8fd22264
5 changed files with 540 additions and 297 deletions
@@ -7,7 +7,8 @@ import '../../domain/entities/game_entities.dart';
class LobbyPlayer {
final String name;
final bool host;
const LobbyPlayer(this.name, this.host);
final int seat; // جایگاهِ مطلق (۰..۳)
const LobbyPlayer(this.name, this.host, this.seat);
}
/// وضعیت اتاق انتظارِ میز خصوصی (دورهمی).
@@ -15,12 +16,14 @@ class TableLobby {
final String code;
final List<LobbyPlayer> players;
final bool isHost;
final int youSeat; // جایگاهِ مطلقِ خودِ کاربر (برای چیدمانِ صحنه)
final int remaining;
final bool unlimited;
const TableLobby({
required this.code,
required this.players,
required this.isHost,
required this.youSeat,
required this.remaining,
required this.unlimited,
});
@@ -29,15 +32,19 @@ class TableLobby {
code: (j['code'] ?? '') as String,
players: ((j['players'] as List?) ?? [])
.map((e) => LobbyPlayer(
(e['name'] ?? '') as String, (e['host'] ?? false) as bool))
(e['name'] ?? '') as String,
(e['host'] ?? false) as bool,
(e['seat'] ?? 0) as int,
))
.toList(),
isHost: (j['host'] ?? false) as bool,
youSeat: (j['you_seat'] ?? 0) as int,
remaining: (j['remaining'] ?? 0) as int,
unlimited: (j['unlimited'] ?? false) as bool,
);
String get sig => '$code|$isHost|$remaining|$unlimited|'
'${players.map((p) => '${p.name}${p.host ? '*' : ''}').join(',')}';
String get sig => '$code|$isHost|$youSeat|$remaining|$unlimited|'
'${players.map((p) => '${p.name}${p.host ? '*' : ''}@${p.seat}').join(',')}';
}
class GameUiState extends Equatable {