Skip to content

Commit

Permalink
Merge branch '101-tracking-dashboard'
Browse files Browse the repository at this point in the history
  • Loading branch information
Triky313 committed Apr 9, 2022
2 parents a5b6677 + e36546b commit a1f24ba
Show file tree
Hide file tree
Showing 53 changed files with 1,216 additions and 131 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,14 @@ https://gameinfo.albiononline.com/api/gameinfo/events
Player info
https://gameinfo.albiononline.com/api/gameinfo/players/{player_id}

Player topkills info
https://gameinfo.albiononline.com/api/gameinfo/players/{player_id}/topkills?range=month&offset=0&limit=11
(range=day,week,lastWeek,month,lastMonth)

Player solokills info
https://gameinfo.albiononline.com/api/gameinfo/players/{player_id}/solokills?range=week&offset=0&limit=11
(range=day,week,lastWeek,month,lastMonth)

Guild info
https://gameinfo.albiononline.com/api/gameinfo/guilds/{guild_id} https://gameinfo.albiononline.com/api/gameinfo/guilds/{guild_id}/members

Expand Down
90 changes: 48 additions & 42 deletions src/StatisticsAnalysisTool/App.config
Original file line number Diff line number Diff line change
Expand Up @@ -61,52 +61,58 @@
<setting name="AutoUpdatePreReleaseConfigUrl" serializeAs="String">
<value>https://raw.githubusercontent.com/Triky313/AlbionOnline-StatisticsAnalysis/master/src/StatisticsAnalysisTool/ao-pre-release-update-check.xml</value>
</setting>
<setting name="StatsFileName" serializeAs="String">
<value>Stats.json</value>
</setting>
</StatisticsAnalysisTool.Properties.Settings>
</userSettings>
<applicationSettings>
<StatisticsAnalysisTool.Properties.Settings>
<setting name="LanguageDirectoryName" serializeAs="String">
<value>Languages</value>
</setting>
<setting name="ImageResources" serializeAs="String">
<value>ImageResources</value>
</setting>
<setting name="ItemListFileName" serializeAs="String">
<value>ItemList.json</value>
</setting>
<setting name="DonateUrl" serializeAs="String">
<value>https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&amp;hosted_button_id=LEM458PZ4FV4C&amp;source=url</value>
</setting>
<setting name="DefaultItemListSourceUrl" serializeAs="String">
<value>https://raw.githubusercontent.com/broderickhyman/ao-bin-dumps/master/formatted/items.json</value>
</setting>
<setting name="AutoUpdateConfigUrl" serializeAs="String">
<value>https://raw.githubusercontent.com/Triky313/AlbionOnline-StatisticsAnalysis/master/src/StatisticsAnalysisTool/ao-update-check.xml</value>
</setting>
<setting name="DefaultLanguageCultureName" serializeAs="String">
<value>en-US</value>
</setting>
<setting name="GitHubRepoUrl" serializeAs="String">
<value>https://github.com/Triky313/AlbionOnline-StatisticsAnalysis</value>
</setting>
<setting name="DiscordUrl" serializeAs="String">
<value>https://discord.gg/R2MrB2FwtU</value>
</setting>
<setting name="CityPricesApiUrlDefault" serializeAs="String">
<value>https://www.albion-online-data.com/api/v2/stats/prices/</value>
</setting>
<setting name="CityPricesHistoryApiUrlDefault" serializeAs="String">
<value>https://www.albion-online-data.com/api/v2/stats/history/</value>
</setting>
<setting name="GoldStatsApiUrlDefault" serializeAs="String">
<value>https://www.albion-online-data.com/api/v2/stats/Gold</value>
</setting>
<setting name="GameFilesDirectoryName" serializeAs="String">
<value>GameFiles</value>
</setting>
<setting name="SettingsFileName" serializeAs="String">
<value>Settings.json</value>
</setting>
<setting name="LanguageDirectoryName" serializeAs="String">
<value>Languages</value>
</setting>
<setting name="ImageResources" serializeAs="String">
<value>ImageResources</value>
</setting>
<setting name="ItemListFileName" serializeAs="String">
<value>ItemList.json</value>
</setting>
<setting name="DonateUrl" serializeAs="String">
<value>https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&amp;hosted_button_id=LEM458PZ4FV4C&amp;source=url</value>
</setting>
<setting name="DefaultItemListSourceUrl" serializeAs="String">
<value>https://raw.githubusercontent.com/broderickhyman/ao-bin-dumps/master/formatted/items.json</value>
</setting>
<setting name="AutoUpdateConfigUrl" serializeAs="String">
<value>https://raw.githubusercontent.com/Triky313/AlbionOnline-StatisticsAnalysis/master/src/StatisticsAnalysisTool/ao-update-check.xml</value>
</setting>
<setting name="DefaultLanguageCultureName" serializeAs="String">
<value>en-US</value>
</setting>
<setting name="GitHubRepoUrl" serializeAs="String">
<value>https://github.com/Triky313/AlbionOnline-StatisticsAnalysis</value>
</setting>
<setting name="DiscordUrl" serializeAs="String">
<value>https://discord.com/invite/sahSrSPmaJ</value>
</setting>
<setting name="CityPricesApiUrlDefault" serializeAs="String">
<value>https://www.albion-online-data.com/api/v2/stats/prices/</value>
</setting>
<setting name="CityPricesHistoryApiUrlDefault" serializeAs="String">
<value>https://www.albion-online-data.com/api/v2/stats/history/</value>
</setting>
<setting name="GoldStatsApiUrlDefault" serializeAs="String">
<value>https://www.albion-online-data.com/api/v2/stats/Gold</value>
</setting>
<setting name="GameFilesDirectoryName" serializeAs="String">
<value>GameFiles</value>
</setting>
<setting name="SettingsFileName" serializeAs="String">
<value>Settings.json</value>
</setting>
<setting name="KeepDashboardStatisticsForDays" serializeAs="String">
<value>-90</value>
</setting>
</StatisticsAnalysisTool.Properties.Settings>
</applicationSettings>
<runtime>
Expand Down
98 changes: 97 additions & 1 deletion src/StatisticsAnalysisTool/Common/ApiController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
using System.Reflection;
using System.Text.Json;
using System.Threading.Tasks;
using StatisticsAnalysisTool.Enumerations;
using StatisticsAnalysisTool.Models.ApiModel;

namespace StatisticsAnalysisTool.Common
{
Expand Down Expand Up @@ -133,7 +135,7 @@ public static async Task<GameInfoSearchResponse> GetGameInfoSearchFromJsonAsync(
using var clientHandler = new HttpClientHandler();
clientHandler.ServerCertificateCustomValidationCallback = (_, _, _, _) => true;
using var client = new HttpClient(clientHandler);
client.Timeout = TimeSpan.FromSeconds(120);
client.Timeout = TimeSpan.FromSeconds(600);
try
{
using var response = await client.GetAsync(url);
Expand Down Expand Up @@ -174,6 +176,100 @@ public static async Task<GameInfoPlayersResponse> GetGameInfoPlayersFromJsonAsyn
}
}

public static async Task<List<GameInfoPlayerKillsDeaths>> GetGameInfoPlayerKillsDeathsFromJsonAsync(string userid, GameInfoPlayersType gameInfoPlayersType)
{
var values = new List<GameInfoPlayerKillsDeaths>();

var killsDeathsExtensionString = gameInfoPlayersType == GameInfoPlayersType.Kills ? "kills" : "deaths";
var url = $"https://gameinfo.albiononline.com/api/gameinfo/players/{userid}/{killsDeathsExtensionString}";

using var clientHandler = new HttpClientHandler();
clientHandler.ServerCertificateCustomValidationCallback = (_, _, _, _) => true;
using var client = new HttpClient(clientHandler);
client.Timeout = TimeSpan.FromSeconds(600);
try
{
using var response = await client.GetAsync(url);
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls;
using var content = response.Content;
return JsonSerializer.Deserialize<List<GameInfoPlayerKillsDeaths>>(await content.ReadAsStringAsync()) ?? values;
}
catch (Exception e)
{
ConsoleManager.WriteLineForError(MethodBase.GetCurrentMethod()?.DeclaringType, e);
Log.Error(MethodBase.GetCurrentMethod()?.DeclaringType, e);
return values;
}
}

public static async Task<List<GameInfoPlayerKillsDeaths>> GetGameInfoPlayerTopKillsFromJsonAsync(string userid, UnitOfTime unitOfTime)
{
var values = new List<GameInfoPlayerKillsDeaths>();
var unitOfTimeString = unitOfTime switch
{
UnitOfTime.Day => "day",
UnitOfTime.Week => "week",
UnitOfTime.LastWeek => "lastWeek",
UnitOfTime.Month => "month",
UnitOfTime.LastMonth => "lastMonth",
_ => ""
};

var url = $"https://gameinfo.albiononline.com/api/gameinfo/players/{userid}/topkills?range={unitOfTimeString}&offset=0";

using var clientHandler = new HttpClientHandler();
clientHandler.ServerCertificateCustomValidationCallback = (_, _, _, _) => true;
using var client = new HttpClient(clientHandler);
client.Timeout = TimeSpan.FromSeconds(600);
try
{
using var response = await client.GetAsync(url);
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls;
using var content = response.Content;
return JsonSerializer.Deserialize<List<GameInfoPlayerKillsDeaths>>(await content.ReadAsStringAsync()) ?? values;
}
catch (Exception e)
{
ConsoleManager.WriteLineForError(MethodBase.GetCurrentMethod()?.DeclaringType, e);
Log.Error(MethodBase.GetCurrentMethod()?.DeclaringType, e);
return values;
}
}

public static async Task<List<GameInfoPlayerKillsDeaths>> GetGameInfoPlayerSoloKillsFromJsonAsync(string userid, UnitOfTime unitOfTime)
{
var values = new List<GameInfoPlayerKillsDeaths>();
var unitOfTimeString = unitOfTime switch
{
UnitOfTime.Day => "day",
UnitOfTime.Week => "week",
UnitOfTime.LastWeek => "lastWeek",
UnitOfTime.Month => "month",
UnitOfTime.LastMonth => "lastMonth",
_ => ""
};

var url = $"https://gameinfo.albiononline.com/api/gameinfo/players/{userid}/solokills?range={unitOfTimeString}&offset=0";

using var clientHandler = new HttpClientHandler();
clientHandler.ServerCertificateCustomValidationCallback = (_, _, _, _) => true;
using var client = new HttpClient(clientHandler);
client.Timeout = TimeSpan.FromSeconds(600);
try
{
using var response = await client.GetAsync(url);
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls;
using var content = response.Content;
return JsonSerializer.Deserialize<List<GameInfoPlayerKillsDeaths>>(await content.ReadAsStringAsync()) ?? values;
}
catch (Exception e)
{
ConsoleManager.WriteLineForError(MethodBase.GetCurrentMethod()?.DeclaringType, e);
Log.Error(MethodBase.GetCurrentMethod()?.DeclaringType, e);
return values;
}
}

//public static async Task<GameInfoGuildsResponse> GetGameInfoGuildsFromJsonAsync(string guildId)
//{
// var url = $"https://gameinfo.albiononline.com/api/gameinfo/guilds/{guildId}";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace StatisticsAnalysisTool.Common
namespace StatisticsAnalysisTool.Common.Converters
{
public static class Converter
{
Expand Down
5 changes: 5 additions & 0 deletions src/StatisticsAnalysisTool/Common/ExtensionMethod.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ namespace StatisticsAnalysisTool.Common
{
public static class ExtensionMethod
{
public static bool IsDefault<T>(this T value) where T : struct
{
return value.Equals(default(T));
}

public static string SetYesOrNo(this bool value)
{
return (value) ? LanguageController.Translation("YES") : LanguageController.Translation("NO");
Expand Down
13 changes: 8 additions & 5 deletions src/StatisticsAnalysisTool/Common/LanguageController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,14 @@
using System.Reflection;
using System.Threading;
using System.Windows;
using System.Windows.Markup;
using System.Xml;

namespace StatisticsAnalysisTool.Common
{
public static class LanguageController
{
private static readonly Dictionary<string, string> _translations = new();
private static readonly Dictionary<string, string> Translations = new();
private static CultureInfo _currentCultureInfo;
private static readonly ILog Log = LogManager.GetLogger(MethodBase.GetCurrentMethod()?.DeclaringType);
public static List<FileInformation> LanguageFiles { get; set; }
Expand All @@ -31,6 +32,8 @@ public static CultureInfo CurrentCultureInfo
try
{
Thread.CurrentThread.CurrentUICulture = value;
Thread.CurrentThread.CurrentCulture = value;
FrameworkElement.LanguageProperty.OverrideMetadata(typeof(FrameworkElement), new FrameworkPropertyMetadata(XmlLanguage.GetLanguage(CultureInfo.CurrentCulture.IetfLanguageTag)));
}
catch (Exception e)
{
Expand Down Expand Up @@ -86,7 +89,7 @@ public static string Translation(string key)
{
try
{
if (_translations.TryGetValue(key, out var value))
if (Translations.TryGetValue(key, out var value))
{
return !string.IsNullOrEmpty(value) ? value : key;
}
Expand Down Expand Up @@ -146,7 +149,7 @@ private static bool ReadAndAddLanguageFile(string filePath)
{
try
{
_translations.Clear();
Translations.Clear();
var xmlReader = XmlReader.Create(filePath);
while (xmlReader.Read())
if (xmlReader.Name == "translation" && xmlReader.HasAttributes)
Expand All @@ -167,13 +170,13 @@ private static void AddTranslationsToDictionary(XmlReader xmlReader)
{
while (xmlReader.MoveToNextAttribute())
{
if (_translations.ContainsKey(xmlReader.Value))
if (Translations.ContainsKey(xmlReader.Value))
{
Log.Warn($"{nameof(AddTranslationsToDictionary)}: {Translation("DOUBLE_VALUE_EXISTS_IN_THE_LANGUAGE_FILE")}: {xmlReader.Value}");
}
else if (xmlReader.Name == "name")
{
_translations.Add(xmlReader.Value, xmlReader.ReadString());
Translations.Add(xmlReader.Value, xmlReader.ReadString());
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace StatisticsAnalysisTool.Enumerations;

public enum GameInfoPlayersType
{
Kills,
Deaths
}
10 changes: 10 additions & 0 deletions src/StatisticsAnalysisTool/Enumerations/UnitOfTime.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
namespace StatisticsAnalysisTool.Enumerations;

public enum UnitOfTime
{
Day,
Week,
LastWeek,
Month,
LastMonth
}
21 changes: 10 additions & 11 deletions src/StatisticsAnalysisTool/Enumerations/ValueType.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
namespace StatisticsAnalysisTool.Enumerations
namespace StatisticsAnalysisTool.Enumerations;

public enum ValueType
{
public enum ValueType
{
Fame,
ReSpec,
Silver,
FactionFame,
FactionPoints,
Might,
Favor
}
Fame,
ReSpec,
Silver,
FactionFame,
FactionPoints,
Might,
Favor
}
10 changes: 10 additions & 0 deletions src/StatisticsAnalysisTool/Languages/de-DE.xml
Original file line number Diff line number Diff line change
Expand Up @@ -527,4 +527,14 @@
<translation name="GET_ITEMS_JSON">Items.json erhalten</translation>
<translation name="CHARACTER_NAME_TO_TRACK">Charaktername zum tracken</translation>
<translation name="THIS_CHARACTER_IS_NOT_TRACKED">Dieser Charakter wird nicht getrackt</translation>
<translation name="DATA_FROM_ALBION_ONLINE_SERVERS">Daten von Albion Online Servern</translation>
<translation name="TODAY">Heute</translation>
<translation name="WEEK">Woche</translation>
<translation name="MONTH">Monat</translation>
<translation name="KILLS">Tötungen</translation>
<translation name="SOLO_KILLS">Solo Tötungen</translation>
<translation name="DEATHS">Tode</translation>
<translation name="AVERAGE_ITEM_POWER_WHEN_KILLING">Durchschnittliche Gegenstandsstärke beim Töten</translation>
<translation name="AVERAGE_ITEM_POWER_OF_THE_KILLED_ENEMIES">Durchschnittliche Gegenstandsstärke der getöteten Feinde</translation>
<translation name="AVERAGE_ITEM_POWER_WHEN_DYING">Durchschnittliche Gegenstandsstärke beim Sterben</translation>
</translations>
10 changes: 10 additions & 0 deletions src/StatisticsAnalysisTool/Languages/en-US.xml
Original file line number Diff line number Diff line change
Expand Up @@ -527,4 +527,14 @@
<translation name="GET_ITEMS_JSON">Get Items.json</translation>
<translation name="CHARACTER_NAME_TO_TRACK">Character name to track</translation>
<translation name="THIS_CHARACTER_IS_NOT_TRACKED">This character is not tracked</translation>
<translation name="DATA_FROM_ALBION_ONLINE_SERVERS">Data from Albion Online servers</translation>
<translation name="TODAY">Today</translation>
<translation name="WEEK">Week</translation>
<translation name="MONTH">Month</translation>
<translation name="KILLS">Kills</translation>
<translation name="SOLO_KILLS">Solo kills</translation>
<translation name="DEATHS">Deaths</translation>
<translation name="AVERAGE_ITEM_POWER_WHEN_KILLING">Average item power when killing</translation>
<translation name="AVERAGE_ITEM_POWER_OF_THE_KILLED_ENEMIES">Average item power of the killed enemies</translation>
<translation name="AVERAGE_ITEM_POWER_WHEN_DYING">Average item power when dying</translation>
</translations>
Loading

0 comments on commit a1f24ba

Please sign in to comment.