using AssortGenerator.Models.Input; using AssortGenerator.Models.Other; using System.Collections.Generic; using System.IO; using System.Linq; using System.Text.Json; namespace AssortGenerator.Common.Helpers { public static class QuestHelper { private static QuestRoot _questData; private static List _assortUnlocks; public static QuestRoot GetQuestData() { if (_questData == null) { var questFilePath = InputFileHelper.GetInputFilePaths().FirstOrDefault(x => x.Contains("resp.client.quest.list")); var questDataJson = File.ReadAllText(questFilePath); _questData = JsonSerializer.Deserialize(questDataJson); } return _questData; } public static List GetAssortUnlocks() { if (_assortUnlocks == null) { _assortUnlocks = new List(); foreach (var quest in GetQuestData().data) { if (quest._id == "5b478b1886f7744d1b23c57d") { var x = 1; } foreach (var reward in quest.rewards.Success) { if (string.Equals(reward.type, "assortmentunlock", System.StringComparison.OrdinalIgnoreCase)) { _assortUnlocks.Add(new AssortUnlocks { AssortUnlockId = reward.id, ItemUnlockedId = reward.target, ItemUnlockedTemplateId = reward.items[0]._tpl, LoyaltyLevel = (int)reward.loyaltyLevel, QuestId = quest._id, QuestRewardId = reward.id, TraderId = reward.traderId, TraderType = TraderHelper.GetTraderTypeById(reward.traderId), Criteria = "Success" } ); } } } } return _assortUnlocks; } } }