Skip to content

Commit

Permalink
Add support for fractured mods
Browse files Browse the repository at this point in the history
- Add fractured mods support
- Add fractured item test
- Update api test data
- Update test for map with curse
  • Loading branch information
domialex committed Sep 19, 2020
1 parent c496b4e commit 52991fc
Show file tree
Hide file tree
Showing 13 changed files with 82 additions and 8 deletions.
1 change: 1 addition & 0 deletions src/Sidekick.Business/Apis/Poe/Models/Modifiers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@ public class Modifiers
public List<Modifier> Crafted { get; set; } = new List<Modifier>();
public List<Modifier> Enchant { get; set; } = new List<Modifier>();
public List<Modifier> Pseudo { get; set; } = new List<Modifier>();
public List<Modifier> Fractured { get; set; } = new List<Modifier>();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ public StatDataService(IPoeTradeClient poeApiClient,

private List<StatData> VeiledPatterns { get; set; }

private List<StatData> FracturedPatterns { get; set; }

private Regex NewLinePattern { get; set; }
private Regex IncreasedPattern { get; set; }

Expand All @@ -53,6 +55,7 @@ public async Task OnInit()
EnchantPatterns = new List<StatData>();
CraftedPatterns = new List<StatData>();
VeiledPatterns = new List<StatData>();
FracturedPatterns = new List<StatData>();

NewLinePattern = new Regex("(?:\\\\)*[\\r\\n]+");
IncreasedPattern = new Regex(languageProvider.Language.ModifierIncreased);
Expand Down Expand Up @@ -83,6 +86,7 @@ public async Task OnInit()
case "enchant": suffix = "(?:\\ \\(enchant\\)\\n|(?<!(?:\\n.*){2,})$)"; patterns = EnchantPatterns; break;
case "crafted": suffix = "(?:\\ \\(crafted\\)\\n|(?<!(?:\\n.*){2,})$)"; patterns = CraftedPatterns; break;
case "veiled": suffix = "(?:\\ \\(veiled\\)\\n|(?<!(?:\\n.*){2,})$)"; patterns = VeiledPatterns; break;
case "fractured": suffix = "(?:\\ \\(fractured\\)\\n|(?<!(?:\\n.*){2,})$)"; patterns = FracturedPatterns; break;
}

foreach (var entry in category.Entries)
Expand Down Expand Up @@ -159,7 +163,8 @@ public Modifiers ParseMods(string text)
FillMods(mods.Implicit, ImplicitPatterns, text);
FillMods(mods.Enchant, EnchantPatterns, text);
FillMods(mods.Crafted, CraftedPatterns, text);
// FillMods(mods.Veiled, VeiledPatterns, text);
//FillMods(mods.Veiled, VeiledPatterns, text);
FillMods(mods.Fractured, FracturedPatterns, text);

FillPseudo(mods.Pseudo, mods.Explicit);
FillPseudo(mods.Pseudo, mods.Implicit);
Expand Down Expand Up @@ -302,6 +307,12 @@ public StatData GetById(string id)
return result;
}

result = FracturedPatterns.FirstOrDefault(x => x.Id == id);
if (result != null)
{
return result;
}

return null;
}
}
Expand Down
5 changes: 5 additions & 0 deletions src/Sidekick.Business/Apis/Poe/Trade/Search/Results/Hashes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ public class Hashes
[JsonIgnore]
public List<LineContentValue> Pseudo => Parse(ApiPseudo);

[JsonPropertyName("fractured")]
public List<List<JsonElement>> ApiFractured { get; set; }
[JsonIgnore]
public List<LineContentValue> Fractured => Parse(ApiFractured);

private List<LineContentValue> Parse(List<List<JsonElement>> values)
{
var result = new List<LineContentValue>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ public class Mods
public List<Mod> Explicit { get; set; } = new List<Mod>();
public List<Mod> Crafted { get; set; } = new List<Mod>();
public List<Mod> Enchant { get; set; } = new List<Mod>();
public List<Mod> Fractured { get; set; } = new List<Mod>();

[JsonIgnore]
public List<Mod> Pseudo { get; set; } = new List<Mod>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ public class ResultItem

public bool Corrupted { get; set; }

public bool Fractured { get; set; }

public Influences Influences { get; set; } = new Influences();

public bool Verified { get; set; }
Expand Down Expand Up @@ -58,6 +60,9 @@ public class ResultItem
[JsonPropertyName("enchantMods")]
public List<string> EnchantMods { get; set; }

[JsonPropertyName("fracturedMods")]
public List<string> FracturedMods { get; set; }

public List<Socket> Sockets { get; set; } = new List<Socket>();

public Extended Extended { get; set; } = new Extended();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,12 @@ public TradeItem(Result result, IStatDataService statDataService)
result.Item.PseudoMods,
result.Item.Extended.Mods?.Pseudo,
result.Item.Extended.Hashes?.Pseudo);

ParseMods(statDataService,
Modifiers.Fractured,
result.Item.FracturedMods,
result.Item.Extended.Mods?.Fractured,
result.Item.Extended.Hashes?.Fractured);
}

private void ParseMods(IStatDataService statDataService, List<Modifier> modifiers, List<string> texts, List<Mod> mods, List<LineContentValue> hashes)
Expand Down
6 changes: 3 additions & 3 deletions src/Sidekick/Sidekick.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
<UseWPF>true</UseWPF>
<UseWindowsForms>true</UseWindowsForms>
<ApplicationIcon>Resources\ExaltedOrb.ico</ApplicationIcon>
<AssemblyVersion>1.0.2.0</AssemblyVersion>
<FileVersion>1.0.2.0</FileVersion>
<Version>1.0.2</Version>
<AssemblyVersion>1.0.3.0</AssemblyVersion>
<FileVersion>1.0.3.0</FileVersion>
<Version>1.0.3</Version>
<ApplicationManifest>app.manifest</ApplicationManifest>
<Description>A Path of Exile helper that shows item prices using the official Path of Exile Trade API.</Description>
<PackageProjectUrl>https://github.com/domialex/Sidekick</PackageProjectUrl>
Expand Down
8 changes: 8 additions & 0 deletions src/Sidekick/Views/Prices/ItemPreview.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,14 @@
</ItemsControl.ItemTemplate>
</ItemsControl>

<ItemsControl ItemsSource="{Binding Path=ViewModel.PreviewItem.Item.Modifiers.Fractured}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<local:ItemMod Modifier="{Binding}" />
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>

<Border
Margin="0,2,0,5"
BorderBrush="Gray"
Expand Down
1 change: 1 addition & 0 deletions src/Sidekick/Views/Prices/PriceViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,7 @@ private void InitializeFilters()
InitializeMods(Item.Modifiers.Implicit);
InitializeMods(Item.Modifiers.Explicit);
InitializeMods(Item.Modifiers.Crafted);
InitializeMods(Item.Modifiers.Fractured);

if (Filters.Count == 0)
{
Expand Down
36 changes: 36 additions & 0 deletions tests/Sidekick.Business.Tests/ItemParserTests/EquipmentParsing.cs
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,24 @@ public async Task ParseMagicWeapon()
.Should().Contain(expectedExplicits);
}

[Test]
public async Task ParseFracturedItem()
{
var actual = await Subject.ParseItem(FracturedItem);

actual.Type.Should().Be("Iron Greaves");
actual.Rarity.Should().Be(Apis.Poe.Models.Rarity.Rare);

var expectedFractured = new[]
{
"10% increased Movement Speed"
};

actual.Modifiers.Fractured
.Select(mod => mod.Text)
.Should().Contain(expectedFractured);
}

#region ItemText

private const string UniqueSixLink = @"Rarity: Unique
Expand Down Expand Up @@ -299,6 +317,24 @@ Two Handed Axe
Item Level: 50
--------
11% reduced Enemy Stun Threshold
";

private const string FracturedItem = @"Rarity: Rare
Invasion Track
Iron Greaves
--------
Armour: 6
--------
Sockets: B B
--------
Item Level: 2
--------
10% increased Movement Speed (fractured)
+5 to maximum Life
Regenerate 1.9 Life per second
+8% to Cold Resistance
--------
Fractured Item
";

#endregion
Expand Down
4 changes: 2 additions & 2 deletions tests/Sidekick.Business.Tests/ItemParserTests/MapParsing.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public async Task ParseOccupiedMap()

var expectedExplicits = new[]
{
"Players are Cursed with Enfeeble"
"Players are Cursed with Enfeeble, with 60% increased Effect"
};

actual.Type.Should().Be("Carcass Map");
Expand Down Expand Up @@ -190,7 +190,7 @@ Carcass Map
Area is influenced by The Elder (implicit)
Map is occupied by The Purifier (implicit)
--------
Players are Cursed with Enfeeble
Players are Cursed with Enfeeble, with 60% increased Effect
Monsters have 70% chance to Avoid Elemental Ailments
Monsters fire 2 additional Projectiles
Monsters' skills Chain 2 additional times
Expand Down

Large diffs are not rendered by default.

Large diffs are not rendered by default.

0 comments on commit 52991fc

Please sign in to comment.