feat: add carpet
This commit is contained in:
@@ -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});
|
||||
}
|
||||
Reference in New Issue
Block a user