Original Post
class Hero
{
public int health, strength, weaponStrength, defence;
public bool isAlive;
public string identity;
public static void Good Guy(Hero hero)
{
hero.health = 25;
hero.strength = 6;
hero.weaponStrength = 15;
hero.defence = 7;
hero.isAlive = true;
hero.identity = "Good Guy";
}
}
class Nemisis
{
public int health, strength, weaponStrength, defence;
public bool isEvil, isAlive;
public string identity;
public static void Bad Guy(Nemesis nem1)
{
nem1.health = 20;
nem1.strength = 10;
nem1.weaponStrength = 10;
nem1.defence = 10;
nem1.isEvil = true;
nem1.isAlive = true;
nem1.identity = "Mean Guy";
}
}
class Caculations
{
public int Calculate()
{
Random numGen = new Random();
double attackValue, defenceValue, reduction;
int damage;
attackValue = (strength * weaponStrength) * (numGen.Next(75, 126) * 0.01);
defenceValue = defence * 2;
reduction = (int)attackValue / defenceValue;
damage = (int)attackValue - (int)reduction;
return damage;
}
}
I've got a fairly simple problem in C#. Thank you in advance.
I'm having trouble linking the attributes (strength & weaponStrength) to the calculations to deal the damage in another class that determines the outcome of the battle. I could call the attributes from both the hero and nemesis, but that would require me to write the same formula twice for both classes, is there a better way?