Added files via upload

This commit is contained in:
janavarro95 2016-04-10 22:39:16 -07:00
parent fc5e99bfe6
commit 3035c174fd
6 changed files with 120 additions and 48 deletions

View File

@ -15,26 +15,26 @@ 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)
@ -44,7 +44,7 @@ namespace BuildEndurance
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;
@ -79,8 +79,8 @@ namespace BuildEndurance
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");
}
@ -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;
@ -114,7 +117,7 @@ namespace BuildEndurance
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,7 +125,7 @@ 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;
}
@ -170,7 +173,15 @@ 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;
@ -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");
}
@ -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,7 +364,7 @@ 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.");
@ -368,7 +414,7 @@ namespace BuildEndurance
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.";

View File

@ -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"

View File

@ -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;
@ -133,8 +133,8 @@ namespace BuildHealth
{
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()
{

Binary file not shown.

View File

@ -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.",