Initial setup for testing AI performance, random fixes
All checks were successful
Build / Build (push) Successful in 54s

This commit is contained in:
2025-07-05 13:56:33 +02:00
parent 4499927551
commit 32aaa5150a
33 changed files with 511 additions and 26 deletions

View File

@@ -69,9 +69,9 @@ public class TypeLibrary : IReadOnlyTypeLibrary
public float GetSingleEffectiveness(TypeIdentifier attacking, TypeIdentifier defending)
{
if (attacking.Value < 1 || attacking.Value > _effectiveness.Count)
throw new ArgumentOutOfRangeException(nameof(attacking));
return 1;
if (defending.Value < 1 || defending.Value > _effectiveness.Count)
throw new ArgumentOutOfRangeException(nameof(defending));
return 1;
return _effectiveness[attacking.Value - 1][defending.Value - 1];
}

View File

@@ -65,7 +65,7 @@ public record ImmutableStatisticSet<T> where T : struct
/// <summary>
/// Gets a statistic from the set.
/// </summary>
public T GetStatistic(Statistic stat)
public virtual T GetStatistic(Statistic stat)
{
return stat switch
{
@@ -75,7 +75,7 @@ public record ImmutableStatisticSet<T> where T : struct
Statistic.SpecialAttack => SpecialAttack,
Statistic.SpecialDefense => SpecialDefense,
Statistic.Speed => Speed,
_ => throw new ArgumentException("Invalid statistic."),
_ => throw new ArgumentException($"Invalid statistic {stat}"),
};
}
}
@@ -308,7 +308,7 @@ public abstract record ClampedStatisticSet<T> : StatisticSet<T> where T : struct
var current = GetStatistic(stat);
var newValue = Subtract(current, value);
if (newValue.CompareTo(Min) < 0)
value = Subtract(current, Min);
value = Add(Min, current);
if (value.CompareTo(default) == 0)
return false;
return base.DecreaseStatistic(stat, value);
@@ -400,6 +400,23 @@ public record StatBoostStatisticSet : ClampedStatisticSet<sbyte>
yield return (Statistic.Accuracy, Accuracy);
}
/// <inheritdoc />
public override sbyte GetStatistic(Statistic stat)
{
return stat switch
{
Statistic.Hp => Hp,
Statistic.Attack => Attack,
Statistic.Defense => Defense,
Statistic.SpecialAttack => SpecialAttack,
Statistic.SpecialDefense => SpecialDefense,
Statistic.Speed => Speed,
Statistic.Evasion => Evasion,
Statistic.Accuracy => Accuracy,
_ => throw new ArgumentException($"Invalid statistic {stat}"),
};
}
/// <summary>
/// Resets all statistics to 0.
/// </summary>