title: How do I fix my damage calculation being so high?
body: <p>I have written some C# code for a Commandline RPG. Problem is: Whenever I hit the enemy, it receives a damage that is way too high.</p>
  
  <p>I have made an int variable for the damage and also call DamageCalc() only once. Problem still occurs. 
  I have the assumption that it could be the way i subtracted the Damage from the enemy's HP in line 154.</p>
  
  <p>Here is the code to reproduce the problem. Excuse me for the length of it, but I don't know exactly where the problem occurs, so I cant make it even shorter than i already did.</p>
  
  <p><a href="https://i.stack.imgur.com/fcaDi.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/fcaDi.png" alt="enter image description here"></a></p>
  
  <p>Here you can see the boar with 5 HP. I hit the boar and do 4 Damage. Sadly, the boar gets 10 Damage and its HP goes down to -5.</p>
  
  <pre><code>using System;
  
  namespace ConsoleApp2
  {
      class Player
      {
          Archer archer = new Archer();
          Knight knight = new Knight();
          Assasin assasin = new Assasin();
          CurrentWeapon currentWeapon = new CurrentWeapon();
          public string Name { get; set; }
          public string Klasse { get; set; }
          public int HP { get; set; } = 20;
          public int Level { get; set; } = 0;
      }
  
      class CurrentWeapon
      {
          public string WeaponName { get; set; }
          public float DamageMultiplier { get; set; } = 1;
      }
  
      class Enemy
      {
          public string Type { get; set; }
          public int Attack { get; set; }
          public int HP { get; set; }
          public int Experience { get; set; }
          public bool Dead { get; set; } = false;
  
          //Konstruktor
          public Enemy(string _type, int _attack, int _hp, int _experience)
          {
              Type = _type;
              Attack = _attack;
              HP = _hp;
              Experience = _experience;
          }
      }
  
      class Archer
      {
          public string ClassName { get; set; } = "Archer";
          public int BaseDamage { get; set; } = 6;
          public string WeaponType { get; set; } = "Bow";
      }
      class Knight
      {
          public string ClassName { get; set; } = "Knight";
          public int BaseDamage { get; set; } = 5;
          public string WeaponType { get; set; } = "Greatsword";
      }
      class Assasin
      {
          public string ClassName { get; set; } = "Assasin";
          public int BaseDamage { get; set; } = 4;
          public string WeaponType { get; set; } = "Dagger";
      }
  
      class Program
      {
          static int GenerateNumber(int min, int max)
          {
              Random random = new Random();
              return random.Next(min, max);
          }
  
          static void Main(string[] args)
          {
              Archer archer = new Archer();
              Knight knight = new Knight();
              Assasin assasin = new Assasin();
              CurrentWeapon currentWeapon = new CurrentWeapon();
              Player player = new Player();
  
              int DamageCalc()
              {
                  if (player.Klasse == "Archer")
                  {
                      float outputDamage = archer.BaseDamage * currentWeapon.DamageMultiplier;
                      return (int)Math.Round(outputDamage);
                  }
                  if (player.Klasse == "Knight")
                  {
                      float outputDamage = knight.BaseDamage * currentWeapon.DamageMultiplier;
                      return (int)Math.Round(outputDamage);
                  }
                  if (player.Klasse == "Assasin")
                  {
                      float outputDamage = assasin.BaseDamage * currentWeapon.DamageMultiplier;
                      return (int)Math.Round(outputDamage);
                  }
                  else { return 0; }
              }
              Console.WriteLine(" What shall you be called?");
              player.Name = Console.ReadLine();
              Console.ReadKey();
              Console.WriteLine(player.Name);
              Console.Clear();
              Console.WriteLine("Good, " + player.Name + " choose your class.");
              Console.WriteLine();
              Console.WriteLine(archer.ClassName + " | DMG: " + archer.BaseDamage + " | Weapon Type: " + archer.WeaponType);
              Console.WriteLine(knight.ClassName + " | DMG: " + knight.BaseDamage + " | Weapon Type: " + knight.WeaponType);
              Console.WriteLine(assasin.ClassName + " | DMG: " + assasin.BaseDamage + " | WeaponType : " + assasin.WeaponType);
  
              string UserClass = Console.ReadLine();
              if (UserClass == "Archer")
              {
                  player.Klasse = "Archer";
                  Console.WriteLine("You are now an Archer.");
                  currentWeapon.WeaponName = "Oak bow";
                  Console.WriteLine("You got a " + currentWeapon.WeaponName + ".");
              }
  
              if (UserClass == "Knight")
              {
                  player.Klasse = "Knight";
                  Console.WriteLine("You are now a Knight.");
                  currentWeapon.WeaponName = "Wooden sword";
                  Console.WriteLine("You got a " + currentWeapon.WeaponName + ".");
              }
  
              if (UserClass == "Assasin")
              {
                  player.Klasse = "Assasin";
                  Console.WriteLine("You are now an Assasin.");
                  currentWeapon.WeaponName = "Wooden Dagger";
                  Console.WriteLine("You got a " + currentWeapon.WeaponName + ".");
              }
              Console.ReadKey();
  
              bool Play = true;
              while (Play)
              {
                  Console.Clear();
                  Console.WriteLine("Press any Key to walk.");
                  Console.ReadKey();
                  Console.Clear();
  
                  int randomNumber = Program.GenerateNumber(0, 101);
  
                  if (randomNumber &lt;= 101 &amp;&amp; randomNumber &gt;= 0)
                  {
                      Enemy enemy1 = new Enemy("Wild Boar", Program.GenerateNumber(5, 10), Program.GenerateNumber(2, 4), Program.GenerateNumber(6, 9));
                      Console.WriteLine(" A " + enemy1.Type + " appears! | ATTK: " + enemy1.HP + " | HP: " + enemy1.Attack);
                      while (!enemy1.Dead)
                      {
                          Console.WriteLine("Use your " + currentWeapon.WeaponName + " and attack by pressing 'Q'.");
  
                          if (Console.ReadKey(true).Key == ConsoleKey.Q)
                          {
                          int hitDamage = DamageCalc();
                          enemy1.HP -= hitDamage;
                          Console.WriteLine("You hit the " + enemy1.Type + "! | HP: " + enemy1.HP + " (You did -" + hitDamage +")");
                          if (enemy1.HP &lt;= 0)
                          {
                              Console.WriteLine("You killed the " + enemy1.Type + "! | +" + enemy1.Experience + " Experience!");
                              enemy1.Dead = true;
                          }
                              Console.ReadKey();
                          }
                      }
                  }
              }
          }
      }
  }
  </code></pre>