Implements several more moves

This commit is contained in:
2025-01-27 12:18:48 +01:00
parent 549b92048a
commit 3a75493912
26 changed files with 676 additions and 38 deletions

View File

@@ -168,12 +168,24 @@ public record StatisticSet<T> : ImmutableStatisticSet<T>, IEnumerable<T>, IDeepC
Speed = Add(Speed, value);
break;
default:
throw new ArgumentException("Invalid statistic.");
SetUnknownStat(stat, Add(GetUnknownStat(stat), value));
break;
}
return true;
}
protected virtual T GetUnknownStat(Statistic stat)
{
throw new ArgumentException($"Invalid statistic {stat}");
}
protected virtual void SetUnknownStat(Statistic stat, T value)
{
throw new ArgumentException($"Invalid statistic {stat}");
}
/// <summary>
/// Decreases a statistic in the set by a value.
/// </summary>
@@ -200,14 +212,15 @@ public record StatisticSet<T> : ImmutableStatisticSet<T>, IEnumerable<T>, IDeepC
Speed = Subtract(Speed, value);
break;
default:
throw new ArgumentException("Invalid statistic.");
SetUnknownStat(stat, Subtract(GetUnknownStat(stat), value));
break;
}
return true;
}
/// <inheritdoc />
public IEnumerator<T> GetEnumerator()
public virtual IEnumerator<T> GetEnumerator()
{
yield return Hp;
yield return Attack;
@@ -332,6 +345,47 @@ public record StatBoostStatisticSet : ClampedStatisticSet<sbyte>
sbyte speed) : base(hp, attack, defense, specialAttack, specialDefense, speed)
{
}
/// <inheritdoc />
protected override sbyte GetUnknownStat(Statistic stat)
{
return stat switch
{
Statistic.Evasion => Evasion,
Statistic.Accuracy => Accuracy,
_ => throw new ArgumentException($"Invalid statistic {stat}"),
};
}
/// <inheritdoc />
/// <inheritdoc />
protected override void SetUnknownStat(Statistic stat, sbyte value)
{
switch (stat)
{
case Statistic.Evasion:
Evasion = value;
break;
case Statistic.Accuracy:
Accuracy = value;
break;
default:
throw new ArgumentException($"Invalid statistic {stat}");
}
}
/// <inheritdoc />
public override IEnumerator<sbyte> GetEnumerator()
{
yield return Hp;
yield return Attack;
yield return Defense;
yield return SpecialAttack;
yield return SpecialDefense;
yield return Speed;
yield return Evasion;
yield return Accuracy;
}
}
/// <summary>