Add code to add missing quest assorts to trader assort files
This commit is contained in:
parent
167bba85e2
commit
2abf70a978
File diff suppressed because it is too large
Load Diff
@ -145,15 +145,19 @@ namespace AssortGenerator
|
|||||||
barter_scheme = barterSchemeItems,
|
barter_scheme = barterSchemeItems,
|
||||||
loyal_level_items = loyaltyLevelItems
|
loyal_level_items = loyaltyLevelItems
|
||||||
};
|
};
|
||||||
JsonWriter.WriteJson(outputAssortFile, traderFolderPath, workingPath, "assort");
|
|
||||||
|
|
||||||
// create base file, serialise into json and save into output folder
|
// create base file, serialise into json and save into output folder
|
||||||
var outputBaseFile = traderData.data.Find(x => x._id == trader.Value);
|
var outputBaseFile = traderData.data.Find(x => x._id == trader.Value);
|
||||||
JsonWriter.WriteJson(outputBaseFile, traderFolderPath, workingPath, "base");
|
|
||||||
|
|
||||||
QuestAssort questAssort = GenerateQuestAssortForTrader(trader.Key, outputAssortFile);
|
QuestAssort questAssort = GenerateQuestAssortForTrader(trader.Key, outputAssortFile, out List<AssortUnlocks> missingQuestAssorts);
|
||||||
|
AttemptToAddMissingQuestAssorts(outputAssortFile, questAssort, missingQuestAssorts);
|
||||||
|
|
||||||
|
JsonWriter.WriteJson(outputBaseFile, traderFolderPath, workingPath, "base");
|
||||||
|
JsonWriter.WriteJson(outputAssortFile, traderFolderPath, workingPath, "assort");
|
||||||
JsonWriter.WriteJson(questAssort, traderFolderPath, workingPath, "questassort");
|
JsonWriter.WriteJson(questAssort, traderFolderPath, workingPath, "questassort");
|
||||||
|
|
||||||
|
//UpdateQuestAssortUnlockIds(trader.Value, questAssort, finalisedQuestData, outputAssortFile);
|
||||||
|
|
||||||
// create suits file for ragman
|
// create suits file for ragman
|
||||||
if (trader.Key == Trader.Ragman)
|
if (trader.Key == Trader.Ragman)
|
||||||
{
|
{
|
||||||
@ -161,6 +165,123 @@ namespace AssortGenerator
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void AttemptToAddMissingQuestAssorts(AssortRoot outputAssortFile, QuestAssort questAssort, List<AssortUnlocks> missingQuestAssorts)
|
||||||
|
{
|
||||||
|
// 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)
|
||||||
|
{
|
||||||
|
// 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");
|
||||||
|
}
|
||||||
|
|
||||||
|
// We can add it
|
||||||
|
var item = new Item
|
||||||
|
{
|
||||||
|
_tpl = missingQuestAssort.Items[0]._tpl,
|
||||||
|
_id = missingQuestAssort.Items[0]._id,
|
||||||
|
parentId = "hideout",
|
||||||
|
slotId = "hideout",
|
||||||
|
upd = new Upd
|
||||||
|
{
|
||||||
|
StackObjectsCount = 10
|
||||||
|
}
|
||||||
|
};
|
||||||
|
outputAssortFile.items.Add(item);
|
||||||
|
|
||||||
|
var barterItemListInner = new List<BarterObject>
|
||||||
|
{
|
||||||
|
// 10,000 Roubles
|
||||||
|
new BarterObject() { _tpl = "5449016a4bdc2d6f028b456f", count = 25000 }
|
||||||
|
};
|
||||||
|
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 void UpdateQuestAssortUnlockIds(string traderId, QuestAssort traderQuestAssort, Dictionary<string, Quest> finalisedQuestData, AssortRoot traderAssortRoot)
|
||||||
|
{
|
||||||
|
var alreadyMatchedAssortIds = new List<string>();
|
||||||
|
var assortUnlocks = QuestHelper.GetAssortUnlocks().Where(x => x.TraderId == traderId);
|
||||||
|
foreach (var assort in assortUnlocks)
|
||||||
|
{
|
||||||
|
// Find quest that matches quest assort key
|
||||||
|
Quest matchingQuest = finalisedQuestData.FirstOrDefault(x => x.Key == assort.QuestId).Value;
|
||||||
|
if (matchingQuest == null)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (matchingQuest.QuestName == "Debut")
|
||||||
|
{
|
||||||
|
var x = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
RewardStatus matchingReward = null;
|
||||||
|
switch (assort.Criteria)
|
||||||
|
{
|
||||||
|
case "Success":
|
||||||
|
matchingReward = matchingQuest.rewards.Success.Single(x => x.id == assort.AssortUnlockId);
|
||||||
|
break;
|
||||||
|
case "Started":
|
||||||
|
matchingReward = matchingQuest.rewards.Started.Single(x => x.id == assort.AssortUnlockId);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Try to find assort with an _id of the quests target value
|
||||||
|
var matchingAssortInTrader = traderAssortRoot.items.SingleOrDefault(x => x._id == matchingReward.target);
|
||||||
|
if (matchingAssortInTrader == null)
|
||||||
|
{
|
||||||
|
// Mismatch! quest reward has a target that doesnt exist in trader assort
|
||||||
|
// Update to match quest
|
||||||
|
|
||||||
|
|
||||||
|
Dictionary<string,string> matching = null;
|
||||||
|
switch (assort.Criteria)
|
||||||
|
{
|
||||||
|
case "Success":
|
||||||
|
matching = traderQuestAssort.success;
|
||||||
|
break;
|
||||||
|
case "Started":
|
||||||
|
matching = traderQuestAssort.started;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
var kvp = matching.FirstOrDefault(x => x.Value == matchingQuest._id && !alreadyMatchedAssortIds.Contains(x.Value));
|
||||||
|
|
||||||
|
|
||||||
|
matchingReward.target = kvp.Key;
|
||||||
|
|
||||||
|
// Quests can have multiple unlocks per quest, keep track of processed assort ids
|
||||||
|
alreadyMatchedAssortIds.Add(kvp.Key);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// merges bear and usec ragman clothing dumps into one file
|
/// merges bear and usec ragman clothing dumps into one file
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -199,8 +320,10 @@ namespace AssortGenerator
|
|||||||
/// <param name="trader"></param>
|
/// <param name="trader"></param>
|
||||||
/// <param name="assortRoot"></param>
|
/// <param name="assortRoot"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
private static QuestAssort GenerateQuestAssortForTrader(Trader trader, AssortRoot assortRoot)
|
private static QuestAssort GenerateQuestAssortForTrader(Trader trader, AssortRoot assortRoot, out List<AssortUnlocks> missingQuestAssorts)
|
||||||
{
|
{
|
||||||
|
missingQuestAssorts = new List<AssortUnlocks>();
|
||||||
|
|
||||||
var result = new QuestAssort();
|
var result = new QuestAssort();
|
||||||
var questData = QuestHelper.GetQuestData();
|
var questData = QuestHelper.GetQuestData();
|
||||||
|
|
||||||
@ -208,11 +331,11 @@ namespace AssortGenerator
|
|||||||
List<AssortUnlocks> assortUnlocks = QuestHelper.GetAssortUnlocks();
|
List<AssortUnlocks> assortUnlocks = QuestHelper.GetAssortUnlocks();
|
||||||
|
|
||||||
// Store already matched items
|
// Store already matched items
|
||||||
var assortItemsThatMatchBlackList = new List<string>();
|
var matchedAssortItemIds = new List<string>();
|
||||||
int unknownCount = 1;
|
int unknownCount = 1;
|
||||||
foreach (var assortUnlock in assortUnlocks.Where(x => x.TraderType == trader))
|
foreach (var assortUnlock in assortUnlocks.Where(x => x.TraderType == trader))
|
||||||
{
|
{
|
||||||
if (assortUnlock.QuestId == "64764abcd125ab430a14ccb5")
|
if (assortUnlock.QuestId == "60e71ce009d7c801eb0c0ec6")
|
||||||
{
|
{
|
||||||
var x = 2;
|
var x = 2;
|
||||||
}
|
}
|
||||||
@ -223,7 +346,9 @@ namespace AssortGenerator
|
|||||||
var assortItemModsFromQuest = assortUnlock.Items.Where(x => x.parentId == assortUnlock.ItemUnlockedId);
|
var assortItemModsFromQuest = assortUnlock.Items.Where(x => x.parentId == assortUnlock.ItemUnlockedId);
|
||||||
|
|
||||||
// Get matching assorts from trader
|
// Get matching assorts from trader
|
||||||
var results = GetMatchingTraderAssortsWithScore(assortRoot, assortUnlock, trader, assortItemsThatMatchBlackList);
|
var results = GetMatchingTraderAssortsWithScore(assortRoot, assortUnlock, trader, matchedAssortItemIds);
|
||||||
|
|
||||||
|
// No matches, add a placeholder to output file
|
||||||
if (results.Keys.Count == 0)
|
if (results.Keys.Count == 0)
|
||||||
{
|
{
|
||||||
// no assort found for this unlock, add to questassort with a placeholder value instead of assort id
|
// no assort found for this unlock, add to questassort with a placeholder value instead of assort id
|
||||||
@ -232,9 +357,12 @@ namespace AssortGenerator
|
|||||||
result.success.Add($"UnknownAssortId{unknownCount}", assortUnlock.QuestId);
|
result.success.Add($"UnknownAssortId{unknownCount}", assortUnlock.QuestId);
|
||||||
unknownCount++;
|
unknownCount++;
|
||||||
|
|
||||||
|
missingQuestAssorts.Add(assortUnlock);
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// All the assorts found have a matching score below 0 - very bad
|
||||||
if (results.Values.All( x => x < 0))
|
if (results.Values.All( x => x < 0))
|
||||||
{
|
{
|
||||||
LoggingHelpers.LogError($"{trader} item templateId: {assortUnlock.ItemUnlockedTemplateId} ({ItemName}). questId: {assortUnlock.QuestId}. Only negative scored matches found");
|
LoggingHelpers.LogError($"{trader} item templateId: {assortUnlock.ItemUnlockedTemplateId} ({ItemName}). questId: {assortUnlock.QuestId}. Only negative scored matches found");
|
||||||
@ -242,13 +370,16 @@ namespace AssortGenerator
|
|||||||
result.success.Add($"UnknownAssortId{unknownCount}", assortUnlock.QuestId);
|
result.success.Add($"UnknownAssortId{unknownCount}", assortUnlock.QuestId);
|
||||||
unknownCount++;
|
unknownCount++;
|
||||||
|
|
||||||
|
missingQuestAssorts.Add(assortUnlock);
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
var highestScoringAssortIdMatch = results.OrderByDescending(x => x.Value).Where(x => x.Value > 0).First().Key;
|
// get highest scoring match
|
||||||
|
var highestScoringAssortIdMatch = results.OrderByDescending(x => x.Value).First().Key;
|
||||||
|
|
||||||
// Add assort item id to blacklist so it wont be matched again
|
// Add assort item id to blacklist so it wont be matched again
|
||||||
assortItemsThatMatchBlackList.Add(highestScoringAssortIdMatch);
|
matchedAssortItemIds.Add(highestScoringAssortIdMatch);
|
||||||
|
|
||||||
if (result.success.ContainsKey(highestScoringAssortIdMatch))
|
if (result.success.ContainsKey(highestScoringAssortIdMatch))
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user