diff --git a/src/StatisticsAnalysisTool/App.config b/src/StatisticsAnalysisTool/App.config index 0438cec2d..11d2f649a 100644 --- a/src/StatisticsAnalysisTool/App.config +++ b/src/StatisticsAnalysisTool/App.config @@ -67,6 +67,9 @@ Mails.json + + Vaults.json + diff --git a/src/StatisticsAnalysisTool/App.xaml b/src/StatisticsAnalysisTool/App.xaml index c577e1523..8a01aee4f 100644 --- a/src/StatisticsAnalysisTool/App.xaml +++ b/src/StatisticsAnalysisTool/App.xaml @@ -23,6 +23,7 @@ + diff --git a/src/StatisticsAnalysisTool/Common/ExtensionMethod.cs b/src/StatisticsAnalysisTool/Common/ExtensionMethod.cs index ec5ed66a8..64fcb65e8 100644 --- a/src/StatisticsAnalysisTool/Common/ExtensionMethod.cs +++ b/src/StatisticsAnalysisTool/Common/ExtensionMethod.cs @@ -32,7 +32,7 @@ public static Dictionary ToDictionary(this IEnumerable array) .Select((v, i) => new { Key = i, Value = v }) .ToDictionary(o => o.Key, o => o.Value); } - + public static string ToTimerString(this TimeSpan span) { return $"{span.Hours:00}:{span.Minutes:00}:{span.Seconds:00}"; diff --git a/src/StatisticsAnalysisTool/Common/Locations.cs b/src/StatisticsAnalysisTool/Common/Locations.cs index 4d122fb51..6dc27d923 100644 --- a/src/StatisticsAnalysisTool/Common/Locations.cs +++ b/src/StatisticsAnalysisTool/Common/Locations.cs @@ -1,6 +1,6 @@ -using System; using LiveChartsCore.SkiaSharpView.Painting; using SkiaSharp; +using System; using System.Collections.Generic; using System.Linq; using System.Windows; @@ -12,40 +12,40 @@ public static class Locations { public static readonly Dictionary Names = new() { - {Location.Thetford, "Thetford"}, - {Location.SwampCross, "Swamp Cross"}, - {Location.Lymhurst, "Lymhurst"}, - {Location.ForestCross, "Forest Cross"}, - {Location.Bridgewatch, "Bridgewatch"}, - {Location.SteppeCross, "Steppe Cross"}, - {Location.HighlandCross, "Highland Cross"}, - {Location.BlackMarket, "Black Market"}, - {Location.Martlock, "Martlock"}, - {Location.Caerleon, "Caerleon"}, - {Location.FortSterling, "Fort Sterling"}, - {Location.MountainCross, "Mountain Cross"}, - {Location.ArthursRest, "Arthur's Rest"}, - {Location.MerlynsRest, "Merlyn's Rest"}, - {Location.MorganasRest, "Morgana's Rest"} + { Location.Thetford, "Thetford" }, + { Location.SwampCross, "Swamp Cross" }, + { Location.Lymhurst, "Lymhurst" }, + { Location.ForestCross, "Forest Cross" }, + { Location.Bridgewatch, "Bridgewatch" }, + { Location.SteppeCross, "Steppe Cross" }, + { Location.HighlandCross, "Highland Cross" }, + { Location.BlackMarket, "Black Market" }, + { Location.Martlock, "Martlock" }, + { Location.Caerleon, "Caerleon" }, + { Location.FortSterling, "Fort Sterling" }, + { Location.MountainCross, "Mountain Cross" }, + { Location.ArthursRest, "Arthur's Rest" }, + { Location.MerlynsRest, "Merlyn's Rest" }, + { Location.MorganasRest, "Morgana's Rest" } }; public static readonly Dictionary ParameterNames = new() { - {Location.Thetford, "Thetford"}, - {Location.SwampCross, "Swamp Cross"}, - {Location.Lymhurst, "Lymhurst"}, - {Location.ForestCross, "Forest Cross"}, - {Location.Bridgewatch, "Bridgewatch"}, - {Location.SteppeCross, "Steppe Cross"}, - {Location.HighlandCross, "Highland Cross"}, - {Location.BlackMarket, "Black Market"}, - {Location.Martlock, "Martlock"}, - {Location.Caerleon, "Caerleon"}, - {Location.FortSterling, "Fort Sterling"}, - {Location.MountainCross, "Mountain Cross"}, - {Location.ArthursRest, "Arthurs Rest"}, - {Location.MerlynsRest, "Merlyns Rest"}, - {Location.MorganasRest, "Morganas Rest"} + { Location.Thetford, "Thetford" }, + { Location.SwampCross, "Swamp Cross" }, + { Location.Lymhurst, "Lymhurst" }, + { Location.ForestCross, "Forest Cross" }, + { Location.Bridgewatch, "Bridgewatch" }, + { Location.SteppeCross, "Steppe Cross" }, + { Location.HighlandCross, "Highland Cross" }, + { Location.BlackMarket, "Black Market" }, + { Location.Martlock, "Martlock" }, + { Location.Caerleon, "Caerleon" }, + { Location.FortSterling, "Fort Sterling" }, + { Location.MountainCross, "Mountain Cross" }, + { Location.ArthursRest, "Arthurs Rest" }, + { Location.MerlynsRest, "Merlyns Rest" }, + { Location.MorganasRest, "Morganas Rest" } }; public static string GetName(Location location) diff --git a/src/StatisticsAnalysisTool/Enumerations/EventCodes.cs b/src/StatisticsAnalysisTool/Enumerations/EventCodes.cs index 091fd1fca..400cf939b 100644 --- a/src/StatisticsAnalysisTool/Enumerations/EventCodes.cs +++ b/src/StatisticsAnalysisTool/Enumerations/EventCodes.cs @@ -30,9 +30,9 @@ public enum EventCodes NewCharacter = 26, NewEquipmentItem = 27, // map[0:657 1:2036 2:1 4:28169331 5:Apolo540 6:3 7:90000000 8:[] 9:[0] 252:27] (0: ObjectId, 1: ItemId, 2: Amount, 4: Avarage Market Price, 5: CrafterName) NewSimpleItem = 28, // map[0:505 1:7006 2:1 3:true 4:29033970 252:27] (0: ObjectId, 1: ItemId, 2: Amount) - NewFurnitureItem, - NewJournalItem, - NewLaborerItem, + NewFurnitureItem = 29, + NewJournalItem = 30, + NewLaborerItem = 31, NewSimpleHarvestableObject, NewSimpleHarvestableObjectList, NewHarvestableObject, @@ -91,7 +91,7 @@ public enum EventCodes RegenerationPlayerComboChanged, DurabilityChanged, NewLoot, - AttachItemContainer, // map[0:78 1:[-99 -50 125 -49 86 0 -115 74 -74 67 9 101 -87 -71 -66 -10] 3:[0 0 0 0 0 0 656 657] 4:8 252:89] (0: ObjectId, 3: ItemId[]) + AttachItemContainer = 88, // map[0:78 1:[-99 -50 125 -49 86 0 -115 74 -74 67 9 101 -87 -71 -66 -10] 3:[0 0 0 0 0 0 656 657] 4:8 252:89] (0: ObjectId, 3: ItemId[]) DetachItemContainer, // map[0:[-95 72 -77 -75 -70 34 127 73 -114 -96 28 8 75 -107 -106 125] 252:90] InvalidateItemContainer, LockItemContainer, @@ -380,8 +380,8 @@ public enum EventCodes UnlockVanityUnlock, AvatarUnlocked, CustomizationChanged, - BaseVaultInfo, - GuildVaultInfo, + GuildVaultInfo = 385, + BaseVaultInfo = 386, BankVaultInfo, RecoveryVaultPlayerInfo, RecoveryVaultGuildInfo, diff --git a/src/StatisticsAnalysisTool/Enumerations/OperationCodes.cs b/src/StatisticsAnalysisTool/Enumerations/OperationCodes.cs index f45e91b23..275722f31 100644 --- a/src/StatisticsAnalysisTool/Enumerations/OperationCodes.cs +++ b/src/StatisticsAnalysisTool/Enumerations/OperationCodes.cs @@ -96,7 +96,7 @@ public enum OperationCodes AuctionGetMyOpenAuctions, AuctionGetItemAverageStats, AuctionGetItemAverageValue, - ContainerOpen, + ContainerOpen = 92, // map[0: ObjectId = 405 1:1 2: ObjectGuid = [-46 37 -21 125 -40 -77 125 76 -96 -6 39 120 -46 -21 11 -39] 253:92] ContainerClose, ContainerManageSubContainer, Respawn, diff --git a/src/StatisticsAnalysisTool/Enumerations/VaultLocation.cs b/src/StatisticsAnalysisTool/Enumerations/VaultLocation.cs new file mode 100644 index 000000000..da57c7b27 --- /dev/null +++ b/src/StatisticsAnalysisTool/Enumerations/VaultLocation.cs @@ -0,0 +1,19 @@ +namespace StatisticsAnalysisTool.Enumerations; + +public enum VaultLocation +{ + Unknown = 0, + BankOfThetford = 0006, + BankOfLymhurst = 1001, + ForestCross = 1006, + SteppeCross = 2002, + BankOfBridgewatch = 2003, + HighlandCross = 3002, + BankOfCaerleon = 3006, + BankOfMartlock = 3007, + BankOfFortSterling = 4001, + MountainCross = 4006, + ArthursRest = 4300, + MerlynsRest = -2, + MorganasRest = -3 +} \ No newline at end of file diff --git a/src/StatisticsAnalysisTool/Languages/de-DE.xml b/src/StatisticsAnalysisTool/Languages/de-DE.xml index 93bbdc6c5..e3e492035 100644 --- a/src/StatisticsAnalysisTool/Languages/de-DE.xml +++ b/src/StatisticsAnalysisTool/Languages/de-DE.xml @@ -560,4 +560,6 @@ Verkauf abgelaufen Kauf abgelaufen bis + Lager Historie + Bank \ No newline at end of file diff --git a/src/StatisticsAnalysisTool/Languages/en-US.xml b/src/StatisticsAnalysisTool/Languages/en-US.xml index 3689cf00b..081f70d0b 100644 --- a/src/StatisticsAnalysisTool/Languages/en-US.xml +++ b/src/StatisticsAnalysisTool/Languages/en-US.xml @@ -560,4 +560,6 @@ Sell expired Buy expired to + Storage History + Bank \ No newline at end of file diff --git a/src/StatisticsAnalysisTool/Models/BindingModel/VaultBindings.cs b/src/StatisticsAnalysisTool/Models/BindingModel/VaultBindings.cs new file mode 100644 index 000000000..f8167975f --- /dev/null +++ b/src/StatisticsAnalysisTool/Models/BindingModel/VaultBindings.cs @@ -0,0 +1,103 @@ +using System; +using StatisticsAnalysisTool.Models.NetworkModel; +using StatisticsAnalysisTool.Properties; +using System.Collections.Generic; +using System.ComponentModel; +using System.Linq; +using System.Runtime.CompilerServices; +using System.Windows; + +namespace StatisticsAnalysisTool.Models.BindingModel; + +public class VaultBindings : INotifyPropertyChanged +{ + private List _vaultContainerContent; + private List _vaults; + private Vault _vaultSelected; + private List _vaultContainer; + private VaultContainer _vaultContainerSelected; + private Visibility _lastUpdateVisibility = Visibility.Hidden; + private DateTime _lastUpdate; + + public List Vaults + { + get => _vaults; + set + { + _vaults = value; + OnPropertyChanged(); + } + } + + public Vault VaultSelected + { + get => _vaultSelected; + set + { + _vaultSelected = value; + VaultContainer = _vaultSelected.VaultContainer.FindAll(x => x.LastUpdate.Ticks > 0).OrderBy(y => y.Name).ToList(); + OnPropertyChanged(); + } + } + + public List VaultContainer + { + get => _vaultContainer; + set + { + _vaultContainer = value; + OnPropertyChanged(); + } + } + + public VaultContainer VaultContainerSelected + { + get => _vaultContainerSelected; + set + { + _vaultContainerSelected = value; + VaultContainerContent = _vaultContainer?.FirstOrDefault(x => x.Guid == _vaultContainerSelected.Guid)?.Items ?? new List(); + LastUpdate = _vaultContainerSelected?.LastUpdate ?? new DateTime(0); + LastUpdateVisibility = _vaultContainerSelected?.LastUpdate.Ticks <= 1 ? Visibility.Hidden : Visibility.Visible; + OnPropertyChanged(); + } + } + + public List VaultContainerContent + { + get => _vaultContainerContent; + set + { + _vaultContainerContent = value; + OnPropertyChanged(); + } + } + + public Visibility LastUpdateVisibility + { + get => _lastUpdateVisibility; + set + { + _lastUpdateVisibility = value; + OnPropertyChanged(); + } + } + + public DateTime LastUpdate + { + get => _lastUpdate; + set + { + _lastUpdate = value; + OnPropertyChanged(); + } + } + + public event PropertyChangedEventHandler PropertyChanged; + + [NotifyPropertyChangedInvocator] + protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null) + { + PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); + } +} \ No newline at end of file diff --git a/src/StatisticsAnalysisTool/Models/MainWindowTranslation.cs b/src/StatisticsAnalysisTool/Models/MainWindowTranslation.cs index f3cba473e..bd559770d 100644 --- a/src/StatisticsAnalysisTool/Models/MainWindowTranslation.cs +++ b/src/StatisticsAnalysisTool/Models/MainWindowTranslation.cs @@ -71,6 +71,7 @@ public class MainWindowTranslation public static string Dungeons => LanguageController.Translation("DUNGEONS"); public static string PlayerInformation => LanguageController.Translation("PLAYER_INFORMATION"); public static string MailMonitoring => LanguageController.Translation("MAIL_MONITORING"); + public static string StorageHistory => LanguageController.Translation("STORAGE_HISTORY"); public static string Logging => LanguageController.Translation("LOGGING"); public static string TrackingIsActive => LanguageController.Translation("TRACKING_IS_ACTIVE"); public static string TrackingIsPartiallyActive => LanguageController.Translation("TRACKING_IS_PARTIALLY_ACTIVE"); diff --git a/src/StatisticsAnalysisTool/Models/NetworkModel/ContainerItem.cs b/src/StatisticsAnalysisTool/Models/NetworkModel/ContainerItem.cs new file mode 100644 index 000000000..32881110d --- /dev/null +++ b/src/StatisticsAnalysisTool/Models/NetworkModel/ContainerItem.cs @@ -0,0 +1,12 @@ +using System.Text.Json.Serialization; +using StatisticsAnalysisTool.Common; + +namespace StatisticsAnalysisTool.Models.NetworkModel; + +public class ContainerItem +{ + public int ItemIndex { get; set; } + [JsonIgnore] + public Item Item => ItemController.GetItemByIndex(ItemIndex); + public int Quantity { get; set; } +} \ No newline at end of file diff --git a/src/StatisticsAnalysisTool/Models/NetworkModel/DiscoveredLoot.cs b/src/StatisticsAnalysisTool/Models/NetworkModel/DiscoveredItem.cs similarity index 65% rename from src/StatisticsAnalysisTool/Models/NetworkModel/DiscoveredLoot.cs rename to src/StatisticsAnalysisTool/Models/NetworkModel/DiscoveredItem.cs index b7d66af87..63ef15f32 100644 --- a/src/StatisticsAnalysisTool/Models/NetworkModel/DiscoveredLoot.cs +++ b/src/StatisticsAnalysisTool/Models/NetworkModel/DiscoveredItem.cs @@ -3,16 +3,16 @@ namespace StatisticsAnalysisTool.Models.NetworkModel { - public class DiscoveredLoot + public class DiscoveredItem { - public DiscoveredLoot() + public DiscoveredItem() { - UtcPickupTime = DateTime.UtcNow; + UtcDiscoveryTime = DateTime.UtcNow; } public long ObjectId { get; set; } - public int ItemId { get; set; } - public DateTime UtcPickupTime { get; } + public int ItemIndex { get; set; } + public DateTime UtcDiscoveryTime { get; } public int Quantity { get; set; } public string BodyName { get; set; } public string LooterName { get; set; } diff --git a/src/StatisticsAnalysisTool/Models/NetworkModel/ItemContainerObject.cs b/src/StatisticsAnalysisTool/Models/NetworkModel/ItemContainerObject.cs new file mode 100644 index 000000000..fd7329d73 --- /dev/null +++ b/src/StatisticsAnalysisTool/Models/NetworkModel/ItemContainerObject.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; + +namespace StatisticsAnalysisTool.Models.NetworkModel; + +public class ItemContainerObject +{ + public ItemContainerObject(long? objectId, Guid containerGuid, List slotItemId) + { + ObjectId = objectId; + ContainerGuid = containerGuid; + SlotItemId = slotItemId; + + LastUpdate = DateTime.UtcNow; + } + + public DateTime LastUpdate { get; } + public long? ObjectId { get; set; } + public Guid ContainerGuid { get; set; } + public List SlotItemId { get; set; } +} \ No newline at end of file diff --git a/src/StatisticsAnalysisTool/Models/NetworkModel/Container.cs b/src/StatisticsAnalysisTool/Models/NetworkModel/LootContainer.cs similarity index 95% rename from src/StatisticsAnalysisTool/Models/NetworkModel/Container.cs rename to src/StatisticsAnalysisTool/Models/NetworkModel/LootContainer.cs index 4a333cac4..65b9dd876 100644 --- a/src/StatisticsAnalysisTool/Models/NetworkModel/Container.cs +++ b/src/StatisticsAnalysisTool/Models/NetworkModel/LootContainer.cs @@ -11,7 +11,7 @@ public enum ContainerType Player } - public class Container + public class LootContainer { public string Id { get; set; } diff --git a/src/StatisticsAnalysisTool/Models/NetworkModel/Vault.cs b/src/StatisticsAnalysisTool/Models/NetworkModel/Vault.cs new file mode 100644 index 000000000..e6ec55a6f --- /dev/null +++ b/src/StatisticsAnalysisTool/Models/NetworkModel/Vault.cs @@ -0,0 +1,17 @@ +using StatisticsAnalysisTool.Enumerations; +using StatisticsAnalysisTool.GameData; +using StatisticsAnalysisTool.Network.Manager; +using System.Collections.Generic; +using System.Text.Json.Serialization; + +namespace StatisticsAnalysisTool.Models.NetworkModel; + +public class Vault +{ + public string Location { get; set; } + [JsonIgnore] + public VaultLocation VaultLocation => VaultController.GetVaultLocation(Location); + [JsonIgnore] + public string LocationName => WorldData.GetUniqueNameOrDefault(VaultController.GetVaultLocationIndex(Location)); + public List VaultContainer { get; set; } = new(); +} \ No newline at end of file diff --git a/src/StatisticsAnalysisTool/Models/NetworkModel/VaultContainer.cs b/src/StatisticsAnalysisTool/Models/NetworkModel/VaultContainer.cs new file mode 100644 index 000000000..cb3709b23 --- /dev/null +++ b/src/StatisticsAnalysisTool/Models/NetworkModel/VaultContainer.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; + +namespace StatisticsAnalysisTool.Models.NetworkModel; + +public class VaultContainer +{ + public DateTime LastUpdate { get; set; } + public Guid Guid { get; set; } + public string Name { get; set; } + public string Icon { get; set; } + public List Items { get; set; } = new (); +} \ No newline at end of file diff --git a/src/StatisticsAnalysisTool/Models/NetworkModel/VaultInfo.cs b/src/StatisticsAnalysisTool/Models/NetworkModel/VaultInfo.cs new file mode 100644 index 000000000..0fc71202d --- /dev/null +++ b/src/StatisticsAnalysisTool/Models/NetworkModel/VaultInfo.cs @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; +using StatisticsAnalysisTool.Enumerations; +using StatisticsAnalysisTool.Network.Manager; + +namespace StatisticsAnalysisTool.Models.NetworkModel; + +public class VaultInfo +{ + public VaultInfo(long? objectId, string location, List containerGuidList, List containerNames, List containerIconTags) + { + ObjectId = objectId; + Location = location; + ContainerGuidList = containerGuidList; + ContainerNames = containerNames; + ContainerIconTags = containerIconTags; + } + + public long? ObjectId { get; set; } + public string Location { get; set; } + public VaultLocation VaultLocation => VaultController.GetVaultLocation(Location); + public List ContainerGuidList { get; set; } + public List ContainerNames { get; set; } + public List ContainerIconTags { get; set; } +} \ No newline at end of file diff --git a/src/StatisticsAnalysisTool/Network/AlbionPackageParser.cs b/src/StatisticsAnalysisTool/Network/AlbionPackageParser.cs index 9291b68ca..6d9515e8e 100644 --- a/src/StatisticsAnalysisTool/Network/AlbionPackageParser.cs +++ b/src/StatisticsAnalysisTool/Network/AlbionPackageParser.cs @@ -18,6 +18,10 @@ namespace StatisticsAnalysisTool.Network public class AlbionPackageParser : PhotonParser { private readonly NewEquipmentItemEventHandler _newEquipmentItemEventHandler; + private readonly NewSimpleItemEventHandler _newSimpleItemEventHandler; + private readonly NewFurnitureItemEventHandler _newFurnitureItemEventHandler; + private readonly NewJournalItemEventHandler _newJournalItemEventHandler; + private readonly NewLaborerItemEventHandler _newLaborerItemEventHandler; private readonly OtherGrabbedLootEventHandler _grabbedLootEventHandler; private readonly InventoryDeleteItemEventHandler _inventoryDeleteItemEventHandler; private readonly InventoryPutItemEventHandler _inventoryPutItemEventHandler; @@ -42,6 +46,9 @@ public class AlbionPackageParser : PhotonParser private readonly UpdateFactionStandingEventHandler _updateFactionStandingEventHandler; private readonly ReceivedSeasonPointsEventHandler _receivedSeasonPointsEventHandler; private readonly MightFavorPointsEventHandler _mightFavorPointsEventHandler; + private readonly BaseVaultInfoEventHandler _baseVaultInfoEventHandler; + private readonly GuildVaultInfoEventHandler _guildVaultInfoEventHandler; + private readonly AttachItemContainerEventHandler _attachItemContainerEventHandler; private readonly UseShrineRequestHandler _useShrineRequestHandler; @@ -56,6 +63,10 @@ public class AlbionPackageParser : PhotonParser public AlbionPackageParser(TrackingController trackingController, MainWindowViewModel mainWindowViewModel) { _newEquipmentItemEventHandler = new NewEquipmentItemEventHandler(trackingController); + _newSimpleItemEventHandler = new NewSimpleItemEventHandler(trackingController); + _newFurnitureItemEventHandler = new NewFurnitureItemEventHandler(trackingController); + _newJournalItemEventHandler = new NewJournalItemEventHandler(trackingController); + _newLaborerItemEventHandler = new NewLaborerItemEventHandler(trackingController); _grabbedLootEventHandler = new OtherGrabbedLootEventHandler(trackingController); _inventoryDeleteItemEventHandler = new InventoryDeleteItemEventHandler(trackingController); _inventoryPutItemEventHandler = new InventoryPutItemEventHandler(trackingController); @@ -80,6 +91,9 @@ public AlbionPackageParser(TrackingController trackingController, MainWindowView _updateFactionStandingEventHandler = new UpdateFactionStandingEventHandler(trackingController); _receivedSeasonPointsEventHandler = new ReceivedSeasonPointsEventHandler(trackingController); _mightFavorPointsEventHandler = new MightFavorPointsEventHandler(trackingController); + _baseVaultInfoEventHandler = new BaseVaultInfoEventHandler(trackingController); + _guildVaultInfoEventHandler = new GuildVaultInfoEventHandler(trackingController); + _attachItemContainerEventHandler = new AttachItemContainerEventHandler(trackingController); _useShrineRequestHandler = new UseShrineRequestHandler(trackingController); @@ -108,6 +122,18 @@ protected override async void OnEvent(byte code, Dictionary parame case EventCodes.NewEquipmentItem: await NewEquipmentItemEventHandlerAsync(parameters); return; + case EventCodes.NewSimpleItem: + await NewSimpleItemEventHandlerAsync(parameters); + return; + case EventCodes.NewFurnitureItem: + await NewFurnitureItemEventHandlerAsync(parameters); + return; + case EventCodes.NewJournalItem: + await NewJournalItemEventHandlerAsync(parameters); + return; + case EventCodes.NewLaborerItem: + await NewLaborerItemEventHandlerAsync(parameters); + return; case EventCodes.GrabbedLoot: await GrabbedLootEventHandlerAsync(parameters).ConfigureAwait(true); return; @@ -180,6 +206,15 @@ protected override async void OnEvent(byte code, Dictionary parame case EventCodes.MightFavorPoints: await MightFavorPointsEventHandlerAsync(parameters).ConfigureAwait(true); return; + case EventCodes.BaseVaultInfo: + await BaseVaultInfoEventHandlerAsync(parameters).ConfigureAwait(true); + return; + case EventCodes.RecoveryVaultPlayerInfo: + await RecoveryVaultPlayerInfoEventHandlerAsync(parameters).ConfigureAwait(true); + return; + case EventCodes.AttachItemContainer: + await AttachItemContainerEventHandlerAsync(parameters).ConfigureAwait(true); + return; } } catch (Exception ex) @@ -277,6 +312,30 @@ private async Task NewEquipmentItemEventHandlerAsync(Dictionary pa await _newEquipmentItemEventHandler.OnActionAsync(value); } + private async Task NewSimpleItemEventHandlerAsync(Dictionary parameters) + { + var value = new NewSimpleItemEvent(parameters); + await _newSimpleItemEventHandler.OnActionAsync(value); + } + + private async Task NewFurnitureItemEventHandlerAsync(Dictionary parameters) + { + var value = new NewFurnitureItemEvent(parameters); + await _newFurnitureItemEventHandler.OnActionAsync(value); + } + + private async Task NewJournalItemEventHandlerAsync(Dictionary parameters) + { + var value = new NewJournalItemEvent(parameters); + await _newJournalItemEventHandler.OnActionAsync(value); + } + + private async Task NewLaborerItemEventHandlerAsync(Dictionary parameters) + { + var value = new NewLaborerItemEvent(parameters); + await _newLaborerItemEventHandler.OnActionAsync(value); + } + private async Task GrabbedLootEventHandlerAsync(Dictionary parameters) { var value = new GrabbedLootEvent(parameters); @@ -421,6 +480,24 @@ private async Task MightFavorPointsEventHandlerAsync(Dictionary pa await _mightFavorPointsEventHandler.OnActionAsync(value); } + private async Task BaseVaultInfoEventHandlerAsync(Dictionary parameters) + { + var value = new BaseVaultInfoEvent(parameters); + await _baseVaultInfoEventHandler.OnActionAsync(value); + } + + private async Task RecoveryVaultPlayerInfoEventHandlerAsync(Dictionary parameters) + { + var value = new GuildVaultInfoEvent(parameters); + await _guildVaultInfoEventHandler.OnActionAsync(value); + } + + private async Task AttachItemContainerEventHandlerAsync(Dictionary parameters) + { + var value = new AttachItemContainerEvent(parameters); + await _attachItemContainerEventHandler.OnActionAsync(value); + } + #endregion #region Requests diff --git a/src/StatisticsAnalysisTool/Network/Events/AttachItemContainerEvent.cs b/src/StatisticsAnalysisTool/Network/Events/AttachItemContainerEvent.cs new file mode 100644 index 000000000..c37d3d572 --- /dev/null +++ b/src/StatisticsAnalysisTool/Network/Events/AttachItemContainerEvent.cs @@ -0,0 +1,76 @@ +using StatisticsAnalysisTool.Common; +using StatisticsAnalysisTool.Models.NetworkModel; +using System; +using System.Collections.Generic; +using System.Reflection; + +namespace StatisticsAnalysisTool.Network.Events +{ + public class AttachItemContainerEvent + { + public ItemContainerObject ItemContainerObject; + private readonly long? _objectId; + private readonly Guid _containerGuid; + private readonly List _containerSlots = new(); + + public AttachItemContainerEvent(Dictionary parameters) + { + ConsoleManager.WriteLineForNetworkHandler(GetType().Name, parameters); + + try + { + if (parameters.ContainsKey(0)) + { + _objectId = parameters[0].ObjectToLong(); + } + + if (parameters.ContainsKey(2)) + { + var guid = parameters[2].ObjectToGuid(); + if (guid != null) + { + _containerGuid = (Guid)guid; + } + } + + if (parameters.ContainsKey(3) && parameters[3] != null) + { + var valueType = parameters[3].GetType(); + if (valueType.IsArray && typeof(int[]) == valueType) + { + var intArray = ((int[])parameters[3]).ToDictionary(); + + foreach (var slot in intArray) + { + _containerSlots.Add(slot.Value); + } + } + else if (valueType.IsArray && typeof(short[]) == valueType) + { + var intArray = ((short[])parameters[3]).ToDictionary(); + + foreach (var slot in intArray) + { + _containerSlots.Add(slot.Value); + } + } + else if (valueType.IsArray && typeof(byte[]) == valueType) + { + var byteArray = ((byte[])parameters[3]).ToDictionary(); + + foreach (var unused in byteArray) + { + _containerSlots.Add(0); + } + } + } + + ItemContainerObject = new ItemContainerObject(_objectId, _containerGuid, _containerSlots); + } + catch (Exception e) + { + ConsoleManager.WriteLineForError(MethodBase.GetCurrentMethod()?.DeclaringType, e); + } + } + } +} \ No newline at end of file diff --git a/src/StatisticsAnalysisTool/Network/Events/BaseVaultInfoEvent.cs b/src/StatisticsAnalysisTool/Network/Events/BaseVaultInfoEvent.cs new file mode 100644 index 000000000..e5cf236b4 --- /dev/null +++ b/src/StatisticsAnalysisTool/Network/Events/BaseVaultInfoEvent.cs @@ -0,0 +1,72 @@ +using StatisticsAnalysisTool.Common; +using System; +using System.Collections.Generic; +using System.Reflection; + +namespace StatisticsAnalysisTool.Network.Events +{ + public class BaseVaultInfoEvent + { + public long? ObjectId; + public string Location; + public List VaultGuidList = new(); + public List VaultNames = new(); + public List IconTags = new(); + + public BaseVaultInfoEvent(Dictionary parameters) + { + ConsoleManager.WriteLineForNetworkHandler(GetType().Name, parameters); + + try + { + if (parameters.ContainsKey(0)) + { + ObjectId = parameters[0].ObjectToLong(); + } + + if (parameters.ContainsKey(1)) + { + Location = parameters[1].ToString(); + } + + if (parameters.ContainsKey(2) && parameters[2] != null) + { + var vaultGuidArray = ((object[])parameters[2]).ToDictionary(); + + for (var i = 0; i < vaultGuidArray.Count; i++) + { + var guid = vaultGuidArray[i].ObjectToGuid(); + if (guid != null) + { + VaultGuidList.Add((Guid)guid); + } + } + } + + if (parameters.ContainsKey(3) && parameters[3] != null) + { + var vaultNameArray = ((object[])parameters[3]).ToDictionary(); + + for (var i = 0; i < vaultNameArray.Count; i++) + { + VaultNames.Add(vaultNameArray[i].ToString()); + } + } + + if (parameters.ContainsKey(4) && parameters[4] != null) + { + var iconTagArray = ((object[])parameters[4]).ToDictionary(); + + for (var i = 0; i < iconTagArray.Count; i++) + { + IconTags.Add(iconTagArray[i].ToString()); + } + } + } + catch (Exception e) + { + ConsoleManager.WriteLineForError(MethodBase.GetCurrentMethod()?.DeclaringType, e); + } + } + } +} \ No newline at end of file diff --git a/src/StatisticsAnalysisTool/Network/Events/GuildVaultInfoEvent.cs b/src/StatisticsAnalysisTool/Network/Events/GuildVaultInfoEvent.cs new file mode 100644 index 000000000..e90cc2b9b --- /dev/null +++ b/src/StatisticsAnalysisTool/Network/Events/GuildVaultInfoEvent.cs @@ -0,0 +1,74 @@ +using StatisticsAnalysisTool.Common; +using System; +using System.Collections.Generic; +using System.Reflection; +using StatisticsAnalysisTool.Enumerations; +using StatisticsAnalysisTool.Network.Manager; + +namespace StatisticsAnalysisTool.Network.Events +{ + public class GuildVaultInfoEvent + { + public long? ObjectId; + public VaultLocation Location; + public List VaultGuidList = new (); + public List VaultNames = new (); + public List IconTags = new (); + + public GuildVaultInfoEvent(Dictionary parameters) + { + ConsoleManager.WriteLineForNetworkHandler(GetType().Name, parameters); + + try + { + if (parameters.ContainsKey(0)) + { + ObjectId = parameters[0].ObjectToLong(); + } + + if (parameters.ContainsKey(1)) + { + Location = VaultController.GetVaultLocation(parameters[1].ToString()); + } + + if (parameters.ContainsKey(2) && parameters[2] != null) + { + var vaultGuidArray = ((object[])parameters[2]).ToDictionary(); + + for (var i = 0; i < vaultGuidArray.Count; i++) + { + var guid = vaultGuidArray[i].ObjectToGuid(); + if (guid != null) + { + VaultGuidList.Add((Guid)guid); + } + } + } + + if (parameters.ContainsKey(3) && parameters[3] != null) + { + var vaultNameArray = ((object[])parameters[3]).ToDictionary(); + + for (var i = 0; i < vaultNameArray.Count; i++) + { + VaultNames.Add(vaultNameArray[i].ToString()); + } + } + + if (parameters.ContainsKey(4) && parameters[4] != null) + { + var iconTagArray = ((object[])parameters[4]).ToDictionary(); + + for (var i = 0; i < iconTagArray.Count; i++) + { + IconTags.Add(iconTagArray[i].ToString()); + } + } + } + catch (Exception e) + { + ConsoleManager.WriteLineForError(MethodBase.GetCurrentMethod()?.DeclaringType, e); + } + } + } +} \ No newline at end of file diff --git a/src/StatisticsAnalysisTool/Network/Events/InCombatStateUpdateEvent.cs b/src/StatisticsAnalysisTool/Network/Events/InCombatStateUpdateEvent.cs index 3b7d121a3..8ce8b9bf7 100644 --- a/src/StatisticsAnalysisTool/Network/Events/InCombatStateUpdateEvent.cs +++ b/src/StatisticsAnalysisTool/Network/Events/InCombatStateUpdateEvent.cs @@ -1,10 +1,10 @@ -using log4net; -using StatisticsAnalysisTool.Common; -using System; +using System; using System.Collections.Generic; using System.Reflection; +using log4net; +using StatisticsAnalysisTool.Common; -namespace StatisticsAnalysisTool.Network.Handler +namespace StatisticsAnalysisTool.Network.Events { public class InCombatStateUpdateEvent { diff --git a/src/StatisticsAnalysisTool/Network/Events/NewEquipmentItemEvent.cs b/src/StatisticsAnalysisTool/Network/Events/NewEquipmentItemEvent.cs index 0bf07437e..ac36333f9 100644 --- a/src/StatisticsAnalysisTool/Network/Events/NewEquipmentItemEvent.cs +++ b/src/StatisticsAnalysisTool/Network/Events/NewEquipmentItemEvent.cs @@ -8,12 +8,12 @@ namespace StatisticsAnalysisTool.Network.Events { public class NewEquipmentItemEvent { - public DiscoveredLoot Loot; + public DiscoveredItem Item; private readonly long? _objectId; private readonly int _itemId; private readonly int _quantity; - private Dictionary _spellDictionary { get; } = new (); + private Dictionary SpellDictionary { get; } = new (); public NewEquipmentItemEvent(Dictionary parameters) { @@ -44,7 +44,7 @@ public NewEquipmentItemEvent(Dictionary parameters) var spells = ((byte[]) parameters[8]).ToDictionary(); foreach (var spell in spells) { - _spellDictionary.Add(spell.Key, spell.Value.ObjectToInt()); + SpellDictionary.Add(spell.Key, spell.Value.ObjectToInt()); } } else if (valueType.IsArray && typeof(short[]).Name == valueType.Name) @@ -52,7 +52,7 @@ public NewEquipmentItemEvent(Dictionary parameters) var spells = ((short[]) parameters[8]).ToDictionary(); foreach (var spell in spells) { - _spellDictionary.Add(spell.Key, spell.Value.ObjectToInt()); + SpellDictionary.Add(spell.Key, spell.Value.ObjectToInt()); } } else if (valueType.IsArray && typeof(int[]).Name == valueType.Name) @@ -60,24 +60,24 @@ public NewEquipmentItemEvent(Dictionary parameters) var spells = ((int[]) parameters[8]).ToDictionary(); foreach (var spell in spells) { - _spellDictionary.Add(spell.Key, spell.Value.ObjectToInt()); + SpellDictionary.Add(spell.Key, spell.Value.ObjectToInt()); } } } if (_objectId != null) { - Loot = new DiscoveredLoot() + Item = new DiscoveredItem() { ObjectId = (long)_objectId, - ItemId = _itemId, + ItemIndex = _itemId, Quantity = _quantity, - SpellDictionary = _spellDictionary + SpellDictionary = SpellDictionary }; } else { - Loot = null; + Item = null; } } catch (Exception e) diff --git a/src/StatisticsAnalysisTool/Network/Events/NewFurnitureItemEvent.cs b/src/StatisticsAnalysisTool/Network/Events/NewFurnitureItemEvent.cs new file mode 100644 index 000000000..111b49c41 --- /dev/null +++ b/src/StatisticsAnalysisTool/Network/Events/NewFurnitureItemEvent.cs @@ -0,0 +1,58 @@ +using StatisticsAnalysisTool.Common; +using StatisticsAnalysisTool.Models.NetworkModel; +using System; +using System.Collections.Generic; +using System.Reflection; + +namespace StatisticsAnalysisTool.Network.Events +{ + public class NewFurnitureItemEvent + { + public DiscoveredItem Item; + + private readonly long? _objectId; + private readonly int _itemId; + private readonly int _quantity; + + public NewFurnitureItemEvent(Dictionary parameters) + { + ConsoleManager.WriteLineForNetworkHandler(GetType().Name, parameters); + + try + { + if (parameters.ContainsKey(0)) + { + _objectId = parameters[0].ObjectToLong(); + } + + if (parameters.ContainsKey(1)) + { + _itemId = parameters[1].ObjectToInt(); + } + + if (parameters.ContainsKey(2)) + { + _quantity = parameters[2].ObjectToInt(); + } + + if (_objectId != null) + { + Item = new DiscoveredItem() + { + ObjectId = (long)_objectId, + ItemIndex = _itemId, + Quantity = _quantity + }; + } + else + { + Item = null; + } + } + catch (Exception e) + { + ConsoleManager.WriteLineForError(MethodBase.GetCurrentMethod()?.DeclaringType, e); + } + } + } +} \ No newline at end of file diff --git a/src/StatisticsAnalysisTool/Network/Events/NewJournalItemEvent.cs b/src/StatisticsAnalysisTool/Network/Events/NewJournalItemEvent.cs new file mode 100644 index 000000000..10eb4db01 --- /dev/null +++ b/src/StatisticsAnalysisTool/Network/Events/NewJournalItemEvent.cs @@ -0,0 +1,58 @@ +using StatisticsAnalysisTool.Common; +using StatisticsAnalysisTool.Models.NetworkModel; +using System; +using System.Collections.Generic; +using System.Reflection; + +namespace StatisticsAnalysisTool.Network.Events +{ + public class NewJournalItemEvent + { + public DiscoveredItem Item; + + private readonly long? _objectId; + private readonly int _itemId; + private readonly int _quantity; + + public NewJournalItemEvent(Dictionary parameters) + { + ConsoleManager.WriteLineForNetworkHandler(GetType().Name, parameters); + + try + { + if (parameters.ContainsKey(0)) + { + _objectId = parameters[0].ObjectToLong(); + } + + if (parameters.ContainsKey(1)) + { + _itemId = parameters[1].ObjectToInt(); + } + + if (parameters.ContainsKey(2)) + { + _quantity = parameters[2].ObjectToInt(); + } + + if (_objectId != null) + { + Item = new DiscoveredItem() + { + ObjectId = (long)_objectId, + ItemIndex = _itemId, + Quantity = _quantity + }; + } + else + { + Item = null; + } + } + catch (Exception e) + { + ConsoleManager.WriteLineForError(MethodBase.GetCurrentMethod()?.DeclaringType, e); + } + } + } +} \ No newline at end of file diff --git a/src/StatisticsAnalysisTool/Network/Events/NewLaborerItemEvent.cs b/src/StatisticsAnalysisTool/Network/Events/NewLaborerItemEvent.cs new file mode 100644 index 000000000..cd803e529 --- /dev/null +++ b/src/StatisticsAnalysisTool/Network/Events/NewLaborerItemEvent.cs @@ -0,0 +1,58 @@ +using StatisticsAnalysisTool.Common; +using StatisticsAnalysisTool.Models.NetworkModel; +using System; +using System.Collections.Generic; +using System.Reflection; + +namespace StatisticsAnalysisTool.Network.Events +{ + public class NewLaborerItemEvent + { + public DiscoveredItem Item; + + private readonly long? _objectId; + private readonly int _itemId; + private readonly int _quantity; + + public NewLaborerItemEvent(Dictionary parameters) + { + ConsoleManager.WriteLineForNetworkHandler(GetType().Name, parameters); + + try + { + if (parameters.ContainsKey(0)) + { + _objectId = parameters[0].ObjectToLong(); + } + + if (parameters.ContainsKey(1)) + { + _itemId = parameters[1].ObjectToInt(); + } + + if (parameters.ContainsKey(2)) + { + _quantity = parameters[2].ObjectToInt(); + } + + if (_objectId != null) + { + Item = new DiscoveredItem() + { + ObjectId = (long)_objectId, + ItemIndex = _itemId, + Quantity = _quantity + }; + } + else + { + Item = null; + } + } + catch (Exception e) + { + ConsoleManager.WriteLineForError(MethodBase.GetCurrentMethod()?.DeclaringType, e); + } + } + } +} \ No newline at end of file diff --git a/src/StatisticsAnalysisTool/Network/Events/NewLootEvent.cs b/src/StatisticsAnalysisTool/Network/Events/NewLootEvent.cs index fc0ff4641..f611122b8 100644 --- a/src/StatisticsAnalysisTool/Network/Events/NewLootEvent.cs +++ b/src/StatisticsAnalysisTool/Network/Events/NewLootEvent.cs @@ -21,7 +21,7 @@ public NewLootEvent(Dictionary parameters) // 2 = mob id? var bodyName = (string) parameters[3]; - var container = new Container + var container = new LootContainer { Id = containerId, Owner = bodyName, Type = BodyName.StartsWith("@MOB") ? ContainerType.Monster : ContainerType.Player diff --git a/src/StatisticsAnalysisTool/Network/Events/NewSimpleItemEvent.cs b/src/StatisticsAnalysisTool/Network/Events/NewSimpleItemEvent.cs index d24493dd9..998294c48 100644 --- a/src/StatisticsAnalysisTool/Network/Events/NewSimpleItemEvent.cs +++ b/src/StatisticsAnalysisTool/Network/Events/NewSimpleItemEvent.cs @@ -8,7 +8,7 @@ namespace StatisticsAnalysisTool.Network.Events { public class NewSimpleItemEvent { - public DiscoveredLoot Loot; + public DiscoveredItem Item; private readonly long? _objectId; private readonly int _itemId; @@ -37,16 +37,16 @@ public NewSimpleItemEvent(Dictionary parameters) if (_objectId != null) { - Loot = new DiscoveredLoot() + Item = new DiscoveredItem() { ObjectId = (long)_objectId, - ItemId = _itemId, + ItemIndex = _itemId, Quantity = _quantity }; } else { - Loot = null; + Item = null; } } catch (Exception e) diff --git a/src/StatisticsAnalysisTool/Network/Events/PartyChangedOrderEvent.cs b/src/StatisticsAnalysisTool/Network/Events/PartyChangedOrderEvent.cs index 92ccfb2c9..d8ae63b65 100644 --- a/src/StatisticsAnalysisTool/Network/Events/PartyChangedOrderEvent.cs +++ b/src/StatisticsAnalysisTool/Network/Events/PartyChangedOrderEvent.cs @@ -1,9 +1,9 @@ -using StatisticsAnalysisTool.Common; -using System; +using System; using System.Collections.Generic; using System.Reflection; +using StatisticsAnalysisTool.Common; -namespace StatisticsAnalysisTool.Network.Handler +namespace StatisticsAnalysisTool.Network.Events { public class PartyChangedOrderEvent { diff --git a/src/StatisticsAnalysisTool/Network/Handler/AttachItemContainerEventHandler.cs b/src/StatisticsAnalysisTool/Network/Handler/AttachItemContainerEventHandler.cs new file mode 100644 index 000000000..5125e3ec4 --- /dev/null +++ b/src/StatisticsAnalysisTool/Network/Handler/AttachItemContainerEventHandler.cs @@ -0,0 +1,26 @@ +using StatisticsAnalysisTool.Network.Events; +using StatisticsAnalysisTool.Network.Manager; +using System.Threading.Tasks; + +namespace StatisticsAnalysisTool.Network.Handler +{ + public class AttachItemContainerEventHandler + { + private readonly TrackingController _trackingController; + + public AttachItemContainerEventHandler(TrackingController trackingController) + { + _trackingController = trackingController; + } + + public async Task OnActionAsync(AttachItemContainerEvent value) + { + if (_trackingController.IsTrackingAllowedByMainCharacter()) + { + _trackingController.VaultController.AddContainer(value.ItemContainerObject); + } + + await Task.CompletedTask; + } + } +} \ No newline at end of file diff --git a/src/StatisticsAnalysisTool/Network/Handler/BaseVaultInfoEventHandler.cs b/src/StatisticsAnalysisTool/Network/Handler/BaseVaultInfoEventHandler.cs new file mode 100644 index 000000000..4546e1563 --- /dev/null +++ b/src/StatisticsAnalysisTool/Network/Handler/BaseVaultInfoEventHandler.cs @@ -0,0 +1,27 @@ +using StatisticsAnalysisTool.Network.Events; +using StatisticsAnalysisTool.Network.Manager; +using System.Threading.Tasks; +using StatisticsAnalysisTool.Models.NetworkModel; + +namespace StatisticsAnalysisTool.Network.Handler +{ + public class BaseVaultInfoEventHandler + { + private readonly TrackingController _trackingController; + + public BaseVaultInfoEventHandler(TrackingController trackingController) + { + _trackingController = trackingController; + } + + public async Task OnActionAsync(BaseVaultInfoEvent value) + { + if (_trackingController.IsTrackingAllowedByMainCharacter()) + { + _trackingController.VaultController.SetCurrentVault(new VaultInfo(value.ObjectId, value.Location, value.VaultGuidList, value.VaultNames, value.IconTags)); + } + + await Task.CompletedTask; + } + } +} \ No newline at end of file diff --git a/src/StatisticsAnalysisTool/Network/Handler/GuildVaultInfoEventHandler.cs b/src/StatisticsAnalysisTool/Network/Handler/GuildVaultInfoEventHandler.cs new file mode 100644 index 000000000..cb258bab3 --- /dev/null +++ b/src/StatisticsAnalysisTool/Network/Handler/GuildVaultInfoEventHandler.cs @@ -0,0 +1,22 @@ +using StatisticsAnalysisTool.Network.Events; +using StatisticsAnalysisTool.Network.Manager; +using System.Threading.Tasks; + +namespace StatisticsAnalysisTool.Network.Handler +{ + public class GuildVaultInfoEventHandler + { + private readonly TrackingController _trackingController; + + public GuildVaultInfoEventHandler(TrackingController trackingController) + { + _trackingController = trackingController; + } + + public async Task OnActionAsync(GuildVaultInfoEvent value) + { + + await Task.CompletedTask; + } + } +} \ No newline at end of file diff --git a/src/StatisticsAnalysisTool/Network/Handler/InCombatStateUpdateEventHandler.cs b/src/StatisticsAnalysisTool/Network/Handler/InCombatStateUpdateEventHandler.cs index e9ae15eed..f50d8b1e4 100644 --- a/src/StatisticsAnalysisTool/Network/Handler/InCombatStateUpdateEventHandler.cs +++ b/src/StatisticsAnalysisTool/Network/Handler/InCombatStateUpdateEventHandler.cs @@ -1,5 +1,6 @@ using StatisticsAnalysisTool.Network.Manager; using System.Threading.Tasks; +using StatisticsAnalysisTool.Network.Events; namespace StatisticsAnalysisTool.Network.Handler { diff --git a/src/StatisticsAnalysisTool/Network/Handler/NewEquipmentItemEventHandler.cs b/src/StatisticsAnalysisTool/Network/Handler/NewEquipmentItemEventHandler.cs index ac9194377..6b851cb57 100644 --- a/src/StatisticsAnalysisTool/Network/Handler/NewEquipmentItemEventHandler.cs +++ b/src/StatisticsAnalysisTool/Network/Handler/NewEquipmentItemEventHandler.cs @@ -17,12 +17,15 @@ public NewEquipmentItemEventHandler(TrackingController trackingController) public async Task OnActionAsync(NewEquipmentItemEvent value) { - //_trackingController.LootController.AddDiscoveredLoot(value.Loot); + if (_trackingController.IsTrackingAllowedByMainCharacter()) + { + _trackingController.VaultController.Add(value.Item); + } _trackingController.EntityController.AddEquipmentItem(new EquipmentItemInternal { - ItemIndex = value.Loot.ItemId, - SpellDictionary = value.Loot.SpellDictionary + ItemIndex = value.Item.ItemIndex, + SpellDictionary = value.Item.SpellDictionary }); await Task.CompletedTask; } diff --git a/src/StatisticsAnalysisTool/Network/Handler/NewFurnitureItemEventHandler.cs b/src/StatisticsAnalysisTool/Network/Handler/NewFurnitureItemEventHandler.cs new file mode 100644 index 000000000..6cc964554 --- /dev/null +++ b/src/StatisticsAnalysisTool/Network/Handler/NewFurnitureItemEventHandler.cs @@ -0,0 +1,26 @@ +using StatisticsAnalysisTool.Network.Events; +using StatisticsAnalysisTool.Network.Manager; +using System.Threading.Tasks; + +namespace StatisticsAnalysisTool.Network.Handler +{ + public class NewFurnitureItemEventHandler + { + private readonly TrackingController _trackingController; + + public NewFurnitureItemEventHandler(TrackingController trackingController) + { + _trackingController = trackingController; + } + + public async Task OnActionAsync(NewFurnitureItemEvent value) + { + if (_trackingController.IsTrackingAllowedByMainCharacter()) + { + _trackingController.VaultController.Add(value.Item); + } + + await Task.CompletedTask; + } + } +} \ No newline at end of file diff --git a/src/StatisticsAnalysisTool/Network/Handler/NewJournalItemEventHandler.cs b/src/StatisticsAnalysisTool/Network/Handler/NewJournalItemEventHandler.cs new file mode 100644 index 000000000..1b1685bf2 --- /dev/null +++ b/src/StatisticsAnalysisTool/Network/Handler/NewJournalItemEventHandler.cs @@ -0,0 +1,26 @@ +using StatisticsAnalysisTool.Network.Events; +using StatisticsAnalysisTool.Network.Manager; +using System.Threading.Tasks; + +namespace StatisticsAnalysisTool.Network.Handler +{ + public class NewJournalItemEventHandler + { + private readonly TrackingController _trackingController; + + public NewJournalItemEventHandler(TrackingController trackingController) + { + _trackingController = trackingController; + } + + public async Task OnActionAsync(NewJournalItemEvent value) + { + if (_trackingController.IsTrackingAllowedByMainCharacter()) + { + _trackingController.VaultController.Add(value.Item); + } + + await Task.CompletedTask; + } + } +} \ No newline at end of file diff --git a/src/StatisticsAnalysisTool/Network/Handler/NewLaborerItemEventHandler.cs b/src/StatisticsAnalysisTool/Network/Handler/NewLaborerItemEventHandler.cs new file mode 100644 index 000000000..bc5625a50 --- /dev/null +++ b/src/StatisticsAnalysisTool/Network/Handler/NewLaborerItemEventHandler.cs @@ -0,0 +1,26 @@ +using StatisticsAnalysisTool.Network.Events; +using StatisticsAnalysisTool.Network.Manager; +using System.Threading.Tasks; + +namespace StatisticsAnalysisTool.Network.Handler +{ + public class NewLaborerItemEventHandler + { + private readonly TrackingController _trackingController; + + public NewLaborerItemEventHandler(TrackingController trackingController) + { + _trackingController = trackingController; + } + + public async Task OnActionAsync(NewLaborerItemEvent value) + { + if (_trackingController.IsTrackingAllowedByMainCharacter()) + { + _trackingController.VaultController.Add(value.Item); + } + + await Task.CompletedTask; + } + } +} \ No newline at end of file diff --git a/src/StatisticsAnalysisTool/Network/Handler/NewSimpleItemEventHandler.cs b/src/StatisticsAnalysisTool/Network/Handler/NewSimpleItemEventHandler.cs index 707ad6f5b..2ae05edbb 100644 --- a/src/StatisticsAnalysisTool/Network/Handler/NewSimpleItemEventHandler.cs +++ b/src/StatisticsAnalysisTool/Network/Handler/NewSimpleItemEventHandler.cs @@ -1,6 +1,5 @@ -using StatisticsAnalysisTool.Enumerations; +using StatisticsAnalysisTool.Network.Events; using StatisticsAnalysisTool.Network.Manager; -using StatisticsAnalysisTool.Network.Events; using System.Threading.Tasks; namespace StatisticsAnalysisTool.Network.Handler @@ -16,7 +15,11 @@ public NewSimpleItemEventHandler(TrackingController trackingController) public async Task OnActionAsync(NewSimpleItemEvent value) { - //_trackingController.LootController.AddDiscoveredLoot(value.Loot); + if (_trackingController.IsTrackingAllowedByMainCharacter()) + { + _trackingController.VaultController.Add(value.Item); + } + await Task.CompletedTask; } } diff --git a/src/StatisticsAnalysisTool/Network/Handler/PartyChangedOrderEventHandler.cs b/src/StatisticsAnalysisTool/Network/Handler/PartyChangedOrderEventHandler.cs index 7f8de9362..d284c9541 100644 --- a/src/StatisticsAnalysisTool/Network/Handler/PartyChangedOrderEventHandler.cs +++ b/src/StatisticsAnalysisTool/Network/Handler/PartyChangedOrderEventHandler.cs @@ -1,5 +1,6 @@ using StatisticsAnalysisTool.Network.Manager; using System.Threading.Tasks; +using StatisticsAnalysisTool.Network.Events; namespace StatisticsAnalysisTool.Network.Handler { diff --git a/src/StatisticsAnalysisTool/Network/Handler/UseLootChestEventHandler.cs b/src/StatisticsAnalysisTool/Network/Handler/UseLootChestEventHandler.cs index b292614cb..a382edfa8 100644 --- a/src/StatisticsAnalysisTool/Network/Handler/UseLootChestEventHandler.cs +++ b/src/StatisticsAnalysisTool/Network/Handler/UseLootChestEventHandler.cs @@ -16,7 +16,7 @@ public UseLootChestEventHandler(TrackingController trackingController) public async Task OnActionAsync(UseLootChestResponse value) { - Debug.Print($"Loot: {value.Loot.LooterName}"); + Debug.Print($"Loot: {value.Item.LooterName}"); await Task.CompletedTask; } } diff --git a/src/StatisticsAnalysisTool/Network/Manager/ILootController.cs b/src/StatisticsAnalysisTool/Network/Manager/ILootController.cs index 88bece5a3..201388aa8 100644 --- a/src/StatisticsAnalysisTool/Network/Manager/ILootController.cs +++ b/src/StatisticsAnalysisTool/Network/Manager/ILootController.cs @@ -7,7 +7,7 @@ namespace StatisticsAnalysisTool.Network.Manager public interface ILootController { public Task AddLootAsync(Loot loot); - public void AddDiscoveredLoot(DiscoveredLoot loot); + public void AddDiscoveredLoot(DiscoveredItem item); public Task AddPutLootAsync(long? objectId, Guid? playerGuid); public void ResetViewedLootLists(); } diff --git a/src/StatisticsAnalysisTool/Network/Manager/LootController.cs b/src/StatisticsAnalysisTool/Network/Manager/LootController.cs index 1120b2cc6..68a4450fb 100644 --- a/src/StatisticsAnalysisTool/Network/Manager/LootController.cs +++ b/src/StatisticsAnalysisTool/Network/Manager/LootController.cs @@ -21,7 +21,7 @@ public class LootController : ILootController private readonly MainWindowViewModel _mainWindowViewModel; private readonly Dictionary _putLoot = new(); - private readonly List _discoveredLoot = new(); + private readonly List _discoveredLoot = new(); private readonly List _lootLoggerObjects = new(); private readonly List _topLooters = new(); @@ -98,14 +98,14 @@ public void ClearLootLogger() _topLooters.Clear(); } - public void AddDiscoveredLoot(DiscoveredLoot loot) + public void AddDiscoveredLoot(DiscoveredItem item) { - if (_discoveredLoot.Exists(x => x.ObjectId == loot.ObjectId)) + if (_discoveredLoot.Exists(x => x.ObjectId == item.ObjectId)) { return; } - _discoveredLoot.Add(loot); + _discoveredLoot.Add(item); } public async Task AddPutLootAsync(long? objectId, Guid? interactGuid) @@ -144,8 +144,8 @@ private async Task LootMergeAsync() var loot = new Loot() { LootedBody = discoveredLoot.BodyName, - IsTrash = ItemController.IsTrash(discoveredLoot.ItemId), - ItemIndex = discoveredLoot.ItemId, + IsTrash = ItemController.IsTrash(discoveredLoot.ItemIndex), + ItemIndex = discoveredLoot.ItemIndex, LooterName = discoveredLoot.LooterName, Quantity = discoveredLoot.Quantity }; diff --git a/src/StatisticsAnalysisTool/Network/Manager/TrackingController.cs b/src/StatisticsAnalysisTool/Network/Manager/TrackingController.cs index 910e4d893..509ed484d 100644 --- a/src/StatisticsAnalysisTool/Network/Manager/TrackingController.cs +++ b/src/StatisticsAnalysisTool/Network/Manager/TrackingController.cs @@ -33,6 +33,7 @@ public class TrackingController : ITrackingController public LootController LootController; public StatisticController StatisticController; public MailController MailController; + public VaultController VaultController; private readonly List _notificationTypesFilters = new(); public TrackingController(MainWindowViewModel mainWindowViewModel, MainWindow mainWindow) @@ -45,6 +46,7 @@ public TrackingController(MainWindowViewModel mainWindowViewModel, MainWindow ma LootController = new LootController(this, mainWindowViewModel); StatisticController = new StatisticController(this, mainWindowViewModel); MailController = new MailController(mainWindowViewModel); + VaultController = new VaultController(mainWindowViewModel); CountUpTimer = new CountUpTimer(this, mainWindowViewModel); } @@ -98,6 +100,9 @@ public void SetNewCluster(MapType mapType, Guid? mapGuid, string clusterIndex, s } StatisticController.SetKillsDeathsValues(); + VaultController.ResetDiscoveredItems(); + VaultController.ResetVaultContainer(); + VaultController.ResetCurrentVaultInfo(); } private bool TryChangeCluster(string index, string mapName) diff --git a/src/StatisticsAnalysisTool/Network/Manager/VaultController.cs b/src/StatisticsAnalysisTool/Network/Manager/VaultController.cs new file mode 100644 index 000000000..989099be9 --- /dev/null +++ b/src/StatisticsAnalysisTool/Network/Manager/VaultController.cs @@ -0,0 +1,253 @@ +using log4net; +using StatisticsAnalysisTool.Common; +using StatisticsAnalysisTool.Enumerations; +using StatisticsAnalysisTool.Models.NetworkModel; +using StatisticsAnalysisTool.Properties; +using StatisticsAnalysisTool.ViewModels; +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.IO; +using System.Linq; +using System.Reflection; +using System.Text; +using System.Text.Json; +using System.Windows; + +namespace StatisticsAnalysisTool.Network.Manager; + +public class VaultController +{ + private static readonly ILog Log = LogManager.GetLogger(MethodBase.GetCurrentMethod()?.DeclaringType); + + private readonly MainWindowViewModel _mainWindowViewModel; + private VaultInfo _currentVaultInfo; + private readonly List _discoveredItems = new(); + private readonly List _vaultContainer = new(); + private ObservableCollection _vault = new(); + + private ObservableCollection Vaults + { + get => _vault; + set + { + _vault = value; + OnVaultsChange?.Invoke(); + } + } + + public VaultController(MainWindowViewModel mainWindowViewModel) + { + _mainWindowViewModel = mainWindowViewModel; + + OnVaultsChange += UpdateUi; + } + + public event Action OnVaultsChange; + + public void SetCurrentVault(VaultInfo vaultInfo) + { + if (vaultInfo == null || vaultInfo.VaultLocation == VaultLocation.Unknown) + { + _currentVaultInfo = null; + return; + } + + _currentVaultInfo = vaultInfo; + } + + public void Add(DiscoveredItem item) + { + if (_discoveredItems.Exists(x => x.ObjectId == item.ObjectId)) + { + return; + } + + _discoveredItems.Add(item); + } + + public void AddContainer(ItemContainerObject newContainerObject) + { + if (newContainerObject?.ContainerGuid == default) + { + return; + } + + var container = _vaultContainer.FirstOrDefault(x => x.ContainerGuid == newContainerObject.ContainerGuid); + if (container != null) + { + _vaultContainer.Remove(container); + } + + _vaultContainer.Add(newContainerObject); + + ParseVault(); + } + + public void ResetVaultContainer() + { + _vaultContainer.Clear(); + } + + public void ResetDiscoveredItems() + { + _discoveredItems.Clear(); + } + + public void ResetCurrentVaultInfo() + { + _currentVaultInfo = null; + } + + private void ParseVault() + { + if (_currentVaultInfo == null || GetVaultLocation(_currentVaultInfo?.Location) == VaultLocation.Unknown) + { + return; + } + + var removableVaultInfo = Vaults.FirstOrDefault(x => x.Location == _currentVaultInfo.Location); + + if (removableVaultInfo != null) + { + Vaults.Remove(removableVaultInfo); + } + + var vault = new Vault() + { + Location = _currentVaultInfo.Location + }; + + try + { + for (var i = 0; i < _currentVaultInfo.ContainerGuidList.Count; i++) + { + var vaultContainer = new VaultContainer() + { + Guid = _currentVaultInfo.ContainerGuidList[i], + Icon = _currentVaultInfo.ContainerIconTags[i], + Name = (_currentVaultInfo.ContainerNames[i] == "@BUILDINGS_T1_BANK") ? LanguageController.Translation("BANK") : _currentVaultInfo.ContainerNames[i] + }; + + var itemContainer = _vaultContainer.FirstOrDefault(x => x.ContainerGuid == vaultContainer.Guid); + if (itemContainer != null) + { + vaultContainer.LastUpdate = itemContainer.LastUpdate; + SetItemsToVaultContainer(itemContainer, vaultContainer, _discoveredItems); + } + + vault.VaultContainer.Add(vaultContainer); + } + + Vaults.Add(vault); + OnVaultsChange?.Invoke(); + } + catch (Exception e) + { + ConsoleManager.WriteLineForError(MethodBase.GetCurrentMethod()?.DeclaringType, e); + } + } + + private void SetItemsToVaultContainer(ItemContainerObject containerObject, VaultContainer vaultContainer, List discoveredItems) + { + foreach (var slotItemId in containerObject?.SlotItemId ?? new List()) + { + var slotItem = discoveredItems.FirstOrDefault(x => x.ObjectId == slotItemId); + + if (slotItem == null || slotItem.ItemIndex == 0) + { + vaultContainer.Items.Add(new ContainerItem() + { + ItemIndex = 0, + Quantity = 0 + }); + + continue; + } + + vaultContainer.Items.Add(new ContainerItem() + { + ItemIndex = slotItem.ItemIndex, + Quantity = slotItem.Quantity + }); + } + } + + public static VaultLocation GetVaultLocation(string value) + { + var clusterInfoArray = value.Split("@"); + return clusterInfoArray.ElementAtOrDefault(1) != null ? GetVaultLocationByIndex(clusterInfoArray[1]) : VaultLocation.Unknown; + } + + public static string GetVaultLocationIndex(string value) + { + var clusterInfoArray = value.Split("@"); + return clusterInfoArray.ElementAtOrDefault(1) != null ? clusterInfoArray[1] : "UNKNOWN"; + } + + #region Ui + + private void UpdateUi() + { + Application.Current.Dispatcher.Invoke(() => + { + _mainWindowViewModel.VaultBindings.Vaults = Vaults.ToList(); + }); + } + + #endregion + + #region Load / Save local file data + + public void LoadFromFile() + { + var localFilePath = $"{AppDomain.CurrentDomain.BaseDirectory}{Settings.Default.VaultsFileName}"; + + if (File.Exists(localFilePath)) + { + try + { + var localFileString = File.ReadAllText(localFilePath, Encoding.UTF8); + var vaults = JsonSerializer.Deserialize>(localFileString) ?? new List(); + Vaults = new ObservableCollection(vaults); + return; + } + catch (Exception e) + { + ConsoleManager.WriteLineForError(MethodBase.GetCurrentMethod()?.DeclaringType, e); + Log.Error(MethodBase.GetCurrentMethod()?.DeclaringType, e); + Vaults = new ObservableCollection(); + return; + } + } + + Vaults = new ObservableCollection(); + } + + public void SaveInFile() + { + var localFilePath = $"{AppDomain.CurrentDomain.BaseDirectory}{Settings.Default.VaultsFileName}"; + + try + { + var fileString = JsonSerializer.Serialize(Vaults); + File.WriteAllText(localFilePath, fileString, Encoding.UTF8); + } + catch (Exception e) + { + ConsoleManager.WriteLineForError(MethodBase.GetCurrentMethod()?.DeclaringType, e); + Log.Error(MethodBase.GetCurrentMethod()?.DeclaringType, e); + } + } + + #endregion + + #region Helper methods + + private static VaultLocation GetVaultLocationByIndex(string index) + { + return Enum.TryParse(index, true, out VaultLocation location) ? location : VaultLocation.Unknown; + } + + #endregion +} \ No newline at end of file diff --git a/src/StatisticsAnalysisTool/Network/Operations/Responses/UseLootChestResponse.cs b/src/StatisticsAnalysisTool/Network/Operations/Responses/UseLootChestResponse.cs index 227527948..015c3ebf0 100644 --- a/src/StatisticsAnalysisTool/Network/Operations/Responses/UseLootChestResponse.cs +++ b/src/StatisticsAnalysisTool/Network/Operations/Responses/UseLootChestResponse.cs @@ -8,7 +8,7 @@ namespace StatisticsAnalysisTool.Network.Operations.Responses { public class UseLootChestResponse { - public DiscoveredLoot Loot; + public DiscoveredItem Item; //private readonly long? _objectId; //private readonly string _deadPlayer; diff --git a/src/StatisticsAnalysisTool/Properties/Settings.Designer.cs b/src/StatisticsAnalysisTool/Properties/Settings.Designer.cs index db0d41d8d..0dcae18df 100644 --- a/src/StatisticsAnalysisTool/Properties/Settings.Designer.cs +++ b/src/StatisticsAnalysisTool/Properties/Settings.Designer.cs @@ -367,5 +367,17 @@ public string MailsFileName { this["MailsFileName"] = value; } } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("Vaults.json")] + public string VaultsFileName { + get { + return ((string)(this["VaultsFileName"])); + } + set { + this["VaultsFileName"] = value; + } + } } } diff --git a/src/StatisticsAnalysisTool/Properties/Settings.settings b/src/StatisticsAnalysisTool/Properties/Settings.settings index fdcaf9150..4afe550a5 100644 --- a/src/StatisticsAnalysisTool/Properties/Settings.settings +++ b/src/StatisticsAnalysisTool/Properties/Settings.settings @@ -98,5 +98,8 @@ Mails.json + + Vaults.json + \ No newline at end of file diff --git a/src/StatisticsAnalysisTool/StatisticsAnalysisTool.csproj b/src/StatisticsAnalysisTool/StatisticsAnalysisTool.csproj index 787a9a261..98098fd52 100644 --- a/src/StatisticsAnalysisTool/StatisticsAnalysisTool.csproj +++ b/src/StatisticsAnalysisTool/StatisticsAnalysisTool.csproj @@ -396,6 +396,10 @@ + + $(DefaultXamlRuntime) + Designer + $(DefaultXamlRuntime) Designer @@ -472,11 +476,15 @@ $(DefaultXamlRuntime) Designer + + $(DefaultXamlRuntime) + $(DefaultXamlRuntime) + \ No newline at end of file diff --git a/src/StatisticsAnalysisTool/Styles/StorageHistoryStyle.xaml b/src/StatisticsAnalysisTool/Styles/StorageHistoryStyle.xaml new file mode 100644 index 000000000..671d9b4cf --- /dev/null +++ b/src/StatisticsAnalysisTool/Styles/StorageHistoryStyle.xaml @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/StatisticsAnalysisTool/UserControls/StorageHistoryControl.xaml b/src/StatisticsAnalysisTool/UserControls/StorageHistoryControl.xaml new file mode 100644 index 000000000..a6a576e0c --- /dev/null +++ b/src/StatisticsAnalysisTool/UserControls/StorageHistoryControl.xaml @@ -0,0 +1,36 @@ + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/StatisticsAnalysisTool/UserControls/StorageHistoryControl.xaml.cs b/src/StatisticsAnalysisTool/UserControls/StorageHistoryControl.xaml.cs new file mode 100644 index 000000000..b5aa0b96b --- /dev/null +++ b/src/StatisticsAnalysisTool/UserControls/StorageHistoryControl.xaml.cs @@ -0,0 +1,13 @@ +namespace StatisticsAnalysisTool.UserControls +{ + /// + /// Interaction logic for StorageHistoryControl.xaml + /// + public partial class StorageHistoryControl + { + public StorageHistoryControl() + { + InitializeComponent(); + } + } +} \ No newline at end of file diff --git a/src/StatisticsAnalysisTool/ViewModels/MainWindowViewModel.cs b/src/StatisticsAnalysisTool/ViewModels/MainWindowViewModel.cs index 9f1d867f5..8829ad66f 100644 --- a/src/StatisticsAnalysisTool/ViewModels/MainWindowViewModel.cs +++ b/src/StatisticsAnalysisTool/ViewModels/MainWindowViewModel.cs @@ -26,6 +26,7 @@ using System.Windows; using System.Windows.Data; using System.Windows.Media; +using StatisticsAnalysisTool.Models.BindingModel; // ReSharper disable UnusedMember.Global @@ -133,6 +134,8 @@ public class MainWindowViewModel : INotifyPropertyChanged private string _mailsSearchText; private DateTime _datePickerMailsFrom = new (2017, 1, 1); private DateTime _datePickerMailsTo = DateTime.UtcNow.AddDays(1); + private VaultBindings _vaultBindings = new (); + private Vault _vaultSelected; public MainWindowViewModel(MainWindow mainWindow) { @@ -710,6 +713,7 @@ public void StartTracking() TrackingController?.DungeonController?.SetOrUpdateDungeonsDataUiAsync(); TrackingController?.StatisticController?.LoadFromFile(); TrackingController?.MailController?.LoadFromFile(); + TrackingController?.VaultController?.LoadFromFile(); TrackingController?.CountUpTimer.Start(); @@ -724,6 +728,7 @@ public void StopTracking() TrackingController?.DungeonController?.SaveDungeonsInFile(); TrackingController?.StatisticController?.SaveInFile(); TrackingController?.MailController?.SaveInFile(); + TrackingController?.VaultController?.SaveInFile(); TrackingController?.UnregisterEvents(); TrackingController?.CountUpTimer?.Stop(); @@ -1877,6 +1882,16 @@ public MailStatsObject MailStatsObject } } + public VaultBindings VaultBindings + { + get => _vaultBindings; + set + { + _vaultBindings = value; + OnPropertyChanged(); + } + } + public string MailsSearchText { get => _mailsSearchText; diff --git a/src/StatisticsAnalysisTool/Views/MainWindow.xaml b/src/StatisticsAnalysisTool/Views/MainWindow.xaml index 98460e1df..d37fda593 100644 --- a/src/StatisticsAnalysisTool/Views/MainWindow.xaml +++ b/src/StatisticsAnalysisTool/Views/MainWindow.xaml @@ -151,6 +151,11 @@ + + + + +