diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index 6682aa9..f4e54b1 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -2,7 +2,7 @@ name: Build And Test on: [push] env: - BuildVersion: '0.42.${{github.run_number}}' + BuildVersion: '0.43.${{github.run_number}}' SolutionFile: 'src/OpenRpg.sln' DemoProject: 'src/OpenRpg.Demos.Web/OpenRpg.Demos.Web.csproj' EditorProject: 'src/OpenRpg.Editor/OpenRpg.Editor.csproj' diff --git a/docs/genres.md b/docs/genres.md index 1fd29ee..c7dd1a2 100644 --- a/docs/genres.md +++ b/docs/genres.md @@ -9,7 +9,7 @@ The `Genres` project is a layering/contractual approach that allows you to expre You maybe don't, but if we take a step back and think about more RPG games, there are some common themes/settings/mechanics at play, for example if is list some common `Fantasy` themes: - They often have some form of *Human*, *Dwarf*, *Elf* `Races` - They often have some form of *Fighter*, *Rogue*, *Mage* `Classes` -- They often have the notion of `Health` and `Magic` +- They often have the notion of `Health` and `Mana` - They often have different kinds of `Damage` like *Blunt*, *Fire*, *Wind*, *Piercing* - You can often equip *weapons*, *chest/leg/shoulder/hand* items - You can often modify your equipment with *runes/gems/enchantments* @@ -31,9 +31,9 @@ The other **REALLY IMPORTANT** thing it provides is a contract so everyone using As mentioned above this provides some out the box functionality and type data for common Fantasy themes, so at a high level things like: - Fantasy Stat Types (Strength, Dexterity etc) -- Fantasy State Types (Health, Magic) +- Fantasy State Types (Health, Mana) - Fantasy Damage/Defense Types (Fire, Ice, Wind, Slash, Blunt etc) -- Fantasy Effect Types (Strength Bonus Amount/Percentage, Magic Restore Speed etc) +- Fantasy Effect Types (Strength Bonus Amount/Percentage, Mana Restore Speed etc) > There is so much more and its recommended you check over the classes in the `Types`, `Extensions` namespaces for exact additions this library provides. diff --git a/src/OpenRpg.Demos.Infrastructure/Data/ClassTemplateDataGenerator.cs b/src/OpenRpg.Demos.Infrastructure/Data/ClassTemplateDataGenerator.cs index 5e2dcfe..58636be 100644 --- a/src/OpenRpg.Demos.Infrastructure/Data/ClassTemplateDataGenerator.cs +++ b/src/OpenRpg.Demos.Infrastructure/Data/ClassTemplateDataGenerator.cs @@ -49,7 +49,7 @@ public ClassTemplate GenerateMageClass() new StaticEffect {Potency = 4, EffectType = FantasyEffectTypes.IntelligenceBonusAmount}, new StaticEffect {Potency = 10, EffectType = FantasyEffectTypes.DarkDamageAmount}, new StaticEffect {Potency = 10, EffectType = FantasyEffectTypes.DarkDefenseAmount}, - new StaticEffect {Potency = 30, EffectType = FantasyEffectTypes.MagicBonusAmount} + new StaticEffect {Potency = 30, EffectType = FantasyEffectTypes.ManaBonusAmount} }; var classTemplate = new ClassTemplate diff --git a/src/OpenRpg.Demos.Infrastructure/Data/RaceTemplateDataGenerator.cs b/src/OpenRpg.Demos.Infrastructure/Data/RaceTemplateDataGenerator.cs index bd2cc5c..4e83f17 100644 --- a/src/OpenRpg.Demos.Infrastructure/Data/RaceTemplateDataGenerator.cs +++ b/src/OpenRpg.Demos.Infrastructure/Data/RaceTemplateDataGenerator.cs @@ -31,7 +31,7 @@ public RaceTemplate GenerateHumanTemplate() new StaticEffect {Potency = 1, EffectType = FantasyEffectTypes.DarkDamageAmount}, new StaticEffect {Potency = 5, EffectType = FantasyEffectTypes.DarkDefenseAmount}, new StaticEffect {Potency = 80, EffectType = FantasyEffectTypes.HealthBonusAmount}, - new StaticEffect {Potency = 10, EffectType = FantasyEffectTypes.MagicBonusAmount} + new StaticEffect {Potency = 10, EffectType = FantasyEffectTypes.ManaBonusAmount} }; var raceTemplate = new RaceTemplate @@ -60,7 +60,7 @@ public RaceTemplate GenerateElfTemplate() new StaticEffect {Potency = 5, EffectType = FantasyEffectTypes.DarkDamageAmount}, new StaticEffect {Potency = 10, EffectType = FantasyEffectTypes.DarkDefenseAmount}, new StaticEffect {Potency = 70, EffectType = FantasyEffectTypes.HealthBonusAmount}, - new StaticEffect {Potency = 30, EffectType = FantasyEffectTypes.MagicBonusAmount} + new StaticEffect {Potency = 30, EffectType = FantasyEffectTypes.ManaBonusAmount} }; var raceTemplate = new RaceTemplate diff --git a/src/OpenRpg.Demos.Web/Components/Characters/CharacterVitals.razor b/src/OpenRpg.Demos.Web/Components/Characters/CharacterVitals.razor index 6df91c9..6688f45 100644 --- a/src/OpenRpg.Demos.Web/Components/Characters/CharacterVitals.razor +++ b/src/OpenRpg.Demos.Web/Components/Characters/CharacterVitals.razor @@ -12,8 +12,8 @@
-

Magic

- +

Mana

+
} diff --git a/src/OpenRpg.Demos.Web/Pages/Curves/AdvancedEffects.razor b/src/OpenRpg.Demos.Web/Pages/Curves/AdvancedEffects.razor index ce489d2..5ff8e6d 100644 --- a/src/OpenRpg.Demos.Web/Pages/Curves/AdvancedEffects.razor +++ b/src/OpenRpg.Demos.Web/Pages/Curves/AdvancedEffects.razor @@ -36,7 +36,7 @@ So far everything you have been touching on uses the `StaticEffect` behind the scenes which expresses an `EffectType` and a `Potency`, however the potency is a fixed value, so if its 10, its always going to be 10. For most use cases this is perfectly fine, however imagine if you were making a Souls-like game and you wanted to make a weapon whos - `Damage` stat scaled with your `Strength` stat, or if your `Necromancer` class got a `MaxMagic` boost at night time. + `Damage` stat scaled with your `Strength` stat, or if your `Necromancer` class got a `MaxMana` boost at night time. `ScaledEffects` let you achieve these sorts of use cases by replacing the static `Potency` with a `PotencyFunction` that allows us to *compute* the effects potency based off other factors and plot it on a curve. diff --git a/src/OpenRpg.Demos.Web/Pages/Entities/AdvancedStats.razor b/src/OpenRpg.Demos.Web/Pages/Entities/AdvancedStats.razor index 696a338..184142e 100644 --- a/src/OpenRpg.Demos.Web/Pages/Entities/AdvancedStats.razor +++ b/src/OpenRpg.Demos.Web/Pages/Entities/AdvancedStats.razor @@ -56,7 +56,7 @@ To get around this we try to think about the differences between static vs dynamic data in persistence terms and you generally want to cull all static data on persistence actions as it should all be regenerated when the character is loaded in, the only data - that REALLY needs persisting from the stats is dynamic data like Health and Magic and any other `State` variables you add. + that REALLY needs persisting from the stats is dynamic data like Health and Mana and any other `State` variables you add.
diff --git a/src/OpenRpg.Demos.Web/Pages/Entities/CharacterStatsComponents.razor b/src/OpenRpg.Demos.Web/Pages/Entities/CharacterStatsComponents.razor index b408686..658c4ca 100644 --- a/src/OpenRpg.Demos.Web/Pages/Entities/CharacterStatsComponents.razor +++ b/src/OpenRpg.Demos.Web/Pages/Entities/CharacterStatsComponents.razor @@ -44,7 +44,7 @@ var character = new DefaultEntity(); character.Stats.MaxHealth(100); - character.Stats.MaxMagic(10); + character.Stats.MaxMana(10); character.Stats.Strength(11); character.Stats.Dexterity(12); character.Stats.Intelligence(12); @@ -101,7 +101,7 @@ new Effect {Potency = 1, EffectType = FantasyEffectTypes.DarkDamageAmount}, new Effect {Potency = 5, EffectType = FantasyEffectTypes.DarkDefenseAmount}, new Effect {Potency = 50, EffectType = FantasyEffectTypes.HealthBonusAmount}, - new Effect {Potency = 10, EffectType = FantasyEffectTypes.MagicBonusAmount} + new Effect {Potency = 10, EffectType = FantasyEffectTypes.ManaBonusAmount} }; var classEffects = new[] @@ -228,8 +228,8 @@ ManualStatsExample.Stats = new EntityStatsVariables(); ManualStatsExample.Stats.MaxHealth(100); ManualStatsExample.State.Health(50); - ManualStatsExample.Stats.MaxMagic(10); - ManualStatsExample.State.Magic(7); + ManualStatsExample.Stats.MaxMana(10); + ManualStatsExample.State.Mana(7); ManualStatsExample.Stats.Strength(11); ManualStatsExample.Stats.Dexterity(12); @@ -259,7 +259,7 @@ new StaticEffect {Potency = 1, EffectType = FantasyEffectTypes.DarkDamageAmount}, new StaticEffect {Potency = 5, EffectType = FantasyEffectTypes.DarkDefenseAmount}, new StaticEffect {Potency = 50, EffectType = FantasyEffectTypes.HealthBonusAmount}, - new StaticEffect {Potency = 10, EffectType = FantasyEffectTypes.MagicBonusAmount} + new StaticEffect {Potency = 10, EffectType = FantasyEffectTypes.ManaBonusAmount} }; var classEffects = new[] diff --git a/src/OpenRpg.Demos.Web/Pages/Entities/DefaultEntityClasses.razor b/src/OpenRpg.Demos.Web/Pages/Entities/DefaultEntityClasses.razor index ee02e23..d196981 100644 --- a/src/OpenRpg.Demos.Web/Pages/Entities/DefaultEntityClasses.razor +++ b/src/OpenRpg.Demos.Web/Pages/Entities/DefaultEntityClasses.razor @@ -44,8 +44,8 @@ character.Class = new DefaultCharacterClass(3, new DefaultClassTemplate { NameLocaleId = "Fighter" }); character.Stats.MaxHealth(100); character.State.Health(50); - character.Stats.MaxMagic(10); - character.State.Magic(7); + character.Stats.MaxMana(10); + character.State.Mana(7); character.Stats.Strength(11); character.Stats.Dexterity(12); character.Stats.Intelligence(12); @@ -147,8 +147,8 @@ _manualCharacter.Stats.MaxHealth(100); _manualCharacter.State.Health(50); - _manualCharacter.Stats.MaxMagic(10); - _manualCharacter.State.Magic(7); + _manualCharacter.Stats.MaxMana(10); + _manualCharacter.State.Mana(7); _manualCharacter.Stats.Strength(11); _manualCharacter.Stats.Dexterity(12); diff --git a/src/OpenRpg.Demos.Web/Pages/Items/ItemsWithModifications.razor b/src/OpenRpg.Demos.Web/Pages/Items/ItemsWithModifications.razor index 16c1e99..d8c735c 100644 --- a/src/OpenRpg.Demos.Web/Pages/Items/ItemsWithModifications.razor +++ b/src/OpenRpg.Demos.Web/Pages/Items/ItemsWithModifications.razor @@ -157,7 +157,7 @@ new StaticEffect { EffectType = FantasyEffectTypes.DamageBonusAmount, Potency = 15.0f }, new StaticEffect { EffectType = FantasyEffectTypes.DarkDamageAmount, Potency = 30.0f }, new StaticEffect { EffectType = FantasyEffectTypes.IntelligenceBonusAmount, Potency = 5.0f }, - new StaticEffect { EffectType = FantasyEffectTypes.MagicBonusAmount, Potency = 40.0f } + new StaticEffect { EffectType = FantasyEffectTypes.ManaBonusAmount, Potency = 40.0f } } }; template.Variables.QualityType(FantasyItemQualityTypes.RareQuality); diff --git a/src/OpenRpg.Demos.Web/Pages/Items/ItemsWithRequirements.razor b/src/OpenRpg.Demos.Web/Pages/Items/ItemsWithRequirements.razor index 57d7350..4d2753a 100644 --- a/src/OpenRpg.Demos.Web/Pages/Items/ItemsWithRequirements.razor +++ b/src/OpenRpg.Demos.Web/Pages/Items/ItemsWithRequirements.razor @@ -160,7 +160,7 @@ new StaticEffect { EffectType = FantasyEffectTypes.DamageBonusAmount, Potency = 15.0f }, new StaticEffect { EffectType = FantasyEffectTypes.DarkDamageAmount, Potency = 30.0f }, new StaticEffect { EffectType = FantasyEffectTypes.IntelligenceBonusAmount, Potency = 5.0f }, - new StaticEffect { EffectType = FantasyEffectTypes.MagicBonusAmount, Potency = 40.0f } + new StaticEffect { EffectType = FantasyEffectTypes.ManaBonusAmount, Potency = 40.0f } } }; template.Variables.QualityType(FantasyItemQualityTypes.RareQuality); diff --git a/src/OpenRpg.Entities/Types/CoreTemplateDataVariableTypes.cs b/src/OpenRpg.Entities/Types/CoreTemplateDataVariableTypes.cs index a56b52b..4a1478a 100644 --- a/src/OpenRpg.Entities/Types/CoreTemplateDataVariableTypes.cs +++ b/src/OpenRpg.Entities/Types/CoreTemplateDataVariableTypes.cs @@ -9,6 +9,6 @@ public interface CoreTemplateDataVariableTypes public static int Level = 5001; // For adding the procedural associations - public static int ProceduralAssociations = 5001; + public static int ProceduralAssociations = 5002; } } \ No newline at end of file diff --git a/src/OpenRpg.Genres.Fantasy/Extensions/EntityStatVariableExtensions.cs b/src/OpenRpg.Genres.Fantasy/Extensions/EntityStatVariableExtensions.cs index 3f1ff61..ea80692 100644 --- a/src/OpenRpg.Genres.Fantasy/Extensions/EntityStatVariableExtensions.cs +++ b/src/OpenRpg.Genres.Fantasy/Extensions/EntityStatVariableExtensions.cs @@ -18,11 +18,11 @@ public static class EntityStatVariableExtensions public static void Wisdom(this EntityStatsVariables stats, int value) => stats[FantasyEntityStatsVariableTypes.Wisdom] = value; public static void Charisma(this EntityStatsVariables stats, int value) => stats[FantasyEntityStatsVariableTypes.Charisma] = value; - public static void MaxMagic(this EntityStatsVariables stats, int value) => stats[FantasyEntityStatsVariableTypes.MaxMagic] = value; - public static int MaxMagic(this EntityStatsVariables stats) => (int)stats.Get(FantasyEntityStatsVariableTypes.MaxMagic); + public static void MaxMana(this EntityStatsVariables stats, int value) => stats[FantasyEntityStatsVariableTypes.MaxMana] = value; + public static int MaxMana(this EntityStatsVariables stats) => (int)stats.Get(FantasyEntityStatsVariableTypes.MaxMana); - public static void MagicRegen(this EntityStatsVariables stats, float value) => stats[FantasyEntityStatsVariableTypes.MagicRegen] = value; - public static float MagicRegen(this EntityStatsVariables stats) => stats.Get(FantasyEntityStatsVariableTypes.MagicRegen); + public static void ManaRegen(this EntityStatsVariables stats, float value) => stats[FantasyEntityStatsVariableTypes.ManaRegen] = value; + public static float ManaRegen(this EntityStatsVariables stats) => stats.Get(FantasyEntityStatsVariableTypes.ManaRegen); public static float IceDamage(this EntityStatsVariables stats) => stats.Get(FantasyEntityStatsVariableTypes.IceDamage); public static float FireDamage(this EntityStatsVariables stats) => stats.Get(FantasyEntityStatsVariableTypes.FireDamage); diff --git a/src/OpenRpg.Genres.Fantasy/Extensions/EntityStateVariableExtensions.cs b/src/OpenRpg.Genres.Fantasy/Extensions/EntityStateVariableExtensions.cs index e936f1f..a33025d 100644 --- a/src/OpenRpg.Genres.Fantasy/Extensions/EntityStateVariableExtensions.cs +++ b/src/OpenRpg.Genres.Fantasy/Extensions/EntityStateVariableExtensions.cs @@ -6,25 +6,25 @@ namespace OpenRpg.Genres.Fantasy.Extensions { public static class EntityStateVariableExtensions { - public static int Magic(this EntityStateVariables state) => (int)state.Get(FantasyEntityStateVariableTypes.Magic); - public static void Magic(this EntityStateVariables state, int value) => state[FantasyEntityStateVariableTypes.Magic] = value; + public static int Mana(this EntityStateVariables state) => (int)state.Get(FantasyEntityStateVariableTypes.Mana); + public static void Mana(this EntityStateVariables state, int value) => state[FantasyEntityStateVariableTypes.Mana] = value; - public static void AddMagic(this EntityStateVariables state, int change, int? maxMagic = null) + public static void AddMana(this EntityStateVariables state, int change, int? maxMana = null) { - var newValue = state.Magic() + change; - if (maxMagic.HasValue) - { state.AddValue(FantasyEntityStateVariableTypes.Magic, newValue, 0, maxMagic.Value); } + var newValue = state.Mana() + change; + if (maxMana.HasValue) + { state.AddValue(FantasyEntityStateVariableTypes.Mana, newValue, 0, maxMana.Value); } else - { state.Magic(newValue); } + { state.Mana(newValue); } } - public static void DeductMagic(this EntityStateVariables state, int change, int? maxMagic = null) + public static void DeductMana(this EntityStateVariables state, int change, int? maxMana = null) { - var newValue = state.Magic() - change; - if (maxMagic.HasValue) - { state.AddValue(FantasyEntityStateVariableTypes.Magic, newValue, 0, maxMagic.Value); } + var newValue = state.Mana() - change; + if (maxMana.HasValue) + { state.AddValue(FantasyEntityStateVariableTypes.Mana, newValue, 0, maxMana.Value); } else - { state.Magic(newValue); } + { state.Mana(newValue); } } } } \ No newline at end of file diff --git a/src/OpenRpg.Genres.Fantasy/Extensions/FantasyEntityExtensions.cs b/src/OpenRpg.Genres.Fantasy/Extensions/FantasyEntityExtensions.cs new file mode 100644 index 0000000..b2e282e --- /dev/null +++ b/src/OpenRpg.Genres.Fantasy/Extensions/FantasyEntityExtensions.cs @@ -0,0 +1,10 @@ +using OpenRpg.Entities.Entity; + +namespace OpenRpg.Genres.Fantasy.Extensions +{ + public static class FantasyEntityExtensions + { + public static float GetManaPercentage(this Entity entity) + { return (float)entity.State.Mana() / entity.Stats.MaxMana(); } + } +} \ No newline at end of file diff --git a/src/OpenRpg.Genres.Fantasy/Requirements/DefaultFantasyCharacterRequirementChecker.cs b/src/OpenRpg.Genres.Fantasy/Requirements/DefaultFantasyCharacterRequirementChecker.cs index ff2f05a..c978273 100644 --- a/src/OpenRpg.Genres.Fantasy/Requirements/DefaultFantasyCharacterRequirementChecker.cs +++ b/src/OpenRpg.Genres.Fantasy/Requirements/DefaultFantasyCharacterRequirementChecker.cs @@ -29,8 +29,8 @@ public override bool IsRequirementMet(Character character, Requirement requireme if(requirement.RequirementType == FantasyRequirementTypes.CharismaRequirement) { return character.Stats.Charisma() >= requirement.Association.AssociatedValue; } - if(requirement.RequirementType == FantasyRequirementTypes.MaxMagicRequirement) - { return character.Stats.MaxMagic() >= requirement.Association.AssociatedValue; } + if(requirement.RequirementType == FantasyRequirementTypes.MaxManaRequirement) + { return character.Stats.MaxMana() >= requirement.Association.AssociatedValue; } return base.IsRequirementMet(character, requirement); } diff --git a/src/OpenRpg.Genres.Fantasy/State/Populators/FantasyStatePopulator.cs b/src/OpenRpg.Genres.Fantasy/State/Populators/FantasyStatePopulator.cs index 2422433..f787143 100644 --- a/src/OpenRpg.Genres.Fantasy/State/Populators/FantasyStatePopulator.cs +++ b/src/OpenRpg.Genres.Fantasy/State/Populators/FantasyStatePopulator.cs @@ -20,7 +20,8 @@ public void Populate(EntityStateVariables state, ComputedEffects computedEffects var entityStats = statsVars as EntityStatsVariables; state.Health(entityStats.MaxHealth()); - state.Magic(entityStats.MaxMagic()); + state.Stamina(entityStats.MaxStamina()); + state.Mana(entityStats.MaxMana()); } } } \ No newline at end of file diff --git a/src/OpenRpg.Genres.Fantasy/Stats/Populators/FantasyStatsPopulator.cs b/src/OpenRpg.Genres.Fantasy/Stats/Populators/FantasyStatsPopulator.cs index 1dfb116..69f1b5f 100644 --- a/src/OpenRpg.Genres.Fantasy/Stats/Populators/FantasyStatsPopulator.cs +++ b/src/OpenRpg.Genres.Fantasy/Stats/Populators/FantasyStatsPopulator.cs @@ -18,6 +18,7 @@ public FantasyStatsPopulator(IEnumerable additional new FantasyMeleeStatPopulator(), new FantasyElementalStatPopulator(), new AbilityStatPopulator(), + new CriticalStatPopulator() }; if (additionalStatPopulators != null) diff --git a/src/OpenRpg.Genres.Fantasy/Stats/Populators/Partial/FantasyMeleeStatPopulator.cs b/src/OpenRpg.Genres.Fantasy/Stats/Populators/Partial/FantasyMeleeStatPopulator.cs index e1c94f3..77f202e 100644 --- a/src/OpenRpg.Genres.Fantasy/Stats/Populators/Partial/FantasyMeleeStatPopulator.cs +++ b/src/OpenRpg.Genres.Fantasy/Stats/Populators/Partial/FantasyMeleeStatPopulator.cs @@ -5,9 +5,11 @@ using OpenRpg.Entities.Effects.Processors; using OpenRpg.Entities.Entity.Populators.Stats; using OpenRpg.Entities.Stats.Variables; +using OpenRpg.Genres.Extensions; using OpenRpg.Genres.Fantasy.Effects; using OpenRpg.Genres.Fantasy.Extensions; using OpenRpg.Genres.Fantasy.Types; +using OpenRpg.Genres.Types; namespace OpenRpg.Genres.Fantasy.Stats.Populators.Partial { @@ -37,7 +39,6 @@ public void Populate(EntityStatsVariables stats, ComputedEffects computedEffects stats.PiercingDefense(CalculateStatsWithModifier(computedEffects, FantasyEffectTypes.AllMeleeDefenseBonusPercentage, FantasyEffectTypes.AllMeleeDefenseBonusPercentage, EffectRelationships.PiercingDefenseRelationship, piercingModifier)); stats.SlashingDefense(CalculateStatsWithModifier(computedEffects, FantasyEffectTypes.AllMeleeDefenseBonusPercentage, FantasyEffectTypes.AllMeleeDefenseBonusPercentage, EffectRelationships.SlashingDefenseRelationship, slashingOrUnarmedModifier)); stats.UnarmedDefense(CalculateStatsWithModifier(computedEffects, FantasyEffectTypes.AllMeleeDefenseBonusPercentage, FantasyEffectTypes.AllMeleeDefenseBonusPercentage, EffectRelationships.UnarmedDefenseRelationship, slashingOrUnarmedModifier)); - } } } \ No newline at end of file diff --git a/src/OpenRpg.Genres.Fantasy/Stats/Populators/Partial/FantasyVitalsStatPopulator.cs b/src/OpenRpg.Genres.Fantasy/Stats/Populators/Partial/FantasyVitalsStatPopulator.cs index 6cf910a..4d6d688 100644 --- a/src/OpenRpg.Genres.Fantasy/Stats/Populators/Partial/FantasyVitalsStatPopulator.cs +++ b/src/OpenRpg.Genres.Fantasy/Stats/Populators/Partial/FantasyVitalsStatPopulator.cs @@ -20,12 +20,18 @@ public void Populate(EntityStatsVariables stats, ComputedEffects computedEffects var maxHealth = (int)computedEffects.CalculateTotalValueFor(FantasyEffectTypes.HealthBonusAmount, FantasyEffectTypes.HealthBonusPercentage, constitutionBonus); stats.MaxHealth(maxHealth); + var maxStamina = (int)computedEffects.CalculateTotalValueFor(FantasyEffectTypes.StaminaBonusAmount, FantasyEffectTypes.StaminaBonusPercentage, constitutionBonus); + stats.MaxStamina(maxStamina); + var intelligenceBonus = stats.Intelligence() * 5; - var maxMagic = (int)computedEffects.CalculateTotalValueFor(FantasyEffectTypes.MagicBonusAmount, FantasyEffectTypes.MagicBonusPercentage, intelligenceBonus); - stats.MaxMagic(maxMagic); + var maxMana = (int)computedEffects.CalculateTotalValueFor(FantasyEffectTypes.ManaBonusAmount, FantasyEffectTypes.ManaBonusPercentage, intelligenceBonus); + stats.MaxMana(maxMana); stats.HealthRegen(computedEffects.CalculateTotalValueFor(FantasyEffectTypes.HealthRegenBonusAmount, FantasyEffectTypes.HealthRegenBonusPercentage)); - stats.MagicRegen(computedEffects.CalculateTotalValueFor(FantasyEffectTypes.MagicRegenBonusAmount, FantasyEffectTypes.MagicRegenBonusPercentage)); + stats.ManaRegen(computedEffects.CalculateTotalValueFor(FantasyEffectTypes.ManaRegenBonusAmount, FantasyEffectTypes.ManaRegenBonusPercentage)); + stats.StaminaRegen(computedEffects.CalculateTotalValueFor(FantasyEffectTypes.StaminaRegenBonusAmount, FantasyEffectTypes.StaminaRegenBonusPercentage)); + + stats.MovementSpeed(computedEffects.CalculateTotalValueFor(FantasyEffectTypes.MovementSpeedBonusAmount, FantasyEffectTypes.MovementSpeedBonusPercentage)); } } } \ No newline at end of file diff --git a/src/OpenRpg.Genres.Fantasy/Types/FantasyEffectTypes.cs b/src/OpenRpg.Genres.Fantasy/Types/FantasyEffectTypes.cs index ba59c12..4b39680 100644 --- a/src/OpenRpg.Genres.Fantasy/Types/FantasyEffectTypes.cs +++ b/src/OpenRpg.Genres.Fantasy/Types/FantasyEffectTypes.cs @@ -3,111 +3,106 @@ namespace OpenRpg.Genres.Fantasy.Types public interface FantasyEffectTypes : Genres.Types.GenreEffectTypes { // Generic Melee/Magic - public static readonly int AllMeleeAttackBonusAmount = 50; - public static readonly int AllMeleeDefenseBonusAmount = 51; - public static readonly int AllElementDamageBonusAmount = 53; - public static readonly int AllElementDefenseBonusAmount = 54; - public static readonly int AllMeleeAttackBonusPercentage = 55; - public static readonly int AllMeleeDefenseBonusPercentage = 56; - public static readonly int AllElementDamageBonusPercentage = 57; - public static readonly int AllElementDefenseBonusPercentage = 58; + public static readonly int AllMeleeAttackBonusAmount = 200; + public static readonly int AllMeleeDefenseBonusAmount = 201; + public static readonly int AllElementDamageBonusAmount = 203; + public static readonly int AllElementDefenseBonusAmount = 204; + public static readonly int AllMeleeAttackBonusPercentage = 205; + public static readonly int AllMeleeDefenseBonusPercentage = 206; + public static readonly int AllElementDamageBonusPercentage = 207; + public static readonly int AllElementDefenseBonusPercentage = 208; - // General Attribute Amount - public static readonly int DexterityBonusAmount = 70; - public static readonly int IntelligenceBonusAmount = 71; - public static readonly int WisdomBonusAmount = 72; - public static readonly int StrengthBonusAmount = 73; - public static readonly int ConstitutionBonusAmount = 74; - public static readonly int CharismaBonusAmount = 75; - public static readonly int MagicRegenBonusAmount = 76; - public static readonly int MagicRegenBonusPercentage = 78; - public static readonly int MagicBonusAmount = 77; - public static readonly int MagicRestoreAmount = 79; - public static readonly int ExperienceRestoreAmount = 80; + // General Attribute + public static readonly int StrengthBonusAmount = 220; + public static readonly int StrengthBonusPercentage = 221; + public static readonly int DexterityBonusAmount = 222; + public static readonly int DexterityBonusPercentage = 223; + public static readonly int ConstitutionBonusAmount = 224; + public static readonly int ConstitutionBonusPercentage = 225; + public static readonly int IntelligenceBonusAmount = 226; + public static readonly int IntelligenceBonusPercentage = 227; + public static readonly int WisdomBonusAmount = 228; + public static readonly int WisdomBonusPercentage = 229; + public static readonly int CharismaBonusAmount = 230; + public static readonly int CharismaBonusPercentage = 231; + public static readonly int ManaRegenBonusAmount = 232; + public static readonly int ManaRegenBonusPercentage = 233; + public static readonly int ManaBonusAmount = 234; + public static readonly int ManaBonusPercentage = 235; + public static readonly int ManaRestoreAmount = 236; + public static readonly int ManaRestorePercentage = 237; - // General Attribute Percentage - public static readonly int DexterityBonusPercentage = 90; - public static readonly int IntelligenceBonusPercentage = 91; - public static readonly int WisdomBonusPercentage = 92; - public static readonly int StrengthBonusPercentage = 93; - public static readonly int ConstitutionBonusPercentage = 94; - public static readonly int CharismaBonusPercentage = 95; - public static readonly int HealthBonusPercentage = 96; - public static readonly int HealthRestorePercentage = 97; - public static readonly int MagicBonusPercentage = 98; - public static readonly int MagicRestorePercentage = 99; - public static readonly int ExperienceRestorePercentage = 100; // Melee Damage (Damage Types) - public static readonly int SlashingDamageAmount = 110; - public static readonly int PiercingDamageAmount = 111; - public static readonly int BluntDamageAmount = 112; - public static readonly int UnarmedDamageAmount = 113; - public static readonly int SlashingDamagePercentage = 114; - public static readonly int PiercingDamagePercentage = 115; - public static readonly int BluntDamagePercentage = 116; - public static readonly int UnarmedDamagePercentage = 117; + public static readonly int SlashingDamageAmount = 260; + public static readonly int PiercingDamageAmount = 261; + public static readonly int BluntDamageAmount = 262; + public static readonly int UnarmedDamageAmount = 263; + public static readonly int SlashingDamagePercentage = 264; + public static readonly int PiercingDamagePercentage = 265; + public static readonly int BluntDamagePercentage = 266; + public static readonly int UnarmedDamagePercentage = 267; // Melee Defense (Defense Types) - public static readonly int SlashingDefenseAmount = 130; - public static readonly int PiercingDefenseAmount = 131; - public static readonly int BluntDefenseAmount = 132; - public static readonly int UnarmedDefenseAmount = 133; - public static readonly int SlashingDefensePercentage = 134; - public static readonly int PiercingDefensePercentage = 135; - public static readonly int BluntDefensePercentage = 136; - public static readonly int UnarmedDefensePercentage = 137; + public static readonly int SlashingDefenseAmount = 290; + public static readonly int PiercingDefenseAmount = 291; + public static readonly int BluntDefenseAmount = 292; + public static readonly int UnarmedDefenseAmount = 293; + public static readonly int SlashingDefensePercentage = 294; + public static readonly int PiercingDefensePercentage = 295; + public static readonly int BluntDefensePercentage = 296; + public static readonly int UnarmedDefensePercentage = 297; // Melee Type Bonus (Damage/Defense Bonus) - public static readonly int SlashingBonusAmount = 150; - public static readonly int PiercingBonusAmount = 151; - public static readonly int BluntBonusAmount = 152; - public static readonly int UnarmedBonusAmount = 153; - public static readonly int SlashingBonusPercentage = 154; - public static readonly int PiercingBonusPercentage = 155; - public static readonly int BluntBonusPercentage = 156; - public static readonly int UnarmedBonusPercentage = 157; + public static readonly int SlashingBonusAmount = 320; + public static readonly int PiercingBonusAmount = 321; + public static readonly int BluntBonusAmount = 322; + public static readonly int UnarmedBonusAmount = 323; + public static readonly int SlashingBonusPercentage = 324; + public static readonly int PiercingBonusPercentage = 325; + public static readonly int BluntBonusPercentage = 326; + public static readonly int UnarmedBonusPercentage = 327; // Magic Damage (Raw Damage) - public static readonly int FireDamageAmount = 170; - public static readonly int IceDamageAmount = 171; - public static readonly int EarthDamageAmount = 172; - public static readonly int WindDamageAmount = 173; - public static readonly int LightDamageAmount = 174; - public static readonly int DarkDamageAmount = 175; - public static readonly int FireDamagePercentage = 176; - public static readonly int IceDamagePercentage = 177; - public static readonly int EarthDamagePercentage = 178; - public static readonly int WindDamagePercentage = 179; - public static readonly int LightDamagePercentage = 180; - public static readonly int DarkDamagePercentage = 181; + public static readonly int FireDamageAmount = 350; + public static readonly int IceDamageAmount = 351; + public static readonly int EarthDamageAmount = 352; + public static readonly int WindDamageAmount = 353; + public static readonly int LightDamageAmount = 354; + public static readonly int DarkDamageAmount = 355; + public static readonly int FireDamagePercentage = 356; + public static readonly int IceDamagePercentage = 357; + public static readonly int EarthDamagePercentage = 358; + public static readonly int WindDamagePercentage = 359; + public static readonly int LightDamagePercentage = 360; + public static readonly int DarkDamagePercentage = 361; // Magic Defense (Defense Bonus) - public static readonly int FireDefenseAmount = 200; - public static readonly int IceDefenseAmount = 201; - public static readonly int EarthDefenseAmount = 202; - public static readonly int WindDefenseAmount = 204; - public static readonly int LightDefenseAmount = 205; - public static readonly int DarkDefenseAmount = 206; - public static readonly int FireDefensePercentage = 207; - public static readonly int IceDefensePercentage = 208; - public static readonly int EarthDefensePercentage = 209; - public static readonly int WindDefensePercentage = 210; - public static readonly int LightDefensePercentage = 211; - public static readonly int DarkDefensePercentage = 212; + public static readonly int FireDefenseAmount = 390; + public static readonly int IceDefenseAmount = 391; + public static readonly int EarthDefenseAmount = 392; + public static readonly int WindDefenseAmount = 393; + public static readonly int LightDefenseAmount = 394; + public static readonly int DarkDefenseAmount = 395; + public static readonly int FireDefensePercentage = 396; + public static readonly int IceDefensePercentage = 397; + public static readonly int EarthDefensePercentage = 398; + public static readonly int WindDefensePercentage = 399; + public static readonly int LightDefensePercentage = 400; + public static readonly int DarkDefensePercentage = 401; // Magic Bonus (Damage Bonus) - public static readonly int FireBonusAmount = 230; - public static readonly int IceBonusAmount = 231; - public static readonly int EarthBonusAmount = 232; - public static readonly int WindBonusAmount = 233; - public static readonly int LightBonusAmount = 234; - public static readonly int DarkBonusAmount = 235; - public static readonly int FireBonusPercentage = 236; - public static readonly int IceBonusPercentage = 237; - public static readonly int EarthBonusPercentage = 238; - public static readonly int WindBonusPercentage = 239; - public static readonly int LightBonusPercentage = 240; - public static readonly int DarkBonusPercentage = 241; + public static readonly int FireBonusAmount = 430; + public static readonly int IceBonusAmount = 431; + public static readonly int EarthBonusAmount = 432; + public static readonly int WindBonusAmount = 433; + public static readonly int LightBonusAmount = 434; + public static readonly int DarkBonusAmount = 435; + public static readonly int FireBonusPercentage = 436; + public static readonly int IceBonusPercentage = 437; + public static readonly int EarthBonusPercentage = 438; + public static readonly int WindBonusPercentage = 439; + public static readonly int LightBonusPercentage = 440; + public static readonly int DarkBonusPercentage = 441; } } \ No newline at end of file diff --git a/src/OpenRpg.Genres.Fantasy/Types/FantasyEntityStateVariableTypes.cs b/src/OpenRpg.Genres.Fantasy/Types/FantasyEntityStateVariableTypes.cs index 9127680..43800ea 100644 --- a/src/OpenRpg.Genres.Fantasy/Types/FantasyEntityStateVariableTypes.cs +++ b/src/OpenRpg.Genres.Fantasy/Types/FantasyEntityStateVariableTypes.cs @@ -4,6 +4,6 @@ namespace OpenRpg.Genres.Fantasy.Types { public interface FantasyEntityStateVariableTypes : GenreEntityStateVariableTypes { - public static int Magic = 51; + public static int Mana = 51; } } \ No newline at end of file diff --git a/src/OpenRpg.Genres.Fantasy/Types/FantasyEntityStatsVariableTypes.cs b/src/OpenRpg.Genres.Fantasy/Types/FantasyEntityStatsVariableTypes.cs index 26b9b46..b00e471 100644 --- a/src/OpenRpg.Genres.Fantasy/Types/FantasyEntityStatsVariableTypes.cs +++ b/src/OpenRpg.Genres.Fantasy/Types/FantasyEntityStatsVariableTypes.cs @@ -2,8 +2,8 @@ namespace OpenRpg.Genres.Fantasy.Types { public interface FantasyEntityStatsVariableTypes : Genres.Types.GenreEntityStatsVariableTypes { - public static readonly int MaxMagic = 50; - public static readonly int MagicRegen = 51; + public static readonly int MaxMana = 50; + public static readonly int ManaRegen = 51; // Base stats public static readonly int Strength = 60; diff --git a/src/OpenRpg.Genres.Fantasy/Types/FantasyRequirementTypes.cs b/src/OpenRpg.Genres.Fantasy/Types/FantasyRequirementTypes.cs index 54052fb..63f4a5f 100644 --- a/src/OpenRpg.Genres.Fantasy/Types/FantasyRequirementTypes.cs +++ b/src/OpenRpg.Genres.Fantasy/Types/FantasyRequirementTypes.cs @@ -8,6 +8,6 @@ public interface FantasyRequirementTypes : Genres.Types.GenreRequirementTypes public static readonly int IntelligenceRequirement = 53; public static readonly int WisdomRequirement = 54; public static readonly int CharismaRequirement = 55; - public static readonly int MaxMagicRequirement = 56; + public static readonly int MaxManaRequirement = 56; } } \ No newline at end of file diff --git a/src/OpenRpg.Genres/Extensions/EntityExtensions.cs b/src/OpenRpg.Genres/Extensions/EntityExtensions.cs index b543dee..46084d0 100644 --- a/src/OpenRpg.Genres/Extensions/EntityExtensions.cs +++ b/src/OpenRpg.Genres/Extensions/EntityExtensions.cs @@ -1,7 +1,6 @@ using System.Collections.Generic; using OpenRpg.Core.Effects; using OpenRpg.Core.Templates; -using OpenRpg.Entities.Effects; using OpenRpg.Entities.Entity; using OpenRpg.Entities.Extensions; using OpenRpg.Items.Extensions; @@ -19,5 +18,11 @@ public static IReadOnlyCollection GetEffects(this Entity entity, ITempl if (entity.Variables.HasEquipment()) { effects.AddRange(entity.Variables.Equipment().GetEffects(templateAccessor)); } return effects; } + + public static float GetHealthPercentage(this Entity entity) + { return (float)entity.State.Health() / entity.Stats.MaxHealth(); } + + public static float GetStaminaPercentage(this Entity entity) + { return (float)entity.State.Stamina() / entity.Stats.MaxStamina(); } } } \ No newline at end of file diff --git a/src/OpenRpg.Genres/Extensions/EntityStatVariableExtensions.cs b/src/OpenRpg.Genres/Extensions/EntityStatVariableExtensions.cs index 4949679..de3cb9b 100644 --- a/src/OpenRpg.Genres/Extensions/EntityStatVariableExtensions.cs +++ b/src/OpenRpg.Genres/Extensions/EntityStatVariableExtensions.cs @@ -9,11 +9,19 @@ public static class EntityStatVariableExtensions public static int MaxHealth(this EntityStatsVariables stats) => (int)stats.Get(GenreEntityStatsVariableTypes.MaxHealth); public static void MaxHealth(this EntityStatsVariables stats, int value) => stats[GenreEntityStatsVariableTypes.MaxHealth] = value; + public static int MaxStamina(this EntityStatsVariables stats) => (int)stats.Get(GenreEntityStatsVariableTypes.MaxStamina); + public static void MaxStamina(this EntityStatsVariables stats, int value) => stats[GenreEntityStatsVariableTypes.MaxStamina] = value; + public static float Damage(this EntityStatsVariables stats) => stats.Get(GenreEntityStatsVariableTypes.Damage); public static void Damage(this EntityStatsVariables stats, float value) => stats[GenreEntityStatsVariableTypes.Damage] = value; public static float Defense(this EntityStatsVariables stats) => stats.Get(GenreEntityStatsVariableTypes.Defense); public static void Defense(this EntityStatsVariables stats, float value) => stats[GenreEntityStatsVariableTypes.Defense] = value; + public static float CriticalDamageChance(this EntityStatsVariables stats) => stats.GetValueOrDefault(GenreEntityStatsVariableTypes.CriticalDamageChance, 0); + public static void CriticalDamageChance(this EntityStatsVariables stats, float criticalDamageChance) => stats[GenreEntityStatsVariableTypes.CriticalDamageChance] = criticalDamageChance; + public static float CriticalDamageMultiplier(this EntityStatsVariables stats) => stats.GetValueOrDefault(GenreEntityStatsVariableTypes.CriticalDamageMultiplier, 0); + public static void CriticalDamageMultiplier(this EntityStatsVariables stats, float criticalDamageMultiplier) => stats[GenreEntityStatsVariableTypes.CriticalDamageMultiplier] = criticalDamageMultiplier; + public static float CooldownReduction(this EntityStatsVariables stats) => stats.GetValueOrDefault(GenreEntityStatsVariableTypes.CooldownReduction, 0); public static void CooldownReduction(this EntityStatsVariables stats, float cooldownReduction) => stats[GenreEntityStatsVariableTypes.CooldownReduction] = cooldownReduction; @@ -24,6 +32,12 @@ public static class EntityStatVariableExtensions public static void AttackRange(this EntityStatsVariables stats, float attackSpeed) => stats[GenreEntityStatsVariableTypes.AttackRange] = attackSpeed; public static float HealthRegen(this EntityStatsVariables stats) => stats.GetValueOrDefault(GenreEntityStatsVariableTypes.HealthRegen, 0); - public static void HealthRegen(this EntityStatsVariables stats, float healthRegen) => stats[GenreEntityStatsVariableTypes.HealthRegen] = healthRegen; + public static void HealthRegen(this EntityStatsVariables stats, float staminaRegen) => stats[GenreEntityStatsVariableTypes.HealthRegen] = staminaRegen; + + public static float StaminaRegen(this EntityStatsVariables stats) => stats.GetValueOrDefault(GenreEntityStatsVariableTypes.StaminaRegen, 0); + public static void StaminaRegen(this EntityStatsVariables stats, float staminaRegen) => stats[GenreEntityStatsVariableTypes.StaminaRegen] = staminaRegen; + + public static float MovementSpeed(this EntityStatsVariables stats) => stats.GetValueOrDefault(GenreEntityStatsVariableTypes.MovementSpeed, 0); + public static void MovementSpeed(this EntityStatsVariables stats, float movementSpeed) => stats[GenreEntityStatsVariableTypes.MovementSpeed] = movementSpeed; } } \ No newline at end of file diff --git a/src/OpenRpg.Genres/Extensions/EntityStateVariablesExtensions.cs b/src/OpenRpg.Genres/Extensions/EntityStateVariablesExtensions.cs index d78c74e..d6f1ec4 100644 --- a/src/OpenRpg.Genres/Extensions/EntityStateVariablesExtensions.cs +++ b/src/OpenRpg.Genres/Extensions/EntityStateVariablesExtensions.cs @@ -12,6 +12,9 @@ public static class EntityStateVariablesExtensions public static int Health(this EntityStateVariables state) => (int)state.Get(GenreEntityStateVariableTypes.Health); public static void Health(this EntityStateVariables state, int value) => state[GenreEntityStateVariableTypes.Health] = value; + public static int Stamina(this EntityStateVariables state) => (int)state.Get(GenreEntityStateVariableTypes.Stamina); + public static void Stamina(this EntityStateVariables state, int value) => state[GenreEntityStateVariableTypes.Stamina] = value; + public static void AddHealth(this EntityStateVariables state, int change, int? maxHealth = null) { var newValue = state.Health() + change; @@ -34,6 +37,28 @@ public static void DeductHealth(this EntityStateVariables state, int change, int { state.AddValue(GenreEntityStateVariableTypes.Health, newValue, 0, maxHealth.Value); } } + public static void AddStamina(this EntityStateVariables state, int change, int? maxStamina = null) + { + var newValue = state.Health() + change; + if(newValue <= 0) { newValue = 0; } + + if(maxStamina == null) + { state.Stamina(newValue); } + else + { state.AddValue(GenreEntityStateVariableTypes.Stamina, newValue, 0, maxStamina.Value); } + } + + public static void DeductStamina(this EntityStateVariables state, int change, int? maxStamina = null) + { + var newValue = state.Health() - change; + if(newValue <= 0) { newValue = 0; } + + if (maxStamina == null) + { state.Stamina(newValue); } + else + { state.AddValue(GenreEntityStateVariableTypes.Health, newValue, 0, maxStamina.Value); } + } + public static void ApplyDamageToTarget(this EntityStateVariables state, ProcessedAttack attack) { var summedAttack = attack.DamageDone.Sum(x => x.Value); diff --git a/src/OpenRpg.Genres/Populators/Entity/State/BasicEntityStatePopulator.cs b/src/OpenRpg.Genres/Populators/Entity/State/BasicEntityStatePopulator.cs index d7d1997..7634379 100644 --- a/src/OpenRpg.Genres/Populators/Entity/State/BasicEntityStatePopulator.cs +++ b/src/OpenRpg.Genres/Populators/Entity/State/BasicEntityStatePopulator.cs @@ -19,6 +19,7 @@ public void Populate(EntityStateVariables varsToPopulate, ComputedEffects comput var entityStats = statsVars as EntityStatsVariables; varsToPopulate.Health(entityStats.MaxHealth()); + varsToPopulate.Stamina(entityStats.MaxStamina()); } } } \ No newline at end of file diff --git a/src/OpenRpg.Genres/Populators/Entity/Stats/CriticalStatPopulator.cs b/src/OpenRpg.Genres/Populators/Entity/Stats/CriticalStatPopulator.cs new file mode 100644 index 0000000..76a77e2 --- /dev/null +++ b/src/OpenRpg.Genres/Populators/Entity/Stats/CriticalStatPopulator.cs @@ -0,0 +1,24 @@ +using System.Collections.Generic; +using OpenRpg.Core.Variables; +using OpenRpg.Entities.Effects.Processors; +using OpenRpg.Entities.Entity.Populators.Stats; +using OpenRpg.Entities.Extensions; +using OpenRpg.Entities.Stats.Variables; +using OpenRpg.Genres.Extensions; +using OpenRpg.Genres.Types; + +namespace OpenRpg.Genres.Populators.Entity.Stats +{ + public class CriticalStatPopulator : IEntityPartialStatPopulator + { + public int Priority => 10; + + public void Populate(EntityStatsVariables stats, ComputedEffects computedEffects, IReadOnlyCollection relatedVars) + { + stats.CriticalDamageChance(computedEffects.CalculateTotalValueFor(GenreEffectTypes.CriticalRateBonusAmount, + GenreEffectTypes.CriticalRateBonusPercentage)); + stats.CriticalDamageMultiplier(computedEffects.CalculateTotalValueFor(GenreEffectTypes.CriticalDamageBonusAmount, + GenreEffectTypes.CriticalDamageBonusPercentage)); + } + } +} \ No newline at end of file diff --git a/src/OpenRpg.Genres/Populators/Entity/Stats/DamageStatPopulator.cs b/src/OpenRpg.Genres/Populators/Entity/Stats/DamageStatPopulator.cs index f28b321..0b89826 100644 --- a/src/OpenRpg.Genres/Populators/Entity/Stats/DamageStatPopulator.cs +++ b/src/OpenRpg.Genres/Populators/Entity/Stats/DamageStatPopulator.cs @@ -13,23 +13,11 @@ namespace OpenRpg.Genres.Populators.Entity.Stats public class DamageStatPopulator : IEntityPartialStatPopulator { public int Priority => 10; - - public float ComputeTotal(ComputedEffects computedEffects) - { - var amount = computedEffects.Get(GenreEffectTypes.DamageBonusAmount); - var percentage = computedEffects.Get(GenreEffectTypes.DamageBonusPercentage); - - if (percentage == 0) - { return amount; } - - var addition = amount * (percentage/100); - return amount + addition; - } public void Populate(EntityStatsVariables stats, ComputedEffects computedEffects, IReadOnlyCollection relatedVars) { - var totalValue = ComputeTotal(computedEffects); - stats.Damage(totalValue); + stats.Damage(computedEffects.CalculateTotalValueFor(GenreEffectTypes.DamageBonusAmount, + GenreEffectTypes.DamageBonusPercentage)); } } } \ No newline at end of file diff --git a/src/OpenRpg.Genres/Populators/Entity/Stats/DefenseStatPopulator.cs b/src/OpenRpg.Genres/Populators/Entity/Stats/DefenseStatPopulator.cs index e3cda6b..9a0b255 100644 --- a/src/OpenRpg.Genres/Populators/Entity/Stats/DefenseStatPopulator.cs +++ b/src/OpenRpg.Genres/Populators/Entity/Stats/DefenseStatPopulator.cs @@ -1,6 +1,5 @@ using System.Collections.Generic; using OpenRpg.Core.Variables; -using OpenRpg.Entities.Effects; using OpenRpg.Entities.Effects.Processors; using OpenRpg.Entities.Entity.Populators.Stats; using OpenRpg.Entities.Extensions; @@ -13,23 +12,11 @@ namespace OpenRpg.Genres.Populators.Entity.Stats public class DefenseStatPopulator : IEntityPartialStatPopulator { public int Priority => 10; - - public float ComputeTotal(ComputedEffects computedEffects) - { - var amount = computedEffects.Get(GenreEffectTypes.DefenseBonusAmount); - var percentage = computedEffects.Get(GenreEffectTypes.DefenseBonusPercentage); - - if (percentage == 0) - { return amount; } - - var addition = amount * (percentage/100); - return amount + addition; - } public void Populate(EntityStatsVariables stats, ComputedEffects computedEffects, IReadOnlyCollection relatedVars) { - var totalValue = ComputeTotal(computedEffects); - stats.Defense(totalValue); + stats.Defense(computedEffects.CalculateTotalValueFor(GenreEffectTypes.DefenseBonusAmount, + GenreEffectTypes.DefenseBonusPercentage)); } } } \ No newline at end of file diff --git a/src/OpenRpg.Genres/Requirements/DefaultCharacterRequirementChecker.cs b/src/OpenRpg.Genres/Requirements/DefaultCharacterRequirementChecker.cs index dd18971..c793644 100644 --- a/src/OpenRpg.Genres/Requirements/DefaultCharacterRequirementChecker.cs +++ b/src/OpenRpg.Genres/Requirements/DefaultCharacterRequirementChecker.cs @@ -1,4 +1,5 @@ using System.Linq; +using OpenRpg.Combat.Extensions; using OpenRpg.Core.Requirements; using OpenRpg.Entities.Extensions; using OpenRpg.Entities.Requirements; @@ -85,6 +86,18 @@ public virtual bool IsRequirementMet(Character character, Requirement requiremen if(requirement.RequirementType == GenreRequirementTypes.MaxHealthRequirement) { return character.Stats.MaxHealth() >= requirement.Association.AssociatedValue; } + if(requirement.RequirementType == GenreRequirementTypes.MaxStaminaRequirement) + { return character.Stats.MaxStamina() >= requirement.Association.AssociatedValue; } + + if(requirement.RequirementType == GenreRequirementTypes.MovementSpeedRequirement) + { return character.Stats.MovementSpeed() >= requirement.Association.AssociatedValue; } + + if (requirement.RequirementType == GenreRequirementTypes.ActiveEffectRequirement) + { + if(!character.Variables.HasActiveEffects()) { return false; } + return character.Variables.ActiveEffects().HasEffect(requirement.Association.AssociatedId); + } + return true; } diff --git a/src/OpenRpg.Genres/Types/GenreEffectTypes.cs b/src/OpenRpg.Genres/Types/GenreEffectTypes.cs index 6150f9e..611236e 100644 --- a/src/OpenRpg.Genres/Types/GenreEffectTypes.cs +++ b/src/OpenRpg.Genres/Types/GenreEffectTypes.cs @@ -7,25 +7,43 @@ public interface GenreEffectTypes // Pure Damage Types public static readonly int DamageBonusAmount = 1; public static readonly int DamageBonusPercentage = 2; + public static readonly int CriticalRateBonusAmount = 3; + public static readonly int CriticalRateBonusPercentage = 4; + static readonly int CriticalDamageBonusAmount = 5; + static readonly int CriticalDamageBonusPercentage = 6; // Pure Defense Types - public static readonly int DefenseBonusAmount = 10; - public static readonly int DefenseBonusPercentage = 11; + public static readonly int DefenseBonusAmount = 21; + public static readonly int DefenseBonusPercentage = 22; - // Attributes - public static readonly int AllAttributeBonusAmount = 20; - public static readonly int AllAttributeBonusPercentage = 21; - public static readonly int HealthBonusAmount = 22; - public static readonly int HealthRestoreAmount = 23; - public static readonly int HealthRegenBonusAmount = 24; - public static readonly int HealthRegenBonusPercentage = 25; + // Attributes / Other + public static readonly int AllAttributeBonusAmount = 40; + public static readonly int AllAttributeBonusPercentage = 41; + public static readonly int ExperienceRestoreAmount = 42; + public static readonly int ExperienceRestorePercentage = 43; + public static readonly int MovementSpeedBonusAmount = 44; + public static readonly int MovementSpeedBonusPercentage = 45; + + // Vitals + public static readonly int HealthBonusAmount = 60; + public static readonly int HealthBonusPercentage = 61; + public static readonly int HealthRestoreAmount = 62; + public static readonly int HealthRestorePercentage = 63; + public static readonly int HealthRegenBonusAmount = 64; + public static readonly int HealthRegenBonusPercentage = 65; + public static readonly int StaminaBonusAmount = 66; + public static readonly int StaminaBonusPercentage = 67; + public static readonly int StaminaRestoreAmount = 68; + public static readonly int StaminaRestorePercentage = 69; + public static readonly int StaminaRegenBonusAmount = 70; + public static readonly int StaminaRegenBonusPercentage = 71; // Ability Related - public static readonly int AttackRangeBonusAmount = 30; - public static readonly int AttackRangeBonusPercentage = 31; - public static readonly int AttackSizeBonusAmount = 32; - public static readonly int AttackSizeBonusPercentage = 33; - public static readonly int CooldownReductionBonusAmount = 34; - public static readonly int CooldownReductionBonusPercentage = 35; + public static readonly int AttackRangeBonusAmount = 90; + public static readonly int AttackRangeBonusPercentage = 91; + public static readonly int AttackSizeBonusAmount = 92; + public static readonly int AttackSizeBonusPercentage = 93; + public static readonly int CooldownReductionBonusAmount = 94; + public static readonly int CooldownReductionBonusPercentage = 95; } } \ No newline at end of file diff --git a/src/OpenRpg.Genres/Types/GenreEntityStateVariableTypes.cs b/src/OpenRpg.Genres/Types/GenreEntityStateVariableTypes.cs index 2f41fa9..9606785 100644 --- a/src/OpenRpg.Genres/Types/GenreEntityStateVariableTypes.cs +++ b/src/OpenRpg.Genres/Types/GenreEntityStateVariableTypes.cs @@ -5,5 +5,6 @@ namespace OpenRpg.Genres.Types public interface GenreEntityStateVariableTypes : CoreEntityStateVariableTypes { public static readonly int Health = 1; + public static readonly int Stamina = 2; } } \ No newline at end of file diff --git a/src/OpenRpg.Genres/Types/GenreEntityStatsVariableTypes.cs b/src/OpenRpg.Genres/Types/GenreEntityStatsVariableTypes.cs index c7587d9..627cc15 100644 --- a/src/OpenRpg.Genres/Types/GenreEntityStatsVariableTypes.cs +++ b/src/OpenRpg.Genres/Types/GenreEntityStatsVariableTypes.cs @@ -7,9 +7,14 @@ public interface GenreEntityStatsVariableTypes : CoreEntityStatsVariableTypes // Base stats public static readonly int MaxHealth = 1; public static readonly int HealthRegen = 2; + public static readonly int MaxStamina = 3; + public static readonly int StaminaRegen = 4; + public static readonly int MovementSpeed = 5; // Attack stats public static readonly int Damage = 10; + public static readonly int CriticalDamageChance = 11; + public static readonly int CriticalDamageMultiplier = 12; // Defense stats public static readonly int Defense = 20; diff --git a/src/OpenRpg.Genres/Types/GenreRequirementTypes.cs b/src/OpenRpg.Genres/Types/GenreRequirementTypes.cs index 114a733..9be398c 100644 --- a/src/OpenRpg.Genres/Types/GenreRequirementTypes.cs +++ b/src/OpenRpg.Genres/Types/GenreRequirementTypes.cs @@ -14,5 +14,8 @@ public interface GenreRequirementTypes public static readonly int ActiveEffectRequirement = 9; public static readonly int MaxHealthRequirement = 10; public static readonly int TradeSkillRequirement = 11; + public static readonly int MaxStaminaRequirement = 12; + public static readonly int MovementSpeedRequirement = 13; + } } \ No newline at end of file