using System;

namespace IndieExchange
{
    // Integer arithmetic: exactly p selections in every 100 consecutive opportunities
    // at unchanged p. A miss consumes its selection; it never creates catch-up debt.
    internal sealed class PercentageCounter
    {
        public int Remainder { get; private set; }
        public PercentageCounter(int remainder) { Remainder = Math.Max(0, Math.Min(99, remainder)); }
        public bool Next(int percentage)
        {
            percentage = Math.Max(0, Math.Min(100, percentage));
            Remainder += percentage;
            if (Remainder < 100) return false;
            Remainder -= 100;
            return true;
        }
    }

    [Serializable]
    public sealed class IndiePlacementStats
    {
        public long opportunities;
        public long selected;
        public long shown;
        public long unavailable;
        public long fallbackShown;
        public int remainder;
        public int publicRemainder;
        public IndiePlacementStats Copy() => (IndiePlacementStats)MemberwiseClone();
    }
}

