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

@@ -28,6 +28,8 @@ public interface IReadOnlyTypeLibrary
/// This is equivalent to running get_single_effectiveness on each defending type, and multiplying the results with each other.
/// </summary>
float GetEffectiveness(TypeIdentifier attacking, IReadOnlyList<TypeIdentifier> defending);
IEnumerable<(TypeIdentifier type, float effectiveness)> GetAllEffectivenessFromAttacking(TypeIdentifier attacking);
}
/// <inheritdoc />
@@ -70,6 +72,17 @@ public class TypeLibrary : IReadOnlyTypeLibrary
defending.Aggregate<TypeIdentifier, float>(1,
(current, type) => current * GetSingleEffectiveness(attacking, type));
/// <inheritdoc />
public IEnumerable<(TypeIdentifier, float)> GetAllEffectivenessFromAttacking(TypeIdentifier attacking)
{
if (attacking.Value < 1 || attacking.Value > _effectiveness.Count)
throw new ArgumentOutOfRangeException(nameof(attacking));
for (var i = 0; i < _effectiveness.Count; i++)
{
yield return (new TypeIdentifier((byte)(i + 1)), _effectiveness[attacking.Value - 1][i]);
}
}
/// <summary>
/// Registers a new type in the library.
/// </summary>