feat: add carpet

This commit is contained in:
2026-07-03 21:56:34 +03:30
parent 5160deb973
commit 7acd72c286
21 changed files with 536 additions and 156 deletions
@@ -0,0 +1,38 @@
import '../../../../core/config.dart';
/// یک فرشِ ایرانی که به‌جای میزِ بازی استفاده می‌شود. تصویر از backend می‌آید.
class Carpet {
final String id;
final String title;
final int priceCoins;
final bool vip; // برای VIP رایگان
final bool owned;
const Carpet({
required this.id,
required this.title,
required this.priceCoins,
required this.vip,
required this.owned,
});
/// 'classic' یعنی میزِ ترسیمیِ پیش‌فرض (بدون تصویر).
bool get isClassic => id == 'classic';
String get imageUrl => '${AppConfig.baseUrl}/carpets/$id.jpg';
factory Carpet.fromJson(Map<String, dynamic> j) => Carpet(
id: (j['id'] ?? '') as String,
title: (j['title'] ?? '') as String,
priceCoins: (j['price_coins'] ?? 0) as int,
vip: (j['vip'] ?? false) as bool,
owned: (j['owned'] ?? false) as bool,
);
}
/// نتیجه‌ی دریافتِ فرش‌ها: فهرست + شناسه‌ی فرشِ انتخابی.
class CarpetCatalog {
final List<Carpet> carpets;
final String selected;
const CarpetCatalog({required this.carpets, required this.selected});
}