Block matching basics complete
This commit is contained in:
parent
014107c76b
commit
89e98fc8c6
|
@ -7,6 +7,7 @@ using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Filtration.ItemFilterPreview.Model;
|
using Filtration.ItemFilterPreview.Model;
|
||||||
using Filtration.ItemFilterPreview.Services;
|
using Filtration.ItemFilterPreview.Services;
|
||||||
|
using Filtration.ObjectModel;
|
||||||
using Filtration.ObjectModel.BlockItemTypes;
|
using Filtration.ObjectModel.BlockItemTypes;
|
||||||
using Filtration.ObjectModel.Enums;
|
using Filtration.ObjectModel.Enums;
|
||||||
using Moq;
|
using Moq;
|
||||||
|
@ -110,6 +111,314 @@ namespace Filtration.ItemFilterPreview.Tests.Services
|
||||||
Assert.AreEqual(expectedResult, result);
|
Assert.AreEqual(expectedResult, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[TestCase(FilterPredicateOperator.Equal, 1, false)]
|
||||||
|
[TestCase(FilterPredicateOperator.Equal, 2, true)]
|
||||||
|
[TestCase(FilterPredicateOperator.Equal, 3, false)]
|
||||||
|
[TestCase(FilterPredicateOperator.GreaterThan, 1, true)]
|
||||||
|
[TestCase(FilterPredicateOperator.GreaterThan, 2, false)]
|
||||||
|
[TestCase(FilterPredicateOperator.GreaterThan, 3, false)]
|
||||||
|
[TestCase(FilterPredicateOperator.GreaterThanOrEqual, 1, true)]
|
||||||
|
[TestCase(FilterPredicateOperator.GreaterThanOrEqual, 2, true)]
|
||||||
|
[TestCase(FilterPredicateOperator.GreaterThanOrEqual, 3, false)]
|
||||||
|
[TestCase(FilterPredicateOperator.LessThan, 1, false)]
|
||||||
|
[TestCase(FilterPredicateOperator.LessThan, 2, false)]
|
||||||
|
[TestCase(FilterPredicateOperator.LessThan, 3, true)]
|
||||||
|
[TestCase(FilterPredicateOperator.LessThanOrEqual, 1, false)]
|
||||||
|
[TestCase(FilterPredicateOperator.LessThanOrEqual, 2, true)]
|
||||||
|
[TestCase(FilterPredicateOperator.LessThanOrEqual, 3, true)]
|
||||||
|
[TestCase(-1, 3, false)]
|
||||||
|
public void HeightBlockItemMatch_ReturnsCorrectResult(FilterPredicateOperator testInputFilterPredicateOperator, int testInputBlockItemHeight, bool expectedResult)
|
||||||
|
{
|
||||||
|
//Arrange
|
||||||
|
var testInputItem = Mock.Of<IItem>(i => i.Height == 2);
|
||||||
|
var testInputBlockItem = new HeightBlockItem(testInputFilterPredicateOperator, testInputBlockItemHeight);
|
||||||
|
|
||||||
|
//Act
|
||||||
|
var result = _testUtility.ItemBlockItemMatcher.HeightBlockItemMatch(testInputBlockItem, testInputItem);
|
||||||
|
|
||||||
|
//Assert
|
||||||
|
Assert.AreEqual(expectedResult, result);
|
||||||
|
}
|
||||||
|
|
||||||
|
[TestCase(FilterPredicateOperator.Equal, 49, false)]
|
||||||
|
[TestCase(FilterPredicateOperator.Equal, 50, true)]
|
||||||
|
[TestCase(FilterPredicateOperator.Equal, 51, false)]
|
||||||
|
[TestCase(FilterPredicateOperator.GreaterThan, 49, true)]
|
||||||
|
[TestCase(FilterPredicateOperator.GreaterThan, 50, false)]
|
||||||
|
[TestCase(FilterPredicateOperator.GreaterThan, 51, false)]
|
||||||
|
[TestCase(FilterPredicateOperator.GreaterThanOrEqual, 49, true)]
|
||||||
|
[TestCase(FilterPredicateOperator.GreaterThanOrEqual, 50, true)]
|
||||||
|
[TestCase(FilterPredicateOperator.GreaterThanOrEqual, 51, false)]
|
||||||
|
[TestCase(FilterPredicateOperator.LessThan, 49, false)]
|
||||||
|
[TestCase(FilterPredicateOperator.LessThan, 50, false)]
|
||||||
|
[TestCase(FilterPredicateOperator.LessThan, 51, true)]
|
||||||
|
[TestCase(FilterPredicateOperator.LessThanOrEqual, 49, false)]
|
||||||
|
[TestCase(FilterPredicateOperator.LessThanOrEqual, 50, true)]
|
||||||
|
[TestCase(FilterPredicateOperator.LessThanOrEqual, 51, true)]
|
||||||
|
[TestCase(-1, 51, false)]
|
||||||
|
public void ItemLevelBlockItemMatch_ReturnsCorrectResult(FilterPredicateOperator testInputFilterPredicateOperator, int testInputBlockItemItemLevel, bool expectedResult)
|
||||||
|
{
|
||||||
|
//Arrange
|
||||||
|
var testInputItem = Mock.Of<IItem>(i => i.ItemLevel == 50);
|
||||||
|
var testInputBlockItem = new ItemLevelBlockItem(testInputFilterPredicateOperator, testInputBlockItemItemLevel);
|
||||||
|
|
||||||
|
//Act
|
||||||
|
var result = _testUtility.ItemBlockItemMatcher.ItemLevelBlockItemMatch(testInputBlockItem, testInputItem);
|
||||||
|
|
||||||
|
//Assert
|
||||||
|
Assert.AreEqual(expectedResult, result);
|
||||||
|
}
|
||||||
|
|
||||||
|
[TestCase(FilterPredicateOperator.Equal, 2, false)]
|
||||||
|
[TestCase(FilterPredicateOperator.Equal, 3, true)]
|
||||||
|
[TestCase(FilterPredicateOperator.Equal, 4, false)]
|
||||||
|
[TestCase(FilterPredicateOperator.GreaterThan, 2, true)]
|
||||||
|
[TestCase(FilterPredicateOperator.GreaterThan, 3, false)]
|
||||||
|
[TestCase(FilterPredicateOperator.GreaterThan, 4, false)]
|
||||||
|
[TestCase(FilterPredicateOperator.GreaterThanOrEqual, 2, true)]
|
||||||
|
[TestCase(FilterPredicateOperator.GreaterThanOrEqual, 3, true)]
|
||||||
|
[TestCase(FilterPredicateOperator.GreaterThanOrEqual, 4, false)]
|
||||||
|
[TestCase(FilterPredicateOperator.LessThan, 2, false)]
|
||||||
|
[TestCase(FilterPredicateOperator.LessThan, 3, false)]
|
||||||
|
[TestCase(FilterPredicateOperator.LessThan, 4, true)]
|
||||||
|
[TestCase(FilterPredicateOperator.LessThanOrEqual, 2, false)]
|
||||||
|
[TestCase(FilterPredicateOperator.LessThanOrEqual, 3, true)]
|
||||||
|
[TestCase(FilterPredicateOperator.LessThanOrEqual, 4, true)]
|
||||||
|
[TestCase(-1, 3, false)]
|
||||||
|
public void LinkedSocketsBlockItemMatch_ReturnsCorrectResult(FilterPredicateOperator testInputFilterPredicateOperator, int testInputBlockItemLinkedSockets, bool expectedResult)
|
||||||
|
{
|
||||||
|
//Arrange
|
||||||
|
var testInputItem = Mock.Of<IItem>(i => i.LinkedSockets == 3);
|
||||||
|
var testInputBlockItem = new LinkedSocketsBlockItem(testInputFilterPredicateOperator, testInputBlockItemLinkedSockets);
|
||||||
|
|
||||||
|
//Act
|
||||||
|
var result = _testUtility.ItemBlockItemMatcher.LinkedSocketsBlockItemMatch(testInputBlockItem, testInputItem);
|
||||||
|
|
||||||
|
//Assert
|
||||||
|
Assert.AreEqual(expectedResult, result);
|
||||||
|
}
|
||||||
|
|
||||||
|
[TestCase(FilterPredicateOperator.Equal, 11, false)]
|
||||||
|
[TestCase(FilterPredicateOperator.Equal, 12, true)]
|
||||||
|
[TestCase(FilterPredicateOperator.Equal, 13, false)]
|
||||||
|
[TestCase(FilterPredicateOperator.GreaterThan, 11, true)]
|
||||||
|
[TestCase(FilterPredicateOperator.GreaterThan, 12, false)]
|
||||||
|
[TestCase(FilterPredicateOperator.GreaterThan, 13, false)]
|
||||||
|
[TestCase(FilterPredicateOperator.GreaterThanOrEqual, 11, true)]
|
||||||
|
[TestCase(FilterPredicateOperator.GreaterThanOrEqual, 12, true)]
|
||||||
|
[TestCase(FilterPredicateOperator.GreaterThanOrEqual, 13, false)]
|
||||||
|
[TestCase(FilterPredicateOperator.LessThan, 11, false)]
|
||||||
|
[TestCase(FilterPredicateOperator.LessThan, 12, false)]
|
||||||
|
[TestCase(FilterPredicateOperator.LessThan, 13, true)]
|
||||||
|
[TestCase(FilterPredicateOperator.LessThanOrEqual, 11, false)]
|
||||||
|
[TestCase(FilterPredicateOperator.LessThanOrEqual, 12, true)]
|
||||||
|
[TestCase(FilterPredicateOperator.LessThanOrEqual, 13, true)]
|
||||||
|
[TestCase(-1, 13, false)]
|
||||||
|
public void QualityBlockItemMatch_ReturnsCorrectResult(FilterPredicateOperator testInputFilterPredicateOperator, int testInputBlockItemQuality, bool expectedResult)
|
||||||
|
{
|
||||||
|
//Arrange
|
||||||
|
var testInputItem = Mock.Of<IItem>(i => i.Quality == 12);
|
||||||
|
var testInputBlockItem = new QualityBlockItem(testInputFilterPredicateOperator, testInputBlockItemQuality);
|
||||||
|
|
||||||
|
//Act
|
||||||
|
var result = _testUtility.ItemBlockItemMatcher.QualityBlockItemMatch(testInputBlockItem, testInputItem);
|
||||||
|
|
||||||
|
//Assert
|
||||||
|
Assert.AreEqual(expectedResult, result);
|
||||||
|
}
|
||||||
|
|
||||||
|
[TestCase(FilterPredicateOperator.Equal, ItemRarity.Normal, false)]
|
||||||
|
[TestCase(FilterPredicateOperator.Equal, ItemRarity.Magic , true)]
|
||||||
|
[TestCase(FilterPredicateOperator.Equal, ItemRarity.Rare, false)]
|
||||||
|
[TestCase(FilterPredicateOperator.GreaterThan, ItemRarity.Normal, true)]
|
||||||
|
[TestCase(FilterPredicateOperator.GreaterThan, ItemRarity.Magic, false)]
|
||||||
|
[TestCase(FilterPredicateOperator.GreaterThan, ItemRarity.Rare, false)]
|
||||||
|
[TestCase(FilterPredicateOperator.GreaterThanOrEqual, ItemRarity.Normal, true)]
|
||||||
|
[TestCase(FilterPredicateOperator.GreaterThanOrEqual, ItemRarity.Magic, true)]
|
||||||
|
[TestCase(FilterPredicateOperator.GreaterThanOrEqual, ItemRarity.Rare, false)]
|
||||||
|
[TestCase(FilterPredicateOperator.LessThan, ItemRarity.Normal, false)]
|
||||||
|
[TestCase(FilterPredicateOperator.LessThan, ItemRarity.Magic, false)]
|
||||||
|
[TestCase(FilterPredicateOperator.LessThan, ItemRarity.Rare, true)]
|
||||||
|
[TestCase(FilterPredicateOperator.LessThanOrEqual, ItemRarity.Normal, false)]
|
||||||
|
[TestCase(FilterPredicateOperator.LessThanOrEqual, ItemRarity.Magic, true)]
|
||||||
|
[TestCase(FilterPredicateOperator.LessThanOrEqual, ItemRarity.Rare, true)]
|
||||||
|
[TestCase(-1, 13, false)]
|
||||||
|
public void RarityBlockItemMatch_ReturnsCorrectResult(FilterPredicateOperator testInputFilterPredicateOperator, int testInputBlockItemRarity, bool expectedResult)
|
||||||
|
{
|
||||||
|
//Arrange
|
||||||
|
var testInputItem = Mock.Of<IItem>(i => i.ItemRarity == ItemRarity.Magic);
|
||||||
|
var testInputBlockItem = new RarityBlockItem(testInputFilterPredicateOperator, testInputBlockItemRarity);
|
||||||
|
|
||||||
|
//Act
|
||||||
|
var result = _testUtility.ItemBlockItemMatcher.RarityBlockItemMatch(testInputBlockItem, testInputItem);
|
||||||
|
|
||||||
|
//Assert
|
||||||
|
Assert.AreEqual(expectedResult, result);
|
||||||
|
}
|
||||||
|
|
||||||
|
[TestCase(FilterPredicateOperator.Equal, 2, false)]
|
||||||
|
[TestCase(FilterPredicateOperator.Equal, 3, true)]
|
||||||
|
[TestCase(FilterPredicateOperator.Equal, 4, false)]
|
||||||
|
[TestCase(FilterPredicateOperator.GreaterThan, 2, true)]
|
||||||
|
[TestCase(FilterPredicateOperator.GreaterThan, 3, false)]
|
||||||
|
[TestCase(FilterPredicateOperator.GreaterThan, 4, false)]
|
||||||
|
[TestCase(FilterPredicateOperator.GreaterThanOrEqual, 2, true)]
|
||||||
|
[TestCase(FilterPredicateOperator.GreaterThanOrEqual, 3, true)]
|
||||||
|
[TestCase(FilterPredicateOperator.GreaterThanOrEqual, 4, false)]
|
||||||
|
[TestCase(FilterPredicateOperator.LessThan, 2, false)]
|
||||||
|
[TestCase(FilterPredicateOperator.LessThan, 3, false)]
|
||||||
|
[TestCase(FilterPredicateOperator.LessThan, 4, true)]
|
||||||
|
[TestCase(FilterPredicateOperator.LessThanOrEqual, 2, false)]
|
||||||
|
[TestCase(FilterPredicateOperator.LessThanOrEqual, 3, true)]
|
||||||
|
[TestCase(FilterPredicateOperator.LessThanOrEqual, 4, true)]
|
||||||
|
[TestCase(-1, 3, false)]
|
||||||
|
public void SocketsBlockItemMatch_ReturnsCorrectResult(FilterPredicateOperator testInputFilterPredicateOperator, int testInputBlockItemSockets, bool expectedResult)
|
||||||
|
{
|
||||||
|
//Arrange
|
||||||
|
var testInputItem = Mock.Of<IItem>(i => i.Sockets == 3);
|
||||||
|
var testInputBlockItem = new SocketsBlockItem(testInputFilterPredicateOperator, testInputBlockItemSockets);
|
||||||
|
|
||||||
|
//Act
|
||||||
|
var result = _testUtility.ItemBlockItemMatcher.SocketsBlockItemMatch(testInputBlockItem, testInputItem);
|
||||||
|
|
||||||
|
//Assert
|
||||||
|
Assert.AreEqual(expectedResult, result);
|
||||||
|
}
|
||||||
|
|
||||||
|
[TestCase(FilterPredicateOperator.Equal, 1, false)]
|
||||||
|
[TestCase(FilterPredicateOperator.Equal, 2, true)]
|
||||||
|
[TestCase(FilterPredicateOperator.Equal, 3, false)]
|
||||||
|
[TestCase(FilterPredicateOperator.GreaterThan, 1, true)]
|
||||||
|
[TestCase(FilterPredicateOperator.GreaterThan, 2, false)]
|
||||||
|
[TestCase(FilterPredicateOperator.GreaterThan, 3, false)]
|
||||||
|
[TestCase(FilterPredicateOperator.GreaterThanOrEqual, 1, true)]
|
||||||
|
[TestCase(FilterPredicateOperator.GreaterThanOrEqual, 2, true)]
|
||||||
|
[TestCase(FilterPredicateOperator.GreaterThanOrEqual, 3, false)]
|
||||||
|
[TestCase(FilterPredicateOperator.LessThan, 1, false)]
|
||||||
|
[TestCase(FilterPredicateOperator.LessThan, 2, false)]
|
||||||
|
[TestCase(FilterPredicateOperator.LessThan, 3, true)]
|
||||||
|
[TestCase(FilterPredicateOperator.LessThanOrEqual, 1, false)]
|
||||||
|
[TestCase(FilterPredicateOperator.LessThanOrEqual, 2, true)]
|
||||||
|
[TestCase(FilterPredicateOperator.LessThanOrEqual, 3, true)]
|
||||||
|
[TestCase(-1, 3, false)]
|
||||||
|
public void WidthBlockItemMatch_ReturnsCorrectResult(FilterPredicateOperator testInputFilterPredicateOperator, int testInputBlockItemWidth, bool expectedResult)
|
||||||
|
{
|
||||||
|
//Arrange
|
||||||
|
var testInputItem = Mock.Of<IItem>(i => i.Width == 2);
|
||||||
|
var testInputBlockItem = new WidthBlockItem(testInputFilterPredicateOperator, testInputBlockItemWidth);
|
||||||
|
|
||||||
|
//Act
|
||||||
|
var result = _testUtility.ItemBlockItemMatcher.WidthBlockItemMatch(testInputBlockItem, testInputItem);
|
||||||
|
|
||||||
|
//Assert
|
||||||
|
Assert.AreEqual(expectedResult, result);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void SocketGroupBlockItemMatch_SingleItemSocketGroup_SingleBlockItemSocketGroup_Match_ReturnsCorrectResult()
|
||||||
|
{
|
||||||
|
//Arrange
|
||||||
|
var testInputBlockItem = new SocketGroupBlockItem();
|
||||||
|
testInputBlockItem.Items.Add("RGB");
|
||||||
|
|
||||||
|
var testInputItem = Mock.Of<IItem>(i => i.LinkedSocketGroups == new List<SocketGroup>
|
||||||
|
{
|
||||||
|
new SocketGroup(new List<Socket>
|
||||||
|
{
|
||||||
|
new Socket(SocketColor.Red),
|
||||||
|
new Socket(SocketColor.Green),
|
||||||
|
new Socket(SocketColor.Blue),
|
||||||
|
}, true)
|
||||||
|
});
|
||||||
|
|
||||||
|
//Act
|
||||||
|
var result = _testUtility.ItemBlockItemMatcher.SocketGroupBlockItemMatch(testInputBlockItem, testInputItem);
|
||||||
|
|
||||||
|
//Assert
|
||||||
|
Assert.IsTrue(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void SocketGroupBlockItemMatch_SingleItemSocketGroup_SingleBlockItemSocketGroup_NoMatch_ReturnsCorrectResult()
|
||||||
|
{
|
||||||
|
//Arrange
|
||||||
|
var testInputBlockItem = new SocketGroupBlockItem();
|
||||||
|
testInputBlockItem.Items.Add("RGB");
|
||||||
|
|
||||||
|
var testInputItem = Mock.Of<IItem>(i => i.LinkedSocketGroups == new List<SocketGroup>
|
||||||
|
{
|
||||||
|
new SocketGroup(new List<Socket>
|
||||||
|
{
|
||||||
|
new Socket(SocketColor.Red),
|
||||||
|
new Socket(SocketColor.Green)
|
||||||
|
}, true)
|
||||||
|
});
|
||||||
|
|
||||||
|
//Act
|
||||||
|
var result = _testUtility.ItemBlockItemMatcher.SocketGroupBlockItemMatch(testInputBlockItem, testInputItem);
|
||||||
|
|
||||||
|
//Assert
|
||||||
|
Assert.IsFalse(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void SocketGroupBlockItemMatch_MultipleItemSocketGroup_SingleBlockItemSocketGroup_NoMatch_ReturnsCorrectResult()
|
||||||
|
{
|
||||||
|
//Arrange
|
||||||
|
var testInputBlockItem = new SocketGroupBlockItem();
|
||||||
|
testInputBlockItem.Items.Add("RGB");
|
||||||
|
testInputBlockItem.Items.Add("RGWW");
|
||||||
|
testInputBlockItem.Items.Add("RRGG");
|
||||||
|
testInputBlockItem.Items.Add("WWWW");
|
||||||
|
|
||||||
|
var testInputItem = Mock.Of<IItem>(i => i.LinkedSocketGroups == new List<SocketGroup>
|
||||||
|
{
|
||||||
|
new SocketGroup(new List<Socket>
|
||||||
|
{
|
||||||
|
new Socket(SocketColor.Red),
|
||||||
|
new Socket(SocketColor.Green),
|
||||||
|
new Socket(SocketColor.White),
|
||||||
|
new Socket(SocketColor.Green)
|
||||||
|
|
||||||
|
}, true)
|
||||||
|
});
|
||||||
|
|
||||||
|
//Act
|
||||||
|
var result = _testUtility.ItemBlockItemMatcher.SocketGroupBlockItemMatch(testInputBlockItem, testInputItem);
|
||||||
|
|
||||||
|
//Assert
|
||||||
|
Assert.IsFalse(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void SocketGroupBlockItemMatch_MultipleItemSocketGroup_SingleBlockItemSocketGroup_Match_ReturnsCorrectResult()
|
||||||
|
{
|
||||||
|
//Arrange
|
||||||
|
var testInputBlockItem = new SocketGroupBlockItem();
|
||||||
|
testInputBlockItem.Items.Add("RGB");
|
||||||
|
testInputBlockItem.Items.Add("RGWW");
|
||||||
|
testInputBlockItem.Items.Add("RGWG");
|
||||||
|
testInputBlockItem.Items.Add("WWWW");
|
||||||
|
|
||||||
|
var testInputItem = Mock.Of<IItem>(i => i.LinkedSocketGroups == new List<SocketGroup>
|
||||||
|
{
|
||||||
|
new SocketGroup(new List<Socket>
|
||||||
|
{
|
||||||
|
new Socket(SocketColor.Red),
|
||||||
|
new Socket(SocketColor.Green),
|
||||||
|
new Socket(SocketColor.White),
|
||||||
|
new Socket(SocketColor.Green)
|
||||||
|
|
||||||
|
}, true)
|
||||||
|
});
|
||||||
|
|
||||||
|
//Act
|
||||||
|
var result = _testUtility.ItemBlockItemMatcher.SocketGroupBlockItemMatch(testInputBlockItem, testInputItem);
|
||||||
|
|
||||||
|
//Assert
|
||||||
|
Assert.IsTrue(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private class ItemBlockItemMatcherTestUtility
|
private class ItemBlockItemMatcherTestUtility
|
||||||
{
|
{
|
||||||
|
|
|
@ -58,8 +58,6 @@
|
||||||
</ApplicationDefinition>
|
</ApplicationDefinition>
|
||||||
<Compile Include="Model\Item.cs" />
|
<Compile Include="Model\Item.cs" />
|
||||||
<Compile Include="Model\ItemCollection.cs" />
|
<Compile Include="Model\ItemCollection.cs" />
|
||||||
<Compile Include="Model\Socket.cs" />
|
|
||||||
<Compile Include="Model\SocketGroup.cs" />
|
|
||||||
<Compile Include="Services\ItemBlockItemMatcher.cs" />
|
<Compile Include="Services\ItemBlockItemMatcher.cs" />
|
||||||
<Compile Include="Services\ItemFilterProcessor.cs" />
|
<Compile Include="Services\ItemFilterProcessor.cs" />
|
||||||
<Compile Include="UserControls\ItemSocketsControl.xaml.cs">
|
<Compile Include="UserControls\ItemSocketsControl.xaml.cs">
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using Filtration.ObjectModel;
|
||||||
using Filtration.ObjectModel.Enums;
|
using Filtration.ObjectModel.Enums;
|
||||||
|
|
||||||
namespace Filtration.ItemFilterPreview.Model
|
namespace Filtration.ItemFilterPreview.Model
|
||||||
|
@ -18,6 +19,7 @@ namespace Filtration.ItemFilterPreview.Model
|
||||||
ItemRarity ItemRarity { get; set; }
|
ItemRarity ItemRarity { get; set; }
|
||||||
int Sockets { get; }
|
int Sockets { get; }
|
||||||
int LinkedSockets { get; }
|
int LinkedSockets { get; }
|
||||||
|
IEnumerable<SocketGroup> LinkedSocketGroups { get; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class Item : IItem
|
public class Item : IItem
|
||||||
|
@ -29,6 +31,11 @@ namespace Filtration.ItemFilterPreview.Model
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public IEnumerable<SocketGroup> LinkedSocketGroups
|
||||||
|
{
|
||||||
|
get { return SocketGroups.Where(s => s.Linked); }
|
||||||
|
}
|
||||||
|
|
||||||
public List<SocketGroup> SocketGroups
|
public List<SocketGroup> SocketGroups
|
||||||
{
|
{
|
||||||
get { return _socketGroups; }
|
get { return _socketGroups; }
|
||||||
|
|
|
@ -1,14 +0,0 @@
|
||||||
using System.Windows.Media;
|
|
||||||
|
|
||||||
namespace Filtration.ItemFilterPreview.Model
|
|
||||||
{
|
|
||||||
public class Socket
|
|
||||||
{
|
|
||||||
public Socket(Color color)
|
|
||||||
{
|
|
||||||
Color = color;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Color Color { get; }
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,9 +1,13 @@
|
||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Windows;
|
||||||
using Filtration.ItemFilterPreview.Model;
|
using Filtration.ItemFilterPreview.Model;
|
||||||
|
using Filtration.ObjectModel;
|
||||||
using Filtration.ObjectModel.BlockItemBaseTypes;
|
using Filtration.ObjectModel.BlockItemBaseTypes;
|
||||||
using Filtration.ObjectModel.BlockItemTypes;
|
using Filtration.ObjectModel.BlockItemTypes;
|
||||||
using Filtration.ObjectModel.Enums;
|
using Filtration.ObjectModel.Enums;
|
||||||
|
using Filtration.ObjectModel.Extensions;
|
||||||
|
|
||||||
namespace Filtration.ItemFilterPreview.Services
|
namespace Filtration.ItemFilterPreview.Services
|
||||||
{
|
{
|
||||||
|
@ -31,35 +35,78 @@ namespace Filtration.ItemFilterPreview.Services
|
||||||
return NumericFilterPredicateBlockItemMatch(dropLevelBlockItem, item.DropLevel);
|
return NumericFilterPredicateBlockItemMatch(dropLevelBlockItem, item.DropLevel);
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool NumericFilterPredicateBlockItemMatch<T>(T numericFilterPredicateBlockItem, int matchValue) where T : NumericFilterPredicateBlockItem
|
public bool HeightBlockItemMatch(HeightBlockItem heightBlockItem, IItem item)
|
||||||
{
|
{
|
||||||
switch (numericFilterPredicateBlockItem.FilterPredicate.PredicateOperator)
|
return NumericFilterPredicateBlockItemMatch(heightBlockItem, item.Height);
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool ItemLevelBlockItemMatch(ItemLevelBlockItem itemLevelBlockItem, IItem item)
|
||||||
|
{
|
||||||
|
return NumericFilterPredicateBlockItemMatch(itemLevelBlockItem, item.ItemLevel);
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool LinkedSocketsBlockItemMatch(LinkedSocketsBlockItem linkedSocketsBlockItem, IItem item)
|
||||||
|
{
|
||||||
|
return NumericFilterPredicateBlockItemMatch(linkedSocketsBlockItem, item.LinkedSockets);
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool QualityBlockItemMatch(QualityBlockItem qualityBlockItem, IItem item)
|
||||||
|
{
|
||||||
|
return NumericFilterPredicateBlockItemMatch(qualityBlockItem, item.Quality);
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool RarityBlockItemMatch(RarityBlockItem qualityBlockItem, IItem item)
|
||||||
|
{
|
||||||
|
return NumericFilterPredicateBlockItemMatch(qualityBlockItem, (int)item.ItemRarity);
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool SocketsBlockItemMatch(SocketsBlockItem socketsBlockItem, IItem item)
|
||||||
|
{
|
||||||
|
return NumericFilterPredicateBlockItemMatch(socketsBlockItem, item.Sockets);
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool WidthBlockItemMatch(WidthBlockItem widthBlockItem, IItem item)
|
||||||
|
{
|
||||||
|
return NumericFilterPredicateBlockItemMatch(widthBlockItem, item.Width);
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool SocketGroupBlockItemMatch(SocketGroupBlockItem socketGroupBlockItem, IItem item)
|
||||||
|
{
|
||||||
|
|
||||||
|
foreach (var blockItemSocketGroup in socketGroupBlockItem.SocketGroups) // for each group of sockets in the block item
|
||||||
{
|
{
|
||||||
case FilterPredicateOperator.Equal:
|
foreach (var itemLinkedSocketGroup in item.LinkedSocketGroups) // for each linked socket group in the item
|
||||||
{
|
{
|
||||||
return matchValue == numericFilterPredicateBlockItem.FilterPredicate.PredicateOperand;
|
if (SocketGroupHasRequiredSocketColors(itemLinkedSocketGroup, blockItemSocketGroup))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
case FilterPredicateOperator.GreaterThan:
|
}
|
||||||
{
|
return false;
|
||||||
return matchValue > numericFilterPredicateBlockItem.FilterPredicate.PredicateOperand;
|
}
|
||||||
}
|
|
||||||
case FilterPredicateOperator.GreaterThanOrEqual:
|
private bool SocketGroupHasRequiredSocketColors(SocketGroup itemLinkedSocketGroup, SocketGroup blockItemSocketGroup)
|
||||||
{
|
{
|
||||||
return matchValue >= numericFilterPredicateBlockItem.FilterPredicate.PredicateOperand;
|
|
||||||
}
|
var blockSocketGroupColorCounts = blockItemSocketGroup.GroupBy(i => i.Color, (key, values) => new { SocketColor = key, Count = values.Count() }).ToList();
|
||||||
case FilterPredicateOperator.LessThan:
|
var itemSocketGroupColorCounts = itemLinkedSocketGroup.GroupBy(i => i.Color, (key, values) => new {SocketColor = key, Count = values.Count()}).ToList();
|
||||||
{
|
|
||||||
return matchValue < numericFilterPredicateBlockItem.FilterPredicate.PredicateOperand;
|
foreach (var blockItemSocketColorCount in blockSocketGroupColorCounts)
|
||||||
}
|
{
|
||||||
case FilterPredicateOperator.LessThanOrEqual:
|
var match = itemSocketGroupColorCounts.FirstOrDefault(i => i.SocketColor == blockItemSocketColorCount.SocketColor && i.Count >= blockItemSocketColorCount.Count);
|
||||||
{
|
if (match == null)
|
||||||
return matchValue <= numericFilterPredicateBlockItem.FilterPredicate.PredicateOperand;
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private bool NumericFilterPredicateBlockItemMatch<T>(T numericFilterPredicateBlockItem, int matchValue) where T : NumericFilterPredicateBlockItem
|
||||||
|
{
|
||||||
|
return numericFilterPredicateBlockItem.FilterPredicate.CompareUsing(matchValue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,11 +1,19 @@
|
||||||
using System.Linq;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
using System.Windows.Media;
|
using System.Windows.Media;
|
||||||
using Filtration.ObjectModel.BlockItemBaseTypes;
|
using Filtration.ObjectModel.BlockItemBaseTypes;
|
||||||
|
using Filtration.ObjectModel.Enums;
|
||||||
|
|
||||||
namespace Filtration.ObjectModel.BlockItemTypes
|
namespace Filtration.ObjectModel.BlockItemTypes
|
||||||
{
|
{
|
||||||
public class SocketGroupBlockItem : StringListBlockItem
|
public class SocketGroupBlockItem : StringListBlockItem
|
||||||
{
|
{
|
||||||
|
public SocketGroupBlockItem()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public override string PrefixText => "SocketGroup";
|
public override string PrefixText => "SocketGroup";
|
||||||
public override int MaximumAllowed => 1;
|
public override int MaximumAllowed => 1;
|
||||||
public override string DisplayHeading => "Socket Group";
|
public override string DisplayHeading => "Socket Group";
|
||||||
|
@ -17,8 +25,47 @@ namespace Filtration.ObjectModel.BlockItemTypes
|
||||||
return "Socket Group " + summaryItemText.TrimStart(' ');
|
return "Socket Group " + summaryItemText.TrimStart(' ');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public IEnumerable<SocketGroup> SocketGroups
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return
|
||||||
|
Items.Select(socketGroup => socketGroup.Select(socketChar => new Socket(StringToSocketColor(socketChar))).ToList())
|
||||||
|
.Select(socketList => new SocketGroup(socketList, true))
|
||||||
|
.ToList();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public override Color SummaryBackgroundColor => Colors.GhostWhite;
|
public override Color SummaryBackgroundColor => Colors.GhostWhite;
|
||||||
public override Color SummaryTextColor => Colors.Black;
|
public override Color SummaryTextColor => Colors.Black;
|
||||||
public override int SortOrder => 9;
|
public override int SortOrder => 9;
|
||||||
|
|
||||||
|
private SocketColor StringToSocketColor(char socketColorString)
|
||||||
|
{
|
||||||
|
switch (socketColorString)
|
||||||
|
{
|
||||||
|
case 'R':
|
||||||
|
{
|
||||||
|
return SocketColor.Red;
|
||||||
|
}
|
||||||
|
case 'G':
|
||||||
|
{
|
||||||
|
return SocketColor.Green;
|
||||||
|
}
|
||||||
|
case 'B':
|
||||||
|
{
|
||||||
|
return SocketColor.Blue;
|
||||||
|
}
|
||||||
|
case 'W':
|
||||||
|
{
|
||||||
|
return SocketColor.White;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
throw new InvalidOperationException("Invalid socket color");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -82,6 +82,8 @@
|
||||||
<Compile Include="Properties\Annotations.cs" />
|
<Compile Include="Properties\Annotations.cs" />
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
<Compile Include="ReplaceColorsParameterSet.cs" />
|
<Compile Include="ReplaceColorsParameterSet.cs" />
|
||||||
|
<Compile Include="Socket.cs" />
|
||||||
|
<Compile Include="SocketGroup.cs" />
|
||||||
<Compile Include="ThemeEditor\Theme.cs" />
|
<Compile Include="ThemeEditor\Theme.cs" />
|
||||||
<Compile Include="ThemeEditor\ThemeComponent.cs" />
|
<Compile Include="ThemeEditor\ThemeComponent.cs" />
|
||||||
<Compile Include="ThemeEditor\ThemeComponentCollection.cs" />
|
<Compile Include="ThemeEditor\ThemeComponentCollection.cs" />
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
using System.ComponentModel;
|
using System;
|
||||||
|
using System.ComponentModel;
|
||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
using Filtration.ObjectModel.Annotations;
|
using Filtration.ObjectModel.Annotations;
|
||||||
using Filtration.ObjectModel.Enums;
|
using Filtration.ObjectModel.Enums;
|
||||||
|
@ -42,6 +43,37 @@ namespace Filtration.ObjectModel
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool CompareUsing(int target)
|
||||||
|
{
|
||||||
|
switch (PredicateOperator)
|
||||||
|
{
|
||||||
|
case FilterPredicateOperator.Equal:
|
||||||
|
{
|
||||||
|
return target == PredicateOperand;
|
||||||
|
}
|
||||||
|
case FilterPredicateOperator.GreaterThan:
|
||||||
|
{
|
||||||
|
return target > PredicateOperand;
|
||||||
|
}
|
||||||
|
case FilterPredicateOperator.GreaterThanOrEqual:
|
||||||
|
{
|
||||||
|
return target >= PredicateOperand;
|
||||||
|
}
|
||||||
|
case FilterPredicateOperator.LessThan:
|
||||||
|
{
|
||||||
|
return target < PredicateOperand;
|
||||||
|
}
|
||||||
|
case FilterPredicateOperator.LessThanOrEqual:
|
||||||
|
{
|
||||||
|
return target <= PredicateOperand;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public override string ToString()
|
public override string ToString()
|
||||||
{
|
{
|
||||||
return PredicateOperator.GetAttributeDescription() + " " + PredicateOperand;
|
return PredicateOperator.GetAttributeDescription() + " " + PredicateOperand;
|
||||||
|
|
|
@ -0,0 +1,14 @@
|
||||||
|
using Filtration.ObjectModel.Enums;
|
||||||
|
|
||||||
|
namespace Filtration.ObjectModel
|
||||||
|
{
|
||||||
|
public class Socket
|
||||||
|
{
|
||||||
|
public Socket(SocketColor color)
|
||||||
|
{
|
||||||
|
Color = color;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SocketColor Color { get; }
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,7 +1,7 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace Filtration.ItemFilterPreview.Model
|
namespace Filtration.ObjectModel
|
||||||
{
|
{
|
||||||
public class SocketGroup : List<Socket>
|
public class SocketGroup : List<Socket>
|
||||||
{
|
{
|
Loading…
Reference in New Issue