Skip to content

Commit

Permalink
Merge branch 'dev' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
Triky313 committed Mar 22, 2023
2 parents 09c8ece + 965aa0c commit 12e94df
Show file tree
Hide file tree
Showing 19 changed files with 362 additions and 92 deletions.
9 changes: 0 additions & 9 deletions src/StatisticsAnalysisTool/App.config
Original file line number Diff line number Diff line change
Expand Up @@ -242,15 +242,6 @@
<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>
Expand Down
28 changes: 21 additions & 7 deletions src/StatisticsAnalysisTool/Common/ApiController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,14 @@
using StatisticsAnalysisTool.Properties;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Reflection;
using System.Text.Json;
using System.Threading.Tasks;
using StatisticsAnalysisTool.Network;

namespace StatisticsAnalysisTool.Common;

Expand Down Expand Up @@ -41,13 +43,13 @@ public static async Task<List<MarketResponse>> GetCityItemPricesFromJsonAsync(st
return new List<MarketResponse>();
}

var url = SettingsController.CurrentSettings.CityPricesApiUrl ?? Settings.Default.CityPricesApiUrlDefault;
var url = Path.Combine(GetServerBaseUrlByCurrentServer(), "stats/prices/");
url += uniqueName;

if (marketLocations?.Count >= 1)
{
url += "?locations=";
url = marketLocations.Aggregate(url, (current, location) => current + $"{(int)location},");
url = marketLocations.Aggregate(url, (current, location) => current + $"{(int) location},");
}

if (qualities?.Count >= 1)
Expand All @@ -65,7 +67,7 @@ public static async Task<List<MarketResponse>> GetCityItemPricesFromJsonAsync(st

ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls;
using var response = await client.GetAsync(url);
if (response.StatusCode == (HttpStatusCode)429)
if (response.StatusCode == (HttpStatusCode) 429)
{
throw new TooManyRequestsException();
}
Expand Down Expand Up @@ -93,12 +95,12 @@ public static async Task<List<MarketHistoriesResponse>> GetHistoryItemPricesFrom

if (locations?.Count > 0)
{
locationsString = string.Join(",", locations.Select(x => ((int)x).ToString()));
locationsString = string.Join(",", locations.Select(x => ((int) x).ToString()));
}

var qualitiesString = quality.ToString();

var url = SettingsController.CurrentSettings.CityPricesHistoryApiUrl ?? Settings.Default.CityPricesHistoryApiUrlDefault;
var url = Path.Combine(GetServerBaseUrlByCurrentServer(), "stats/history/");
url += uniqueName;
url += $"?locations={locationsString}";
url += $"&date={date:M-d-yy}";
Expand All @@ -115,7 +117,7 @@ public static async Task<List<MarketHistoriesResponse>> GetHistoryItemPricesFrom
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls;
using var response = await client.GetAsync(url);
using var content = response.Content;
if (response.StatusCode == (HttpStatusCode)429)
if (response.StatusCode == (HttpStatusCode) 429)
{
throw new TooManyRequestsException();
}
Expand Down Expand Up @@ -326,7 +328,9 @@ public static async Task<List<GameInfoPlayerKillsDeaths>> GetGameInfoPlayerSoloK
public static async Task<List<GoldResponseModel>> GetGoldPricesFromJsonAsync(DateTime? dateTime, int count, int timeout = 300)
{
var dateString = dateTime != null ? $"{dateTime:yyyy-MM-dd'T'HH:mm:ss}" : string.Empty;
var url = $"{SettingsController.CurrentSettings.GoldStatsApiUrl ?? Settings.Default.GoldStatsApiUrlDefault}?date={dateString}&count={count}";

var url = Path.Combine(GetServerBaseUrlByCurrentServer(), "stats/Gold/");
url += $"?date={dateString}&count={count}";

using var clientHandler = new HttpClientHandler();
clientHandler.ServerCertificateCustomValidationCallback = (_, _, _, _) => true;
Expand Down Expand Up @@ -553,5 +557,15 @@ private static MarketResponse MergeMarketAndPortalPrices(List<MarketResponse> li

#endregion

private static string GetServerBaseUrlByCurrentServer()
{
return NetworkManager.AlbionServer switch
{
AlbionServer.West => SettingsController.CurrentSettings.AlbionDataProjectBaseUrlWest,
AlbionServer.East => SettingsController.CurrentSettings.AlbionDataProjectBaseUrlEast,
_ => SettingsController.CurrentSettings.AlbionDataProjectBaseUrlWest
};
}

#endregion
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,8 @@ public class SettingsObject
public bool IsOpenItemWindowInNewWindowChecked { get; set; } = true;
public bool IsInfoWindowShownOnStart { get; set; } = true;
public string SelectedAlertSound { get; set; }
public string CityPricesApiUrl { get; set; } = "https://www.albion-online-data.com/api/v2/stats/prices/";
public string CityPricesHistoryApiUrl { get; set; } = "https://www.albion-online-data.com/api/v2/stats/history/";
public string GoldStatsApiUrl { get; set; } = "https://www.albion-online-data.com/api/v2/stats/Gold";
public string AlbionDataProjectBaseUrlWest { get; set; } = "https://albion-online-data.com/api/v2/";
public string AlbionDataProjectBaseUrlEast { get; set; } = "https://east.albion-online-data.com/api/v2/";
public double MainWindowHeight { get; set; } = 100;
public double MainWindowWidth { get; set; } = 100;
public bool MainWindowMaximized { get; set; }
Expand Down
8 changes: 8 additions & 0 deletions src/StatisticsAnalysisTool/Enumerations/AlbionServer.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
namespace StatisticsAnalysisTool.Enumerations;

public enum AlbionServer
{
Unknown,
West,
East
}
3 changes: 2 additions & 1 deletion src/StatisticsAnalysisTool/Enumerations/TreasureType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@ public enum TreasureType
HellGate,
Corrupted,
StaticDungeon,
Avalon
Avalon,
Mist
}
6 changes: 6 additions & 0 deletions src/StatisticsAnalysisTool/Languages/de-DE.xml
Original file line number Diff line number Diff line change
Expand Up @@ -700,4 +700,10 @@
<translation name="RESOURCE_VALUE">Ressourcenwert</translation>
<translation name="TOTAL_MARKET_VALUE">Gesammter Marktwert</translation>
<translation name="NAVIGATION_TAB_VISIBILITY">Navigation Tab Sichtbarkeit</translation>
<translation name="SERVER">Server</translation>
<translation name="UNKNOWN_SERVER">Unbekannter Server</translation>
<translation name="WEST_SERVER">West Server</translation>
<translation name="EAST_SERVER">Ost Server</translation>
<translation name="ALBION_DATA_PROJECT_BASE_URL_WEST">Albion data project base url WEST</translation>
<translation name="ALBION_DATA_PROJECT_BASE_URL_EAST">Albion data project base url OST</translation>
</translations>
6 changes: 6 additions & 0 deletions src/StatisticsAnalysisTool/Languages/en-US.xml
Original file line number Diff line number Diff line change
Expand Up @@ -700,4 +700,10 @@
<translation name="RESOURCE_VALUE">Resource value</translation>
<translation name="TOTAL_MARKET_VALUE">Total market value</translation>
<translation name="NAVIGATION_TAB_VISIBILITY">Navigation tab visibility</translation>
<translation name="SERVER">Server</translation>
<translation name="UNKNOWN_SERVER">Unknown Server</translation>
<translation name="WEST_SERVER">West Server</translation>
<translation name="EAST_SERVER">East Server</translation>
<translation name="ALBION_DATA_PROJECT_BASE_URL_WEST">Albion data project base url WEST</translation>
<translation name="ALBION_DATA_PROJECT_BASE_URL_EAST">Albion data project base url EAST</translation>
</translations>
145 changes: 141 additions & 4 deletions src/StatisticsAnalysisTool/Models/LootedChests.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System.ComponentModel;
using System.Runtime.CompilerServices;
using StatisticsAnalysisTool.Common;
using StatisticsAnalysisTool.Common;
using StatisticsAnalysisTool.Properties;
using System.ComponentModel;
using System.Runtime.CompilerServices;

namespace StatisticsAnalysisTool.Models;

Expand Down Expand Up @@ -39,6 +39,14 @@ public class LootedChests : INotifyPropertyChanged
private int _hellGatesEpicMonth;
private int _hellGatesLegendaryWeek;
private int _hellGatesLegendaryMonth;
private int _mistCommonWeek;
private int _mistCommonMonth;
private int _mistUncommonWeek;
private int _mistUncommonMonth;
private int _mistEpicWeek;
private int _mistEpicMonth;
private int _mistLegendaryWeek;
private int _mistLegendaryMonth;
private int _outlandsCommonYear;
private int _outlandsUncommonYear;
private int _outlandsEpicYear;
Expand All @@ -55,6 +63,10 @@ public class LootedChests : INotifyPropertyChanged
private int _hellGatesUncommonYear;
private int _hellGatesEpicYear;
private int _hellGatesLegendaryYear;
private int _mistCommonYear;
private int _mistUncommonYear;
private int _mistEpicYear;
private int _mistLegendaryYear;
private int _randomSoloDungeonCommonWeek;
private int _randomSoloDungeonCommonMonth;
private int _randomSoloDungeonCommonYear;
Expand Down Expand Up @@ -437,7 +449,7 @@ public int RandomSoloDungeonLegendaryYear
OnPropertyChanged();
}
}

#endregion

#region Avalonian Road bindings
Expand Down Expand Up @@ -688,13 +700,138 @@ public int HellGateLegendaryYear

#endregion

#region Mist bindings

public int MistCommonWeek
{
get => _mistCommonWeek;
set
{
_mistCommonWeek = value;
OnPropertyChanged();
}
}

public int MistCommonMonth
{
get => _mistCommonMonth;
set
{
_mistCommonMonth = value;
OnPropertyChanged();
}
}

public int MistCommonYear
{
get => _mistCommonYear;
set
{
_mistCommonYear = value;
OnPropertyChanged();
}
}

public int MistUncommonWeek
{
get => _mistUncommonWeek;
set
{
_mistUncommonWeek = value;
OnPropertyChanged();
}
}

public int MistUncommonMonth
{
get => _mistUncommonMonth;
set
{
_mistUncommonMonth = value;
OnPropertyChanged();
}
}

public int MistUncommonYear
{
get => _mistUncommonYear;
set
{
_mistUncommonYear = value;
OnPropertyChanged();
}
}

public int MistEpicWeek
{
get => _mistEpicWeek;
set
{
_mistEpicWeek = value;
OnPropertyChanged();
}
}

public int MistEpicMonth
{
get => _mistEpicMonth;
set
{
_mistEpicMonth = value;
OnPropertyChanged();
}
}

public int MistEpicYear
{
get => _mistEpicYear;
set
{
_mistEpicYear = value;
OnPropertyChanged();
}
}

public int MistLegendaryWeek
{
get => _mistLegendaryWeek;
set
{
_mistLegendaryWeek = value;
OnPropertyChanged();
}
}

public int MistLegendaryMonth
{
get => _mistLegendaryMonth;
set
{
_mistLegendaryMonth = value;
OnPropertyChanged();
}
}

public int MistLegendaryYear
{
get => _mistLegendaryYear;
set
{
_mistLegendaryYear = value;
OnPropertyChanged();
}
}

#endregion

public static string TranslationLootedChests => LanguageController.Translation("LOOTED_CHESTS");
public static string TranslationOpenWorld => LanguageController.Translation("OPEN_WORLD");
public static string TranslationStaticDungeons => LanguageController.Translation("STATIC_DUNGEONS");
public static string TranslationAvalonianRoads => LanguageController.Translation("AVALONIAN_ROADS");
public static string TranslationRandomSoloDungeons => LanguageController.Translation("RANDOM_SOLO_DUNGEONS");
public static string TranslationRandomGroupDungeons => LanguageController.Translation("RANDOM_GROUP_DUNGEONS");
public static string TranslationHellGates => LanguageController.Translation("HELLGATES");
public static string TranslationMists => LanguageController.Translation("MISTS");
public static string TranslationLast7Days => LanguageController.Translation("LAST_7_DAYS");
public static string TranslationLast30Days => LanguageController.Translation("LAST_30_DAYS");
public static string TranslationLast365Days => LanguageController.Translation("LAST_365_DAYS");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ public class SettingsWindowTranslation
public static string OpenToolDirectory => LanguageController.Translation("OPEN_TOOL_DIRECTORY");
public static string OpenDebugConsole => LanguageController.Translation("OPEN_DEBUG_CONSOLE");
public static string CreateDesktopShortcut => LanguageController.Translation("CREATE_DESKTOP_SHORTCUT");
public static string CityPricesApiUrl => LanguageController.Translation("CITY_PRICES_API_URL");
public static string CityPricesHistoryApiUrl => LanguageController.Translation("CITY_PRICES_HISTORY_API_URL");
public static string AlbionDataProjectBaseUrlWest => LanguageController.Translation("ALBION_DATA_PROJECT_BASE_URL_WEST");
public static string AlbionDataProjectBaseUrlEast => LanguageController.Translation("ALBION_DATA_PROJECT_BASE_URL_EAST");
public static string GoldStatsApiUrl => LanguageController.Translation("GOLD_STATS_API_URL");
public static string IsLootLoggerSaveReminderActive => LanguageController.Translation("IS_LOOT_LOGGER_SAVE_REMINDER_ACTIVE");
public static string ExportLootLoggingFileWithRealItemName => LanguageController.Translation("EXPORT_LOOT_LOGGING_FILE_WITH_REAL_ITEM_NAME");
Expand Down
Loading

0 comments on commit 12e94df

Please sign in to comment.