Cleaned up project with better structure.
This commit is contained in:
@@ -0,0 +1,61 @@
|
||||
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()
|
||||
{
|
||||
string noUnderscore = Id.Replace("_", " ").ToLower();
|
||||
return char.ToUpper(noUnderscore[0]) + noUnderscore.Substring(1);
|
||||
}
|
||||
|
||||
public static string GetReadableName(string input)
|
||||
{
|
||||
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()
|
||||
{
|
||||
string result = GetReadableName() + ": \r";
|
||||
|
||||
foreach (Ingredient ingredient in Inputs)
|
||||
{
|
||||
result += $"{GetReadableName(ingredient.Item)} ({ingredient.Amount}),\r";
|
||||
}
|
||||
|
||||
if (Inputs.Count <= 0) return result;
|
||||
|
||||
result = result.Remove(result.Length - 2);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user