Project_WL/Assets/WL/Equip/WLEquipDrops.cs

59 lines
3.2 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// ─────────────────────────────────────────────────────────────────────────────
// WLEquipDrops.cs — 던전 클리어 때 FR 드랍표로 장비·강화석 지급 (#821)
//
// 훅 = `WLIslandBridge.OnStageCleared` 의 `WLIslandExpansionGate.Unlock(cfg);` 다음 1줄.
// FR 의 드랍 규칙(ItemDropGroupTable 10000 분율 → ItemDropPackageTable 가중 추첨)을 그대로 돌린다.
// 값(그룹 ID · 횟수 · 강화석)은 WLEquipSettings.
// ─────────────────────────────────────────────────────────────────────────────
using System.Collections.Generic;
using UnityEngine;
using WL.Combat.Stage;
namespace WL.Equip
{
public static class WLEquipDrops
{
public static string LastGrantLog { get; private set; } = "";
public static int Grants { get; private set; }
static readonly System.Random s_rng = new System.Random();
static readonly List<WLEquipTables.Drop> s_drops = new List<WLEquipTables.Drop>(8);
public static void OnStageCleared(in StageClearResult r)
{
var cfg = WLEquipSettings.Instance;
if (cfg == null || cfg.enabled_ == 0) return;
if (!r.win) return;
int rolls = cfg.clearDropRolls + (r.isBoss ? cfg.bossExtraRolls : 0);
string log = Grant(cfg.clearDropGroupId, rolls, cfg.clearStoneItemIds, cfg.clearStoneCountEach, cfg.clearGoldBonus);
Grants++;
LastGrantLog = "클리어 드랍(" + r.index + ") — " + log;
if (cfg.verboseLog != 0) Debug.Log("[WL-821] " + LastGrantLog);
}
/// <summary>드랍 그룹을 rolls 번 굴려 지급 + 강화석 + 골드. 돌려주는 문자열 = 지급 내역.</summary>
public static string Grant(int groupId, int rolls, int[] stoneIds, int stoneEach, int goldBonus)
{
if (!WLInventory.EnsureLoaded()) return "인벤 로드 실패";
s_drops.Clear();
for (int i = 0; i < rolls; i++) WLEquipTables.RollDropGroup(groupId, s_drops, s_rng);
var gained = new List<Item>();
var sb = new System.Text.StringBuilder();
for (int i = 0; i < s_drops.Count; i++)
{
WLInventory.AddItem(s_drops[i].itemId, 1, s_drops[i].count, gained);
var j = WLEquipTables.FindItemJson(s_drops[i].itemId);
sb.Append(j != null ? j.Item_name : s_drops[i].itemId.ToString()).Append("×").Append(s_drops[i].count).Append(' ');
}
if (stoneIds != null && stoneEach > 0)
{
for (int i = 0; i < stoneIds.Length; i++) WLInventory.AddItem(stoneIds[i], 1, stoneEach);
sb.Append("강화석 ").Append(stoneIds.Length).Append("종×").Append(stoneEach).Append(' ');
}
if (goldBonus > 0) { WLInventory.AddGold(goldBonus); sb.Append("골드+").Append(goldBonus); }
WLInventory.Commit("획득 — " + sb);
return sb.ToString();
}
}
}