feat(core): 보물 상자 시스템 추가

- TreasureChest 모델 추가
- ChestService 서비스 추가
This commit is contained in:
JiWoong Sul
2026-01-19 15:49:26 +09:00
parent d41dd0fb90
commit f51bf8c540
2 changed files with 389 additions and 0 deletions

View File

@@ -0,0 +1,115 @@
import 'package:asciineverdie/src/core/model/equipment_item.dart';
/// 상자 보상 타입
enum ChestRewardType {
/// 장비 아이템
equipment,
/// 포션
potion,
/// 골드
gold,
/// 경험치
experience,
}
/// 상자 내용물 (개봉 결과)
class ChestReward {
const ChestReward._({
required this.type,
this.equipment,
this.potionId,
this.potionCount,
this.gold,
this.experience,
});
/// 장비 보상 생성
factory ChestReward.equipment(EquipmentItem item) {
return ChestReward._(
type: ChestRewardType.equipment,
equipment: item,
);
}
/// 포션 보상 생성
factory ChestReward.potion(String potionId, int count) {
return ChestReward._(
type: ChestRewardType.potion,
potionId: potionId,
potionCount: count,
);
}
/// 골드 보상 생성
factory ChestReward.gold(int amount) {
return ChestReward._(
type: ChestRewardType.gold,
gold: amount,
);
}
/// 경험치 보상 생성
factory ChestReward.experience(int amount) {
return ChestReward._(
type: ChestRewardType.experience,
experience: amount,
);
}
/// 보상 타입
final ChestRewardType type;
/// 장비 (type == equipment일 때)
final EquipmentItem? equipment;
/// 포션 ID (type == potion일 때)
final String? potionId;
/// 포션 수량 (type == potion일 때)
final int? potionCount;
/// 골드 (type == gold일 때)
final int? gold;
/// 경험치 (type == experience일 때)
final int? experience;
/// 장비 보상인지 여부
bool get isEquipment => type == ChestRewardType.equipment;
/// 포션 보상인지 여부
bool get isPotion => type == ChestRewardType.potion;
/// 골드 보상인지 여부
bool get isGold => type == ChestRewardType.gold;
/// 경험치 보상인지 여부
bool get isExperience => type == ChestRewardType.experience;
}
/// 복귀 보상 상자 데이터
class ReturnChestReward {
const ReturnChestReward({
required this.hoursAway,
required this.chestCount,
required this.bonusChestCount,
});
/// 떠나있던 시간 (시간 단위)
final int hoursAway;
/// 기본 상자 개수
final int chestCount;
/// 보너스 상자 개수 (광고 시청 시 추가)
final int bonusChestCount;
/// 총 상자 개수 (광고 포함)
int get totalChests => chestCount + bonusChestCount;
/// 보상이 있는지 여부
bool get hasReward => chestCount > 0;
}