diff --git a/KekboomKawaii.csproj b/KekboomKawaii.csproj index 6dc052f..cce2937 100644 --- a/KekboomKawaii.csproj +++ b/KekboomKawaii.csproj @@ -118,6 +118,7 @@ + @@ -523,6 +524,22 @@ + + + + + + + + + + + + + + + + diff --git a/Models/EnchantProperty.cs b/Models/EnchantProperty.cs new file mode 100644 index 0000000..64b07a2 --- /dev/null +++ b/Models/EnchantProperty.cs @@ -0,0 +1,69 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace KekboomKawaii.Models +{ + public class EnchantProperty + { + + + public string Name { get; set; } + public float Value { get; set; } + + public string DisplayValue { get + { + if (Name.Contains("Mult")) + { + return $"{Value * 100}%"; + } + return Value.ToString("F2"); + } + } + + public string DisplayPropertyImage + { + get + { + if(Name.Contains("ThunderAtk")) + return $@"pack://application:,,,/Resources/Enchant/icon_atk_dian.png"; + else if (Name.Contains("CommonAtk")) + return $@"pack://application:,,,/Resources/Enchant/icon_atk.png"; + else if (Name.Contains("IceAtk")) + return $@"pack://application:,,,/Resources/Enchant/icon_atk_bing.png"; + else if (Name.Contains("PhyAtk")) + return $@"pack://application:,,,/Resources/Enchant/icon_atk.png"; + else if (Name.Contains("FireAtk")) + return $@"pack://application:,,,/Resources/Enchant/icon_atk_huo.png"; + + else if (Name.Contains("PhyDef")) + return $@"pack://application:,,,/Resources/Enchant/icon_def.png"; + else if (Name.Contains("ElementDef")) + return $@"pack://application:,,,/Resources/Enchant/icon_resist_all.png"; + else if (Name.Contains("IceDef")) + return $@"pack://application:,,,/Resources/Enchant/icon_def_bing.png"; + else if (Name.Contains("FireDef")) + return $@"pack://application:,,,/Resources/Enchant/icon_def_huo.png"; + else if (Name.Contains("ThunderDef")) + return $@"pack://application:,,,/Resources/Enchant/icon_def_dian.png"; + else if (Name.Contains("MaxHealth")) + return $@"pack://application:,,,/Resources/Enchant/icon_hp.png"; + else if (Name.Contains("Crit")) + return $@"pack://application:,,,/Resources/Enchant/icon_baoji.png"; + return ""; + } + } + + public EnchantProperty() + { + + } + public EnchantProperty(string name, float value) + { + Name = name; + Value= value; + } + } +} diff --git a/Models/Equipment.cs b/Models/Equipment.cs index 5851100..0ddae2a 100644 --- a/Models/Equipment.cs +++ b/Models/Equipment.cs @@ -14,25 +14,34 @@ public class Equipment public string Name { get; set; } public int Enchant { get; set; } public int Star { get; set; } - public Dictionary Properties { get; set; } - public string DisplayEquipmentImage => $@"pack://application:,,,/Resources/Equipment/{Name}.png"; + public List Properties { get; set; } + + public string DisplayEquipmentImage + { + get + { + var reg = new Regex(@"([0-9])"); + var result = reg.Replace(Name, ""); + return $@"pack://application:,,,/Resources/Equipment/{result}.png"; + } + } public Equipment() { - Properties = new Dictionary(); + Properties = new List(); } // core_OS_blue#0#1,ThunderAtkAdded;2,20.000000;|1,ThunderDefAdded;2,61.000000;|1,CommonAtkAdded;2,15.000000;#0# //shawl_orange#29#1,CommonAtkAdded;2,679.502686;|1,IceDefAdded;2,1366.897705;|1,ThunderDefAdded;2,215.000000;|1,MaxHealthAdded;2,4125.000000;#5# - public Equipment(string rawEquipment) : this() + public Equipment(string rawEquipment) : this() { //var reg = new Regex(@"(\w+)#(\d+)#(\d+),(\w+);([\d,]*\.?\d*);\|(\d+),(\w+);([\d,]*\.?\d*);\|(\d+),(\w+);([\d,]*\.?\d*);\|(\d+),(\w+);([\d,]*\.?\d*);#(\d+)#"); var reg = new Regex(@"(\w+)#(\d+)#(.+)#(\d+)#"); - var reg2 = new Regex(@"(\d+),(\w+);([\d,]*\.?\d*);"); + var reg2 = new Regex(@"(\d+),(\w+);(\d+),(\d+\.*\d*);"); var resultCollection = reg.Matches(rawEquipment)[0].Groups; @@ -42,11 +51,11 @@ public Equipment(string rawEquipment) : this() var properties = resultCollection[3].Value.Split('|'); - foreach(var property in properties) + foreach (var property in properties) { var collection = reg2.Matches(property)[0].Groups; - Properties.Add(collection[2].Value, float.Parse(collection[3].Value)); + Properties.Add(new EnchantProperty(collection[2].Value, float.Parse(collection[4].Value))); } Star = int.Parse(resultCollection[4].Value); diff --git a/Resources/Enchant/Icon_def_yineng.png b/Resources/Enchant/Icon_def_yineng.png new file mode 100644 index 0000000..a2eaa97 Binary files /dev/null and b/Resources/Enchant/Icon_def_yineng.png differ diff --git a/Resources/Enchant/icon_atk.png b/Resources/Enchant/icon_atk.png new file mode 100644 index 0000000..eeddca3 Binary files /dev/null and b/Resources/Enchant/icon_atk.png differ diff --git a/Resources/Enchant/icon_atk_bing.png b/Resources/Enchant/icon_atk_bing.png new file mode 100644 index 0000000..2a2053e Binary files /dev/null and b/Resources/Enchant/icon_atk_bing.png differ diff --git a/Resources/Enchant/icon_atk_dian.png b/Resources/Enchant/icon_atk_dian.png new file mode 100644 index 0000000..c861a56 Binary files /dev/null and b/Resources/Enchant/icon_atk_dian.png differ diff --git a/Resources/Enchant/icon_atk_huo.png b/Resources/Enchant/icon_atk_huo.png new file mode 100644 index 0000000..492c080 Binary files /dev/null and b/Resources/Enchant/icon_atk_huo.png differ diff --git a/Resources/Enchant/icon_baoji.png b/Resources/Enchant/icon_baoji.png new file mode 100644 index 0000000..987c670 Binary files /dev/null and b/Resources/Enchant/icon_baoji.png differ diff --git a/Resources/Enchant/icon_def.png b/Resources/Enchant/icon_def.png new file mode 100644 index 0000000..8da58f0 Binary files /dev/null and b/Resources/Enchant/icon_def.png differ diff --git a/Resources/Enchant/icon_def_bing.png b/Resources/Enchant/icon_def_bing.png new file mode 100644 index 0000000..290ecc6 Binary files /dev/null and b/Resources/Enchant/icon_def_bing.png differ diff --git a/Resources/Enchant/icon_def_dian.png b/Resources/Enchant/icon_def_dian.png new file mode 100644 index 0000000..f81e925 Binary files /dev/null and b/Resources/Enchant/icon_def_dian.png differ diff --git a/Resources/Enchant/icon_def_huo.png b/Resources/Enchant/icon_def_huo.png new file mode 100644 index 0000000..ba7d9e0 Binary files /dev/null and b/Resources/Enchant/icon_def_huo.png differ diff --git a/Resources/Enchant/icon_hp.png b/Resources/Enchant/icon_hp.png new file mode 100644 index 0000000..41af8f9 Binary files /dev/null and b/Resources/Enchant/icon_hp.png differ diff --git a/Resources/Enchant/icon_resist_all.png b/Resources/Enchant/icon_resist_all.png new file mode 100644 index 0000000..3c50185 Binary files /dev/null and b/Resources/Enchant/icon_resist_all.png differ diff --git a/ViewModels/PlayerListViewModel.cs b/ViewModels/PlayerListViewModel.cs index 4060754..d956235 100644 --- a/ViewModels/PlayerListViewModel.cs +++ b/ViewModels/PlayerListViewModel.cs @@ -15,17 +15,22 @@ public class PlayerListViewModel : ObservableCollection { private PlayerViewModel selectedPlayerViewModel; - public PlayerViewModel SelectedPlayerViewModel { get { return selectedPlayerViewModel; } set { selectedPlayerViewModel = value;OnPropertyChanged(); } } + public PlayerViewModel SelectedPlayerViewModel { get { return selectedPlayerViewModel; } set { selectedPlayerViewModel = value; OnPropertyChanged(); } } public PlayerListViewModel() { Global.Sniffer.PlayerDataEvent += Sniffer_PayloadEvent; } - private void Sniffer_PayloadEvent(PlayerData userChat) + private void Sniffer_PayloadEvent(PlayerData data) { Application.Current.Dispatcher.Invoke(() => { - Add(new PlayerViewModel(userChat)); + var items = this.Where(e => e.UID == data.UID).ToArray(); + for (var i = 0; i < items.Length; i++) + { + Remove(items[i]); + } + Add(new PlayerViewModel(data)); }); } protected void OnPropertyChanged([CallerMemberName] string propertyName = null) diff --git a/ViewModels/PlayerViewModel.cs b/ViewModels/PlayerViewModel.cs index 887fd47..f838065 100644 --- a/ViewModels/PlayerViewModel.cs +++ b/ViewModels/PlayerViewModel.cs @@ -15,6 +15,14 @@ public class PlayerViewModel : ViewModelBase public string CurentPosition => playerData.CurentPosition; public string PlayerName => playerData.PlayerName; public string UID => playerData.UID; + public string UUID + { + get + { + int[] ints = (int[])GetValue("uid"); + return $"{ints[1]}{ints[0]}"; + } + } public string Title => GetValue("EquippingTitle").ToString(); public string GuildName => GetValue("GuildName").ToString(); public GuildPostEnum GuildPost => (GuildPostEnum)GetValue("GuildPost"); @@ -26,14 +34,14 @@ public class PlayerViewModel : ViewModelBase public float PhysicalAttack => float.TryParse(GetValue("PhysicalAttack").ToString(), out float value) ? value : 0.0f; public float HP => float.TryParse(GetValue("MaxHP").ToString(), out float value) ? value : 0.0f; public float Critical => float.TryParse(GetValue("Crit").ToString(), out float value) ? value : 0.0f; - public float CriticalRatio => float.TryParse(GetValue("GetCritMult").ToString(),out float value) ? value : 0.0f; + public float CriticalRatio => float.TryParse(GetValue("GetCritMult").ToString(), out float value) ? value : 0.0f; public int Level => (int)GetValue("level"); private object GetValue(string key) { - if(playerData.KeyData.TryGetValue(key, out object value)) + if (playerData.KeyData.TryGetValue(key, out object value)) { - return value; + return value; } return new object(); @@ -46,7 +54,7 @@ public List WeaponList { var list = new List(); - for(var i = 0; i < 3; i++) + for (var i = 0; i < 3; i++) { if (playerData.KeyData.TryGetValue($"Weapon_{i}", out object val)) { diff --git a/Views/PlayerView.xaml b/Views/PlayerView.xaml index 01d73b2..eb621a2 100644 --- a/Views/PlayerView.xaml +++ b/Views/PlayerView.xaml @@ -10,8 +10,8 @@ d:DesignHeight="450" d:DesignWidth="800"> - - + + @@ -34,32 +34,40 @@ + + + + + + + + - + - - + + - + - + - + - + @@ -74,26 +82,42 @@ - + - - + + - + - - - - - + + + + + - + + + + + + + + + + + + + + + + +