Skip to content

Commit 5616719

Browse files
authored
Merge pull request #853 from Sidekick-Poe/feature/ninja-exchange
Overhauled Poe.Ninja integration in Sidekick
2 parents c7fc9ba + 968a3ed commit 5616719

File tree

85 files changed

+1852
-1019
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

85 files changed

+1852
-1019
lines changed

data/poe1.ninja.items.json

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.

data/poe2.ninja.items.json

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.

src/Sidekick.Apis.Poe.Trade/Items/ApiItemProvider.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,10 +91,11 @@ private void FillCategoryItems(List<ApiCategory> categories, string categoryId,
9191
information.InvariantText = apiData?.Text;
9292
information.Image = apiData?.Image;
9393

94-
if (string.IsNullOrEmpty(information.InvariantText) && gameLanguageProvider.IsEnglish())
94+
if (gameLanguageProvider.IsEnglish())
9595
{
9696
information.InvariantName = entry.Name;
97-
information.InvariantText = entry.Text;
97+
information.InvariantType = entry.Type;
98+
if (string.IsNullOrEmpty(information.InvariantText)) information.InvariantText = entry.Text;
9899
}
99100

100101
if (!string.IsNullOrEmpty(information.Name))

src/Sidekick.Apis.Poe.Trade/Models/Items/ApiItem.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ public int? MaxLinks
124124
}
125125

126126
[JsonIgnore]
127-
public int? GemLevel => GetPropertyValue("Level", 16);
127+
public int? GemLevel => GetPropertyValue("Level", 1);
128128

129129
[JsonIgnore]
130130
public int? MapTier => GetPropertyValue("Map Tier", 16);

src/Sidekick.Apis.Poe.Trade/Parser/Properties/Definitions/ClusterJewelPassiveCountProperty.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,7 @@ public override void ParseAfterModifiers(Item item)
2121
}
2222

2323
var grant = ParseGrantTexts(item.Modifiers);
24-
if (grant == null)
25-
{
26-
item.Properties.ClusterJewelGrantText = grant;
27-
}
24+
if (grant != null) item.Properties.ClusterJewelGrantText = grant;
2825
}
2926

3027
private int ParseSmallPassiveCount(List<Modifier> modifierLines)

src/Sidekick.Apis.Poe.Trade/Static/ApiStaticDataProvider.cs

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using Sidekick.Apis.Poe.Items;
33
using Sidekick.Apis.Poe.Languages;
44
using Sidekick.Apis.Poe.Trade.Clients;
5+
using Sidekick.Apis.Poe.Trade.Clients.Models;
56
using Sidekick.Apis.Poe.Trade.Static.Models;
67
using Sidekick.Common.Cache;
78
using Sidekick.Common.Enums;
@@ -28,25 +29,18 @@ ISettingsService settingsService
2829
public async Task Initialize()
2930
{
3031
var game = await settingsService.GetGame();
31-
var cacheKey = $"{game.GetValueAttribute()}_StaticData";
32+
await InitializeText(game);
33+
await InitializeInvariant(game);
34+
}
3235

36+
private async Task InitializeText(GameType game)
37+
{
38+
var cacheKey = $"{game.GetValueAttribute()}_StaticData";
3339
var result = await cacheProvider.GetOrSet(cacheKey, () => tradeApiClient.FetchData<StaticItemCategory>(game, gameLanguageProvider.Language, "static"), (cache) => cache.Result.Any());
3440
if (result == null) throw new SidekickException("Could not fetch data from the trade API.");
3541

3642
TextDictionary.Clear();
37-
InvariantDictionary.Clear();
38-
foreach (var category in result.Result)
39-
{
40-
foreach (var entry in category.Entries)
41-
{
42-
if (entry.Id == null! || entry.Text == null || entry.Id == "sep") continue;
43-
44-
entry.Image = $"https://web.poecdn.com{entry.Image}";
45-
TextDictionary.TryAdd(entry.Text, entry);
46-
}
47-
}
48-
49-
await InitializeInvariant(game);
43+
FillDictionary(TextDictionary, result, x => x.Text);
5044
}
5145

5246
private async Task InitializeInvariant(GameType game)
@@ -55,14 +49,21 @@ private async Task InitializeInvariant(GameType game)
5549
var result = await cacheProvider.GetOrSet(cacheKey, () => tradeApiClient.FetchData<StaticItemCategory>(game, gameLanguageProvider.InvariantLanguage, "static"), (cache) => cache.Result.Any());
5650
if (result == null) throw new SidekickException("Could not fetch invariant data from the trade API.");
5751

52+
InvariantDictionary.Clear();
53+
FillDictionary(InvariantDictionary, result, x => x.Id);
54+
}
55+
56+
private void FillDictionary(Dictionary<string, StaticItem> dictionary, FetchResult<StaticItemCategory> result, Func<StaticItem, string?> keyFunc)
57+
{
5858
foreach (var category in result.Result)
5959
{
6060
foreach (var entry in category.Entries)
6161
{
62-
if (entry.Id == null! || entry.Text == null || entry.Id == "sep") continue;
62+
var key = keyFunc(entry);
63+
if (key == null || entry.Id == null! || entry.Text == null || entry.Id == "sep") continue;
6364

6465
entry.Image = $"https://web.poecdn.com{entry.Image}";
65-
InvariantDictionary.TryAdd(entry.Id, entry);
66+
dictionary.TryAdd(key, entry);
6667
}
6768
}
6869
}

src/Sidekick.Apis.Poe/Items/ItemApiInformation.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ public class ItemApiInformation
1010

1111
public string? InvariantName { get; set; }
1212

13+
public string? InvariantType { get; set; }
14+
1315
public string? Image { get; set; }
1416

1517
public string? Name { get; set; }

src/Sidekick.Apis.Poe2Scout/Items/ScoutItemProvider.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using Sidekick.Apis.Poe.Extensions;
2+
using Sidekick.Apis.Poe.Items;
23
using Sidekick.Apis.Poe2Scout.Categories;
34
using Sidekick.Apis.Poe2Scout.Categories.Models;
45
using Sidekick.Apis.Poe2Scout.Clients;
@@ -19,6 +20,9 @@ public class ScoutItemProvider(
1920

2021
public async Task<ScoutItem?> GetItem(string? text)
2122
{
23+
var game = await settingsService.GetGame();
24+
if (game == GameType.PathOfExile) return null;
25+
2226
if (string.IsNullOrEmpty(text)) return null;
2327

2428
var items = await GetOrFetchItems();

src/Sidekick.Apis.PoeNinja/Api/ItemType.cs

Lines changed: 0 additions & 96 deletions
This file was deleted.

src/Sidekick.Apis.PoeNinja/Api/PoeNinjaCacheItem.cs

Lines changed: 0 additions & 8 deletions
This file was deleted.

0 commit comments

Comments
 (0)