Пример #1
0
        /// <summary>
        /// Removes three different spirits, prioritizing the oldest spirits in the meter
        /// </summary>
        /// <returns></returns>
        public bool RemoveThreeDifferentSpirits()
        {
            bool success = false;

            Spirits[] copy    = Meter.ToArray();
            int       i_found = 0;
            int       j_found = 0;
            int       k_found = 0;

            // Find three different spirits
            for (int i = 0; i < copy.Length - 2 && !success; i++)
            {
                for (int j = 1; j < copy.Length - 1 && !success; j++)
                {
                    for (int k = 2; k < copy.Length && !success; k++)
                    {
                        if (copy[i] != copy[j] && copy[j] != copy[k])
                        {
                            i_found = i;
                            j_found = j;
                            k_found = k;
                            success = true;
                        }
                    }
                }
            }

            // Remove three different spirits
            for (int i = 0; i < copy.Length; i++)
            {
                Spirits s = Meter.Dequeue();
                if (!(i == i_found || i == j_found || i == k_found))
                {
                    Meter.Enqueue(s);
                }
            }

            return(success);
        }