From dee3fbad6d3d354959e5151cb7ac51f1e244953a Mon Sep 17 00:00:00 2001 From: Amirmahdi Nourkazemi Date: Mon, 15 Jun 2026 17:50:38 +0330 Subject: [PATCH] feat: drag and undrag state --- lib/features/game/flame/card_component.dart | 2 ++ lib/features/game/flame/hokm_game.dart | 1 + 2 files changed, 3 insertions(+) diff --git a/lib/features/game/flame/card_component.dart b/lib/features/game/flame/card_component.dart index 6f4764e..9d1c45a 100644 --- a/lib/features/game/flame/card_component.dart +++ b/lib/features/game/flame/card_component.dart @@ -16,6 +16,7 @@ class CardComponent extends PositionComponent VoidCallback? onPlay; // در صورت مجاز بودن، بازیِ این کارت bool dimmed; // کارت غیرمجاز/غیرفعال Vector2? home; // موقعیت اصلی در دست (برای برگشت پس از کشیدنِ ناقص) + int restPriority = 0; // ترتیب لایه‌ی اصلی در دست (برای بازگردانی پس از کشیدن) Rect? dropZone; // ناحیه‌ی وسط میز؛ رهاکردن کارت در آن یعنی بازی Sprite? _sprite; bool _dragging = false; @@ -97,6 +98,7 @@ class CardComponent extends PositionComponent } void _returnHome() { + priority = restPriority; // بازگردانی ترتیب لایه تا روی کارت‌های دیگر نیفتد if (home == null) return; add(MoveToEffect(home!, EffectController(duration: 0.2, curve: Curves.easeOut))); } diff --git a/lib/features/game/flame/hokm_game.dart b/lib/features/game/flame/hokm_game.dart index 0f3b58e..293dc06 100644 --- a/lib/features/game/flame/hokm_game.dart +++ b/lib/features/game/flame/hokm_game.dart @@ -234,6 +234,7 @@ class HokmGame extends FlameGame { c.dimmed = dim; c.home = target; c.dropZone = _dropZone(); + c.restPriority = 10 + i; c.priority = 10 + i; _moveTo(c, target); }