示例#1
0
 public void WeaponRepository_CheckExperience_ShouldReturnTrue()
 {
     Assert.IsTrue(_repo.CheckExperience(new Axe
     {
         Experience = 120
     }));
 }
示例#2
0
        private void PlayerAttack()
        {
            _console.WriteLine($"Swung {_player.Weapon.Name}");

            if (_random.Next(100) < _player.MissChance)
            {
                _console.WriteLine("Attack Missed");
                _console.ReadKey();
            }

            else if (_random.Next(100) < _player.CriticalStrikeChance)
            {
                _enemy.DoDamage(_player.Weapon.Damage + _player.CriticalStrikeChance);
                _console.WriteLine($"{_enemy.Name} Damaged for { _player.Weapon.Damage + _player.CriticalStrikeChance} with Critical Hit");
                _console.ReadKey();
            }
            else
            {
                _enemy.DoDamage(_player.Weapon.Damage);
                _console.WriteLine($"{_enemy.Name} Damaged for {_player.Weapon.Damage}");
                _console.ReadKey();
            }

            if (_enemy.Health <= 0)
            {
                _console.Clear();
                _console.WriteLine($"You Won");
                _console.WriteLine($"Gained {_enemy.Gold} Gold and {_enemy.Experience} experience for winning");
                _console.ReadKey();
                _player.Weapon.Experience += _enemy.Weapon.Experience;
                _player.Experience        += _enemy.Experience;
                _player.Gold += _enemy.Gold;
                _player.EnemiesSlain++;

                if (_playerRepo.CheckExperience(_player))
                {
                    _player.GainLevel();
                    _console.WriteLine("Player Level Gained");
                    _console.ReadKey();
                }

                if (_weaponRepo.CheckExperience(_player.Weapon))
                {
                    _player.Weapon.GainLevel();
                    _console.WriteLine("Weapon Level Gained");
                    _console.ReadKey();
                }

                NextFight();
            }
        }