diff --git a/POEApi.Model.Tests/IFilterTests.cs b/POEApi.Model.Tests/IFilterTests.cs index 51fafef6..c705241d 100644 --- a/POEApi.Model.Tests/IFilterTests.cs +++ b/POEApi.Model.Tests/IFilterTests.cs @@ -68,5 +68,27 @@ public void AreDivineVesselsApplicable() Assert.IsTrue(filter.Applicable(vessel.First())); } } + + [TestMethod] + public void AreOfferingsApplicable() + { + string fakeStashInfo = Encoding.UTF8.GetString(Files.SampleStashWithDivineVessel); + filter = new OfferingFilter(); + + using (var stream = GenerateStreamFromString(fakeStashInfo)) + { + _mockTransport.Setup(m => m.GetStash(0, "", "", false)).Returns(stream); + + var stash = _model.GetStash(0, "", ""); + + Assert.IsNotNull(stash); + + var offerings = stash.GetItemsByTab(1).Where(x => x is Offering); + + Assert.AreEqual(3, offerings.Count()); + + Assert.IsTrue(offerings.All(filter.Applicable)); + } + } } } \ No newline at end of file diff --git a/POEApi.Model/ItemFactory.cs b/POEApi.Model/ItemFactory.cs index 07c2c172..2e2703be 100644 --- a/POEApi.Model/ItemFactory.cs +++ b/POEApi.Model/ItemFactory.cs @@ -31,8 +31,15 @@ public static Item Get(JSONProxy.Item item) if (item.TypeLine.Contains("Map") && item.DescrText != null && item.DescrText.Contains("Travel to this Map")) return new Map(item); - if (item.FrameType == 0 && item.TypeLine == "Divine Vessel") - return new DivineVessel(item); + if (item.FrameType == 0) + { + if (item.TypeLine == "Divine Vessel") + return new DivineVessel(item); + + if(item.TypeLine == "Offering to the Goddess") + return new Offering(item); + } + return new Gear(item); } diff --git a/POEApi.Model/Offering.cs b/POEApi.Model/Offering.cs new file mode 100644 index 00000000..1712971f --- /dev/null +++ b/POEApi.Model/Offering.cs @@ -0,0 +1,10 @@ +namespace POEApi.Model +{ + public class Offering : Item + { + public Offering(JSONProxy.Item item) : base(item) + { + + } + } +} \ No newline at end of file diff --git a/POEApi.Model/POEApi.Model.csproj b/POEApi.Model/POEApi.Model.csproj index d4ae8329..e1d194fa 100644 --- a/POEApi.Model/POEApi.Model.csproj +++ b/POEApi.Model/POEApi.Model.csproj @@ -76,6 +76,7 @@ + diff --git a/Procurement/ForumExportTemplate.txt b/Procurement/ForumExportTemplate.txt index 0e26dda3..9749e2f8 100644 --- a/Procurement/ForumExportTemplate.txt +++ b/Procurement/ForumExportTemplate.txt @@ -159,6 +159,10 @@ Please message me here or ingame if something catches your eye. My IGN is {IGN}. {DivineVessel} [/spoiler] +[spoiler="          Offering of the Goddess          "] +{Offering} +[/spoiler] + Thanks for visiting! [url=https://github.com/Stickymaddness/Procurement/][img]http://i.imgur.com/ZHBMImo.png[/img][/url] diff --git a/Procurement/Procurement.csproj b/Procurement/Procurement.csproj index 3343b2bd..01f915ad 100644 --- a/Procurement/Procurement.csproj +++ b/Procurement/Procurement.csproj @@ -180,6 +180,7 @@ + diff --git a/Procurement/ViewModel/Filters/ForumExport/DivineVesselFilter.cs b/Procurement/ViewModel/Filters/ForumExport/DivineVesselFilter.cs index 0036c5a5..2a8cc15e 100644 --- a/Procurement/ViewModel/Filters/ForumExport/DivineVesselFilter.cs +++ b/Procurement/ViewModel/Filters/ForumExport/DivineVesselFilter.cs @@ -13,4 +13,17 @@ public bool Applicable(Item item) return item is DivineVessel; } } + + public class OfferingFilter : IFilter + { + public bool CanFormCategory { get; } = true; + public string Keyword { get; } = "Offering to the Goddess"; + public string Help { get; } = "Offering to the Goddesses"; + public FilterGroup Group { get; } + public bool Applicable(Item item) + { + return item is Offering; + } + } + } \ No newline at end of file diff --git a/Procurement/ViewModel/ForumExportVisitors/OfferingVisitor.cs b/Procurement/ViewModel/ForumExportVisitors/OfferingVisitor.cs new file mode 100644 index 00000000..3e43bdab --- /dev/null +++ b/Procurement/ViewModel/ForumExportVisitors/OfferingVisitor.cs @@ -0,0 +1,17 @@ +using System.Collections.Generic; +using System.Linq; +using POEApi.Model; +using Procurement.ViewModel.Filters.ForumExport; + +namespace Procurement.ViewModel.ForumExportVisitors +{ + internal class OfferingVisitor : VisitorBase + { + private const string TOKEN = "{Offering}"; + + public override string Visit(IEnumerable items, string current) + { + return current.Replace(TOKEN, runFilter(items.OrderBy(i => i.TypeLine))); + } + } +} \ No newline at end of file diff --git a/Procurement/ViewModel/ItemHoverViewModelFactory.cs b/Procurement/ViewModel/ItemHoverViewModelFactory.cs index b2b3c641..61d0b7a3 100644 --- a/Procurement/ViewModel/ItemHoverViewModelFactory.cs +++ b/Procurement/ViewModel/ItemHoverViewModelFactory.cs @@ -28,6 +28,10 @@ internal static ItemHoverViewModel Create(Item item) if(vessel != null) r = Rarity.Normal; + var offering = item as Offering; + if (offering != null) + r = Rarity.Normal; + if (r != null) { switch (r)