From 0c45548a3de7eaebe9ac92c6c1212178e5bea4ce Mon Sep 17 00:00:00 2001 From: Doriel Rivalet <100863878+DorielRivalet@users.noreply.github.com> Date: Mon, 7 Aug 2023 19:51:58 -0300 Subject: [PATCH] feat: add more achievements --- .../Models/Collections/Achievements.cs | 28 ++++- MHFZ_Overlay/Services/AchievementService.cs | 108 +++++++++++++++++- MHFZ_Overlay/Views/Windows/MainWindow.xaml.cs | 1 + 3 files changed, 133 insertions(+), 4 deletions(-) diff --git a/MHFZ_Overlay/Models/Collections/Achievements.cs b/MHFZ_Overlay/Models/Collections/Achievements.cs index ada9089e..2a22c084 100644 --- a/MHFZ_Overlay/Models/Collections/Achievements.cs +++ b/MHFZ_Overlay/Models/Collections/Achievements.cs @@ -5309,7 +5309,7 @@ that beautiful bird regains its brilliance Description = string.Empty, Rank = AchievementRank.Platinum, Image = @"pack://application:,,,/MHFZ_Overlay;component/Assets/Icons/png/extreme_poison.png", - Objective = "Defeat Zenith★4 Gasurabazura solo without Poison Cure.", + Objective = "Defeat Zenith★4 Gasurabazura solo without Anti-Venom.", IsSecret = true, Hint = "No cures allowed! But your halk is allowed to help.", } @@ -5340,5 +5340,31 @@ that beautiful bird regains its brilliance Hint = string.Empty, } }, + { + 408, new Achievement() + { + CompletionDate = DateTime.UnixEpoch, + Title = "Challenge Acepted", + Description = string.Empty, + Rank = AchievementRank.Silver, + Image = @"pack://application:,,,/MHFZ_Overlay;component/Assets/Icons/achievement/stamp.jpg", + Objective = "Accept a rare gacha challenge.", + IsSecret = false, + Hint = string.Empty, + } + }, + { + 409, new Achievement() + { + CompletionDate = DateTime.UnixEpoch, + Title = "No cheats allowed!", + Description = string.Empty, + Rank = AchievementRank.Bronze, + Image = @"pack://application:,,,/MHFZ_Overlay;component/Assets/Icons/achievement/unknown_red.jpg", + Objective = "Enter the Konami Code on the start of a quest.", + IsSecret = true, + Hint = "Sorry, but that cheat code won't give you 30 more tries on this quest.", + } + }, }); } diff --git a/MHFZ_Overlay/Services/AchievementService.cs b/MHFZ_Overlay/Services/AchievementService.cs index 70dfb88f..950ccb31 100644 --- a/MHFZ_Overlay/Services/AchievementService.cs +++ b/MHFZ_Overlay/Services/AchievementService.cs @@ -2377,7 +2377,7 @@ join playerGear in databaseManagerInstance.AllPlayerGear on quest.RunID equals p return false; } - case 361: // TODO gacha stuff + case 361: // TODO challenges stuff case 362: case 363: case 364: @@ -2420,12 +2420,114 @@ join playerGear in databaseManagerInstance.AllPlayerGear on quest.RunID equals p case 401: case 402: case 403: + return false; case 404: + completedQuests = from quest in databaseManagerInstance.AllQuests + join activeSkills in databaseManagerInstance.AllActiveSkills on quest.RunID equals activeSkills.RunID + where quest.QuestID == Numbers.QuestIDLV9999CrimsonFatalis && quest.PartySize == 1 && + !(activeSkills.ActiveSkill1ID == 193 || activeSkills.ActiveSkill1ID == 194 || + activeSkills.ActiveSkill2ID == 193 || activeSkills.ActiveSkill2ID == 194 || + activeSkills.ActiveSkill3ID == 193 || activeSkills.ActiveSkill3ID == 194 || + activeSkills.ActiveSkill4ID == 193 || activeSkills.ActiveSkill4ID == 194 || + activeSkills.ActiveSkill5ID == 193 || activeSkills.ActiveSkill5ID == 194 || + activeSkills.ActiveSkill6ID == 193 || activeSkills.ActiveSkill6ID == 194 || + activeSkills.ActiveSkill7ID == 193 || activeSkills.ActiveSkill7ID == 194 || + activeSkills.ActiveSkill8ID == 193 || activeSkills.ActiveSkill8ID == 194 || + activeSkills.ActiveSkill9ID == 193 || activeSkills.ActiveSkill9ID == 194 || + activeSkills.ActiveSkill10ID == 193 || activeSkills.ActiveSkill10ID == 194 || + activeSkills.ActiveSkill11ID == 193 || activeSkills.ActiveSkill11ID == 194 || + activeSkills.ActiveSkill12ID == 193 || activeSkills.ActiveSkill12ID == 194 || + activeSkills.ActiveSkill13ID == 193 || activeSkills.ActiveSkill13ID == 194 || + activeSkills.ActiveSkill14ID == 193 || activeSkills.ActiveSkill14ID == 194 || + activeSkills.ActiveSkill15ID == 193 || activeSkills.ActiveSkill15ID == 194 || + activeSkills.ActiveSkill16ID == 193 || activeSkills.ActiveSkill16ID == 194 || + activeSkills.ActiveSkill17ID == 193 || activeSkills.ActiveSkill17ID == 194 || + activeSkills.ActiveSkill18ID == 193 || activeSkills.ActiveSkill18ID == 194 || + activeSkills.ActiveSkill19ID == 193 || activeSkills.ActiveSkill19ID == 194) + select quest; + if (completedQuests != null && completedQuests.Any()) + { + return true; + } + else + { + return false; + } case 405: + completedQuests = from quest in databaseManagerInstance.AllQuests + join playerGear in databaseManagerInstance.AllPlayerGear on quest.RunID equals playerGear.RunID + where quest.QuestID == Numbers.QuestIDZ4Gasurabazura && quest.PartySize == 1 && playerGear.PlayerInventoryDictionary != null && + !(JsonConvert.DeserializeObject>>>(playerGear.PlayerInventoryDictionary)?.Values + .SelectMany(list => list) + .Any(innerDict => innerDict.ContainsKey(13607)) ?? false) + select quest; + if (completedQuests != null && completedQuests.Any()) + { + return true; + } + else + { + return false; + } case 406: - case 407: - { return false; + case 407: // TODO test + completedQuests = from quest in databaseManagerInstance.AllQuests + join playerGear in databaseManagerInstance.AllPlayerGear on quest.RunID equals playerGear.RunID + where quest.QuestID == Numbers.QuestIDUpperShitenUnknown && + quest.PartySize == 1 && + playerGear.PlayerInventoryDictionary != null && + (JsonConvert.DeserializeObject>>>(playerGear.PlayerInventoryDictionary)?.Values + .SelectMany(list => list) + .All(innerDict => innerDict.ContainsKey(0)) ?? false) + select quest; + if (completedQuests != null && completedQuests.Any()) + { + return true; + } + else + { + return false; + } + case 408: + return false; + case 409: + { + var keyboardCode = new List { "W", "W", "S", "S", "A", "D", "A", "D", "D2", "D1", }; + var gamepadCode = new List { "DPadUp", "DPadUp", "DPadDown", "DPadDown", "DPadLeft", "DPadRight", "DPadLeft", "DPadRight", "B", "A", }; + + var foundData = from quest in databaseManagerInstance.AllQuests + where (quest.KeyStrokesDictionary != null && + JsonConvert.DeserializeObject>(quest.KeyStrokesDictionary) != null && + quest.GamepadInputDictionary != null && + JsonConvert.DeserializeObject>(quest.GamepadInputDictionary) != null) + select quest; + + if (foundData == null) + { + return false; + } + + var foundCode = from quest in databaseManagerInstance.AllQuests + where (JsonConvert.DeserializeObject>(quest.KeyStrokesDictionary)?.Values + .Select((keyValue) => keyValue.Trim()) + .Take(keyboardCode.Count) + .SequenceEqual(keyboardCode) ?? false) + || + (JsonConvert.DeserializeObject>(quest.GamepadInputDictionary)?.Values + .Select((keyValue) => keyValue.Trim()) + .Take(gamepadCode.Count) + .SequenceEqual(gamepadCode) ?? false) + select quest; + + if (foundCode != null && foundCode.Any()) + { + return true; + } + else + { + return false; + } } } } diff --git a/MHFZ_Overlay/Views/Windows/MainWindow.xaml.cs b/MHFZ_Overlay/Views/Windows/MainWindow.xaml.cs index c2217af2..00ff4b9d 100644 --- a/MHFZ_Overlay/Views/Windows/MainWindow.xaml.cs +++ b/MHFZ_Overlay/Views/Windows/MainWindow.xaml.cs @@ -2096,6 +2096,7 @@ private void GlobalHookMouseUpExt(object sender, MouseEventExtArgs e) } } + // TODO: its finicky private void GlobalHookKeyDown(object sender, System.Windows.Forms.KeyEventArgs e) { if (this.keyImages.TryGetValue(e.KeyCode, out var image))