Skip to content

Commit

Permalink
feat(sqlite): track player health and stamina
Browse files Browse the repository at this point in the history
  • Loading branch information
DorielRivalet committed Jan 6, 2023
1 parent 1c4db6b commit 3392f63
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 47 deletions.
59 changes: 13 additions & 46 deletions MHFZ_Overlay/Core/Class/DataAccessLayer/DatabaseManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,8 @@ public void InsertQuestData(string connectionString, DataLoader dataLoader)
Monster3HPDictionary,
Monster4HPDictionary,
HitsTakenBlockedDictionary,
PlayerHPDictionary,
PlayerStaminaDictionary,
PartySize,
OverlayMode
) VALUES (
Expand Down Expand Up @@ -303,6 +305,8 @@ public void InsertQuestData(string connectionString, DataLoader dataLoader)
@Monster3HPDictionary,
@Monster4HPDictionary,
@HitsTakenBlockedDictionary,
@PlayerHPDictionary,
@PlayerStaminaDictionary,
@PartySize,
@OverlayMode
)";
Expand Down Expand Up @@ -387,6 +391,8 @@ public void InsertQuestData(string connectionString, DataLoader dataLoader)
Dictionary<int, Dictionary<int, int>> monster3HPDictionary = dataLoader.model.monster3HPDictionary;
Dictionary<int, Dictionary<int, int>> monster4HPDictionary = dataLoader.model.monster4HPDictionary;
Dictionary<int, Dictionary<int, int>> hitsTakenBlockedDictionary = dataLoader.model.hitsTakenBlockedDictionary;
Dictionary<int, int> playerHPDictionary = dataLoader.model.playerHPDictionary;
Dictionary<int, int> playerStaminaDictionary = dataLoader.model.playerStaminaDictionary;
int partySize = dataLoader.model.PartySize();
string overlayMode = dataLoader.model.GetOverlayMode();
overlayMode = overlayMode.Replace("(", "");
Expand All @@ -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
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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),
Expand Down Expand Up @@ -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,
Expand Down
25 changes: 24 additions & 1 deletion MHFZ_Overlay/addresses/AddressModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<int,Dictionary<int,int>> hitsTakenBlockedDictionary = new Dictionary<int, Dictionary<int, int>>();


public Dictionary<int, int> playerHPDictionary = new Dictionary<int, int>();
public Dictionary<int, int> playerStaminaDictionary = new Dictionary<int, int>();


// Initialize the damageDealt and timeElapsed variables to 0
//int damageDealt = 0;
//int timeElapsed = 0;
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -9058,6 +9077,8 @@ public void resetQuestInfoVariables()
previousTotalAmmo = 0;
previousTotalPartnyaItems = 0;
previousHitsTakenBlocked = 0;
previousPlayerHP = 0;
previousPlayerStamina = 0;
}

public void clearQuestInfoDictionaries()
Expand All @@ -9076,6 +9097,8 @@ public void clearQuestInfoDictionaries()
playerAmmoPouchDictionary.Clear();
partnyaBagDictionary.Clear();
hitsTakenBlockedDictionary.Clear();
playerHPDictionary.Clear();
playerStaminaDictionary.Clear();
}


Expand Down

0 comments on commit 3392f63

Please sign in to comment.