Skip to content

Commit

Permalink
Merge pull request #618 from 5c0r/fix/metamorph_parsing
Browse files Browse the repository at this point in the history
Fix parsing Metamorph Sample and Captured Beast
  • Loading branch information
leMicin authored May 5, 2021
2 parents 556afb0 + 875ff62 commit 72bdc45
Show file tree
Hide file tree
Showing 5 changed files with 80 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,13 @@ public ItemMetadata Parse(ParsingItem parsingItem)
{
result.Rarity = itemRarity;
}

if (result.Category == Category.ItemisedMonster && result.Rarity == Rarity.Unique && string.IsNullOrEmpty(result.Name))
{
result.Name = name;
}


}

return result;
Expand Down
13 changes: 12 additions & 1 deletion src/Sidekick.Infrastructure/PoeApi/Trade/TradeSearchService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,18 @@ public async Task<TradeSearchResult<string>> Search(Item item, PropertyFilters p
};
}

if (item.Metadata.Rarity == Rarity.Unique)
if (item.Metadata.Category == Category.ItemisedMonster)
{
if (!string.IsNullOrEmpty(item.Metadata.Name))
{
request.Query.Term = item.Metadata.Name;
}
else if (!string.IsNullOrEmpty(item.Metadata.Type))
{
request.Query.Type = item.Metadata.Type;
}
}
else if (item.Metadata.Rarity == Rarity.Unique)
{
request.Query.Name = item.Metadata.Name;
request.Query.Type = item.Metadata.Type;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ public async Task<NinjaPrice> Handle(GetPriceFromNinjaQuery request, Cancellatio
case Category.Jewel: fetchItems.Add(poeNinjaClient.FetchItems(ItemType.UniqueJewel)); break;
case Category.Map: fetchItems.Add(poeNinjaClient.FetchItems(ItemType.UniqueMap)); break;
case Category.Weapon: fetchItems.Add(poeNinjaClient.FetchItems(ItemType.UniqueWeapon)); break;
case Category.ItemisedMonster: fetchItems.Add(poeNinjaClient.FetchItems(ItemType.Beast)); break;
}
}
else
Expand Down
4 changes: 3 additions & 1 deletion src/Sidekick.Persistence/Apis/PoeNinja/PoeNinjaRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,16 @@ public async Task<NinjaPrice> Find(Item item)
using var dbContext = new SidekickContext(options);

var name = item.Original.Name;
var type = item.Original.Type;

var translation = await dbContext.NinjaTranslations.FirstOrDefaultAsync(x => x.Translation == name);
if (translation != null)
{
name = translation.English;
}

var query = dbContext.NinjaPrices
.Where(x => x.Name == name);
.Where(x => x.Name == name || x.Name == type);

if (item.Properties != null)
{
Expand Down
59 changes: 57 additions & 2 deletions tests/Sidekick.Application.Tests/Game/Items/Parser/MiscParsing.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,32 @@ public async Task ParseOrgan()

Assert.Equal(Category.ItemisedMonster, actual.Metadata.Category);
Assert.Equal(Rarity.Unique, actual.Metadata.Rarity);
Assert.Null(actual.Metadata.Name);
Assert.Equal("Portentia, the Foul's Heart", actual.Metadata.Name);
Assert.Equal("Portentia, the Foul", actual.Metadata.Type);
}

[Fact]
public async Task ParseRareBeast()
{
var parsedRareBeast = await mediator.Send(new ParseItemCommand(RareBeast));

Assert.Equal(Category.ItemisedMonster, parsedRareBeast.Metadata.Category);
Assert.Equal(Rarity.Rare, parsedRareBeast.Metadata.Rarity);
Assert.Null(parsedRareBeast.Metadata.Name);
Assert.Equal("Farric Tiger Alpha", parsedRareBeast.Metadata.Type);
}

[Fact]
public async Task ParseUniqueBeast()
{
var parsedRareBeast = await mediator.Send(new ParseItemCommand(UniqueBeast));

Assert.Equal(Category.ItemisedMonster, parsedRareBeast.Metadata.Category);
Assert.Equal(Rarity.Unique, parsedRareBeast.Metadata.Rarity);
Assert.Equal("Saqawal, First of the Sky", parsedRareBeast.Metadata.Name);
Assert.Equal("Saqawal, First of the Sky", parsedRareBeast.Metadata.Type);
}

#region ItemText

private const string Prophecy = @"Item Class: Unknown
Expand All @@ -74,7 +96,7 @@ Randomises the numeric values of the random modifiers on an item
Shift click to unstack.
";

private const string Organ = @"Item Class: Unknown
private const string Organ = @"Item Class: Metamorph Sample
Rarity: Unique
Portentia, the Foul's Heart
--------
Expand All @@ -88,6 +110,39 @@ Drops additional Rare Armour
Drops additional Rare Jewellery
--------
Combine this with four other different samples in Tane's Laboratory.";

private const string RareBeast = @"Item Class: Stackable Currency
Rarity: Rare
Foulface the Ravager
Farric Tiger Alpha
--------
Genus: Tigers
Group: Felines
Family: The Wilds
--------
Item Level: 82
--------
Tiger Prey
Spectral Swipe
Accurate
Evasive
Gains Endurance Charges
--------
Right-click to add this to your bestiary.";

private const string UniqueBeast = @"Item Class: Stackable Currency
Rarity: Unique
Saqawal, First of the Sky
--------
Genus: Rhexes
Group: Avians
Family: The Sands
--------
Item Level: 70
--------
Cannot be fully Slowed
--------
Right-click to add this to your bestiary.";
#endregion
}
}

0 comments on commit 72bdc45

Please sign in to comment.