feat: refactor code
This commit is contained in:
@@ -0,0 +1,89 @@
|
||||
/// موجودیتهای کاتالوگ فروشگاه (مستقل از JSON).
|
||||
class CoinPackage {
|
||||
final String id;
|
||||
final String title;
|
||||
final int coins;
|
||||
final int vipDays;
|
||||
final int priceToman;
|
||||
final int bonusPct;
|
||||
const CoinPackage({
|
||||
required this.id,
|
||||
required this.title,
|
||||
required this.coins,
|
||||
required this.vipDays,
|
||||
required this.priceToman,
|
||||
required this.bonusPct,
|
||||
});
|
||||
}
|
||||
|
||||
class TicketPackage {
|
||||
final String id;
|
||||
final String title;
|
||||
final int tickets;
|
||||
final int priceToman;
|
||||
const TicketPackage({
|
||||
required this.id,
|
||||
required this.title,
|
||||
required this.tickets,
|
||||
required this.priceToman,
|
||||
});
|
||||
}
|
||||
|
||||
class CardSkin {
|
||||
final String id;
|
||||
final String title;
|
||||
final int priceCoins;
|
||||
const CardSkin(
|
||||
{required this.id, required this.title, required this.priceCoins});
|
||||
}
|
||||
|
||||
class Booster {
|
||||
final String id;
|
||||
final String title;
|
||||
final int multiplier;
|
||||
final int hours;
|
||||
final int priceToman;
|
||||
const Booster({
|
||||
required this.id,
|
||||
required this.title,
|
||||
required this.multiplier,
|
||||
required this.hours,
|
||||
required this.priceToman,
|
||||
});
|
||||
}
|
||||
|
||||
class VipPackage {
|
||||
final String id;
|
||||
final String title;
|
||||
final int months;
|
||||
final int priceToman;
|
||||
const VipPackage({
|
||||
required this.id,
|
||||
required this.title,
|
||||
required this.months,
|
||||
required this.priceToman,
|
||||
});
|
||||
}
|
||||
|
||||
/// کلِ دادهی فروشگاه: کاتالوگ + کارتهای متعلق به کاربر + کارت انتخابی.
|
||||
class ShopData {
|
||||
final List<CoinPackage> coinPackages;
|
||||
final List<TicketPackage> ticketPackages;
|
||||
final List<CardSkin> cardSkins;
|
||||
final List<Booster> boosters;
|
||||
final List<VipPackage> vipPackages;
|
||||
final List<String> ownedCards;
|
||||
final String selectedCard;
|
||||
|
||||
const ShopData({
|
||||
required this.coinPackages,
|
||||
required this.ticketPackages,
|
||||
required this.cardSkins,
|
||||
required this.boosters,
|
||||
required this.vipPackages,
|
||||
required this.ownedCards,
|
||||
required this.selectedCard,
|
||||
});
|
||||
|
||||
bool owns(String cardId) => cardId == 'simple' || ownedCards.contains(cardId);
|
||||
}
|
||||
Reference in New Issue
Block a user