Skip to content

Commit

Permalink
More big changes to streamline variables
Browse files Browse the repository at this point in the history
  • Loading branch information
grofit committed Sep 15, 2023
1 parent 39c1ba3 commit ff09806
Show file tree
Hide file tree
Showing 49 changed files with 149 additions and 99 deletions.
4 changes: 2 additions & 2 deletions src/OpenRpg.Cards/ICard.cs
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
using OpenRpg.Cards.Variables;
using OpenRpg.Core.Common;
using OpenRpg.Core.Effects;
using OpenRpg.Core.Variables.General;

namespace OpenRpg.Cards
{
/// <summary>
/// The Card interface provides a way to wrap up underlying objects and express them as playable cards
/// </summary>
public interface ICard : IHasLocaleDescription, IHasEffects
public interface ICard : IHasLocaleDescription, IHasEffects, IHasVariables<ICardVariables>
{
int CardType { get; }
ICardVariables Variables { get; }
}
}
3 changes: 2 additions & 1 deletion src/OpenRpg.Cards/Variables/DefaultCardVariables.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
using System.Collections.Generic;
using OpenRpg.Cards.Types;
using OpenRpg.Core.Variables;
using OpenRpg.Core.Variables.General;

namespace OpenRpg.Cards.Variables
{
public class DefaultCardVariables : DefaultVariables<object>, ICardVariables
public class DefaultCardVariables : ObjectVariables, ICardVariables
{
public DefaultCardVariables(IDictionary<int, object> internalVariables = null) : base(ICardCoreVariableTypes.CardVariables, internalVariables)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
using System.Collections.Generic;
using OpenRpg.Combat.Types;
using OpenRpg.Core.Variables;
using OpenRpg.Core.Variables.General;

namespace OpenRpg.Combat.Abilities.Variables
{
public class DefaultAbilityVariables : DefaultVariables<object>, IAbilityVariables
public class DefaultAbilityVariables : ObjectVariables, IAbilityVariables
{
public DefaultAbilityVariables(IDictionary<int, object> internalVariables = null) : base(CombatVariableTypes.AbilityVariable, internalVariables)
{
Expand Down
8 changes: 2 additions & 6 deletions src/OpenRpg.Combat/Effects/IActiveEffects.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@
using System.Collections.Generic;
using OpenRpg.Combat.Variables;
using OpenRpg.Core.Effects;
using OpenRpg.Core.Variables.General;

namespace OpenRpg.Combat.Effects
{
/// <summary>
/// The active effects allows us to wrap up concerns for managing active effects and abstracting away certain details
/// like the stacking etc
/// </summary>
public interface IActiveEffects : IHasEffects
public interface IActiveEffects : IHasEffects, IHasVariables<IActiveEffectsVariables>
{
event EventHandler<ActiveEffect> EffectAdded;
event EventHandler<ActiveEffect> EffectTriggered;
Expand All @@ -20,11 +21,6 @@ public interface IActiveEffects : IHasEffects
/// </summary>
IReadOnlyCollection<ActiveEffect> ActiveEffects { get; }

/// <summary>
/// Variables specific to the active effects
/// </summary>
IActiveEffectsVariables Variables { get; }

/// <summary>
/// This will attempt to add an effect, each implementation may differ how stacking is handled etc
/// </summary>
Expand Down
3 changes: 2 additions & 1 deletion src/OpenRpg.Combat/Effects/TimedEffect.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using OpenRpg.Combat.Variables;
using OpenRpg.Core.Common;
using OpenRpg.Core.Effects;
using OpenRpg.Core.Variables.General;

namespace OpenRpg.Combat.Effects
{
Expand All @@ -12,7 +13,7 @@ namespace OpenRpg.Combat.Effects
/// This just describes how the effect should be processed, and is more akin to a template. It should be
/// used in conjunction with ActiveEffect for actually tracking and processing the effect.
/// </remarks>
public class TimedEffect : Effect, IHasDataId, IHasLocaleDescription
public class TimedEffect : Effect, IHasDataId, IHasLocaleDescription, IHasVariables<ITimedEffectVariables>
{
/// <inheritdoc />
public int Id { get; set; }
Expand Down
2 changes: 1 addition & 1 deletion src/OpenRpg.Combat/Processors/Attacks/IAttackGenerator.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using OpenRpg.Combat.Attacks;
using OpenRpg.Core.Stats.Variables;
using OpenRpg.Core.Stats;

namespace OpenRpg.Combat.Processors.Attacks
{
Expand Down
1 change: 1 addition & 0 deletions src/OpenRpg.Combat/Processors/Attacks/IAttackProcessor.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using OpenRpg.Combat.Attacks;
using OpenRpg.Core.Stats;
using OpenRpg.Core.Stats.Variables;

namespace OpenRpg.Combat.Processors.Attacks
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
using System.Collections.Generic;
using OpenRpg.Combat.Types;
using OpenRpg.Core.Variables;
using OpenRpg.Core.Variables.General;

namespace OpenRpg.Combat.Variables
{
public class DefaultActiveEffectsVariables : DefaultVariables<object>, IActiveEffectsVariables
public class DefaultActiveEffectsVariables : ObjectVariables, IActiveEffectsVariables
{
public DefaultActiveEffectsVariables(IDictionary<int, object> internalVariables = null) : base(CombatVariableTypes.ActiveEffectsVariable, internalVariables)
{
Expand Down
3 changes: 2 additions & 1 deletion src/OpenRpg.Combat/Variables/DefaultTimedEffectVariables.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
using System.Collections.Generic;
using OpenRpg.Combat.Types;
using OpenRpg.Core.Variables;
using OpenRpg.Core.Variables.General;

namespace OpenRpg.Combat.Variables
{
public class DefaultTimedEffectVariables : DefaultVariables<object>, ITimedEffectVariables
public class DefaultTimedEffectVariables : ObjectVariables, ITimedEffectVariables
{
public DefaultTimedEffectVariables(IDictionary<int, object> internalVariables = null) : base(CombatVariableTypes.TimedEffectVariable, internalVariables)
{
Expand Down
4 changes: 2 additions & 2 deletions src/OpenRpg.Core/Classes/IClass.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
using OpenRpg.Core.Classes.Variables;
using OpenRpg.Core.Variables.General;

namespace OpenRpg.Core.Classes
{
public interface IClass
public interface IClass : IHasVariables<IClassVariables>
{
int Level { get; set; }
IClassTemplate ClassTemplate { get; }
IClassVariables Variables { get; }
}
}
4 changes: 2 additions & 2 deletions src/OpenRpg.Core/Classes/IClassTemplate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
using OpenRpg.Core.Common;
using OpenRpg.Core.Effects;
using OpenRpg.Core.Requirements;
using OpenRpg.Core.Variables.General;

namespace OpenRpg.Core.Classes
{
public interface IClassTemplate : IHasDataId, IHasEffects, IHasRequirements, IHasLocaleDescription
public interface IClassTemplate : IHasDataId, IHasEffects, IHasRequirements, IHasLocaleDescription, IHasVariables<IClassTemplateVariables>
{
IClassTemplateVariables Variables { get; }
}
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
using System.Collections.Generic;
using OpenRpg.Core.Types;
using OpenRpg.Core.Variables;
using OpenRpg.Core.Variables.General;

namespace OpenRpg.Core.Classes.Variables
{
public class DefaultClassTemplateVariables : DefaultVariables<object>, IClassTemplateVariables
public class DefaultClassTemplateVariables : ObjectVariables, IClassTemplateVariables
{
public DefaultClassTemplateVariables(IDictionary<int, object> internalVariables = null) : base(CoreVariableTypes.ClassTemplateVariables, internalVariables)
{
Expand Down
3 changes: 2 additions & 1 deletion src/OpenRpg.Core/Classes/Variables/DefaultClassVariables.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
using System.Collections.Generic;
using OpenRpg.Core.Types;
using OpenRpg.Core.Variables;
using OpenRpg.Core.Variables.General;

namespace OpenRpg.Core.Classes.Variables
{
public class DefaultClassVariables : DefaultVariables<object>, IClassVariables
public class DefaultClassVariables : ObjectVariables, IClassVariables
{
public DefaultClassVariables(IDictionary<int, object> internalVariables = null) : base(CoreVariableTypes.ClassVariables, internalVariables)
{
Expand Down
4 changes: 2 additions & 2 deletions src/OpenRpg.Core/Entity/DefaultEntity.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System;
using OpenRpg.Core.State.Entity;
using OpenRpg.Core.Stats.Variables;
using OpenRpg.Core.Stats.Entity;
using OpenRpg.Core.Variables.Entity;

namespace OpenRpg.Core.Entity
Expand All @@ -13,7 +13,7 @@ public class DefaultEntity : IEntity
public Guid UniqueId { get; set; } = Guid.NewGuid();
public string NameLocaleId { get; set; } = string.Empty;
public string DescriptionLocaleId { get; set; } = string.Empty;
public IStatsVariables Stats { get; set; } = new DefaultStatsVariables();
public IEntityStatsVariables Stats { get; set; } = new DefaultEntityStatsVariables();
public IEntityStateVariables State { get; set; } = new DefaultEntityStateVariables();
public IEntityVariables Variables { get; set; } = new DefaultEntityVariables();

Expand Down
12 changes: 5 additions & 7 deletions src/OpenRpg.Core/Entity/IEntity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
using OpenRpg.Core.State;
using OpenRpg.Core.State.Entity;
using OpenRpg.Core.Stats;
using OpenRpg.Core.Stats.Entity;
using OpenRpg.Core.Variables.Entity;
using OpenRpg.Core.Variables.General;

namespace OpenRpg.Core.Entity
{
Expand All @@ -14,11 +16,7 @@ namespace OpenRpg.Core.Entity
/// to add additional requirements on but this gives a building block to allow more functionality in
/// the base layers.
/// </remarks>
public interface IEntity : IIsUnique, IHasLocaleDescription, IHasStats, IHasState<IEntityStateVariables>
{
/// <summary>
/// The variables for this entity
/// </summary>
IEntityVariables Variables { get; }
}
public interface IEntity : IIsUnique, IHasLocaleDescription,
IHasState<IEntityStateVariables>, IHasStats<IEntityStatsVariables>, IHasVariables<IEntityVariables>
{}
}
2 changes: 2 additions & 0 deletions src/OpenRpg.Core/OpenRpg.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,6 @@
<LangVersion>8</LangVersion>
</PropertyGroup>



</Project>
4 changes: 2 additions & 2 deletions src/OpenRpg.Core/Races/IRaceTemplate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
using OpenRpg.Core.Effects;
using OpenRpg.Core.Races.Variables;
using OpenRpg.Core.Requirements;
using OpenRpg.Core.Variables.General;

namespace OpenRpg.Core.Races
{
public interface IRaceTemplate : IHasDataId, IHasEffects, IHasRequirements, IHasLocaleDescription
public interface IRaceTemplate : IHasDataId, IHasEffects, IHasRequirements, IHasLocaleDescription, IHasVariables<IRaceTemplateVariables>
{
IRaceTemplateVariables Variables { get; }
}
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
using System.Collections.Generic;
using OpenRpg.Core.Types;
using OpenRpg.Core.Variables;
using OpenRpg.Core.Variables.General;

namespace OpenRpg.Core.Races.Variables
{
public class DefaultRaceTemplateVariables : DefaultVariables<object>, IRaceTemplateVariables
public class DefaultRaceTemplateVariables : ObjectVariables, IRaceTemplateVariables
{
public DefaultRaceTemplateVariables(IDictionary<int, object> internalVariables = null) : base(CoreVariableTypes.RaceTemplateVariables, internalVariables)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using OpenRpg.Core.Variables;

namespace OpenRpg.Core.Stats.Variables
namespace OpenRpg.Core.State
{
/// <summary>
/// State variables are manually maintained state values which may depend upon Stat values but are tracked separately
Expand Down
13 changes: 13 additions & 0 deletions src/OpenRpg.Core/Stats/Entity/DefaultEntityStateVariables.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using System.Collections.Generic;
using OpenRpg.Core.Types;
using OpenRpg.Core.Variables;

namespace OpenRpg.Core.Stats.Entity
{
public class DefaultEntityStatsVariables : DefaultVariables<float>, IEntityStatsVariables
{
public DefaultEntityStatsVariables(IDictionary<int, float> internalVariables = null) : base(CoreVariableTypes.EntityStateVariables, internalVariables)
{
}
}
}
7 changes: 7 additions & 0 deletions src/OpenRpg.Core/Stats/Entity/IEntityStateVariables.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
using OpenRpg.Core.Stats.Variables;

namespace OpenRpg.Core.Stats.Entity
{
public interface IEntityStatsVariables : IStatsVariables
{ }
}
4 changes: 2 additions & 2 deletions src/OpenRpg.Core/Stats/IHasStats.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

namespace OpenRpg.Core.Stats
{
public interface IHasStats
public interface IHasStats<out T> where T : IStatsVariables
{
IStatsVariables Stats { get; }
T Stats { get; }
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using OpenRpg.Core.Variables;

namespace OpenRpg.Core.Stats.Variables
namespace OpenRpg.Core.Stats
{
/// <summary>
/// Stat variables generally contain static stat data which is computed from effects active on the entity
Expand Down
3 changes: 2 additions & 1 deletion src/OpenRpg.Core/Variables/Entity/DefaultEntityVariables.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
using System.Collections.Generic;
using OpenRpg.Core.Types;
using OpenRpg.Core.Variables.General;

namespace OpenRpg.Core.Variables.Entity
{
public class DefaultEntityVariables : DefaultVariables<object>, IEntityVariables
public class DefaultEntityVariables : ObjectVariables, IEntityVariables
{
public DefaultEntityVariables(IDictionary<int, object> internalVariables = null) : base(CoreVariableTypes.EntityVariables, internalVariables)
{
Expand Down
7 changes: 7 additions & 0 deletions src/OpenRpg.Core/Variables/General/IHasVariables.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace OpenRpg.Core.Variables.General
{
public interface IHasVariables<out T> where T : IVariables<object>
{
T Variables { get; }
}
}
11 changes: 11 additions & 0 deletions src/OpenRpg.Core/Variables/General/ObjectVariables.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using System.Collections.Generic;

namespace OpenRpg.Core.Variables.General
{
public class ObjectVariables : DefaultVariables<object>
{
public ObjectVariables(int variableType, IDictionary<int, object> internalVariables = null) : base(variableType, internalVariables)
{
}
}
}
Loading

0 comments on commit ff09806

Please sign in to comment.