diff --git a/src/OpenRpg.Cards/Types/CardVariableTypes.cs b/src/OpenRpg.Cards/Types/ICardCoreVariableTypes.cs similarity index 62% rename from src/OpenRpg.Cards/Types/CardVariableTypes.cs rename to src/OpenRpg.Cards/Types/ICardCoreVariableTypes.cs index 51c1efd..30b6868 100644 --- a/src/OpenRpg.Cards/Types/CardVariableTypes.cs +++ b/src/OpenRpg.Cards/Types/ICardCoreVariableTypes.cs @@ -3,7 +3,7 @@ namespace OpenRpg.Cards.Types { - public interface CardVariableTypes : ItemVariableTypes, CombatVariableTypes + public interface ICardCoreVariableTypes : ItemCoreVariableTypes, CombatVariableTypes { public static int CardVariables = 50; } diff --git a/src/OpenRpg.Cards/Variables/DefaultCardVariables.cs b/src/OpenRpg.Cards/Variables/DefaultCardVariables.cs index dff6058..2738904 100644 --- a/src/OpenRpg.Cards/Variables/DefaultCardVariables.cs +++ b/src/OpenRpg.Cards/Variables/DefaultCardVariables.cs @@ -6,7 +6,7 @@ namespace OpenRpg.Cards.Variables { public class DefaultCardVariables : DefaultVariables, ICardVariables { - public DefaultCardVariables(IDictionary internalVariables = null) : base(CardVariableTypes.CardVariables, internalVariables) + public DefaultCardVariables(IDictionary internalVariables = null) : base(ICardCoreVariableTypes.CardVariables, internalVariables) { } } diff --git a/src/OpenRpg.Combat/Extensions/IItemEntityVariableExtensions.cs b/src/OpenRpg.Combat/Extensions/IItemEntityVariableExtensions.cs new file mode 100644 index 0000000..ca3cade --- /dev/null +++ b/src/OpenRpg.Combat/Extensions/IItemEntityVariableExtensions.cs @@ -0,0 +1,21 @@ +using OpenRpg.Combat.Effects; +using OpenRpg.Combat.Types; +using OpenRpg.Core.Variables.Entity; + +namespace OpenRpg.Combat.Extensions +{ + /// + /// This allows you to extend the underlying entity to add active effects onto them + /// + public static class CombatEntityVariableExtensions + { + public static bool HasActiveEffects(this IEntityVariables vars) + { return vars.ContainsKey(CombatEntityVariableTypes.ActiveEffects); } + + public static IActiveEffects ActiveEffects(this IEntityVariables vars) + { return vars[CombatEntityVariableTypes.ActiveEffects] as IActiveEffects; } + + public static void ActiveEffects(this IEntityVariables vars, IActiveEffects activeEffects) + { vars[CombatEntityVariableTypes.ActiveEffects] = activeEffects; } + } +} \ No newline at end of file diff --git a/src/OpenRpg.Combat/Types/CombatEntityVariableTypes.cs b/src/OpenRpg.Combat/Types/CombatEntityVariableTypes.cs new file mode 100644 index 0000000..7a2fe7a --- /dev/null +++ b/src/OpenRpg.Combat/Types/CombatEntityVariableTypes.cs @@ -0,0 +1,9 @@ +using OpenRpg.Core.Types; + +namespace OpenRpg.Combat.Types +{ + public interface CombatEntityVariableTypes : EntityVariableTypes + { + public static readonly int ActiveEffects = 10; + } +} \ No newline at end of file diff --git a/src/OpenRpg.Core/Types/EntityVariableTypes.cs b/src/OpenRpg.Core/Types/EntityVariableTypes.cs new file mode 100644 index 0000000..3552785 --- /dev/null +++ b/src/OpenRpg.Core/Types/EntityVariableTypes.cs @@ -0,0 +1,8 @@ +namespace OpenRpg.Core.Types +{ + public interface EntityVariableTypes + { + // Unknown + public static readonly int Unknown = 0; + } +} \ No newline at end of file diff --git a/src/OpenRpg.Items/Equipment/DefaultEquipmentSlots.cs b/src/OpenRpg.Items/Equipment/DefaultEquipmentSlots.cs index 4513b30..1b9288c 100644 --- a/src/OpenRpg.Items/Equipment/DefaultEquipmentSlots.cs +++ b/src/OpenRpg.Items/Equipment/DefaultEquipmentSlots.cs @@ -6,7 +6,7 @@ namespace OpenRpg.Items.Equipment { public class DefaultEquipmentSlots : DefaultVariables, IEquipmentSlots { - public DefaultEquipmentSlots(IDictionary internalVariables = null) : base(ItemVariableTypes.EquipmentSlotVariables, internalVariables) + public DefaultEquipmentSlots(IDictionary internalVariables = null) : base(ItemCoreVariableTypes.EquipmentSlotVariables, internalVariables) { } } diff --git a/src/OpenRpg.Items/Extensions/IItemEntityVariableExtensions.cs b/src/OpenRpg.Items/Extensions/IItemEntityVariableExtensions.cs new file mode 100644 index 0000000..806e3f9 --- /dev/null +++ b/src/OpenRpg.Items/Extensions/IItemEntityVariableExtensions.cs @@ -0,0 +1,31 @@ +using OpenRpg.Core.Variables.Entity; +using OpenRpg.Items.Equipment; +using OpenRpg.Items.Inventory; +using OpenRpg.Items.Types; + +namespace OpenRpg.Items.Extensions +{ + /// + /// This allows you to extend the underlying entity to add equipment or inventory responsibilities onto them + /// + public static class ItemEntityVariableExtensions + { + public static bool HasEquipment(this IEntityVariables vars) + { return vars.ContainsKey(ItemEntityVariableTypes.Equipment); } + + public static IEquipment Equipment(this IEntityVariables vars) + { return vars[ItemEntityVariableTypes.Equipment] as IEquipment; } + + public static void Equipment(this IEntityVariables vars, IEquipment equipment) + { vars[ItemEntityVariableTypes.Equipment] = equipment; } + + public static bool HasInventory(this IEntityVariables vars) + { return vars.ContainsKey(ItemEntityVariableTypes.Inventory); } + + public static IInventory Inventory(this IEntityVariables vars) + { return vars[ItemEntityVariableTypes.Inventory] as IInventory; } + + public static void Inventory(this IEntityVariables vars, IInventory inventory) + { vars[ItemEntityVariableTypes.Inventory] = inventory; } + } +} \ No newline at end of file diff --git a/src/OpenRpg.Items/Extensions/IItemVariablesExtensions.cs b/src/OpenRpg.Items/Extensions/IItemVariablesExtensions.cs index 969f3eb..213de41 100644 --- a/src/OpenRpg.Items/Extensions/IItemVariablesExtensions.cs +++ b/src/OpenRpg.Items/Extensions/IItemVariablesExtensions.cs @@ -9,25 +9,29 @@ public static class ItemVariablesExtensions { public static IItemVariables Clone(this DefaultItemVariables itemVariables) { - return new DefaultItemVariables { InternalVariables = new Dictionary(itemVariables.InternalVariables) }; + return new DefaultItemVariables + { + InternalVariables = new Dictionary(itemVariables.InternalVariables) + }; } public static bool HasAmount(this IItemVariables variables) - { return variables.ContainsKey(DefaultItemVariableTypes.Amount); } + { return variables.ContainsKey(ItemVariableTypes.Amount); } public static int Amount(this IItemVariables variables) { - var amountObject = variables.Get(DefaultItemVariableTypes.Amount); + var amountObject = variables.Get(ItemVariableTypes.Amount); var amount = Convert.ToInt32(amountObject); return amount == 0 ? 1 : amount; } - public static void Amount(this IItemVariables variables, int value) => variables[DefaultItemVariableTypes.Amount] = value; - + public static void Amount(this IItemVariables variables, int value) + { variables[ItemVariableTypes.Amount] = value; } + public static bool HasWeight(this IItemVariables variables) - { return variables.ContainsKey(DefaultItemVariableTypes.Weight); } + { return variables.ContainsKey(ItemVariableTypes.Weight); } - public static int Weight(this IItemVariables variables) => Convert.ToInt32(variables.Get(DefaultItemVariableTypes.Weight)); - public static void Weight(this IItemVariables variables, int value) => variables[DefaultItemVariableTypes.Weight] = value; + public static int Weight(this IItemVariables variables) => Convert.ToInt32(variables.Get(ItemVariableTypes.Weight)); + public static void Weight(this IItemVariables variables, int value) => variables[ItemVariableTypes.Weight] = value; } } \ No newline at end of file diff --git a/src/OpenRpg.Items/Inventory/DefaultInventoryVariables.cs b/src/OpenRpg.Items/Inventory/DefaultInventoryVariables.cs index f8a6e50..fde54ed 100644 --- a/src/OpenRpg.Items/Inventory/DefaultInventoryVariables.cs +++ b/src/OpenRpg.Items/Inventory/DefaultInventoryVariables.cs @@ -6,7 +6,7 @@ namespace OpenRpg.Items.Inventory { public class DefaultInventoryVariables : DefaultVariables, IInventoryVariables { - public DefaultInventoryVariables(IDictionary internalVariables = null) : base(ItemVariableTypes.InventoryVariables, internalVariables) + public DefaultInventoryVariables(IDictionary internalVariables = null) : base(ItemCoreVariableTypes.InventoryVariables, internalVariables) { } } diff --git a/src/OpenRpg.Items/Loot/DefaultLootTableEntryVariables.cs b/src/OpenRpg.Items/Loot/DefaultLootTableEntryVariables.cs index cba1a61..1efbd80 100644 --- a/src/OpenRpg.Items/Loot/DefaultLootTableEntryVariables.cs +++ b/src/OpenRpg.Items/Loot/DefaultLootTableEntryVariables.cs @@ -6,7 +6,7 @@ namespace OpenRpg.Items.Loot { public class DefaultLootTableEntryVariables : DefaultVariables, ILootTableEntryVariables { - public DefaultLootTableEntryVariables(IDictionary internalVariables = null) : base(ItemVariableTypes.LootTableEntryVariables, internalVariables) + public DefaultLootTableEntryVariables(IDictionary internalVariables = null) : base(ItemCoreVariableTypes.LootTableEntryVariables, internalVariables) { } } diff --git a/src/OpenRpg.Items/Templates/DefaultItemTemplateVariables.cs b/src/OpenRpg.Items/Templates/DefaultItemTemplateVariables.cs index 3eeda66..085e90b 100644 --- a/src/OpenRpg.Items/Templates/DefaultItemTemplateVariables.cs +++ b/src/OpenRpg.Items/Templates/DefaultItemTemplateVariables.cs @@ -6,7 +6,7 @@ namespace OpenRpg.Items.Templates { public class DefaultItemTemplateVariables : DefaultVariables, IItemTemplateVariables { - public DefaultItemTemplateVariables(IDictionary internalVariables = null) : base(ItemVariableTypes.ItemTemplateVariables, internalVariables) + public DefaultItemTemplateVariables(IDictionary internalVariables = null) : base(ItemCoreVariableTypes.ItemTemplateVariables, internalVariables) { } } diff --git a/src/OpenRpg.Items/Types/DefaultItemVariableTypes.cs b/src/OpenRpg.Items/Types/DefaultItemVariableTypes.cs deleted file mode 100644 index 3ac0041..0000000 --- a/src/OpenRpg.Items/Types/DefaultItemVariableTypes.cs +++ /dev/null @@ -1,10 +0,0 @@ -namespace OpenRpg.Items.Types -{ - public interface DefaultItemVariableTypes - { - public static int Unknown = 0; - - public static int Amount = 1; - public static int Weight = 2; - } -} \ No newline at end of file diff --git a/src/OpenRpg.Items/Types/ItemCoreVariableTypes.cs b/src/OpenRpg.Items/Types/ItemCoreVariableTypes.cs new file mode 100644 index 0000000..74f7d5b --- /dev/null +++ b/src/OpenRpg.Items/Types/ItemCoreVariableTypes.cs @@ -0,0 +1,14 @@ +using OpenRpg.Core.Types; + +namespace OpenRpg.Items.Types +{ + public interface ItemCoreVariableTypes : CoreVariableTypes + { + public static int ItemTemplateVariables = 20; + public static int InventoryVariables = 21; + public static int ItemVariables = 23; + public static int EquipmentVariables = 24; + public static int LootTableEntryVariables = 25; + public static int EquipmentSlotVariables = 26; + } +} \ No newline at end of file diff --git a/src/OpenRpg.Items/Types/ItemEntityVariableTypes.cs b/src/OpenRpg.Items/Types/ItemEntityVariableTypes.cs new file mode 100644 index 0000000..020b695 --- /dev/null +++ b/src/OpenRpg.Items/Types/ItemEntityVariableTypes.cs @@ -0,0 +1,10 @@ +using OpenRpg.Core.Types; + +namespace OpenRpg.Items.Types +{ + public interface ItemEntityVariableTypes : EntityVariableTypes + { + public static readonly int Equipment = 1; + public static readonly int Inventory = 2; + } +} \ No newline at end of file diff --git a/src/OpenRpg.Items/Types/ItemVariableTypes.cs b/src/OpenRpg.Items/Types/ItemVariableTypes.cs index 5d050a2..9166310 100644 --- a/src/OpenRpg.Items/Types/ItemVariableTypes.cs +++ b/src/OpenRpg.Items/Types/ItemVariableTypes.cs @@ -1,14 +1,10 @@ -using OpenRpg.Core.Types; - namespace OpenRpg.Items.Types { - public interface ItemVariableTypes : CoreVariableTypes + public interface ItemVariableTypes { - public static int ItemTemplateVariables = 20; - public static int InventoryVariables = 21; - public static int ItemVariables = 23; - public static int EquipmentVariables = 24; - public static int LootTableEntryVariables = 25; - public static int EquipmentSlotVariables = 26; + public static int Unknown = 0; + + public static int Amount = 1; + public static int Weight = 2; } } \ No newline at end of file diff --git a/src/OpenRpg.Items/Variables/DefaultEquipmentVariables.cs b/src/OpenRpg.Items/Variables/DefaultEquipmentVariables.cs index 19c7f3b..86fce9d 100644 --- a/src/OpenRpg.Items/Variables/DefaultEquipmentVariables.cs +++ b/src/OpenRpg.Items/Variables/DefaultEquipmentVariables.cs @@ -6,7 +6,7 @@ namespace OpenRpg.Items.Variables { public class DefaultEquipmentVariables : DefaultVariables, IEquipmentVariables { - public DefaultEquipmentVariables(IDictionary internalVariables = null) : base(ItemVariableTypes.EquipmentVariables, internalVariables) + public DefaultEquipmentVariables(IDictionary internalVariables = null) : base(ItemCoreVariableTypes.EquipmentVariables, internalVariables) { } } diff --git a/src/OpenRpg.Items/Variables/DefaultItemVariables.cs b/src/OpenRpg.Items/Variables/DefaultItemVariables.cs index 762152a..37052cd 100644 --- a/src/OpenRpg.Items/Variables/DefaultItemVariables.cs +++ b/src/OpenRpg.Items/Variables/DefaultItemVariables.cs @@ -6,7 +6,7 @@ namespace OpenRpg.Items.Variables { public class DefaultItemVariables : DefaultVariables, IItemVariables { - public DefaultItemVariables(IDictionary internalVariables = null) : base(ItemVariableTypes.ItemVariables, internalVariables) + public DefaultItemVariables(IDictionary internalVariables = null) : base(ItemCoreVariableTypes.ItemVariables, internalVariables) { } }