|
|
|
|
@@ -6,19 +6,23 @@ using System.ComponentModel;
|
|
|
|
|
using System.Diagnostics;
|
|
|
|
|
using System.IO;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Net;
|
|
|
|
|
using System.Runtime;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Text.RegularExpressions;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
|
|
namespace Jsarus
|
|
|
|
|
{
|
|
|
|
|
internal class Program
|
|
|
|
|
{
|
|
|
|
|
public static string version = "1.2.0";
|
|
|
|
|
public static string version = "1.3.0";
|
|
|
|
|
public static string cd = Directory.GetCurrentDirectory();
|
|
|
|
|
public static Process p = new Process();
|
|
|
|
|
private static ConsoleKeyInfo keyInfo;
|
|
|
|
|
static void Main(string[] args)
|
|
|
|
|
{
|
|
|
|
|
WebClient wc = new WebClient();
|
|
|
|
|
Message.Splash("Jsarus", "mikx");
|
|
|
|
|
Message.CMW("Creating directories...", true, 1);
|
|
|
|
|
if (!Directory.Exists($@"Data\Modded")) { Directory.CreateDirectory($@"Data\Modded"); }
|
|
|
|
|
@@ -28,33 +32,69 @@ namespace Jsarus
|
|
|
|
|
|
|
|
|
|
string ModName = settings["ModName"].ToObject<string>();
|
|
|
|
|
string GameContentPath = settings["GameContentPath"].ToObject<string>();
|
|
|
|
|
bool KeepData = settings["KeepData"].ToObject<bool>();
|
|
|
|
|
string[] CopyList = settings["CopyList"].ToObject<string[]>();
|
|
|
|
|
|
|
|
|
|
int ItemWeight = settings["D_Itemable"]["ItemWeight"].ToObject<int>();
|
|
|
|
|
int ItemStack = settings["D_Itemable"]["ItemStack"].ToObject<int>();
|
|
|
|
|
if (!File.Exists("data.json")) { wc.DownloadFile("https://mxio.ovh/icarus/jsarus/data.json", "data.json"); }
|
|
|
|
|
|
|
|
|
|
int ExperienceMultiplier = settings["D_ExperienceEvents"]["ExperienceMultiplier"].ToObject<int>();
|
|
|
|
|
JObject data = JObject.Parse(File.ReadAllText("data.json"));
|
|
|
|
|
int DataVersion = data["version"].ToObject<int>();
|
|
|
|
|
JObject dataRemote = JObject.Parse(wc.DownloadString("https://mxio.ovh/icarus/jsarus/data.json"));
|
|
|
|
|
int DataVersionRemote = dataRemote["version"].ToObject<int>();
|
|
|
|
|
|
|
|
|
|
string[] ActionList = settings["D_StaminaActionCosts"]["ActionList"].ToObject<string>().Split('|');
|
|
|
|
|
int DivideCostPer = settings["D_StaminaActionCosts"]["DivideCostPer"].ToObject<int>();
|
|
|
|
|
if (KeepData)
|
|
|
|
|
{
|
|
|
|
|
Message.CMW("Keeping your custom data.", true, 1);
|
|
|
|
|
if (DataVersion < DataVersionRemote)
|
|
|
|
|
{
|
|
|
|
|
Message.CMW("Consider setting \"KeepData\" to \"true\" in your \"settings.json\"!", true, 1);
|
|
|
|
|
Message.CMW("Your data is outdated. Should we update it? (y/n)", true, 3);
|
|
|
|
|
Message.CMW("If you are not sure, answer \"y\".", true, 1);
|
|
|
|
|
keyInfo = Console.ReadKey(true);
|
|
|
|
|
if (keyInfo.Key == ConsoleKey.Y)
|
|
|
|
|
{
|
|
|
|
|
Message.CMW("Getting the latest data...", true, 1);
|
|
|
|
|
if (File.Exists("data.json")) { File.Copy("data.json", "data.backup.json", true); }
|
|
|
|
|
Message.CMW("A backup has been made to \"data.backup.json\".", true, 1);
|
|
|
|
|
wc.DownloadFile("https://mxio.ovh/icarus/jsarus/data.json", "data.json");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
Message.CMW("Getting the latest data...", true, 1);
|
|
|
|
|
wc.DownloadFile("https://mxio.ovh/icarus/jsarus/data.json", "data.json");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
string[] PickList = settings["D_ToolDamage"]["PickList"].ToObject<string>().Split('|');
|
|
|
|
|
string[] PickEfficiencyList = settings["D_ToolDamage"]["PickEfficiencyList"].ToObject<string>().Split('|');
|
|
|
|
|
int ItemWeight = data["D_Itemable"]["ItemWeight"].ToObject<int>();
|
|
|
|
|
int ItemStack = data["D_Itemable"]["ItemStack"].ToObject<int>();
|
|
|
|
|
|
|
|
|
|
string[] AxeList = settings["D_ToolDamage"]["AxeList"].ToObject<string>().Split('|');
|
|
|
|
|
string[] AxeEfficiencyList = settings["D_ToolDamage"]["AxeEfficiencyList"].ToObject<string>().Split('|');
|
|
|
|
|
int ExperienceMultiplier = data["D_ExperienceEvents"]["ExperienceMultiplier"].ToObject<int>();
|
|
|
|
|
|
|
|
|
|
string[] RecipeListOre = settings["D_ProcessorRecipes"]["RecipeListOre"].ToObject<string>().Split('|');
|
|
|
|
|
string[] RecipeList = settings["D_ProcessorRecipes"]["RecipeList"].ToObject<string>().Split('|');
|
|
|
|
|
string[] RecipeListStack = settings["D_ProcessorRecipes"]["RecipeListStack"].ToObject<string>().Split('|');
|
|
|
|
|
int RequiredMillijoules = settings["D_ProcessorRecipes"]["RequiredMillijoules"].ToObject<int>();
|
|
|
|
|
int RequiredAmount = settings["D_ProcessorRecipes"]["RequiredAmount"].ToObject<int>();
|
|
|
|
|
int CraftedAmount = settings["D_ProcessorRecipes"]["CraftedAmount"].ToObject<int>();
|
|
|
|
|
string[] ActionList = data["D_StaminaActionCosts"]["ActionList"].ToObject<string>().Split('|');
|
|
|
|
|
int DivideCostPer = data["D_StaminaActionCosts"]["DivideCostPer"].ToObject<int>();
|
|
|
|
|
|
|
|
|
|
string[] InventoryList = settings["D_InventoryInfo"]["InventoryList"].ToObject<string>().Split('|');
|
|
|
|
|
int InventorySize = settings["D_InventoryInfo"]["InventorySize"].ToObject<int>();
|
|
|
|
|
string[] PickList = data["D_ToolDamage"]["PickList"].ToObject<string>().Split('|');
|
|
|
|
|
string[] PickEfficiencyList = data["D_ToolDamage"]["PickEfficiencyList"].ToObject<string>().Split('|');
|
|
|
|
|
|
|
|
|
|
string[] supportedJson = { @"Traits\D_Itemable.json", @"Experience\D_ExperienceEvents.json", @"Tools\D_StaminaActionCosts.json", @"Tools\D_ToolDamage.json", @"Crafting\D_ProcessorRecipes.json", @"Inventory\D_InventoryInfo.json" };
|
|
|
|
|
string[] AxeList = data["D_ToolDamage"]["AxeList"].ToObject<string>().Split('|');
|
|
|
|
|
string[] AxeEfficiencyList = data["D_ToolDamage"]["AxeEfficiencyList"].ToObject<string>().Split('|');
|
|
|
|
|
|
|
|
|
|
string[] RecipeListOre = data["D_ProcessorRecipes"]["RecipeListOre"].ToObject<string>().Split('|');
|
|
|
|
|
string[] RecipeList = data["D_ProcessorRecipes"]["RecipeList"].ToObject<string>().Split('|');
|
|
|
|
|
string[] RecipeListStack = data["D_ProcessorRecipes"]["RecipeListStack"].ToObject<string>().Split('|');
|
|
|
|
|
int RequiredMillijoules = data["D_ProcessorRecipes"]["RequiredMillijoules"].ToObject<int>();
|
|
|
|
|
int RequiredAmount = data["D_ProcessorRecipes"]["RequiredAmount"].ToObject<int>();
|
|
|
|
|
int CraftedAmount = data["D_ProcessorRecipes"]["CraftedAmount"].ToObject<int>();
|
|
|
|
|
|
|
|
|
|
string[] InventoryList = data["D_InventoryInfo"]["InventoryList"].ToObject<string>().Split('|');
|
|
|
|
|
int InventorySize = data["D_InventoryInfo"]["InventorySize"].ToObject<int>();
|
|
|
|
|
|
|
|
|
|
string[] GeneratorList = data["D_Generator"]["GeneratorList"].ToObject<string>().Split('|');
|
|
|
|
|
int GenerationRate = data["D_Generator"]["GenerationRate"].ToObject<int>();
|
|
|
|
|
int GenerationRatio = data["D_Generator"]["GenerationRatio"].ToObject<int>();
|
|
|
|
|
|
|
|
|
|
string[] supportedJson = { @"Traits\D_Itemable.json", @"Experience\D_ExperienceEvents.json", @"Tools\D_StaminaActionCosts.json", @"Tools\D_ToolDamage.json", @"Crafting\D_ProcessorRecipes.json", @"Inventory\D_InventoryInfo.json", @"Traits\D_Generator.json" };
|
|
|
|
|
|
|
|
|
|
var dir = Directory.GetDirectories(@"Data\Vanilla");
|
|
|
|
|
|
|
|
|
|
@@ -75,9 +115,29 @@ namespace Jsarus
|
|
|
|
|
Message.CMW($"Copied {sj.Split('\\')[1]}.", true, 2);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Message.CMW($"We extracted the data, should we continue and mod it? (y/n)", true, 1);
|
|
|
|
|
ConsoleKeyInfo keyInfo = Console.ReadKey(true);
|
|
|
|
|
if (keyInfo.Key == ConsoleKey.N) { return; } else
|
|
|
|
|
Message.CMW("Generating the Item Database for dynamic modding...", true, 1);
|
|
|
|
|
JArray itemsDB = new JArray();
|
|
|
|
|
JObject items = new JObject();
|
|
|
|
|
JObject item = JObject.Parse(File.ReadAllText(@"Data\Vanilla\Traits\D_Itemable.json"));
|
|
|
|
|
foreach (var i in item["Rows"])
|
|
|
|
|
{
|
|
|
|
|
string iname = i["Name"].ToObject<string>().Substring(5);
|
|
|
|
|
int iweight = 0;
|
|
|
|
|
if (i["Weight"] != null) { iweight = i["Weight"].ToObject<int>(); } else { iweight = 0; }
|
|
|
|
|
bool istack = false;
|
|
|
|
|
int istacksize = 1;
|
|
|
|
|
if (i["MaxStack"] != null) { istack = true; istacksize = i["MaxStack"].ToObject<int>(); }
|
|
|
|
|
items = new JObject()
|
|
|
|
|
{
|
|
|
|
|
{ "name", iname },
|
|
|
|
|
{ "weight", iweight },
|
|
|
|
|
{ "dostack", istack },
|
|
|
|
|
{ "stack", istacksize }
|
|
|
|
|
};
|
|
|
|
|
itemsDB.Add(items);
|
|
|
|
|
}
|
|
|
|
|
var rawDB = JsonConvert.SerializeObject(itemsDB, Formatting.Indented);
|
|
|
|
|
File.WriteAllText($@"Data/itemDB.json", rawDB);
|
|
|
|
|
|
|
|
|
|
foreach (var d in dir)
|
|
|
|
|
{
|
|
|
|
|
@@ -168,8 +228,11 @@ namespace Jsarus
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case "D_ProcessorRecipes.json":
|
|
|
|
|
JArray itemDB = JArray.Parse(File.ReadAllText(@"Data\itemDB.json"));
|
|
|
|
|
foreach (var r in job["Rows"])
|
|
|
|
|
{
|
|
|
|
|
//JToken entry = itemDB.FirstOrDefault(t => (bool)(t["name"]?.ToString().Contains(r["Name"]?.ToString())));
|
|
|
|
|
|
|
|
|
|
if (r["Inputs"].Count() > 0)
|
|
|
|
|
{
|
|
|
|
|
if (RecipeListOre.Contains(r["Name"].ToString()))
|
|
|
|
|
@@ -203,6 +266,7 @@ namespace Jsarus
|
|
|
|
|
r["Outputs"][0]["Count"] = CraftedAmount;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
@@ -215,6 +279,20 @@ namespace Jsarus
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case "D_Generator.json":
|
|
|
|
|
foreach (var r in job["Rows"])
|
|
|
|
|
{
|
|
|
|
|
if (GeneratorList.Contains(r["Name"].ToString()))
|
|
|
|
|
{
|
|
|
|
|
r["GenerationRate"] = GenerationRate;
|
|
|
|
|
if (r["GenerationRatio"] != null)
|
|
|
|
|
{
|
|
|
|
|
r["GenerationRatio"] = GenerationRatio;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
Message.CMW($"Saving {f}...", true, 1);
|
|
|
|
|
var raw = JsonConvert.SerializeObject(job, Formatting.Indented);
|
|
|
|
|
|