Tidy up, updated ItemBaseTypes and ItemClasses files to Path of Exile 2.3.4
This commit is contained in:
56
Filtration.ObjectModel/FilteredItem.cs
Normal file
56
Filtration.ObjectModel/FilteredItem.cs
Normal file
@@ -0,0 +1,56 @@
|
||||
using System.Linq;
|
||||
using System.Windows.Media;
|
||||
using Filtration.ObjectModel.BlockItemTypes;
|
||||
using Filtration.ObjectModel.Enums;
|
||||
|
||||
namespace Filtration.ObjectModel
|
||||
{
|
||||
public interface IFilteredItem
|
||||
{
|
||||
IItem Item { get; }
|
||||
IItemFilterBlock ItemFilterBlock { get; }
|
||||
BlockAction BlockAction { get; }
|
||||
Color BackgroundColor { get; }
|
||||
Color BorderColor { get; }
|
||||
Color TextColor { get; }
|
||||
double FontSize { get; }
|
||||
}
|
||||
|
||||
public class FilteredItem : IFilteredItem
|
||||
{
|
||||
public FilteredItem(IItem item, IItemFilterBlock itemFilterBlock)
|
||||
{
|
||||
Item = item;
|
||||
ItemFilterBlock = itemFilterBlock;
|
||||
|
||||
BlockAction = itemFilterBlock?.Action ?? BlockAction.Show;
|
||||
BackgroundColor = itemFilterBlock?.DisplayBackgroundColor ?? new Color { A = 255, R = 0, G = 0, B = 0 };
|
||||
BorderColor = itemFilterBlock?.DisplayBorderColor ?? new Color {A = 255, R = 0, G = 0, B = 0};
|
||||
FontSize = (itemFilterBlock?.DisplayFontSize ?? 34) / 1.8;
|
||||
|
||||
SetTextColor();
|
||||
}
|
||||
|
||||
private void SetTextColor()
|
||||
{
|
||||
if (ItemFilterBlock == null)
|
||||
{
|
||||
TextColor = Item.DefaultTextColor;
|
||||
return;
|
||||
}
|
||||
|
||||
var textColorBlockItem = ItemFilterBlock.BlockItems?.OfType<TextColorBlockItem>().FirstOrDefault();
|
||||
TextColor = textColorBlockItem?.Color ?? Item.DefaultTextColor;
|
||||
}
|
||||
|
||||
|
||||
public IItem Item { get; private set; }
|
||||
public IItemFilterBlock ItemFilterBlock { get; private set; }
|
||||
|
||||
public BlockAction BlockAction { get; private set; }
|
||||
public Color BackgroundColor { get; private set; }
|
||||
public Color TextColor { get; private set; }
|
||||
public Color BorderColor { get; private set; }
|
||||
public double FontSize { get; private set; }
|
||||
}
|
||||
}
|
||||
@@ -33,6 +33,7 @@
|
||||
<ItemGroup>
|
||||
<Reference Include="PresentationCore" />
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.ComponentModel.DataAnnotations" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
@@ -73,12 +74,15 @@
|
||||
<Compile Include="Enums\ThemeComponentType.cs" />
|
||||
<Compile Include="Extensions\EnumHelper.cs" />
|
||||
<Compile Include="Extensions\ItemRarityExtensions.cs" />
|
||||
<Compile Include="FilteredItem.cs" />
|
||||
<Compile Include="IAudioVisualBlockItem.cs" />
|
||||
<Compile Include="IItemFilterBlockItem.cs" />
|
||||
<Compile Include="Item.cs" />
|
||||
<Compile Include="ItemFilterBlock.cs" />
|
||||
<Compile Include="ItemFilterBlockGroup.cs" />
|
||||
<Compile Include="ItemFilterScript.cs" />
|
||||
<Compile Include="ItemFilterSection.cs" />
|
||||
<Compile Include="ItemSet.cs" />
|
||||
<Compile Include="NumericFilterPredicate.cs" />
|
||||
<Compile Include="PathOfExileNamedColors.cs" />
|
||||
<Compile Include="Enums\PathOfExileNamedColor.cs" />
|
||||
|
||||
130
Filtration.ObjectModel/Item.cs
Normal file
130
Filtration.ObjectModel/Item.cs
Normal file
@@ -0,0 +1,130 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Linq;
|
||||
using System.Windows.Media;
|
||||
using Filtration.ObjectModel.Enums;
|
||||
using Filtration.ObjectModel.Extensions;
|
||||
|
||||
namespace Filtration.ObjectModel
|
||||
{
|
||||
public interface IItem
|
||||
{
|
||||
string Description { get; set; }
|
||||
string ItemClass { get; set; }
|
||||
string BaseType { get; set; }
|
||||
int DropLevel { get; set; }
|
||||
int ItemLevel { get; set; }
|
||||
int Height { get; set; }
|
||||
int Width { get; set; }
|
||||
int Quality { get; set; }
|
||||
ItemRarity ItemRarity { get; set; }
|
||||
int SocketCount { get; }
|
||||
int LinkedSockets { get; }
|
||||
IEnumerable<SocketGroup> LinkedSocketGroups { get; }
|
||||
List<SocketGroup> SocketGroups { get; set; }
|
||||
Color DefaultTextColor { get; }
|
||||
}
|
||||
|
||||
[Table("Item")]
|
||||
public class Item : IItem
|
||||
{
|
||||
private List<SocketGroup> _socketGroups;
|
||||
|
||||
public long Id { get; set; }
|
||||
|
||||
[Required]
|
||||
[StringLength(100)]
|
||||
public string Description { get; set; }
|
||||
|
||||
[Required]
|
||||
[StringLength(100)]
|
||||
public string BaseType { get; set; }
|
||||
|
||||
[Required]
|
||||
[StringLength(100)]
|
||||
public string ItemClass { get; set; }
|
||||
|
||||
public int DropLevel { get; set; }
|
||||
|
||||
public int ItemLevel { get; set; }
|
||||
|
||||
public int Height { get; set; }
|
||||
|
||||
public int Width { get; set; }
|
||||
|
||||
public int Quality { get; set; }
|
||||
|
||||
public ItemRarity ItemRarity { get; set; }
|
||||
|
||||
[StringLength(20)]
|
||||
public string Sockets { get; set; }
|
||||
|
||||
public long ItemSetId { get; set; }
|
||||
|
||||
public virtual ItemSet ItemSet { get; set; }
|
||||
|
||||
public int SocketCount { get; private set; }
|
||||
public int LinkedSockets { get; private set; }
|
||||
|
||||
public IEnumerable<SocketGroup> LinkedSocketGroups
|
||||
{
|
||||
get { return SocketGroups.Where(s => s.Linked); }
|
||||
}
|
||||
|
||||
[NotMapped]
|
||||
public List<SocketGroup> SocketGroups
|
||||
{
|
||||
get { return _socketGroups; }
|
||||
set
|
||||
{
|
||||
var socketCount = value.Sum(s => s.Count);
|
||||
if (socketCount < 0 || socketCount > 6)
|
||||
{
|
||||
throw new InvalidOperationException("An item must have between 0 and 6 sockets");
|
||||
}
|
||||
|
||||
var evenSocketCount = socketCount % 2 == 0;
|
||||
var maxSocketGroups = Math.Max(1, evenSocketCount ? socketCount / 2 : socketCount - 1);
|
||||
var maxLinkedSocketGroups = Math.Max(1, evenSocketCount ? maxSocketGroups : maxSocketGroups - 1);
|
||||
|
||||
if (value.Count > maxSocketGroups)
|
||||
{
|
||||
throw new InvalidOperationException("Invalid number of socket groups for the socket count of this item");
|
||||
}
|
||||
|
||||
if (value.Count(s => s.Linked) > maxLinkedSocketGroups)
|
||||
{
|
||||
throw new InvalidOperationException("Invalid number of linked socket groups for the socket count of this item");
|
||||
}
|
||||
|
||||
_socketGroups = value;
|
||||
SocketCount = socketCount;
|
||||
|
||||
var linkedSocketGroups = value.Where(s => s.Linked).ToList();
|
||||
LinkedSockets = linkedSocketGroups.Any() ? linkedSocketGroups.Max(s => s.Count) : 0;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public Color DefaultTextColor
|
||||
{
|
||||
get
|
||||
{
|
||||
if (ItemClass.Contains("Gems"))
|
||||
{
|
||||
return PathOfExileNamedColors.Colors[PathOfExileNamedColor.GemItem];
|
||||
}
|
||||
if (ItemClass.Contains("Quest"))
|
||||
{
|
||||
return PathOfExileNamedColors.Colors[PathOfExileNamedColor.QuestItem];
|
||||
}
|
||||
|
||||
return ItemRarity != ItemRarity.NotSet ? ItemRarity.DefaultRarityTextColor() : PathOfExileNamedColors.Colors[PathOfExileNamedColor.WhiteItem];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
26
Filtration.ObjectModel/ItemSet.cs
Normal file
26
Filtration.ObjectModel/ItemSet.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace Filtration.ObjectModel
|
||||
{
|
||||
[Table("ItemSet")]
|
||||
public class ItemSet
|
||||
{
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors")]
|
||||
public ItemSet()
|
||||
{
|
||||
// ReSharper disable once VirtualMemberCallInContructor
|
||||
Items = new HashSet<Item>();
|
||||
}
|
||||
|
||||
public long Id { get; set; }
|
||||
|
||||
[Required]
|
||||
[StringLength(200)]
|
||||
public string Name { get; set; }
|
||||
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
|
||||
public ICollection<Item> Items { get; set; }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user