Skip to content

Commit

Permalink
Fixed price checking organs
Browse files Browse the repository at this point in the history
Related to #6
  • Loading branch information
leMicin committed Sep 3, 2021
1 parent b19c1e8 commit 3617af8
Show file tree
Hide file tree
Showing 8 changed files with 90 additions and 23 deletions.
3 changes: 3 additions & 0 deletions src/Sidekick.Apis.Poe/Trade/Results/Hashes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,8 @@ public class Hashes

[JsonPropertyName("fractured")]
public List<List<JsonElement>> Fractured { get; set; }

[JsonPropertyName("monster")]
public List<List<JsonElement>> Monster { get; set; }
}
}
29 changes: 17 additions & 12 deletions src/Sidekick.Apis.Poe/Trade/TradeSearchService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -505,25 +505,30 @@ private TradeItem GetItem(Result result)
return item;
}

private static List<LineContentValue> ParseHash(List<List<JsonElement>> values)
private static List<LineContentValue> ParseHash(params List<List<JsonElement>>[] hashes)
{
var result = new List<LineContentValue>();
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;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@

<div class="pa-2">
<ItemLineContentsComponent Item="Item" LineContents="Item.PropertyContents" />
<ItemRequirementsComponent Item="Item" />
<ItemLineContentsComponent Item="Item" LineContents="Item.AdditionalPropertyContents" />

<ItemProperties Item="Item" />

<ItemModifiersComponent Item="Item"
Modifiers="Item.Modifiers.Enchant" />
<ItemModifiersComponent Item="Item"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@

<div class="line-contents">
@foreach (var property in LineContents)
{
<MudText Typo="Typo.body1" Class="font-smallcaps" Align="Align.Center">@((MarkupString)GetLine(property))</MudText>
}
</div>
@if (LineContents != null && LineContents.Count > 0)
{
<div class="line-contents">
@foreach (var property in LineContents)
{
<MudText Typo="Typo.body1" Class="font-smallcaps" Align="Align.Center">@((MarkupString)GetLine(property))</MudText>
}
</div>

<ItemSeparatorComponent Item="Item" />
<ItemSeparatorComponent Item="Item" />
}

@code {
[Parameter] public Item Item { get; set; }
Expand Down
27 changes: 27 additions & 0 deletions src/Sidekick.Modules.Trade/Components/Items/ItemProperties.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@

@if (Item != null)
{
<div class="properties">
@if (Item.Properties.ItemLevel > 0)
{
<MudText Typo="Typo.body1" Class="font-smallcaps" Align="Align.Center">@((MarkupString)GetLine(GameLanguageProvider.Language.DescriptionItemLevel, Item.Properties.ItemLevel))</MudText>
}
</div>
<ItemRequirementsComponent Item="Item" />

@if (Item.RequirementContents != null || Item.Properties.ItemLevel > 0)
{
<ItemSeparatorComponent Item="Item" />
}
}

@code {
[Parameter] public TradeItem Item { get; set; }

[Inject] public IGameLanguageProvider GameLanguageProvider { get; set; }

private string GetLine(string label, object value)
{
return $"{label}: <span style=\"color:#FFFFFF;\">{value}</span>";
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.properties {
color: #7f7f7f;
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
<div class="requirements font-smallcaps">
<MudText Typo="Typo.body1" Class="font-smallcaps" Align="Align.Center">@Resources.Requires @((MarkupString)Text)</MudText>
</div>

<ItemSeparatorComponent Item="Item" />
}

@code {
Expand Down
28 changes: 27 additions & 1 deletion tests/Sidekick.Apis.Poe.Tests/Parser/MetamorphParsing.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
--------
Expand All @@ -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);
}

}
}

0 comments on commit 3617af8

Please sign in to comment.