2021-09-05 20:54:44 +01:00
|
|
|
|
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> _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<QuestRoot>(questDataJson);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return _questData;
|
|
|
|
|
}
|
|
|
|
|
|
2023-07-09 11:36:00 +01:00
|
|
|
|
public static Dictionary<string, Quest> GetFinalisedQuestData()
|
|
|
|
|
{
|
|
|
|
|
var questFilePath = InputFileHelper.GetInputFilePaths().FirstOrDefault(x => x.Contains("quests.json"));
|
|
|
|
|
var questDataJson = File.ReadAllText(questFilePath);
|
|
|
|
|
var finalisedQuestData = JsonSerializer.Deserialize<Dictionary<string, Quest>> (questDataJson);
|
|
|
|
|
|
|
|
|
|
var jsondoc = JsonDocument.Parse(questDataJson);
|
|
|
|
|
var root = jsondoc.RootElement;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return finalisedQuestData;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static JsonDocument GetFinalisedQuestDataJsonDoc()
|
|
|
|
|
{
|
|
|
|
|
var questFilePath = InputFileHelper.GetInputFilePaths().FirstOrDefault(x => x.Contains("quests.json"));
|
|
|
|
|
var questDataJson = File.ReadAllText(questFilePath);
|
|
|
|
|
|
|
|
|
|
var jsondoc = JsonDocument.Parse(questDataJson);
|
|
|
|
|
|
|
|
|
|
return jsondoc;
|
|
|
|
|
}
|
|
|
|
|
|
2021-09-05 20:54:44 +01:00
|
|
|
|
public static List<AssortUnlocks> GetAssortUnlocks()
|
|
|
|
|
{
|
|
|
|
|
if (_assortUnlocks == null)
|
|
|
|
|
{
|
|
|
|
|
_assortUnlocks = new List<AssortUnlocks>();
|
|
|
|
|
foreach (var quest in GetQuestData().data)
|
|
|
|
|
{
|
2023-07-09 11:36:00 +01:00
|
|
|
|
// debut
|
|
|
|
|
if (quest._id == "5936d90786f7742b1420ba5b")
|
|
|
|
|
{
|
|
|
|
|
var x = 2;
|
|
|
|
|
}
|
|
|
|
|
|
2021-09-05 20:54:44 +01:00
|
|
|
|
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),
|
2023-01-31 17:32:55 +00:00
|
|
|
|
Criteria = "Success",
|
|
|
|
|
Items = reward.items
|
2021-09-05 20:54:44 +01:00
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-01-28 12:01:59 +00:00
|
|
|
|
foreach (var reward in quest.rewards.Started)
|
|
|
|
|
{
|
|
|
|
|
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),
|
2023-01-31 17:32:55 +00:00
|
|
|
|
Criteria = "Started",
|
|
|
|
|
Items = reward.items
|
2023-01-28 12:01:59 +00:00
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-09-05 20:54:44 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return _assortUnlocks;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|