Exemplo n.º 1
0
        /// <summary>
        /// Army Defends against the Enemy
        /// </summary>
        /// <param name="enemy"></param>
        private void Defend(IEnemy enemy)
        {
            var liveSoldiers = Recruits.Where(r => !r.IsDead);

            DisplayDefendMessage();

            foreach (var soldier in liveSoldiers)
            {
                var attackDamage = enemy.Attack();
                _writer.WriteMessage(enemy.AttackMessage());
                soldier.Defend(enemy.AttackType, attackDamage);

                // Wonder about putting this inside Defend, but then defend would need to return a string which might be weird?
                _writer.WriteMessage(soldier.DefendMessage(enemy.AttackType, attackDamage));
            }
        }