Further work on static side
This commit is contained in:
@@ -1,8 +1,10 @@
|
||||
using System;
|
||||
|
||||
namespace PkmnLib.Static;
|
||||
|
||||
public record StaticStatisticSet<T>
|
||||
/// <summary>
|
||||
/// A set of statistics that cannot be changed.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The size of the integer to be used</typeparam>
|
||||
public record ImmutableStatisticSet<T>
|
||||
where T : struct
|
||||
{
|
||||
/// <summary>
|
||||
@@ -35,7 +37,8 @@ public record StaticStatisticSet<T>
|
||||
/// </summary>
|
||||
public T Speed { get; protected set; }
|
||||
|
||||
public StaticStatisticSet(T hp, T attack, T defense, T specialAttack, T specialDefense, T speed)
|
||||
/// <inheritdoc cref="ImmutableStatisticSet{T}"/>
|
||||
public ImmutableStatisticSet(T hp, T attack, T defense, T specialAttack, T specialDefense, T speed)
|
||||
{
|
||||
Hp = hp;
|
||||
Attack = attack;
|
||||
@@ -45,6 +48,9 @@ public record StaticStatisticSet<T>
|
||||
Speed = speed;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a statistic from the set.
|
||||
/// </summary>
|
||||
public T GetStatistic(Statistic stat)
|
||||
{
|
||||
return stat switch
|
||||
@@ -60,14 +66,22 @@ public record StaticStatisticSet<T>
|
||||
}
|
||||
}
|
||||
|
||||
public record StatisticSet<T> : StaticStatisticSet<T>
|
||||
/// <summary>
|
||||
/// A set of statistics that can be changed.
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
public record StatisticSet<T> : ImmutableStatisticSet<T>
|
||||
where T : struct
|
||||
{
|
||||
/// <inheritdoc cref="StatisticSet{T}"/>
|
||||
public StatisticSet(T hp, T attack, T defense, T specialAttack, T specialDefense, T speed) : base(hp, attack,
|
||||
defense, specialAttack, specialDefense, speed)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Modifies a statistic in the set.
|
||||
/// </summary>
|
||||
public void SetStatistic(Statistic stat, T value)
|
||||
{
|
||||
switch (stat)
|
||||
@@ -95,6 +109,9 @@ public record StatisticSet<T> : StaticStatisticSet<T>
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Increases a statistic in the set by a value.
|
||||
/// </summary>
|
||||
public void IncreaseStatistic(Statistic stat, T value)
|
||||
{
|
||||
switch (stat)
|
||||
@@ -124,6 +141,9 @@ public record StatisticSet<T> : StaticStatisticSet<T>
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Decreases a statistic in the set by a value.
|
||||
/// </summary>
|
||||
public void DecreaseStatistic(Statistic stat, T value)
|
||||
{
|
||||
switch (stat)
|
||||
|
||||
Reference in New Issue
Block a user