From 3617af8c614273461cad064bcae507bc05b89761 Mon Sep 17 00:00:00 2001 From: Yanic Lemire Date: Fri, 3 Sep 2021 01:09:16 -0400 Subject: [PATCH] Fixed price checking organs Related to #6 --- src/Sidekick.Apis.Poe/Trade/Results/Hashes.cs | 3 ++ .../Trade/TradeSearchService.cs | 29 +++++++++++-------- .../Components/Items/ItemComponent.razor | 4 ++- .../Items/ItemLineContentsComponent.razor | 17 ++++++----- .../Components/Items/ItemProperties.razor | 27 +++++++++++++++++ .../Components/Items/ItemProperties.razor.css | 3 ++ .../Items/ItemRequirementsComponent.razor | 2 -- .../Parser/MetamorphParsing.cs | 28 +++++++++++++++++- 8 files changed, 90 insertions(+), 23 deletions(-) create mode 100644 src/Sidekick.Modules.Trade/Components/Items/ItemProperties.razor create mode 100644 src/Sidekick.Modules.Trade/Components/Items/ItemProperties.razor.css diff --git a/src/Sidekick.Apis.Poe/Trade/Results/Hashes.cs b/src/Sidekick.Apis.Poe/Trade/Results/Hashes.cs index ff2710b81..dd42c3748 100644 --- a/src/Sidekick.Apis.Poe/Trade/Results/Hashes.cs +++ b/src/Sidekick.Apis.Poe/Trade/Results/Hashes.cs @@ -23,5 +23,8 @@ public class Hashes [JsonPropertyName("fractured")] public List> Fractured { get; set; } + + [JsonPropertyName("monster")] + public List> Monster { get; set; } } } diff --git a/src/Sidekick.Apis.Poe/Trade/TradeSearchService.cs b/src/Sidekick.Apis.Poe/Trade/TradeSearchService.cs index 02de84de1..311c8c7c4 100644 --- a/src/Sidekick.Apis.Poe/Trade/TradeSearchService.cs +++ b/src/Sidekick.Apis.Poe/Trade/TradeSearchService.cs @@ -482,7 +482,7 @@ private TradeItem GetItem(Result result) item.Modifiers.Explicit, result.Item.ExplicitMods, result.Item.Extended.Mods?.Explicit, - ParseHash(result.Item.Extended.Hashes?.Explicit)); + ParseHash(result.Item.Extended.Hashes?.Explicit, result.Item.Extended.Hashes?.Monster)); ParseMods(modifierProvider, item.Modifiers.Implicit, @@ -505,25 +505,30 @@ private TradeItem GetItem(Result result) return item; } - private static List ParseHash(List> values) + private static List ParseHash(params List>[] hashes) { var result = new List(); - if (values != null) + + foreach (var values in hashes) { - foreach (var value in values) + if (values != null) { - if (value.Count != 2) + foreach (var value in values) { - continue; - } + if (value.Count != 2) + { + continue; + } - result.Add(new LineContentValue() - { - Value = value[0].GetString(), - Type = value[1].ValueKind == JsonValueKind.Array ? (LineContentType)value[1][0].GetInt32() : LineContentType.Simple - }); + result.Add(new LineContentValue() + { + Value = value[0].GetString(), + Type = value[1].ValueKind == JsonValueKind.Array ? (LineContentType)value[1][0].GetInt32() : LineContentType.Simple + }); + } } } + return result; } diff --git a/src/Sidekick.Modules.Trade/Components/Items/ItemComponent.razor b/src/Sidekick.Modules.Trade/Components/Items/ItemComponent.razor index 7097c2a40..a225f4404 100644 --- a/src/Sidekick.Modules.Trade/Components/Items/ItemComponent.razor +++ b/src/Sidekick.Modules.Trade/Components/Items/ItemComponent.razor @@ -19,8 +19,10 @@
- + + + - @foreach (var property in LineContents) - { - @((MarkupString)GetLine(property)) - } -
+@if (LineContents != null && LineContents.Count > 0) +{ +
+ @foreach (var property in LineContents) + { + @((MarkupString)GetLine(property)) + } +
- + +} @code { [Parameter] public Item Item { get; set; } diff --git a/src/Sidekick.Modules.Trade/Components/Items/ItemProperties.razor b/src/Sidekick.Modules.Trade/Components/Items/ItemProperties.razor new file mode 100644 index 000000000..84b87bdbe --- /dev/null +++ b/src/Sidekick.Modules.Trade/Components/Items/ItemProperties.razor @@ -0,0 +1,27 @@ + +@if (Item != null) +{ +
+ @if (Item.Properties.ItemLevel > 0) + { + @((MarkupString)GetLine(GameLanguageProvider.Language.DescriptionItemLevel, Item.Properties.ItemLevel)) + } +
+ + + @if (Item.RequirementContents != null || Item.Properties.ItemLevel > 0) + { + + } +} + +@code { + [Parameter] public TradeItem Item { get; set; } + + [Inject] public IGameLanguageProvider GameLanguageProvider { get; set; } + + private string GetLine(string label, object value) + { + return $"{label}: {value}"; + } +} diff --git a/src/Sidekick.Modules.Trade/Components/Items/ItemProperties.razor.css b/src/Sidekick.Modules.Trade/Components/Items/ItemProperties.razor.css new file mode 100644 index 000000000..4903278b1 --- /dev/null +++ b/src/Sidekick.Modules.Trade/Components/Items/ItemProperties.razor.css @@ -0,0 +1,3 @@ +.properties { + color: #7f7f7f; +} diff --git a/src/Sidekick.Modules.Trade/Components/Items/ItemRequirementsComponent.razor b/src/Sidekick.Modules.Trade/Components/Items/ItemRequirementsComponent.razor index a5f3e0e4f..da51c6d9e 100644 --- a/src/Sidekick.Modules.Trade/Components/Items/ItemRequirementsComponent.razor +++ b/src/Sidekick.Modules.Trade/Components/Items/ItemRequirementsComponent.razor @@ -3,8 +3,6 @@
@Resources.Requires @((MarkupString)Text)
- - } @code { diff --git a/tests/Sidekick.Apis.Poe.Tests/Parser/MetamorphParsing.cs b/tests/Sidekick.Apis.Poe.Tests/Parser/MetamorphParsing.cs index 1a49e60d1..61d63f53d 100644 --- a/tests/Sidekick.Apis.Poe.Tests/Parser/MetamorphParsing.cs +++ b/tests/Sidekick.Apis.Poe.Tests/Parser/MetamorphParsing.cs @@ -60,7 +60,7 @@ Combine this with four other different samples in Tane's Laboratory. [Fact] public void ParseOrgan() { - var actual = parser.ParseItem(@"Item Class: Metamorph Sample + var actual = parser.ParseItem(@"Item Class: Metamorph Samples Rarity: Unique Portentia, the Foul's Heart -------- @@ -81,5 +81,31 @@ Drops additional Rare Jewellery Assert.Equal("Portentia, the Foul", actual.Metadata.Type); } + [Fact] + public void Portentia() + { + var actual = parser.ParseItem(@"Item Class: Metamorph Samples +Rarity: Unique +Portentia, the Foul's Heart +-------- +Uses: Blood Bubble +-------- +Item Level: 79 +-------- +Drops additional Rare Jewellery +Drops additional Currency Items +Drops additional Currency Items +Drops additional Rare Weapons +Drops additional Rare Armour +-------- +Combine this with four other different samples in Tane's Laboratory."); + + Assert.Equal(Class.MetamorphSample, actual.Metadata.Class); + Assert.Equal(Category.ItemisedMonster, actual.Metadata.Category); + Assert.Equal(Rarity.Unique, actual.Metadata.Rarity); + Assert.Equal("Portentia, the Foul's Heart", actual.Metadata.Name); + Assert.Equal("Portentia, the Foul", actual.Metadata.Type); + } + } }