using System;
using System.Collections.Generic;
using YachtDice.Modifiers.Definition;
using YachtDice.Modifiers.Runtime;

namespace YachtDice.Modifiers.Pipeline
{
    public struct EffectEntry
    {
        public Effect Effect;
        public ModifierInstance Instance;
    }

    public class ModifierComparer : IComparer<EffectEntry>
    {
        public static readonly ModifierComparer Default = new();

        public int Compare(EffectEntry a, EffectEntry b)
        {
            int cmp = a.Effect.Phase.CompareTo(b.Effect.Phase);
            if (cmp != 0) return cmp;

            cmp = a.Effect.Priority.CompareTo(b.Effect.Priority);
            if (cmp != 0) return cmp;

            return string.Compare(a.Instance.Definition.Id, b.Instance.Definition.Id, StringComparison.Ordinal);
        }
    }
}
