Esempio n. 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");
            }
        }
        private void AttackHeroes(Enemy enemyBeingAttacked)
        {
            IEnumerable <Entity> enemies;

            if (enemyBeingAttacked == null)
            {
                enemies = Enemies;
            }
            else
            {
                enemies = Enemies.Where(e => e != enemyBeingAttacked);
            }

            Random rand = new Random();

            foreach (var enemy in enemies)
            {
                var count = Heroes.Count();
                if (count < 1)
                {
                    break;
                }
                enemy.Attack(Heroes.ElementAt(rand.Next(0, count - 1)));
                if (count != Heroes.Count())
                {
                    break;
                }
            }
        }
Esempio n. 3
0
 public bool Continues() =>
 Heroes.Count(x => x.Detachments.Count > 0) > 1;