First pass at filtering assort generation
This commit is contained in:
parent
5fa432ee32
commit
ce251b1e2b
@ -33,6 +33,7 @@ namespace CreateAssortFromFleaJsons
|
|||||||
// Limit flea offers to just this trader
|
// Limit flea offers to just this trader
|
||||||
var traderIdToProcess = "6617beeaa9cfa777ca915b7c"; // REF
|
var traderIdToProcess = "6617beeaa9cfa777ca915b7c"; // REF
|
||||||
var traderSpecificFleaData = _findResults.Where(find => find.user.id == traderIdToProcess);
|
var traderSpecificFleaData = _findResults.Where(find => find.user.id == traderIdToProcess);
|
||||||
|
var uniqueFilteredOffers = FilterUniqueOffers(traderSpecificFleaData);
|
||||||
|
|
||||||
// Prep assort output file
|
// Prep assort output file
|
||||||
var assortResult = new AssortRoot()
|
var assortResult = new AssortRoot()
|
||||||
@ -41,7 +42,7 @@ namespace CreateAssortFromFleaJsons
|
|||||||
barter_scheme = new Dictionary<string, List<List<BarterObject>>>(),
|
barter_scheme = new Dictionary<string, List<List<BarterObject>>>(),
|
||||||
loyal_level_items = new Dictionary<string, int>()
|
loyal_level_items = new Dictionary<string, int>()
|
||||||
};
|
};
|
||||||
foreach (var fleaOffer in traderSpecificFleaData)
|
foreach (var fleaOffer in uniqueFilteredOffers)
|
||||||
{
|
{
|
||||||
// Has only one item
|
// Has only one item
|
||||||
var singularItem = fleaOffer.items.Count == 1;
|
var singularItem = fleaOffer.items.Count == 1;
|
||||||
@ -50,34 +51,50 @@ namespace CreateAssortFromFleaJsons
|
|||||||
var firstItem = fleaOffer.items[0];
|
var firstItem = fleaOffer.items[0];
|
||||||
|
|
||||||
// Add first item
|
// Add first item
|
||||||
assortResult.items.Add(new Item()
|
var firstItemToAdd = new Item
|
||||||
{
|
{
|
||||||
_id = firstItem._id,
|
_id = firstItem._id,
|
||||||
_tpl = firstItem._tpl,
|
_tpl = firstItem._tpl,
|
||||||
parentId = "hideout",
|
parentId = "hideout",
|
||||||
slotId = "hideout",
|
slotId = "hideout",
|
||||||
upd = new Upd
|
upd = firstItem.upd
|
||||||
{
|
};
|
||||||
UnlimitedCount = fleaOffer.unlimitedCount,
|
if (fleaOffer.buyRestrictionMax != null)
|
||||||
StackObjectsCount = firstItem.upd.StackObjectsCount,
|
{
|
||||||
BuyRestrictionMax = fleaOffer.buyRestrictionMax,
|
firstItemToAdd.upd.BuyRestrictionMax = fleaOffer.buyRestrictionMax;
|
||||||
BuyRestrictionCurrent = 0
|
}
|
||||||
}
|
|
||||||
});
|
firstItemToAdd.upd.UnlimitedCount = fleaOffer.unlimitedCount;
|
||||||
|
firstItemToAdd.upd.BuyRestrictionCurrent = 0;
|
||||||
|
|
||||||
|
assortResult.items.Add(firstItemToAdd);
|
||||||
|
|
||||||
// Add child items
|
// Add child items
|
||||||
if (!singularItem)
|
if (!singularItem)
|
||||||
{
|
{
|
||||||
|
// Exclude first item
|
||||||
var childItems = fleaOffer.items.Except([firstItem]);
|
var childItems = fleaOffer.items.Except([firstItem]);
|
||||||
|
var locationValue = 0;
|
||||||
foreach (var childItem in childItems)
|
foreach (var childItem in childItems)
|
||||||
{
|
{
|
||||||
assortResult.items.Add(new Item()
|
var itemToAdd = new Item()
|
||||||
{
|
{
|
||||||
_id = childItem._id,
|
_id = childItem._id,
|
||||||
_tpl = childItem._tpl,
|
_tpl = childItem._tpl,
|
||||||
parentId = childItem.parentId,
|
parentId = childItem.parentId,
|
||||||
slotId = childItem.slotId
|
slotId = childItem.slotId,
|
||||||
});
|
upd = childItem.upd
|
||||||
|
};
|
||||||
|
|
||||||
|
if (childItem.slotId == "cartridges")
|
||||||
|
{
|
||||||
|
itemToAdd.location = locationValue;
|
||||||
|
locationValue++;
|
||||||
|
}
|
||||||
|
|
||||||
|
assortResult.items.Add(itemToAdd);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -97,6 +114,42 @@ namespace CreateAssortFromFleaJsons
|
|||||||
JsonWriter.WriteJson(assortResult, "", Directory.GetCurrentDirectory(), "assort");
|
JsonWriter.WriteJson(assortResult, "", Directory.GetCurrentDirectory(), "assort");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static IEnumerable<FleaOffer> FilterUniqueOffers(IEnumerable<FleaOffer> traderSpecificFleaData)
|
||||||
|
{
|
||||||
|
var results = new List<FleaOffer>();
|
||||||
|
foreach (var offer in traderSpecificFleaData)
|
||||||
|
{
|
||||||
|
// Is a child, add it
|
||||||
|
if (offer.items[0].upd == null)
|
||||||
|
{
|
||||||
|
results.Add(offer);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Has upd object, base item
|
||||||
|
// Get values to compare against
|
||||||
|
var itemCount = offer.items.Count;
|
||||||
|
var offerRootTpl = offer.items[0]._tpl;
|
||||||
|
var itemsCost = offer.itemsCost;
|
||||||
|
var requirementsCount = offer.requirements[0].count;
|
||||||
|
var loyaltyLevel = offer.loyaltyLevel;
|
||||||
|
var buyRestrictionMax = offer.buyRestrictionMax;
|
||||||
|
|
||||||
|
var existingItem = results.Exists((resultOffer => resultOffer.items.Count == itemCount
|
||||||
|
&& resultOffer.items[0]._tpl == offerRootTpl
|
||||||
|
&& resultOffer.itemsCost == itemsCost
|
||||||
|
&& resultOffer.requirements[0].count == requirementsCount
|
||||||
|
&& resultOffer.loyaltyLevel == loyaltyLevel
|
||||||
|
&& resultOffer.buyRestrictionMax.ToString() == buyRestrictionMax.ToString()));
|
||||||
|
|
||||||
|
if (!existingItem)
|
||||||
|
{
|
||||||
|
results.Add(offer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return results;
|
||||||
|
}
|
||||||
|
|
||||||
private static string CreateWorkingFolders()
|
private static string CreateWorkingFolders()
|
||||||
{
|
{
|
||||||
var workingPath = Directory.GetCurrentDirectory();
|
var workingPath = Directory.GetCurrentDirectory();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user