Correctly generate upd object + dont add stackobjectscount to mods

This commit is contained in:
Chomp 2022-07-24 22:22:53 +01:00
parent 9c40f1ae96
commit dfb30cd86a
5 changed files with 29 additions and 2 deletions

View File

@ -19,6 +19,7 @@ namespace AssortGenerator.Common
var options = new JsonSerializerOptions var options = new JsonSerializerOptions
{ {
WriteIndented = true, WriteIndented = true,
DefaultIgnoreCondition = System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingNull,
Encoder = JavaScriptEncoder.Create(UnicodeRanges.BasicLatin, UnicodeRanges.Cyrillic) Encoder = JavaScriptEncoder.Create(UnicodeRanges.BasicLatin, UnicodeRanges.Cyrillic)
}; };

View File

@ -20,8 +20,10 @@ namespace AssortGenerator.Models.Output
public class Upd public class Upd
{ {
public bool UnlimitedCount { get; set; } public Foldable Foldable { get;set;}
public int StackObjectsCount { get; set; } public UpdFireMode FireMode { get;set;}
public bool? UnlimitedCount { get; set; }
public int? StackObjectsCount { get; set; }
public object BuyRestrictionMax { get; set; } public object BuyRestrictionMax { get; set; }
public int? BuyRestrictionCurrent { get; set; } public int? BuyRestrictionCurrent { get; set; }
} }

View File

@ -0,0 +1,7 @@
namespace AssortGenerator.Models.Output
{
public class UpdFireMode
{
public string FireMode { get;set; }
}
}

View File

@ -0,0 +1,7 @@
namespace AssortGenerator.Models.Output
{
public class Foldable
{
public bool Folded { get; set; }
}
}

View File

@ -37,6 +37,16 @@ namespace AssortGenerator
string itemsJson = data.GetProperty("items").ToString(); string itemsJson = data.GetProperty("items").ToString();
List<Item> items = JsonSerializer.Deserialize<List<Item>>(itemsJson); List<Item> items = JsonSerializer.Deserialize<List<Item>>(itemsJson);
// fix items that have ran out of stock in the dump and give it some default values
foreach (var item in items)
{
if (item.upd?.StackObjectsCount == 0 && item.slotId == "hideout")
{
LoggingHelpers.LogError($"item {item._tpl} found with stack count of 0, changing to 100");
item.upd.StackObjectsCount = 100;
}
}
// Find barter scheme node and parse into object // Find barter scheme node and parse into object
var barterSchemeJson = data.GetProperty("barter_scheme").ToString(); var barterSchemeJson = data.GetProperty("barter_scheme").ToString();
var barterSchemeItems = JsonSerializer.Deserialize<Dictionary<string, object>>(barterSchemeJson); var barterSchemeItems = JsonSerializer.Deserialize<Dictionary<string, object>>(barterSchemeJson);