feat(balance): 레벨 기반 장비 손실 확률 시스템

- 저레벨 사망 스파이럴 방지
- 장비 손실 확률 = (레벨 - 5) * 10%
  - Lv 1~5: 0% (절대 안전)
  - Lv 6: 10%
  - Lv 10: 50%
  - Lv 15+: 100%
- 디버그 로그 추가
This commit is contained in:
JiWoong Sul
2026-01-16 00:17:08 +09:00
parent 9e5472728f
commit 306715ca26

View File

@@ -974,40 +974,50 @@ class ProgressService {
ItemRarity? lostItemRarity;
if (!isBossDeath) {
// 무기(슬롯 0)를 제외한 장착된 장비 중 1개를 제물로 삭제
final equippedNonWeaponSlots = <int>[];
for (var i = 1; i < Equipment.slotCount; i++) {
final item = state.equipment.getItemByIndex(i);
// 디버그: 장비 슬롯 상태 확인
// ignore: avoid_print
print('[Death] Slot $i: "${item.name}" isEmpty=${item.isEmpty}');
if (item.isNotEmpty) {
equippedNonWeaponSlots.add(i);
}
}
// 디버그: 장착된 슬롯 목록
// 레벨 기반 장비 손실 확률 계산
// Lv 1~5: 0%, Lv 6: 10%, Lv 10: 50%, Lv 15+: 100%
final level = state.traits.level;
final lossChancePercent = ((level - 5) * 10).clamp(0, 100);
final roll = state.rng.nextInt(100); // 0~99
final shouldLoseEquipment = roll < lossChancePercent;
// ignore: avoid_print
print('[Death] equippedNonWeaponSlots: $equippedNonWeaponSlots');
print('[Death] Lv$level lossChance=$lossChancePercent% roll=$roll '
'shouldLose=$shouldLoseEquipment');
if (equippedNonWeaponSlots.isNotEmpty) {
lostCount = 1;
// 랜덤하게 1개 슬롯 선택
final sacrificeIndex =
equippedNonWeaponSlots[state.rng.nextInt(
equippedNonWeaponSlots.length,
)];
if (shouldLoseEquipment) {
// 무기(슬롯 0)를 제외한 장착된 장비 중 1개를 제물로 삭제
final equippedNonWeaponSlots = <int>[];
for (var i = 1; i < Equipment.slotCount; i++) {
final item = state.equipment.getItemByIndex(i);
if (item.isNotEmpty) {
equippedNonWeaponSlots.add(i);
}
}
// 제물로 바칠 아이템 정보 저장
final lostItem = state.equipment.getItemByIndex(sacrificeIndex);
lostItemName = lostItem.name;
lostItemSlot = EquipmentSlot.values[sacrificeIndex];
lostItemRarity = lostItem.rarity;
if (equippedNonWeaponSlots.isNotEmpty) {
lostCount = 1;
// 랜덤하게 1개 슬롯 선택
final sacrificeIndex =
equippedNonWeaponSlots[state.rng.nextInt(
equippedNonWeaponSlots.length,
)];
// 해당 슬롯을 빈 장비로 교체
newEquipment = newEquipment.setItemByIndex(
sacrificeIndex,
EquipmentItem.empty(lostItemSlot),
);
// 제물로 바칠 아이템 정보 저장
final lostItem = state.equipment.getItemByIndex(sacrificeIndex);
lostItemName = lostItem.name;
lostItemSlot = EquipmentSlot.values[sacrificeIndex];
lostItemRarity = lostItem.rarity;
// 해당 슬롯을 빈 장비로 교체
newEquipment = newEquipment.setItemByIndex(
sacrificeIndex,
EquipmentItem.empty(lostItemSlot),
);
// ignore: avoid_print
print('[Death] Lost item: $lostItemName (slot: $lostItemSlot)');
}
}
}