Skip to content

Commit

Permalink
Add various interfaces for equipment
Browse files Browse the repository at this point in the history
  • Loading branch information
sliekens committed Dec 26, 2024
1 parent b4701c2 commit 99de015
Show file tree
Hide file tree
Showing 11 changed files with 80 additions and 14 deletions.
26 changes: 26 additions & 0 deletions GW2SDK/Features/Items/ICombatEquipment.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
using GuildWars2.Hero;

namespace GuildWars2.Items;

/// <summary>The interface for items that can be equipped to increase the player's combat attributes.</summary>
public interface ICombatEquipment
{
/// <summary>The Attribute Adjustment factor. To calculate the final item stats of the item, multiply this value with an
/// attribute's multiplier, then add the result to the attribute's base value.</summary>
/// <remarks>The formula is: attribute_adjustment * multiplier + value.</remarks>
double AttributeAdjustment { get; }

/// <summary>The ID of the item's attribute combination, used for items with fixed stats. This property is not used for
/// items with selectable stats.</summary>
int? AttributeCombinationId { get; }

/// <summary>The IDs of the attribute combinations that can be chosen for the item. This property is only used for items
/// with selectable stats.</summary>
IReadOnlyList<int> StatChoices { get; }

/// <summary>The effective stats of the item.</summary>
IDictionary<Extensible<AttributeName>, int> Attributes { get; }

/// <summary>The effect which is applied to the player when the item is equipped.</summary>
Buff? Buff { get; }
}
10 changes: 10 additions & 0 deletions GW2SDK/Features/Items/IInfusable.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
namespace GuildWars2.Items;


/// <summary>The interface for items that can be infused (or attuned) to add one extra infusion slot.</summary>
public interface IInfusable
{
/// <summary>If the current item is used in the Mystic Forge to infuse (or attune) equipment, this collection contains the IDs
/// of the infused (or attuned) items. Each item in the collection represents a different recipe.</summary>
IReadOnlyCollection<InfusionSlotUpgradePath> UpgradesInto { get; }
}
8 changes: 8 additions & 0 deletions GW2SDK/Features/Items/IInfused.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
namespace GuildWars2.Items;

/// <summary>The interface for items with an extra infusion slot.</summary>
public interface IInfused
{
/// <summary>If the current item is upgraded, this collection contains the IDs of possible source items.</summary>
IReadOnlyCollection<InfusionSlotUpgradeSource> UpgradesFrom { get; }
}
14 changes: 14 additions & 0 deletions GW2SDK/Features/Items/IUpgradable.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
namespace GuildWars2.Items;

/// <summary>The interface for items with upgrade or infusion slots.</summary>
public interface IUpgradable
{
/// <summary>The ID of the upgrade component in the upgrade slot, if any.</summary>
int? SuffixItemId { get; }

/// <summary>The ID of the upgrade component in the second upgrade slot (two-handed weapons only), if any.</summary>
int? SecondarySuffixItemId { get; }

/// <summary>The infusion slots of the item (only available on ascended and legendary items).</summary>
IReadOnlyList<InfusionSlot> InfusionSlots { get; }
}
4 changes: 3 additions & 1 deletion GW2SDK/Features/Items/Models/Armors/Armor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace GuildWars2.Items;
[PublicAPI]
[Inheritable]
[JsonConverter(typeof(ArmorJsonConverter))]
public record Armor : Item
public record Armor : Item, ICombatEquipment, IUpgradable
{
/// <summary>The default skin ID for the armor. This skin can be unlocked in the wardrobe by binding the item.</summary>
public required int DefaultSkinId { get; init; }
Expand Down Expand Up @@ -41,6 +41,8 @@ public record Armor : Item
/// <summary>The ID of the upgrade component in the upgrade slot, if any.</summary>
public required int? SuffixItemId { get; init; }

int? IUpgradable.SecondarySuffixItemId => null;

/// <summary>The IDs of the attribute combinations that can be chosen for the item. This property is only used for items
/// with selectable stats.</summary>
public required IReadOnlyList<int> StatChoices { get; init; }
Expand Down
8 changes: 5 additions & 3 deletions GW2SDK/Features/Items/Models/Backs/Backpack.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace GuildWars2.Items;
/// <summary>Information about a back item.</summary>
[PublicAPI]
[JsonConverter(typeof(BackpackJsonConverter))]
public sealed record Backpack : Item
public sealed record Backpack : Item, ICombatEquipment, IUpgradable, IInfused, IInfusable
{
/// <summary>The default skin ID for the back item. This skin can be unlocked in the wardrobe by binding the item.</summary>
public required int DefaultSkinId { get; init; }
Expand All @@ -32,12 +32,14 @@ public sealed record Backpack : Item
/// <summary>The ID of the upgrade component in the upgrade slot, if any.</summary>
public required int? SuffixItemId { get; init; }

int? IUpgradable.SecondarySuffixItemId => null;

/// <summary>The IDs of the attribute combinations that can be chosen for the item. This property is only used for items
/// with selectable stats.</summary>
public required IReadOnlyList<int> StatChoices { get; init; }

/// <summary>If the current back item can be infused, this collection contains the IDs of the infused variations of the
/// back item. Each item in the collection represents a possible upgrade path.</summary>
/// <summary>If the current back item can be infused in the Mystic Forge, this collection contains the IDs of the infused variations of the
/// back item. Each item in the collection represents a different recipe.</summary>
public required IReadOnlyCollection<InfusionSlotUpgradePath> UpgradesInto { get; init; }

/// <summary>If the current back item is infused, this collection contains the IDs of possible source items.</summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ namespace GuildWars2.Items;
/// <summary>Information about a crafting material.</summary>
[PublicAPI]
[JsonConverter(typeof(CraftingMaterialJsonConverter))]
public sealed record CraftingMaterial : Item
public sealed record CraftingMaterial : Item, IInfusable
{
/// <summary>If the current material is used in a Mystic Forge recipe to infuse equipment, this collection contains the IDs
/// of the infused items. Each item in the collection represents a possible upgrade path.</summary>
/// <summary>If the current crafting material is used in the Mystic Forge to infuse or attune equipment, this collection contains the IDs
/// of the infused (or attuned) items. Each item in the collection represents a different recipe.</summary>
public required IReadOnlyCollection<InfusionSlotUpgradePath> UpgradesInto { get; init; }

/// <inheritdoc />
Expand Down
6 changes: 3 additions & 3 deletions GW2SDK/Features/Items/Models/Trinkets/Ring.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ namespace GuildWars2.Items;
/// <summary>Information about a ring.</summary>
[PublicAPI]
[JsonConverter(typeof(RingJsonConverter))]
public sealed record Ring : Trinket
public sealed record Ring : Trinket, IInfused, IInfusable
{
/// <summary>If the current ring can be infused or attuned, this collection contains the IDs of the infused/attuned
/// variations of the ring. Each item in the collection represents a possible upgrade path.</summary>
/// <summary>If the current ring can be infused or attuned in the Mystic Forge, this collection contains the IDs of the infused (or attuned)
/// variations of the ring. Each item in the collection represents a different recipe.</summary>
public required IReadOnlyCollection<InfusionSlotUpgradePath> UpgradesInto { get; init; }

/// <summary>If the current ring is infused or attuned, this collection contains the IDs of possible source items.</summary>
Expand Down
4 changes: 3 additions & 1 deletion GW2SDK/Features/Items/Models/Trinkets/Trinket.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace GuildWars2.Items;
[PublicAPI]
[Inheritable]
[JsonConverter(typeof(TrinketJsonConverter))]
public record Trinket : Item
public record Trinket : Item, ICombatEquipment, IUpgradable
{
/// <summary>The infusion slots of the trinket (only available on ascended and legendary items).</summary>
public required IReadOnlyList<InfusionSlot> InfusionSlots { get; init; }
Expand All @@ -31,6 +31,8 @@ public record Trinket : Item
/// <summary>The ID of the upgrade component in the upgrade slot, if any.</summary>
public required int? SuffixItemId { get; init; }

int? IUpgradable.SecondarySuffixItemId => null;

/// <summary>The IDs of the attribute combinations that can be chosen for the item. This property is only used for items
/// with selectable stats.</summary>
public required IReadOnlyList<int> StatChoices { get; init; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace GuildWars2.Items;
[PublicAPI]
[Inheritable]
[JsonConverter(typeof(UpgradeComponentJsonConverter))]
public record UpgradeComponent : Item
public record UpgradeComponent : Item, ICombatEquipment
{
/// <summary>Flags that indicate which types of items are compatible with the upgrade.</summary>
public required UpgradeComponentFlags UpgradeComponentFlags { get; init; }
Expand All @@ -24,6 +24,8 @@ public record UpgradeComponent : Item
/// items with selectable stats.</summary>
public required int? AttributeCombinationId { get; init; }

IReadOnlyList<int> ICombatEquipment.StatChoices { get; } = Empty.ListOfInt32;

/// <summary>The effective stats of the item.</summary>
public required IDictionary<Extensible<AttributeName>, int> Attributes { get; init; }

Expand Down
4 changes: 2 additions & 2 deletions GW2SDK/Features/Items/Models/Weapons/Weapon.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace GuildWars2.Items;
[PublicAPI]
[Inheritable]
[JsonConverter(typeof(WeaponJsonConverter))]
public record Weapon : Item
public record Weapon : Item, ICombatEquipment, IUpgradable
{
/// <summary>The default skin ID for the weapon. This skin can be unlocked in the wardrobe by binding the item.</summary>
public required int DefaultSkinId { get; init; }
Expand All @@ -29,7 +29,7 @@ public record Weapon : Item
/// attribute, which reduces incoming strike damage.</summary>
public required int Defense { get; init; }

/// <summary>The infusion slots of the armor (only available on ascended and legendary items).</summary>
/// <summary>The infusion slots of the weapon (only available on ascended and legendary items).</summary>
public required IReadOnlyList<InfusionSlot> InfusionSlots { get; init; }

/// <summary>The Attribute Adjustment factor. To calculate the final item stats of the item, multiply this value with an
Expand Down

0 comments on commit 99de015

Please sign in to comment.