示例#1
0
        public void Swap()
        {
            Console.WriteLine($"Turns - Swap {Heroes.Count()}");
            if (Active is Hero hero)
            {
                if (Heroes.Count < 2)
                {
                    throw new Exception("cant swap if there is nothing swapable");
                }
                int index = Heroes.IndexOf(hero);
                if (index == 0)
                {
                    Active = Heroes.Last();
                }
                else
                {
                    Active = Heroes[index - 1];
                }

                OnSwapped?.Invoke(this, new EventArgs());
            }
            else
            {
                throw new Exception("can't swap if there isnt a hero");
            }
        }