97 lines
3.7 KiB
C#
Raw Normal View History

2021-09-10 17:57:24 +01:00
using AssortHelpers.Common.Helpers;
using AssortHelpers.Helpers;
using AssortValidator.Common;
using AssortValidator.Common.Helpers;
using AssortValidator.Common.Helpers.Models;
using AssortValidator.Common.Models;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
namespace AssortValidator
{
class Program
{
static void Main(string[] args)
{
2022-01-13 15:25:49 +00:00
var inputPath = DiskHelpers.CreateWorkingFolder("input");
2021-09-10 17:57:24 +01:00
InputFileHelper.SetInputFiles(inputPath);
var assortData = AssortHelper.GetAssortData();
var liveAssortData = AssortHelper.GetLiveAssortData();
2022-01-13 15:29:55 +00:00
AssortHelper.ListAssortFilesFound(assortData);
2021-09-10 17:57:24 +01:00
ListAssortsInLiveNotInOffline(assortData, liveAssortData);
2022-01-13 15:25:49 +00:00
AssortItemChecker.CheckAssortValues(assortData, liveAssortData);
2021-09-10 17:57:24 +01:00
}
2022-01-12 15:08:41 +00:00
private static void ListAssortsInLiveNotInOffline(Dictionary<Trader, Assort> assortData, Dictionary<Trader, Assort> liveAssortData)
2021-09-10 17:57:24 +01:00
{
foreach (var trader in liveAssortData)
{
2022-01-13 15:25:49 +00:00
LoggingHelpers.LogNewLine();
2021-09-10 17:57:24 +01:00
LoggingHelpers.LogInfo($"Checking Trader: {trader.Key}");
LoggingHelpers.LogInfo($"Live assort count: {trader.Value.items.Count}");
var missingAssortCount = 0;
var missingItems = new List<string>();
foreach (var liveAssort in trader.Value.items.Where(x => x.parentId == "hideout"))
{
var offlineAssort = assortData[trader.Key].items.FirstOrDefault(x=>x._tpl == liveAssort._tpl);
if (offlineAssort == null)
{
missingAssortCount++;
2022-01-12 15:08:41 +00:00
var data = ItemTemplateHelper.GetTemplateById(liveAssort._tpl);
if (data is null)
{
LoggingHelpers.LogInfo($"Assort not found skipping: {liveAssort._tpl}");
continue;
}
var itemName = data._name;
2021-09-10 17:57:24 +01:00
int assortLoyaltyLevel = GetAssortLoyaltyLevel(liveAssort._id, trader.Value);
var liveBarterData = trader.Value.barter_scheme.FirstOrDefault(x => x.Key == liveAssort._id).Value;
2022-01-13 15:25:49 +00:00
var firstItemIsMoney = ItemTemplateHelper.IsMoney(liveBarterData.First().First()._tpl);
2021-09-10 17:57:24 +01:00
var isMoneyMessage = firstItemIsMoney ? "money trade" : "barter trade";
missingItems.Add($"{liveAssort._tpl} - {itemName} - Level {assortLoyaltyLevel} - {isMoneyMessage}");
}
}
if (missingAssortCount > 0)
{
2022-01-13 15:25:49 +00:00
LoggingHelpers.LogWarning($"Missing assorts in live but not in existing: {missingAssortCount}");
2021-09-10 17:57:24 +01:00
foreach (var item in missingItems)
{
LoggingHelpers.LogError($"{item}");
}
}
else
{
2022-01-13 15:25:49 +00:00
LoggingHelpers.LogSuccess("Live and existing assorts match :)");
2021-09-10 17:57:24 +01:00
}
}
}
2022-01-12 15:08:41 +00:00
private static int GetAssortLoyaltyLevel(string assortId, Assort assort)
2021-09-10 17:57:24 +01:00
{
int assortLoyaltyLevel = 1;
if (!assort.loyal_level_items.ContainsKey(assortId))
{
2022-01-13 15:25:49 +00:00
LoggingHelpers.LogWarning($"No existing loyalty level record found for itemId: {assortId} assuming level 1");
2021-09-10 17:57:24 +01:00
LoggingHelpers.LogNewLine();
}
else
{
assortLoyaltyLevel = assort.loyal_level_items[assortId];
}
return assortLoyaltyLevel;
}
}
}