diff --git a/MHFZ_Overlay/Models/QuestRestriction.cs b/MHFZ_Overlay/Models/QuestRestriction.cs new file mode 100644 index 00000000..ab2d856b --- /dev/null +++ b/MHFZ_Overlay/Models/QuestRestriction.cs @@ -0,0 +1,48 @@ +// © 2023 The mhfz-overlay developers. +// Use of this source code is governed by a MIT license that can be +// found in the LICENSE file. + +namespace MHFZ_Overlay.Models; + +using System; + +// TODO: ORM +public sealed class QuestRestriction +{ + public bool HalkPot { get; set; } + + public bool CourseAttack { get; set; } + + public bool Halk { get; set; } + + public bool PoogieCuff { get; set; } + + public bool ActiveFeature { get; set; } + + public bool SecretTechnique { get; set; } + + public bool Transcend { get; set; } + + public bool DivaPrayerGem { get; set; } + + public bool TwinHiden { get; set; } + + public bool Rasta { get; set; } + + public bool Partner { get; set; } + + public bool Partnya { get; set; } + + public bool SoulRevival { get; set; } + + public bool DivaSkill { get; set; } + + public bool QuestBonusReward { get; set; } + + public bool SimpleMode { get; set; } + + public bool GPSkill { get; set; } + + public bool Sigil { get; set; } + +} diff --git a/MHFZ_Overlay/Models/Structures/Bitfields.cs b/MHFZ_Overlay/Models/Structures/Bitfields.cs index 1202df59..797d91d9 100644 --- a/MHFZ_Overlay/Models/Structures/Bitfields.cs +++ b/MHFZ_Overlay/Models/Structures/Bitfields.cs @@ -291,7 +291,7 @@ public enum QuestVariant2 : uint /// Level9999 = 64, /// - /// no rasta, partnya, halk, soul revival or similar, halk pot, diva skill, diva prayer gem + /// no rasta, partner, partnya, halk, soul revival or similar, halk pot, diva skill, diva prayer gem /// Road = 128, All = 255, diff --git a/MHFZ_Overlay/Services/DatabaseService.cs b/MHFZ_Overlay/Services/DatabaseService.cs index de2f2315..9c533e0a 100644 --- a/MHFZ_Overlay/Services/DatabaseService.cs +++ b/MHFZ_Overlay/Services/DatabaseService.cs @@ -8181,6 +8181,119 @@ public QuestsGamePatch GetQuestsGamePatch(long runID) return data; } + public QuestRestriction GetQuestRestrictions(long runID) + { + QuestRestriction data = new(); + if (string.IsNullOrEmpty(this.dataSource)) + { + Logger.Warn(CultureInfo.InvariantCulture, "Cannot get quest restrictions. dataSource: {0}", this.dataSource); + return data; + } + + // Use a SQL query to retrieve the Quest for the specific RunID from the database + using (var conn = new SQLiteConnection(this.dataSource)) + { + conn.Open(); + using (var transaction = conn.BeginTransaction()) + { + try + { + using (var cmd = new SQLiteCommand("SELECT * FROM QuestsQuestVariant WHERE RunID = @runID", conn)) + { + cmd.Parameters.AddWithValue("@runID", runID); + + using (var reader = cmd.ExecuteReader()) + { + if (reader.Read()) + { + var questVariant2 = long.Parse(reader["QuestVariant2"]?.ToString() ?? "0", CultureInfo.InvariantCulture); + var questVariant3 = long.Parse(reader["QuestVariant3"]?.ToString() ?? "0", CultureInfo.InvariantCulture); + + data = GetQuestRestrictions((QuestVariant2)questVariant2, (QuestVariant3)questVariant3); + } + } + } + + transaction.Commit(); + } + catch (Exception ex) + { + HandleError(transaction, ex); + } + } + } + + return data; + } + + private QuestRestriction GetQuestRestrictions(QuestVariant2 questVariant2, QuestVariant3 questVariant3) + { + QuestRestriction restrictions = new(); + + if (questVariant2.HasFlag(QuestVariant2.DisableHalkPoogieCuff)) + { + restrictions.HalkPot = true; + restrictions.CourseAttack = true; + } + + if (questVariant2.HasFlag(QuestVariant2.DisableHalkPoogieCuff)) + { + restrictions.Halk = true; + restrictions.PoogieCuff = true; + } + + if (questVariant2.HasFlag(QuestVariant2.DisableActiveFeature)) + { + restrictions.ActiveFeature = true; + } + + if (questVariant2.HasFlag(QuestVariant2.Level9999)) + { + restrictions.SecretTechnique = true; + restrictions.Transcend = true; + restrictions.HalkPot = true; + restrictions.CourseAttack = true; + restrictions.DivaPrayerGem = true; + restrictions.TwinHiden = true; + } + + if (questVariant2.HasFlag(QuestVariant2.Road)) + { + restrictions.Rasta = true; + restrictions.Partner = true; + restrictions.Partnya = true; + restrictions.Halk = true; + restrictions.SoulRevival = true; + restrictions.HalkPot = true; + restrictions.DivaSkill = true; + restrictions.DivaPrayerGem = true; + } + + if (questVariant3.HasFlag(QuestVariant3.DisableRewardBonus)) + { + restrictions.QuestBonusReward = true; + } + + if (questVariant3.HasFlag(QuestVariant3.NoSimpleMode)) + { + restrictions.SimpleMode = true; + } + + if (questVariant3.HasFlag(QuestVariant3.NoGPSkills)) + { + restrictions.Transcend = true; + restrictions.GPSkill = true; + restrictions.DivaSkill = true; + } + + if (questVariant3.HasFlag(QuestVariant3.DisabledSigil)) + { + restrictions.Sigil = true; + } + + return restrictions; + } + private Quest GetLastQuest(SQLiteConnection conn) { Quest quest = new(); diff --git a/MHFZ_Overlay/ViewModels/Windows/AddressModel.cs b/MHFZ_Overlay/ViewModels/Windows/AddressModel.cs index c319f36d..9929d785 100644 --- a/MHFZ_Overlay/ViewModels/Windows/AddressModel.cs +++ b/MHFZ_Overlay/ViewModels/Windows/AddressModel.cs @@ -8468,6 +8468,7 @@ public string GenerateGearStats(long? runID = null) var courseInfo = $"Main: {GetMainCourses(courses.Rights)}\nAdditional: {GetAdditionalCourses(courses.Rights)}"; var patchInfo = DatabaseManagerInstance.GetQuestsGamePatch((long)runID); + var questRestrictions = DatabaseManagerInstance.GetQuestRestrictions((long)runID); // TODO: fix // TODO partnyaBagItems @@ -8477,13 +8478,13 @@ public string GenerateGearStats(long? runID = null) $@"{createdBy} {weaponClass}({gender}){metadata} Set Name: {gearName} -{weaponName}: {realweaponName} +{weaponName}{(questRestrictions.Sigil ? " (disabled sigils)" : string.Empty)}: {realweaponName} Head: {head} Chest: {chest} Arms: {arms} Waist: {waist} Legs: {legs} -Cuffs: {cuffs} +Cuffs: {cuffs}{(questRestrictions.PoogieCuff ? " (disabled cuffs)" : string.Empty)} Run Date: {date} | Run Hash: {hash} @@ -8493,24 +8494,24 @@ public string GenerateGearStats(long? runID = null) Automatic Skills: {automaticSkillsList} -Active Skills{gouBoost}: +Active Skills{(questRestrictions.GPSkill ? " (disabled GP Skills)" : string.Empty)}{gouBoost}: {armorSkills} Caravan Skills: {caravanSkillsList} Diva: -{(divaSkill == "None" ? "No Skill" : divaSkill)} +{(divaSkill == "None" ? "No Skill" : divaSkill)}{(questRestrictions.DivaSkill ? " (disabled skill)" : string.Empty)} Song {(diva.DivaSongBuffOn > 0 ? "ON" : "OFF")} -Diva Prayer Gems: +Diva Prayer Gems{(questRestrictions.DivaPrayerGem ? " (disabled gems)" : string.Empty)}: {GetDivaPrayerGems(diva)} Guild: {guildFood} {GetGuildPoogieEffect(guildPoogie)} -Style Rank: +Style Rank{(questRestrictions.SecretTechnique ? " (disabled secret technique)" : string.Empty)}{(questRestrictions.SoulRevival ? " (disabled soul revival)" : string.Empty)}{(questRestrictions.TwinHiden ? " (disabled twin hiden)" : string.Empty)}: {styleRankSkillsList} Items: @@ -8525,19 +8526,19 @@ public string GenerateGearStats(long? runID = null) Road/Duremudira Skills: {roadDureSkillsList} -Quest: {questName} +Quest{(questRestrictions.QuestBonusReward ? " (disabled bonus reward)" : string.Empty)}: {questName} {questObjectiveType} {questObjectiveQuantity} {questObjectiveName} Category: {questCategory} Party Size: {partySize} Mode: {toggleModeName} -Active Feature {(activeFeatureState == true ? "ON" : "OFF")} +Active Feature {(activeFeatureState == true ? "ON" : "OFF")}{(questRestrictions.ActiveFeature ? " (disabled active feature)" : string.Empty)} -Courses: +Courses{(questRestrictions.CourseAttack ? " (disabled course attack)" : string.Empty)}: {courseInfo} Halk: -{(halk.HalkOn > 0 ? "Active" : "Inactive")} -Halk Pot {(halk.HalkPotEffectOn > 0 ? "ON" : "OFF")} +{(halk.HalkOn > 0 ? "Active" : "Inactive")}{(questRestrictions.Halk ? " (disabled halk)" : string.Empty)} +Halk Pot {(halk.HalkPotEffectOn > 0 ? "ON" : "OFF")}{(questRestrictions.Sigil ? " (disabled halk pot)" : string.Empty)} LV{halk.HalkLevel} Element Type {GetHalkElement(halk)} Status Type {GetHalkStatus(halk)}