Skip to content

Commit

Permalink
player info
Browse files Browse the repository at this point in the history
  • Loading branch information
murbong committed Nov 21, 2022
1 parent 5438970 commit 4baf0bc
Show file tree
Hide file tree
Showing 18 changed files with 165 additions and 33 deletions.
17 changes: 17 additions & 0 deletions KekboomKawaii.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@
</ApplicationDefinition>
<Compile Include="Converter\WindowIconConverter.cs" />
<Compile Include="Global.cs" />
<Compile Include="Models\EnchantProperty.cs" />
<Compile Include="Models\Equipment.cs" />
<Compile Include="Models\ITCPReadable.cs" />
<Compile Include="Models\PlayerData.cs" />
Expand Down Expand Up @@ -523,6 +524,22 @@
<Resource Include="Resources\Equipment\visor_blue.png" />
<Resource Include="Resources\Equipment\visor_purple.png" />
</ItemGroup>
<ItemGroup>
<Resource Include="Resources\Enchant\icon_atk.png" />
<Resource Include="Resources\Enchant\icon_atk_bing.png" />
<Resource Include="Resources\Enchant\icon_atk_dian.png" />
<Resource Include="Resources\Enchant\icon_atk_huo.png" />
<Resource Include="Resources\Enchant\icon_baoji.png" />
<Resource Include="Resources\Enchant\icon_def.png" />
<Resource Include="Resources\Enchant\icon_def_bing.png" />
<Resource Include="Resources\Enchant\icon_def_dian.png" />
<Resource Include="Resources\Enchant\icon_def_huo.png" />
<Resource Include="Resources\Enchant\Icon_def_yineng.png" />
<Resource Include="Resources\Enchant\icon_resist_all.png" />
</ItemGroup>
<ItemGroup>
<Resource Include="Resources\Enchant\icon_hp.png" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="packages\MaterialDesignThemes.4.6.1\build\MaterialDesignThemes.targets" Condition="Exists('packages\MaterialDesignThemes.4.6.1\build\MaterialDesignThemes.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
Expand Down
69 changes: 69 additions & 0 deletions Models/EnchantProperty.cs
Original file line number Diff line number Diff line change
@@ -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;
}
}
}
23 changes: 16 additions & 7 deletions Models/Equipment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,25 +14,34 @@ public class Equipment
public string Name { get; set; }
public int Enchant { get; set; }
public int Star { get; set; }
public Dictionary<string, float> Properties { get; set; }
public string DisplayEquipmentImage => $@"pack://application:,,,/Resources/Equipment/{Name}.png";
public List<EnchantProperty> 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<string, float>();
Properties = new List<EnchantProperty>();
}
// 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;

Expand All @@ -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);
Expand Down
Binary file added Resources/Enchant/Icon_def_yineng.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Resources/Enchant/icon_atk.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Resources/Enchant/icon_atk_bing.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Resources/Enchant/icon_atk_dian.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Resources/Enchant/icon_atk_huo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Resources/Enchant/icon_baoji.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Resources/Enchant/icon_def.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Resources/Enchant/icon_def_bing.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Resources/Enchant/icon_def_dian.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Resources/Enchant/icon_def_huo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Resources/Enchant/icon_hp.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Resources/Enchant/icon_resist_all.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 8 additions & 3 deletions ViewModels/PlayerListViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,22 @@ public class PlayerListViewModel : ObservableCollection<PlayerViewModel>
{

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)
Expand Down
16 changes: 12 additions & 4 deletions ViewModels/PlayerViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand All @@ -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();
Expand All @@ -46,7 +54,7 @@ public List<Weapon> WeaponList
{
var list = new List<Weapon>();

for(var i = 0; i < 3; i++)
for (var i = 0; i < 3; i++)
{
if (playerData.KeyData.TryGetValue($"Weapon_{i}", out object val))
{
Expand Down
62 changes: 43 additions & 19 deletions Views/PlayerView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
d:DesignHeight="450" d:DesignWidth="800">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="2*"/>
<ColumnDefinition Width="4*"/>
<ColumnDefinition Width="250"/>
<ColumnDefinition Width="auto"/>
</Grid.ColumnDefinitions>
<StackPanel Orientation="Vertical">
<Grid>
Expand All @@ -34,32 +34,40 @@
<Run Text="직무 : "/>
<Run Text="{Binding GuildPost,Mode=OneWay}"/>
</TextBlock>
<TextBlock HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="16">
<Run Text="UID : "/>
<Run Text="{Binding UUID,Mode=OneWay}"/>
</TextBlock>
<TextBlock HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="16">
<Run Text="UUID : "/>
<Run Text="{Binding UID,Mode=OneWay}"/>
</TextBlock>
</StackPanel>
<StackPanel Grid.Column="1">
<TextBlock HorizontalAlignment="Left" VerticalAlignment="Center" >
<Run Text="HP : "/>
<Run Text="{Binding HP,Mode=OneWay}"/>
<Run Text="{Binding HP,Mode=OneWay,StringFormat={}{0:F0}}"/>
</TextBlock>
<TextBlock HorizontalAlignment="Left" VerticalAlignment="Center" >
<Run Text="치명타 : "/>
<Run Text="{Binding Critical,Mode=OneWay}"/>
<Run Text="{Binding CriticalRatio,Mode=OneWay}"/>
<Run Text="{Binding Critical,Mode=OneWay,StringFormat={}{0:F0}}"/>
<Run Text="{Binding CriticalRatio,Mode=OneWay,StringFormat={}({0:#0.00%})}"/>
</TextBlock>
<TextBlock HorizontalAlignment="Left" VerticalAlignment="Center" >
<Run Text="물리 공격 : "/>
<Run Text="{Binding PhysicalAttack,Mode=OneWay}"/>
<Run Text="{Binding PhysicalAttack,Mode=OneWay,StringFormat={}{0:F0}}"/>
</TextBlock>
<TextBlock HorizontalAlignment="Left" VerticalAlignment="Center" >
<Run Text="화염 공격 : "/>
<Run Text="{Binding FireAtk,Mode=OneWay}"/>
<Run Text="{Binding FireAtk,Mode=OneWay,StringFormat={}{0:F0}}"/>
</TextBlock>
<TextBlock HorizontalAlignment="Left" VerticalAlignment="Center" >
<Run Text="얼음 공격 : "/>
<Run Text="{Binding IceAtk,Mode=OneWay}"/>
<Run Text="{Binding IceAtk,Mode=OneWay,StringFormat={}{0:F0}}"/>
</TextBlock>
<TextBlock HorizontalAlignment="Left" VerticalAlignment="Center" >
<Run Text="번개 공격 : "/>
<Run Text="{Binding ThunderAtk,Mode=OneWay}"/>
<Run Text="{Binding ThunderAtk,Mode=OneWay,StringFormat={}{0:F0}}"/>
</TextBlock>
<TextBlock HorizontalAlignment="Left" VerticalAlignment="Center" >
<Run Text="이능 공격 : "/>
Expand All @@ -74,26 +82,42 @@
<ListView.ItemTemplate>
<DataTemplate>
<Grid>
<Image Source="{Binding DisplayWeaponImage}" Width="75" Height="75"/>
<Image Source="{Binding DisplayWeaponImage, Mode=OneWay}" Width="75" Height="75"/>
<TextBlock FontSize="24" HorizontalAlignment="Center" VerticalAlignment="Top">
<Run Text="{Binding Star}"/>
<Run Text="{Binding Level}"/>
<Run Text="{Binding Star, Mode=OneWay}"/>
<Run Text="{Binding Level, Mode=OneWay}"/>
</TextBlock>
</Grid>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
<ListView ItemsSource="{Binding EquipmentList}" MaxHeight="400">
<ListView ItemsSource="{Binding EquipmentList}" MaxHeight="240">
<ListView.ItemTemplate>
<DataTemplate>
<Grid Width="400">
<Image Source="{Binding DisplayEquipmentImage}" Width="150" Height="150" HorizontalAlignment="Left"/>
<TextBlock >
<Run Text="{Binding Star}"/>
<Run Text="{Binding Enchant}"/>
<Grid HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Width="400">
<Image Source="{Binding DisplayEquipmentImage}" Width="100" Height="100" HorizontalAlignment="Left" VerticalAlignment="Top"/>
<TextBlock HorizontalAlignment="Left">
<Run Text="{Binding Star, Mode=OneWay}"/>
<Run Text="{Binding Enchant, Mode=OneWay}"/>
</TextBlock>
<ListView ItemsSource="{Binding Properties}" HorizontalAlignment="Right">

<ListView.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Horizontal"></StackPanel>
</ItemsPanelTemplate>
</ListView.ItemsPanel>
<ListView.ItemTemplate>
<DataTemplate>
<Grid>
<StackPanel Orientation="Vertical" Width="60">
<Image Source="{Binding DisplayPropertyImage, Mode=OneWay}" Width="25" Height="25" VerticalAlignment="Top"/>
<TextBlock VerticalAlignment="Bottom" HorizontalAlignment="Center">
<Run Text="{Binding DisplayValue, Mode=OneWay}"/>
</TextBlock>
</StackPanel>
</Grid>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</Grid>
</DataTemplate>
Expand Down

0 comments on commit 4baf0bc

Please sign in to comment.