Esempio n. 1
0
        public IInitiativePair GetNext(IEnumerable <IInitiativePair> initiativePairs)
        {
            _shadowCopy.AddRange(initiativePairs);

            IInitiativePair next = null;

            do
            {
                _shadowCopy.Sort(CompareInitiativePair);
                if (_shadowCopy[0].Initiative >= _initiativeThreshold)
                {
                    next = _shadowCopy[0];
                }
                else if (!IncrementInitiativePairs(_shadowCopy))
                {
                    // Failed to increment, we're going to be looping forever.
                    break;
                }
            } while (next == null);

            _shadowCopy.Clear();
            return(next);
        }
Esempio n. 2
0
 private static int CompareInitiativePair(IInitiativePair lhs, IInitiativePair rhs)
 => rhs.Initiative.CompareTo(lhs.Initiative);