diff --git a/BuildEndurance/Class1.cs b/BuildEndurance/Class1.cs index ce6c2d9f..278fc3a2 100644 --- a/BuildEndurance/Class1.cs +++ b/BuildEndurance/Class1.cs @@ -15,36 +15,36 @@ namespace BuildEndurance public class BuildEndurance : Mod { - public static double BuildEndurance_data_xp_nextlvl=20; - public static double BuildEndurance_data_xp_current=0; + static double BuildEndurance_data_xp_nextlvl = 20; + static double BuildEndurance_data_xp_current = 0; - public static int BuildEndurance_data_current_lvl=0; + static int BuildEndurance_data_current_lvl = 0; - public static int BuildEndurance_data_stam_bonus_acumulated=0; + static int BuildEndurance_data_stam_bonus_acumulated = 0; - public static int BuildEndurance_data_ini_stam_bonus=0; + static int BuildEndurance_data_ini_stam_bonus = 0; - public static bool BuildEndurance_data_clear_mod_effects = false; + static bool BuildEndurance_data_clear_mod_effects = false; - public static int BuildEndurance_data_old_stamina = 0; + static int BuildEndurance_data_old_stamina = 0; - public static bool tool_cleaner = false; + static bool tool_cleaner = false; - public static bool fed = false; + static bool fed = false; public Config ModConfig { get; set; } - public static bool upon_loading = false; + static bool upon_loading = false; //Credit goes to Zoryn for pieces of this config generation that I kinda repurposed. public override void Entry(params object[] objects) { Log.Info("HEYO WORLD"); - + StardewModdingAPI.Events.GameEvents.UpdateTick += EatingCallBack; //sloppy again but it'll do. StardewModdingAPI.Events.GameEvents.OneSecondTick += Tool_Cleanup; - StardewModdingAPI.Events.GameEvents.UpdateTick += ToolCallBack; + StardewModdingAPI.Events.GameEvents.UpdateTick += ToolCallBack; StardewModdingAPI.Events.PlayerEvents.LoadedGame += LoadingCallBack; StardewModdingAPI.Events.TimeEvents.DayOfMonthChanged += SleepCallback; @@ -78,13 +78,13 @@ namespace BuildEndurance ModConfig = JsonConvert.DeserializeObject(Encoding.UTF8.GetString(File.ReadAllBytes(configLocation))); Console.WriteLine("Found BuildEndurance config file."); } - - // DataLoader(); - // MyWritter(); //hopefully loading these after the game is loaded will prevent wierd issues. - + + // DataLoader(); + // MyWritter(); //hopefully loading these after the game is loaded will prevent wierd issues. + Console.WriteLine("BuildEndurance Initialization Completed"); } - + public void ToolCallBack(object sender, EventArgs e) //ultra quick response for checking if a tool is used. @@ -92,10 +92,13 @@ namespace BuildEndurance if (tool_cleaner == true) return; - if (StardewModdingAPI.Entities.SPlayer.CurrentFarmer.usingTool == true) + if (StardewValley.Game1.player.usingTool == true) { - //Console.WriteLine("Tool is being used"); + // Console.WriteLine("Tool is being used"); BuildEndurance_data_xp_current += ModConfig.BuildEndurance_xp_tooluse; + //BuildEndurance_data_xp_current += 1000; For testing purposes + // Log.Info(BuildEndurance_data_xp_current); + tool_cleaner = true; } else return; @@ -110,11 +113,11 @@ namespace BuildEndurance public void EatingCallBack(object sender, EventArgs e) { - + if (StardewValley.Game1.isEating == true) - { - // Console.WriteLine("NOM NOM NOM"); + { + // Console.WriteLine("NOM NOM NOM"); fed = true; //this code will run when the player eats an object. I.E. increases their eating skills. @@ -122,16 +125,16 @@ namespace BuildEndurance //I'm going to assume they ate the food. if ((StardewValley.Game1.isEating == false) && fed == true) { - // Console.WriteLine("NOM NOM NOM"); + //Console.WriteLine("NOM NOM NOM22222222222"); BuildEndurance_data_xp_current += ModConfig.BuildEndurance_xp_eating; fed = false; } - + return; } - + public void LoadingCallBack(object sender, EventArgs e) { @@ -144,7 +147,7 @@ namespace BuildEndurance var player = StardewValley.Game1.player; - + if (BuildEndurance_data_old_stamina == 0) { BuildEndurance_data_old_stamina = player.MaxStamina; //grab the initial stamina value @@ -170,11 +173,19 @@ namespace BuildEndurance if (upon_loading == true) { - Clear_DataLoader(); + + Log.Info("THIS IS MY NEW DAY CALL BACK XP version 1"); + Log.Info(BuildEndurance_data_xp_current); + + Clear_Checker(); + Log.Info("CLEAR???"); + Log.Info(BuildEndurance_data_clear_mod_effects); + + //Clear_DataLoader(); //because this doesn't work propperly at first anyways. //return; - + var player = StardewValley.Game1.player; @@ -188,6 +199,7 @@ namespace BuildEndurance if (BuildEndurance_data_clear_mod_effects == true) { + Clear_DataLoader(); player.MaxStamina = BuildEndurance_data_old_stamina; BuildEndurance_data_xp_nextlvl = ModConfig.BuildEndurance_xp_nextlvl; BuildEndurance_data_xp_current = ModConfig.BuildEndurance_xp_current; @@ -195,6 +207,8 @@ namespace BuildEndurance BuildEndurance_data_old_stamina = player.MaxStamina; BuildEndurance_data_ini_stam_bonus = 0; BuildEndurance_data_current_lvl = 0; + + //because this doesn't work propperly at first anyways. Console.WriteLine("BuildEndurance Reset!"); } @@ -210,6 +224,10 @@ namespace BuildEndurance BuildEndurance_data_xp_nextlvl = (ModConfig.BuildEndurance_xp_curve * BuildEndurance_data_xp_nextlvl); player.MaxStamina += ModConfig.BuildEndurance_stam_increase_upon_lvl_up; BuildEndurance_data_stam_bonus_acumulated += ModConfig.BuildEndurance_stam_increase_upon_lvl_up; + + + Log.Info("THIS IS MY NEW DAY CALL BACK XP version 2!"); + Log.Info(BuildEndurance_data_xp_current); Log.Info("IF YOU SEE THIS TOO MUCH THIS IS AN INFINITE LOOP. CRAP"); } @@ -250,7 +268,7 @@ namespace BuildEndurance public int BuildEndurance_ini_stam_boost { get; set; } public int BuildEndurance_stam_accumulated { get; set; } - + } @@ -261,8 +279,8 @@ namespace BuildEndurance //loads the data to the variables upon loading the game. string myname = StardewValley.Game1.player.name; string mylocation = Path.Combine(PathOnDisk, "BuildEndurance_data_"); - string mylocation2 = mylocation+myname; - string mylocation3 = mylocation2+".txt"; + string mylocation2 = mylocation + myname; + string mylocation3 = mylocation2 + ".txt"; if (!File.Exists(mylocation3)) //if not data.json exists, initialize the data variables to the ModConfig data. I.E. starting out. { Console.WriteLine("Clear Data Loaded could not find the correct file."); @@ -285,6 +303,34 @@ namespace BuildEndurance } } + void Clear_Checker() + { + + //loads the data to the variables upon loading the game. + string myname = StardewValley.Game1.player.name; + string mylocation = Path.Combine(PathOnDisk, "BuildEndurance_data_"); + string mylocation2 = mylocation + myname; + string mylocation3 = mylocation2 + ".txt"; + if (!File.Exists(mylocation3)) //if not data.json exists, initialize the data variables to the ModConfig data. I.E. starting out. + { + Console.WriteLine("Clear Data Loaded could not find the correct file."); + + + BuildEndurance_data_clear_mod_effects = false; + BuildEndurance_data_old_stamina = 0; + BuildEndurance_data_ini_stam_bonus = 0; + //return; + } + + else + { + //loads the BuildEndurance_data upon loading the mod + string[] readtext = File.ReadAllLines(mylocation3); + BuildEndurance_data_clear_mod_effects = Convert.ToBoolean(readtext[14]); + + + } + } @@ -301,7 +347,7 @@ namespace BuildEndurance BuildEndurance_data_xp_nextlvl = ModConfig.BuildEndurance_xp_nextlvl; BuildEndurance_data_xp_current = ModConfig.BuildEndurance_xp_current; BuildEndurance_data_current_lvl = ModConfig.BuildEndurance_current_lvl; - BuildEndurance_data_ini_stam_bonus = ModConfig.BuildEndurance_ini_stam_boost; + BuildEndurance_data_ini_stam_bonus = ModConfig.BuildEndurance_ini_stam_boost; BuildEndurance_data_stam_bonus_acumulated = ModConfig.BuildEndurance_stam_accumulated; BuildEndurance_data_clear_mod_effects = false; BuildEndurance_data_old_stamina = 0; @@ -310,7 +356,7 @@ namespace BuildEndurance else { - // Console.WriteLine("HEY THERE IM LOADING DATA"); + // Console.WriteLine("HEY THERE IM LOADING DATA"); //loads the BuildEndurance_data upon loading the mod string[] readtext = File.ReadAllLines(mylocation3); @@ -318,10 +364,10 @@ namespace BuildEndurance BuildEndurance_data_xp_nextlvl = Convert.ToDouble(readtext[7]); //these array locations refer to the lines in BuildEndurance_data.json BuildEndurance_data_xp_current = Convert.ToDouble(readtext[5]); BuildEndurance_data_ini_stam_bonus = Convert.ToInt32(readtext[9]); - BuildEndurance_data_stam_bonus_acumulated = Convert.ToInt32(readtext[11]); + BuildEndurance_data_stam_bonus_acumulated = Convert.ToInt32(readtext[11]); BuildEndurance_data_clear_mod_effects = Convert.ToBoolean(readtext[14]); BuildEndurance_data_old_stamina = Convert.ToInt32(readtext[16]); - + } } @@ -332,7 +378,7 @@ namespace BuildEndurance string mylocation = Path.Combine(PathOnDisk, "BuildEndurance_data_"); string mylocation2 = mylocation + myname; string mylocation3 = mylocation2 + ".txt"; - string[] mystring3= new string[20]; + string[] mystring3 = new string[20]; if (!File.Exists(mylocation3)) { Console.WriteLine("The data file for BuildEndurance was not found, guess I'll create it when you sleep."); @@ -365,10 +411,10 @@ namespace BuildEndurance File.WriteAllLines(mylocation3, mystring3); } - + else { - // Console.WriteLine("HEY IM SAVING DATA"); + // Console.WriteLine("HEY IM SAVING DATA"); //write out the info to a text file at the end of a day. mystring3[0] = "Player: Build Endurance Data. Modification can cause errors. Edit at your own risk."; diff --git a/BuildEndurance/SMAPI_BuildEndurance.dll b/BuildEndurance/SMAPI_BuildEndurance.dll index 67e31366..dbaaffaa 100644 Binary files a/BuildEndurance/SMAPI_BuildEndurance.dll and b/BuildEndurance/SMAPI_BuildEndurance.dll differ diff --git a/BuildEndurance/manifest.json b/BuildEndurance/manifest.json index 09fbe30f..00076d10 100644 --- a/BuildEndurance/manifest.json +++ b/BuildEndurance/manifest.json @@ -2,12 +2,12 @@ "Name": "BuildEndurance", "Authour": "Alpha_Omegasis", "Version": { - "MajorVersion": 0, + "MajorVersion": 1, "MinorVersion": 0, - "PatchVersion": 1, + "PatchVersion": 0, "Build": "" }, - "Description": "SMAPI port of BuildEndurance. Increase your health as you play.", + "Description": "SMAPI port of BuildEndurance. Increase your health as you play. Updated to support per-character values.", "UniqueID": "4be88c18-b6f3-49b0-ba96-f94b1a5be890", "PerSaveConfigs": false, "EntryDll": "SMAPI_BuildEndurance.dll" diff --git a/BuildHealth/Class1.cs b/BuildHealth/Class1.cs index 322a4184..0a7d5bfc 100644 --- a/BuildHealth/Class1.cs +++ b/BuildHealth/Class1.cs @@ -89,7 +89,7 @@ namespace BuildHealth if (tool_cleaner == true) return; - if (StardewModdingAPI.Entities.SPlayer.CurrentFarmer.usingTool == true) + if (StardewValley.Game1.player.usingTool == true) { //Console.WriteLine("Tool is being used"); BuildHealth_data_xp_current += ModConfig.BuildHealth_xp_tooluse; @@ -132,9 +132,9 @@ namespace BuildHealth public void SleepCallback(object sender, EventArgs e) { if(upon_loading ==true){ - - Clear_DataLoader(); - //This will run when the character goes to sleep. It will increase their sleeping skill. + + Clear_Checker(); + var player = StardewValley.Game1.player; BuildHealth_data_xp_current += ModConfig.BuildHealth_xp_sleeping; @@ -146,7 +146,9 @@ namespace BuildHealth if (BuildHealth_data_clear_mod_effects == true) { - player.maxHealth = BuildHealth_data_old_health; + Clear_DataLoader(); + //This will run when the character goes to sleep. It will increase their sleeping skill. + player.maxHealth = BuildHealth_data_old_health; BuildHealth_data_xp_nextlvl = ModConfig.BuildHealth_xp_nextlvl; BuildHealth_data_xp_current = ModConfig.BuildHealth_xp_current; BuildHealth_data_health_bonus_acumulated = 0; @@ -263,8 +265,32 @@ namespace BuildHealth } } + void Clear_Checker() + { + //loads the data to the variables upon loading the game. + string myname = StardewValley.Game1.player.name; + string mylocation = Path.Combine(PathOnDisk, "BuildHealth_data_"); + string mylocation2 = mylocation + myname; + string mylocation3 = mylocation2 + ".txt"; + if (!File.Exists(mylocation3)) //if not data.json exists, initialize the data variables to the ModConfig data. I.E. starting out. + { + Console.WriteLine("The config file for BuildHealth was not found, guess I'll create it..."); + BuildHealth_data_clear_mod_effects = false; + BuildHealth_data_old_health = 0; + BuildHealth_data_ini_health_bonus = 0; + } + + else + { + //loads the BuildHealth_data upon loading the mod + string[] readtext = File.ReadAllLines(mylocation3); + BuildHealth_data_clear_mod_effects = Convert.ToBoolean(readtext[14]); + + } + } + void DataLoader() { diff --git a/BuildHealth/SMAPI_BuildHealth.dll b/BuildHealth/SMAPI_BuildHealth.dll index b259e05a..48b5275c 100644 Binary files a/BuildHealth/SMAPI_BuildHealth.dll and b/BuildHealth/SMAPI_BuildHealth.dll differ diff --git a/BuildHealth/manifest.json b/BuildHealth/manifest.json index c165e462..23ac2c0b 100644 --- a/BuildHealth/manifest.json +++ b/BuildHealth/manifest.json @@ -2,9 +2,9 @@ "Name": "BuildHealth", "Authour": "Alpha_Omegasis", "Version": { - "MajorVersion": 0, + "MajorVersion": 1, "MinorVersion": 0, - "PatchVersion": 1, + "PatchVersion": 0, "Build": "" }, "Description": "SMAPI port of BuildHealth. Increase your health as you play.",