From 3392f63ef6b383f8b7fe896a87d0253ce46c29b6 Mon Sep 17 00:00:00 2001 From: Doriel Rivalet <100863878+DorielRivalet@users.noreply.github.com> Date: Thu, 5 Jan 2023 21:22:31 -0300 Subject: [PATCH] feat(sqlite): track player health and stamina --- .../Class/DataAccessLayer/DatabaseManager.cs | 59 ++++--------------- MHFZ_Overlay/addresses/AddressModel.cs | 25 +++++++- 2 files changed, 37 insertions(+), 47 deletions(-) diff --git a/MHFZ_Overlay/Core/Class/DataAccessLayer/DatabaseManager.cs b/MHFZ_Overlay/Core/Class/DataAccessLayer/DatabaseManager.cs index 65a91406..69a79eee 100644 --- a/MHFZ_Overlay/Core/Class/DataAccessLayer/DatabaseManager.cs +++ b/MHFZ_Overlay/Core/Class/DataAccessLayer/DatabaseManager.cs @@ -275,6 +275,8 @@ public void InsertQuestData(string connectionString, DataLoader dataLoader) Monster3HPDictionary, Monster4HPDictionary, HitsTakenBlockedDictionary, + PlayerHPDictionary, + PlayerStaminaDictionary, PartySize, OverlayMode ) VALUES ( @@ -303,6 +305,8 @@ public void InsertQuestData(string connectionString, DataLoader dataLoader) @Monster3HPDictionary, @Monster4HPDictionary, @HitsTakenBlockedDictionary, + @PlayerHPDictionary, + @PlayerStaminaDictionary, @PartySize, @OverlayMode )"; @@ -387,6 +391,8 @@ public void InsertQuestData(string connectionString, DataLoader dataLoader) Dictionary> monster3HPDictionary = dataLoader.model.monster3HPDictionary; Dictionary> monster4HPDictionary = dataLoader.model.monster4HPDictionary; Dictionary> hitsTakenBlockedDictionary = dataLoader.model.hitsTakenBlockedDictionary; + Dictionary playerHPDictionary = dataLoader.model.playerHPDictionary; + Dictionary playerStaminaDictionary = dataLoader.model.playerStaminaDictionary; int partySize = dataLoader.model.PartySize(); string overlayMode = dataLoader.model.GetOverlayMode(); overlayMode = overlayMode.Replace("(", ""); @@ -402,13 +408,13 @@ public void InsertQuestData(string connectionString, DataLoader dataLoader) // SELECT LAST_INSERT_ROWID() as ZenithSkillsID; string questData = string.Format( - "{0}{1}{2}{3}{4}{5}{6}{7}{8}{9}{10}{11}{12}{13}{14}{15}{16}{17}{18}{19}{20}{21}{22}{23}{24}{25}", + "{0}{1}{2}{3}{4}{5}{6}{7}{8}{9}{10}{11}{12}{13}{14}{15}{16}{17}{18}{19}{20}{21}{22}{23}{24}{25}{26}{27}", runID, createdAt, createdBy, questID, finalTimeValue, finalTimeDisplay, objectiveImage, objectiveTypeID, objectiveQuantity, starGrade, rankName, objectiveName, date, attackBuffDictionary, hitCountDictionary, damageDealtDictionary, damagePerSecondDictionary, areaChangesDictionary, cartsDictionary, monster1HPDictionary, - monster2HPDictionary, monster3HPDictionary, monster4HPDictionary, hitsTakenBlockedDictionary, partySize, - overlayMode + monster2HPDictionary, monster3HPDictionary, monster4HPDictionary, hitsTakenBlockedDictionary, + playerHPDictionary, playerStaminaDictionary, partySize, overlayMode ); // Calculate the hash value for the data in the row @@ -439,6 +445,8 @@ public void InsertQuestData(string connectionString, DataLoader dataLoader) cmd.Parameters.AddWithValue("@Monster3HPDictionary", JsonConvert.SerializeObject(monster3HPDictionary)); cmd.Parameters.AddWithValue("@Monster4HPDictionary", JsonConvert.SerializeObject(monster4HPDictionary)); cmd.Parameters.AddWithValue("@HitsTakenBlockedDictionary", hitsTakenBlockedDictionary); + cmd.Parameters.AddWithValue("@PlayerHPDictionary", playerHPDictionary); + cmd.Parameters.AddWithValue("@PlayerStaminaDictionary", playerStaminaDictionary); cmd.Parameters.AddWithValue("@PartySize", partySize); cmd.Parameters.AddWithValue("@OverlayMode", overlayMode); @@ -2562,6 +2570,8 @@ ObjectiveTypeID INTEGER NOT NULL CHECK (ObjectiveTypeID >= 0), Monster3HPDictionary TEXT NOT NULL, Monster4HPDictionary TEXT NOT NULL, HitsTakenBlockedDictionary TEXT NOT NULL, + PlayerHPDictionary TEXT NOT NULL, + PlayerStaminaDictionary TEXT NOT NULL, PartySize INTEGER NOT NULL, OverlayMode TEXT NOT NULL, FOREIGN KEY(QuestID) REFERENCES QuestName(QuestNameID), @@ -3305,49 +3315,6 @@ FOREIGN KEY(Item10ID) REFERENCES Item(ItemID) cmd.ExecuteNonQuery(); } - // TODO: addresses - sql = @"CREATE TABLE IF NOT EXISTS PartnyaBag ( - CreatedAt DATETIME NOT NULL, - CreatedBy TEXT NOT NULL, - PartnyaBagID INTEGER PRIMARY KEY AUTOINCREMENT, - RunID INTEGER NOT NULL, - Item1ID INTEGER NOT NULL CHECK (Item1ID >= 0), - Item1Quantity INTEGER NOT NULL, - Item2ID INTEGER NOT NULL CHECK (Item2ID >= 0), - Item2Quantity INTEGER NOT NULL, - Item3ID INTEGER NOT NULL CHECK (Item3ID >= 0), - Item3Quantity INTEGER NOT NULL, - Item4ID INTEGER NOT NULL CHECK (Item4ID >= 0), - Item4Quantity INTEGER NOT NULL, - Item5ID INTEGER NOT NULL CHECK (Item5ID >= 0), - Item5Quantity INTEGER NOT NULL, - Item6ID INTEGER NOT NULL CHECK (Item6ID >= 0), - Item6Quantity INTEGER NOT NULL, - Item7ID INTEGER NOT NULL CHECK (Item7ID >= 0), - Item7Quantity INTEGER NOT NULL, - Item8ID INTEGER NOT NULL CHECK (Item8ID >= 0), - Item8Quantity INTEGER NOT NULL, - Item9ID INTEGER NOT NULL CHECK (Item9ID >= 0), - Item9Quantity INTEGER NOT NULL, - Item10ID INTEGER NOT NULL CHECK (Item10ID >= 0), - Item10Quantity INTEGER NOT NULL, - FOREIGN KEY(RunID) REFERENCES Quests(RunID), - FOREIGN KEY(Item1ID) REFERENCES Item(ItemID), - FOREIGN KEY(Item2ID) REFERENCES Item(ItemID), - FOREIGN KEY(Item3ID) REFERENCES Item(ItemID), - FOREIGN KEY(Item4ID) REFERENCES Item(ItemID), - FOREIGN KEY(Item5ID) REFERENCES Item(ItemID), - FOREIGN KEY(Item6ID) REFERENCES Item(ItemID), - FOREIGN KEY(Item7ID) REFERENCES Item(ItemID), - FOREIGN KEY(Item8ID) REFERENCES Item(ItemID), - FOREIGN KEY(Item9ID) REFERENCES Item(ItemID), - FOREIGN KEY(Item10ID) REFERENCES Item(ItemID) - )"; - using (SQLiteCommand cmd = new SQLiteCommand(sql, conn)) - { - cmd.ExecuteNonQuery(); - } - sql = @"CREATE TABLE IF NOT EXISTS RoadDureSkills ( CreatedAt DATETIME NOT NULL, CreatedBy TEXT NOT NULL, diff --git a/MHFZ_Overlay/addresses/AddressModel.cs b/MHFZ_Overlay/addresses/AddressModel.cs index 698ec1be..6c23d138 100644 --- a/MHFZ_Overlay/addresses/AddressModel.cs +++ b/MHFZ_Overlay/addresses/AddressModel.cs @@ -8709,7 +8709,11 @@ public double CalculateDPS() // time, areaid, hitstakenblocked // can calculate total hits by area by checking areaid, or in total by all sum. public Dictionary> hitsTakenBlockedDictionary = new Dictionary>(); - + + public Dictionary playerHPDictionary = new Dictionary(); + public Dictionary playerStaminaDictionary = new Dictionary(); + + // Initialize the damageDealt and timeElapsed variables to 0 //int damageDealt = 0; //int timeElapsed = 0; @@ -8745,6 +8749,9 @@ public double CalculateDPS() public int previousHitsTakenBlocked = 0; + public int previousPlayerHP = 0; + public int previousPlayerStamina = 0; + public void InsertQuestInfoIntoDictionaries() { //if (TimeInt() == previousTimeInt) @@ -8975,6 +8982,18 @@ public void InsertQuestInfoIntoDictionaries() hitsAreaPairs.Add(AreaHitsTakenBlocked(), AreaID()); hitsTakenBlockedDictionary.Add(TimeInt(), hitsAreaPairs); } + + if (previousPlayerHP != HunterHP()) + { + previousPlayerHP = HunterHP(); + playerHPDictionary.Add(TimeInt(), HunterHP()); + } + + if (previousPlayerStamina != HunterStamina()) + { + previousPlayerStamina = HunterStamina(); + playerStaminaDictionary.Add(TimeInt(), HunterStamina()); + } } public void resetQuestInfoVariables() @@ -9058,6 +9077,8 @@ public void resetQuestInfoVariables() previousTotalAmmo = 0; previousTotalPartnyaItems = 0; previousHitsTakenBlocked = 0; + previousPlayerHP = 0; + previousPlayerStamina = 0; } public void clearQuestInfoDictionaries() @@ -9076,6 +9097,8 @@ public void clearQuestInfoDictionaries() playerAmmoPouchDictionary.Clear(); partnyaBagDictionary.Clear(); hitsTakenBlockedDictionary.Clear(); + playerHPDictionary.Clear(); + playerStaminaDictionary.Clear(); }