fix: some buggs

This commit is contained in:
2026-06-19 00:45:30 +03:30
parent f4d99043c4
commit a4cf2b5f39
7 changed files with 266 additions and 10 deletions
@@ -68,13 +68,18 @@ class _GameScreenState extends State<GameScreen> {
duration: const Duration(seconds: 2)),
);
context.read<GameBloc>().clearNotice();
// خطا پیش از شروعِ بازی (مثلاً سکه‌ی ناکافی) ⇒ کاربر در دیالوگِ
// «جستجوی حریف» گیر نکند؛ به لابی برگردد.
if (state.state == null && state.gameOver == null) {
_exitToLobby(context);
}
}
},
builder: (context, state) {
if (state.state != null && _introTimer == null) {
// کمی «حریفان پیدا شد» نشان بده، بعد اوورلی را کنار بزن و همان
// لحظه انیمیشنِ بُر زدن (با صدا) را اجرا کن.
_introTimer = Timer(const Duration(milliseconds: 700), () {
_introTimer = Timer(const Duration(milliseconds: 1000), () {
if (!mounted) return;
setState(() => _introHidden = true);
_game.endIntro();
@@ -90,6 +95,7 @@ class _GameScreenState extends State<GameScreen> {
_trumpPicker(context),
if (state.handResult != null && state.gameOver == null)
_handResult(state),
if (!_showSearch(state) && _isMyPlayTurn(state)) _turnBanner(),
if (state.gameOver != null) _gameOver(context, state),
],
);
@@ -99,6 +105,34 @@ class _GameScreenState extends State<GameScreen> {
);
}
bool _isMyPlayTurn(GameUiState s) =>
s.state != null &&
s.gameOver == null &&
s.state!.phase == 'playing' &&
s.state!.isMyTurn &&
!s.state!.trickDone;
// بنرِ «نوبت شماست» وقتی کاربر باید کارت بیندازد.
Widget _turnBanner() => Align(
alignment: const Alignment(0, 0.46),
child: IgnorePointer(
child: Container(
padding: const EdgeInsets.symmetric(horizontal: 18, vertical: 8),
decoration: BoxDecoration(
gradient: const LinearGradient(
colors: [Color(0xFFE9B949), Color(0xFFB8860B)]),
borderRadius: BorderRadius.circular(20),
boxShadow: const [BoxShadow(color: Colors.black54, blurRadius: 8)],
),
child: const Text('نوبت شماست',
style: TextStyle(
color: Color(0xFF3A0A12),
fontWeight: FontWeight.bold,
fontSize: 16)),
),
),
);
bool _showTrumpPicker(GameUiState s) =>
s.state != null &&
s.state!.phase == 'choose_trump' &&