feat: add characters

This commit is contained in:
2026-07-10 00:56:58 +03:30
parent 7c067d36f2
commit 97d156c492
28 changed files with 486 additions and 94 deletions
@@ -0,0 +1,34 @@
/// یک شخصیتِ آواتار (کازمتیک تصویری). owned یعنی قابلِ انتخاب.
class AvatarCharacter {
final String id;
final String title;
final int priceCoins;
final bool vip;
final String img; // نامِ فایل: <id>.<ext> (برای ساختِ URL و انتخابِ رندرر)
final bool owned;
const AvatarCharacter({
required this.id,
required this.title,
required this.priceCoins,
required this.vip,
required this.img,
required this.owned,
});
factory AvatarCharacter.fromJson(Map<String, dynamic> j) => AvatarCharacter(
id: (j['id'] ?? '') as String,
title: (j['title'] ?? '') as String,
priceCoins: (j['price_coins'] ?? 0) as int,
vip: (j['vip'] ?? false) as bool,
img: (j['img'] ?? '') as String,
owned: (j['owned'] ?? false) as bool,
);
}
/// کاتالوگِ شخصیت‌ها + شناسه‌ی شخصیتِ انتخابیِ کاربر (خالی ⇒ آواتارِ تصادفی).
class AvatarCatalog {
final List<AvatarCharacter> avatars;
final String selected;
const AvatarCatalog({required this.avatars, required this.selected});
}
+4 -5
View File
@@ -1,11 +1,10 @@
import '../../../../core/config.dart';
/// یک فرشِ ایرانی که به‌جای میزِ بازی استفاده می‌شود. تصویر از backend می‌آید.
/// یک فرشِ ایرانی که به‌جای میزِ بازی استفاده می‌شود. تصویر (URL کامل) از backend می‌آید.
class Carpet {
final String id;
final String title;
final int priceCoins;
final bool vip; // برای VIP رایگان
final String img; // URL کاملِ تصویر (از سرور)؛ خالی برای classic
final bool owned;
const Carpet({
@@ -13,19 +12,19 @@ class Carpet {
required this.title,
required this.priceCoins,
required this.vip,
required this.img,
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,
img: (j['img'] ?? '') as String,
owned: (j['owned'] ?? false) as bool,
);
}