97 lines
3.7 KiB
C#
97 lines
3.7 KiB
C#
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)
|
|
{
|
|
var inputPath = DiskHelpers.CreateWorkingFolder("input");
|
|
InputFileHelper.SetInputFiles(inputPath);
|
|
|
|
var assortData = AssortHelper.GetAssortData();
|
|
var liveAssortData = AssortHelper.GetLiveAssortData();
|
|
|
|
AssortHelper.ListAssortFilesFound(assortData);
|
|
|
|
ListAssortsInLiveNotInOffline(assortData, liveAssortData);
|
|
|
|
AssortItemChecker.CheckAssortValues(assortData, liveAssortData);
|
|
}
|
|
|
|
private static void ListAssortsInLiveNotInOffline(Dictionary<Trader, Assort> assortData, Dictionary<Trader, Assort> liveAssortData)
|
|
{
|
|
foreach (var trader in liveAssortData)
|
|
{
|
|
LoggingHelpers.LogNewLine();
|
|
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++;
|
|
var data = ItemTemplateHelper.GetTemplateById(liveAssort._tpl);
|
|
|
|
if (data is null)
|
|
{
|
|
LoggingHelpers.LogInfo($"Assort not found skipping: {liveAssort._tpl}");
|
|
continue;
|
|
}
|
|
|
|
var itemName = data._name;
|
|
int assortLoyaltyLevel = GetAssortLoyaltyLevel(liveAssort._id, trader.Value);
|
|
|
|
var liveBarterData = trader.Value.barter_scheme.FirstOrDefault(x => x.Key == liveAssort._id).Value;
|
|
var firstItemIsMoney = ItemTemplateHelper.IsMoney(liveBarterData.First().First()._tpl);
|
|
|
|
var isMoneyMessage = firstItemIsMoney ? "money trade" : "barter trade";
|
|
missingItems.Add($"{liveAssort._tpl} - {itemName} - Level {assortLoyaltyLevel} - {isMoneyMessage}");
|
|
}
|
|
}
|
|
if (missingAssortCount > 0)
|
|
{
|
|
LoggingHelpers.LogWarning($"Missing assorts in live but not in existing: {missingAssortCount}");
|
|
foreach (var item in missingItems)
|
|
{
|
|
LoggingHelpers.LogError($"{item}");
|
|
}
|
|
}
|
|
else
|
|
{
|
|
LoggingHelpers.LogSuccess("Live and existing assorts match :)");
|
|
}
|
|
}
|
|
}
|
|
|
|
private static int GetAssortLoyaltyLevel(string assortId, Assort assort)
|
|
{
|
|
int assortLoyaltyLevel = 1;
|
|
if (!assort.loyal_level_items.ContainsKey(assortId))
|
|
{
|
|
LoggingHelpers.LogWarning($"No existing loyalty level record found for itemId: {assortId} assuming level 1");
|
|
LoggingHelpers.LogNewLine();
|
|
}
|
|
else
|
|
{
|
|
assortLoyaltyLevel = assort.loyal_level_items[assortId];
|
|
}
|
|
|
|
return assortLoyaltyLevel;
|
|
}
|
|
}
|
|
}
|