Add helper functions to questhelper

This commit is contained in:
Chomp 2022-01-12 15:07:53 +00:00
parent 52d2f769c1
commit f4d2c20fca

View File

@ -259,21 +259,21 @@ namespace AssortValidator.Common.Helpers
{ "6179afd0bca27a099552e040", "Lost Contact"},
{ "613708a7f8333a5d15594368", "Action Test"}
};
private static QuestRoot _liveQuestData;
private static Dictionary<string, Quest> _liveQuestData;
public static QuestRoot GetLiveQuestData(string filename = "resp.client.quest.list")
public static Dictionary<string, Quest> GetQuestData(string filename = "resp.client.quest.list")
{
if (_liveQuestData == null)
{
var questFilePath = InputFileHelper.GetInputFilePaths().FirstOrDefault(x => x.Contains(filename));
var questDataJson = File.ReadAllText(questFilePath);
_liveQuestData = JsonSerializer.Deserialize<QuestRoot>(questDataJson);
_liveQuestData = JsonSerializer.Deserialize<Dictionary<string, Quest>>(questDataJson);
}
return _liveQuestData;
}
public static List<QuestAssortUnlock> GetQuestAssortUnlocks(List<Quest> quests)
public static List<QuestAssortUnlock> GetQuestAssortUnlocks(IEnumerable<Quest> quests)
{
var results = new List<QuestAssortUnlock>();
@ -283,12 +283,13 @@ namespace AssortValidator.Common.Helpers
{
results.Add(new QuestAssortUnlock{
QuestId = quest._id,
QuestName = QuestHelper.GetQuestNameById(quest._id),
QuestName = GetQuestNameById(quest._id),
TraderId = assortUnlockReward.traderId,
TraderType = TraderHelper.GetTraderTypeById(assortUnlockReward.traderId),
AssortId = assortUnlockReward.items[0]._id,
AssortTemplateId = assortUnlockReward.items[0]._tpl,
LoyaltyLevel = assortUnlockReward.loyaltyLevel.GetValueOrDefault(0)
LoyaltyLevel = assortUnlockReward.loyaltyLevel.GetValueOrDefault(0),
QuestState = "success"
});
}
}
@ -297,6 +298,31 @@ namespace AssortValidator.Common.Helpers
return results;
}
public static QuestAssorts CreateQuestAssortsList(IEnumerable<QuestAssortUnlock> questAssortData)
{
var result = new QuestAssorts();
foreach (var questAssortUnlock in questAssortData)
{
result.success.Add(questAssortUnlock.AssortId, questAssortUnlock.QuestId);
}
return result;
}
public class QuestAssorts
{
public QuestAssorts()
{
started = new Dictionary<string, string>();
success = new Dictionary<string, string>();
fail = new Dictionary<string, string>();
}
public Dictionary<string, string> started { get; set; }
public Dictionary<string, string> success { get; set; }
public Dictionary<string, string> fail { get; set; }
}
private static string GetQuestNameById(string id)
{
if (questNames.ContainsKey(id))