Skip to content

Commit

Permalink
Added Offering to the Goddess Support
Browse files Browse the repository at this point in the history
  • Loading branch information
aydjay committed Sep 15, 2017
1 parent 15c3403 commit 5d585a2
Show file tree
Hide file tree
Showing 9 changed files with 81 additions and 2 deletions.
22 changes: 22 additions & 0 deletions POEApi.Model.Tests/IFilterTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
}
}
}
11 changes: 9 additions & 2 deletions POEApi.Model/ItemFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
10 changes: 10 additions & 0 deletions POEApi.Model/Offering.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
namespace POEApi.Model
{
public class Offering : Item
{
public Offering(JSONProxy.Item item) : base(item)
{

}
}
}
1 change: 1 addition & 0 deletions POEApi.Model/POEApi.Model.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@
<Compile Include="JSONProxy\Stash.cs" />
<Compile Include="Leaguestone.cs" />
<Compile Include="Map.cs" />
<Compile Include="Offering.cs" />
<Compile Include="OrbType.cs" />
<Compile Include="Events\POEEventArgs.cs" />
<Compile Include="Events\POEEventState.cs" />
Expand Down
4 changes: 4 additions & 0 deletions Procurement/ForumExportTemplate.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
1 change: 1 addition & 0 deletions Procurement/Procurement.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@
<Compile Include="ViewModel\ForumExportVisitors\CurrencyVisitor.cs" />
<Compile Include="ViewModel\ForumExportVisitors\DivineVesselVisitor.cs" />
<Compile Include="ViewModel\ForumExportVisitors\EssenceVisitor.cs" />
<Compile Include="ViewModel\ForumExportVisitors\OfferingVisitor.cs" />
<Compile Include="ViewModel\ForumExportVisitors\ProphecyVisitor.cs" />
<Compile Include="ViewModel\Recipes\MatchedSet.cs" />
<Compile Include="ViewModel\SetTabBuyoutViewModel.cs" />
Expand Down
13 changes: 13 additions & 0 deletions Procurement/ViewModel/Filters/ForumExport/DivineVesselFilter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

}
17 changes: 17 additions & 0 deletions Procurement/ViewModel/ForumExportVisitors/OfferingVisitor.cs
Original file line number Diff line number Diff line change
@@ -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<Item> items, string current)
{
return current.Replace(TOKEN, runFilter<OfferingFilter>(items.OrderBy(i => i.TypeLine)));
}
}
}
4 changes: 4 additions & 0 deletions Procurement/ViewModel/ItemHoverViewModelFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 5d585a2

Please sign in to comment.