Files

63 lines
1.5 KiB
C#

using System.Collections.Generic;
using System.Text.Json.Serialization;
public class ItemData
{
[JsonPropertyName("id")]
public string Id { get; set; }
[JsonPropertyName("inputs")]
public List<Ingredient> Inputs { get; set; }
[JsonPropertyName("output")]
public Ingredient Output { get; set; }
[JsonPropertyName("workstation")]
public string Workstation { get; set; }
[JsonPropertyName("texture")]
public string Texture { get; set; }
[JsonPropertyName("research")]
public string Research { get; set; }
[JsonPropertyName("crafttime")]
public double CraftTime { get; set; }
[JsonPropertyName("stacksize")]
public int StackSize { get; set; }
public string GetReadableName()
{
return GetReadableName(Id);
}
public static string GetReadableName(string input)
{
if (string.IsNullOrEmpty(input)) return "";
string noUnderscore = input.Replace("_", " ").ToLower();
return char.ToUpper(noUnderscore[0]) + noUnderscore.Substring(1);
}
public static string GetIndex(string readable)
{
return readable.ToLower().Replace(" ", "_");
}
public string GetCraftingDisplay()
{
if (Inputs.Count <= 0) return GetReadableName() + ": \r";
string result = GetReadableName() + ": \r";
foreach (Ingredient ingredient in Inputs)
{
result += $"{GetReadableName(ingredient.Item)} ({ingredient.Amount}),\r";
}
result = result.Remove(result.Length - 2);
return result;
}
}