This commit is contained in:
Boki 2026-02-26 20:45:24 -05:00
parent 53641fc8e7
commit 657d307485
28 changed files with 2045 additions and 161 deletions

View file

@ -37,6 +37,58 @@ public class SavedSettings
public bool ShowHudDebug { get; set; }
public string OcrEngine { get; set; } = "WinOCR";
public KulemakSettings Kulemak { get; set; } = new();
public DiamondSettings Diamond { get; set; } = new();
}
public class DiamondPriceConfig
{
public string ItemName { get; set; } = "";
public string DisplayName { get; set; } = "";
public double MaxDivinePrice { get; set; }
public bool Enabled { get; set; } = true;
}
public class DiamondSettings
{
public static readonly Dictionary<string, string> KnownDiamonds = new()
{
["SanctumJewel"] = "Time-Lost Diamond",
["SacredFlameJewel"] = "Prism of Belief",
["TrialmasterJewel"] = "The Adorned",
["DeliriumJewel"] = "Megalomaniac Diamond",
["ApostatesHeart"] = "Heart of the Well",
};
public List<DiamondPriceConfig> Prices { get; set; } = DefaultPrices();
private static List<DiamondPriceConfig> DefaultPrices() =>
KnownDiamonds.Select(kv => new DiamondPriceConfig
{
ItemName = kv.Key,
DisplayName = kv.Value,
MaxDivinePrice = 0,
Enabled = false,
}).ToList();
/// <summary>Ensure all known diamonds exist in the list (adds missing ones as disabled).</summary>
public void BackfillKnown()
{
// Remove blank entries
Prices.RemoveAll(p => string.IsNullOrWhiteSpace(p.ItemName));
var existing = new HashSet<string>(Prices.Select(p => p.ItemName), StringComparer.OrdinalIgnoreCase);
foreach (var kv in KnownDiamonds)
{
if (existing.Contains(kv.Key)) continue;
Prices.Add(new DiamondPriceConfig
{
ItemName = kv.Key,
DisplayName = kv.Value,
MaxDivinePrice = 0,
Enabled = false,
});
}
}
}
public class KulemakSettings
@ -71,7 +123,16 @@ public class ConfigStore
public void AddLink(string url, string name = "", LinkMode mode = LinkMode.Live, PostAction? postAction = null)
{
url = StripLive(url);
if (_data.Links.Any(l => l.Url == url)) return;
var existing = _data.Links.FirstOrDefault(l => l.Url == url);
if (existing != null)
{
// Update mode/postAction/name if re-added with different settings
existing.Mode = mode;
existing.PostAction = postAction ?? (mode == LinkMode.Scrap ? PostAction.Salvage : PostAction.Stash);
if (!string.IsNullOrEmpty(name)) existing.Name = name;
Save();
return;
}
_data.Links.Add(new SavedLink
{
Url = url,
@ -177,6 +238,9 @@ public class ConfigStore
link.Url = StripLive(link.Url);
}
// Backfill known diamonds
parsed.Diamond.BackfillKnown();
Log.Information("Loaded config.json from {Path} ({LinkCount} links)", _filePath, parsed.Links.Count);
return parsed;
}