Improve missing quest assort code to add complex items + add terragroup p6 quest assort item
This commit is contained in:
parent
4cb12456b4
commit
7348b8d336
@ -152,5 +152,23 @@
|
||||
"_tpl": "5449016a4bdc2d6f028b456f"
|
||||
}
|
||||
]
|
||||
},
|
||||
"64bd432d6de7c555ad051726": {
|
||||
"questId": "64b907a85e9b86ab7a08cf0d",
|
||||
"itemTpl": "5ac4cd105acfc40016339859",
|
||||
"itemUpd": {
|
||||
"BuyRestrictionMax": 2,
|
||||
"StackObjectsCount": 40000
|
||||
},
|
||||
"barterScheme": [
|
||||
{
|
||||
"count": 1,
|
||||
"_tpl": "5d403f9186f7743cac3f229b"
|
||||
},
|
||||
{
|
||||
"count": 1,
|
||||
"_tpl": "62a0a0bb621468534a797ad5"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
@ -1,6 +1,7 @@
|
||||
using AssortGenerator.Models.Input;
|
||||
using AssortGenerator.Models.Other;
|
||||
using AssortGenerator.Models.Output;
|
||||
using Common.Models;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
@ -124,6 +125,7 @@ namespace AssortGenerator.Common.Helpers
|
||||
{
|
||||
public string questId { get; set; }
|
||||
public string itemTpl { get; set; }
|
||||
public List<Models.Output.Item> items { get;set;}
|
||||
public Upd itemUpd { get; set; }
|
||||
public List<BarterObject> barterScheme { get; set; }
|
||||
}
|
||||
|
@ -27,6 +27,14 @@ namespace AssortGenerator.Models.Output
|
||||
public int? StackObjectsCount { get; set; }
|
||||
public object BuyRestrictionMax { get; set; }
|
||||
public int? BuyRestrictionCurrent { get; set; }
|
||||
|
||||
public Repairable Repairable { get; set; }
|
||||
}
|
||||
|
||||
public class Repairable
|
||||
{
|
||||
public int Durability { get; set; }
|
||||
public int MaxDurability { get; set; }
|
||||
}
|
||||
|
||||
public class BarterObject
|
||||
|
@ -169,28 +169,29 @@ namespace AssortGenerator
|
||||
}
|
||||
}
|
||||
|
||||
private static void AttemptToAddMissingQuestAssorts(AssortRoot outputAssortFile, QuestAssort questAssort, List<AssortUnlocks> missingQuestAssorts, Dictionary<string, MissingAssortPrice> missingQuestAssortPrices)
|
||||
private static void AttemptToAddMissingQuestAssorts(
|
||||
AssortRoot outputAssortFile,
|
||||
QuestAssort questAssort,
|
||||
List<AssortUnlocks> missingQuestAssorts,
|
||||
Dictionary<string, MissingAssortPrice> missingQuestAssortPrices)
|
||||
{
|
||||
// iterate over each missing assort
|
||||
foreach (var missingQuestAssort in missingQuestAssorts)
|
||||
{
|
||||
// Single item, maybe we can add one in (skip complex items like guns/ammo boxes etc)
|
||||
if (missingQuestAssort.Items.Count == 1)
|
||||
var isSimpleItem = missingQuestAssort.Items.Count == 1;
|
||||
|
||||
if (outputAssortFile.items.Any(x => x._id == missingQuestAssort.Items[0]._id))
|
||||
{
|
||||
// Check isn't a weapon
|
||||
var itemTemplate = ItemTemplateHelper.GetTemplateById(missingQuestAssort.Items[0]._tpl);
|
||||
if (itemTemplate._parent == "5447b5f14bdc2d61278b4567")
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (outputAssortFile.items.Any(x => x._id == missingQuestAssort.Items[0]._id))
|
||||
{
|
||||
LoggingHelpers.LogError("OH NO, DUPE ID FOUND");
|
||||
}
|
||||
LoggingHelpers.LogError("OH NO, DUPE ID FOUND");
|
||||
}
|
||||
|
||||
// Find price data
|
||||
var hasPriceData = missingQuestAssortPrices.TryGetValue(missingQuestAssort.AssortUnlockId, out var priceData);
|
||||
if (isSimpleItem)
|
||||
{
|
||||
// We can add it
|
||||
var item = new Item
|
||||
var itemToAdd = new Item
|
||||
{
|
||||
_tpl = missingQuestAssort.Items[0]._tpl,
|
||||
_id = missingQuestAssort.Items[0]._id,
|
||||
@ -198,45 +199,98 @@ namespace AssortGenerator
|
||||
slotId = "hideout"
|
||||
};
|
||||
|
||||
var questAssortPriceData = missingQuestAssortPrices.TryGetValue(missingQuestAssort.AssortUnlockId, out var value);
|
||||
if (questAssortPriceData && value.itemTpl == missingQuestAssort.Items[0]._tpl)
|
||||
// Set stack/buy max counts
|
||||
if (hasPriceData && priceData.itemTpl == missingQuestAssort.Items[0]._tpl)
|
||||
{
|
||||
item.upd = value.itemUpd;
|
||||
itemToAdd.upd = priceData.itemUpd;
|
||||
}
|
||||
else
|
||||
{
|
||||
item.upd = new Upd() { StackObjectsCount = 10 };
|
||||
itemToAdd.upd = new Upd() { StackObjectsCount = 10 };
|
||||
}
|
||||
|
||||
outputAssortFile.items.Add(item);
|
||||
outputAssortFile.items.Add(itemToAdd);
|
||||
}
|
||||
else
|
||||
{
|
||||
// multi-item assort!
|
||||
var itemsToAdd = ConvertRewardToItems(missingQuestAssort.Items);
|
||||
|
||||
var barterItemListInner = new List<BarterObject>();
|
||||
|
||||
if (questAssortPriceData && value.itemTpl == missingQuestAssort.Items[0]._tpl)
|
||||
// Set stack/buy max counts
|
||||
if (hasPriceData && priceData.itemTpl == missingQuestAssort.Items[0]._tpl)
|
||||
{
|
||||
barterItemListInner.AddRange(value.barterScheme);
|
||||
if (itemsToAdd.First().upd == null)
|
||||
{
|
||||
itemsToAdd.First().upd = new Upd();
|
||||
}
|
||||
if (priceData.itemUpd.StackObjectsCount.HasValue)
|
||||
{
|
||||
itemsToAdd.First().upd.StackObjectsCount = priceData.itemUpd.StackObjectsCount.Value;
|
||||
}
|
||||
if (priceData.itemUpd.BuyRestrictionMax != null)
|
||||
{
|
||||
itemsToAdd.First().upd.BuyRestrictionMax = ((JsonElement)priceData.itemUpd.BuyRestrictionMax).GetInt32();
|
||||
itemsToAdd.First().upd.BuyRestrictionCurrent = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
barterItemListInner.Add(new BarterObject() { _tpl = "5449016a4bdc2d6f028b456f", count = 25000 });
|
||||
// no value in json, set stack count to 10
|
||||
itemsToAdd.First().upd.StackObjectsCount = 10;
|
||||
}
|
||||
|
||||
var barterItemListOuter = new List<List<BarterObject>> { barterItemListInner };
|
||||
outputAssortFile.barter_scheme.Add(missingQuestAssort.Items[0]._id, barterItemListOuter);
|
||||
outputAssortFile.items.AddRange(itemsToAdd);
|
||||
}
|
||||
|
||||
outputAssortFile.loyal_level_items[missingQuestAssort.Items[0]._id] = missingQuestAssort.LoyaltyLevel;
|
||||
var barterItemListInner = new List<BarterObject>();
|
||||
if (hasPriceData && priceData.itemTpl == missingQuestAssort.Items[0]._tpl)
|
||||
{
|
||||
barterItemListInner.AddRange(priceData.barterScheme);
|
||||
}
|
||||
else
|
||||
{
|
||||
barterItemListInner.Add(new BarterObject() { _tpl = "5449016a4bdc2d6f028b456f", count = 25000 });
|
||||
}
|
||||
|
||||
var associatedQuestAssort = questAssort.success.FirstOrDefault(x => x.Value == missingQuestAssort.QuestId && x.Key.StartsWith("UnknownAssortId"));
|
||||
if (associatedQuestAssort.Key != null)
|
||||
{
|
||||
LoggingHelpers.LogWarning($"Able to replace missing quest: {missingQuestAssort.QuestId} assort with placeholder");
|
||||
questAssort.success.Remove(associatedQuestAssort.Key);
|
||||
questAssort.success.Add(missingQuestAssort.Items[0]._id, missingQuestAssort.QuestId);
|
||||
}
|
||||
var barterItemListOuter = new List<List<BarterObject>> { barterItemListInner };
|
||||
outputAssortFile.barter_scheme.Add(missingQuestAssort.Items[0]._id, barterItemListOuter);
|
||||
|
||||
outputAssortFile.loyal_level_items[missingQuestAssort.Items[0]._id] = missingQuestAssort.LoyaltyLevel;
|
||||
|
||||
var associatedQuestAssort = questAssort.success.FirstOrDefault(x => x.Value == missingQuestAssort.QuestId && x.Key.StartsWith("UnknownAssortId"));
|
||||
if (associatedQuestAssort.Key != null)
|
||||
{
|
||||
LoggingHelpers.LogWarning($"Able to replace missing quest: {missingQuestAssort.QuestId} assort with placeholder");
|
||||
questAssort.success.Remove(associatedQuestAssort.Key);
|
||||
questAssort.success.Add(missingQuestAssort.Items[0]._id, missingQuestAssort.QuestId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static IEnumerable<Item> ConvertRewardToItems(List<QuestRewardItem> rewardToConvert)
|
||||
{
|
||||
var output = new List<Item>();
|
||||
foreach (var rewardItem in rewardToConvert)
|
||||
{
|
||||
var item = new Item()
|
||||
{
|
||||
_id = rewardItem._id,
|
||||
_tpl = rewardItem._tpl,
|
||||
parentId = rewardItem.parentId ?? "hideout",
|
||||
slotId = rewardItem.slotId ?? "hideout"
|
||||
};
|
||||
|
||||
if (rewardItem.upd != null)
|
||||
{
|
||||
item.upd = (Upd)((JsonElement)rewardItem.upd).Deserialize(typeof(Upd));
|
||||
}
|
||||
|
||||
output.Add(item);
|
||||
}
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
private static void UpdateQuestAssortUnlockIds(string traderId, QuestAssort traderQuestAssort, Dictionary<string, Quest> finalisedQuestData, AssortRoot traderAssortRoot)
|
||||
{
|
||||
var alreadyMatchedAssortIds = new List<string>();
|
||||
|
Loading…
x
Reference in New Issue
Block a user