2025-09-18 10:39:54 +07:00
|
|
|
part of '../game.dart';
|
|
|
|
|
|
|
|
|
|
@freezed
|
2026-10-01 01:43:22 +07:00
|
|
|
abstract class Game with _$Game {
|
|
|
|
|
const Game._();
|
|
|
|
|
|
2025-09-18 10:39:54 +07:00
|
|
|
const factory Game({
|
|
|
|
|
required String id,
|
|
|
|
|
required String name,
|
|
|
|
|
required String type,
|
|
|
|
|
required bool isActive,
|
|
|
|
|
required Map<String, dynamic> metadata,
|
2025-09-18 14:53:39 +07:00
|
|
|
required List<GamePrize> prizes,
|
2025-09-18 10:39:54 +07:00
|
|
|
required String createdAt,
|
|
|
|
|
required String updatedAt,
|
|
|
|
|
}) = _Game;
|
|
|
|
|
|
|
|
|
|
factory Game.empty() => const Game(
|
|
|
|
|
id: '',
|
|
|
|
|
name: '',
|
|
|
|
|
type: '',
|
|
|
|
|
isActive: false,
|
|
|
|
|
metadata: {},
|
2025-09-18 14:53:39 +07:00
|
|
|
prizes: [],
|
2025-09-18 10:39:54 +07:00
|
|
|
createdAt: '',
|
|
|
|
|
updatedAt: '',
|
|
|
|
|
);
|
2026-10-01 01:43:22 +07:00
|
|
|
|
|
|
|
|
/// Biaya sekali main dalam EnakCoin (`metadata.coin_cost`), default 1.
|
|
|
|
|
int get coinCost {
|
|
|
|
|
final value = metadata['coin_cost'];
|
|
|
|
|
final cost = value is num ? value.toInt() : int.tryParse('$value');
|
|
|
|
|
return cost == null || cost <= 0 ? 1 : cost;
|
|
|
|
|
}
|
2025-09-18 10:39:54 +07:00
|
|
|
}
|