The equation:
def defensefunction(attack, defense, damage):
dmg_def = (damage/attack)*(attack - (defense - (attack * 0.5)))
print(dmg_def)
The code above is written in python and works properly but in C# it's another story:
In C#:
public static double DefenseFunction(int attacker_damage, int attacker_attack, int defender_defense)
double var1 = (attacker_damage/attacker_attack);
double var2 = (attacker_attack- (defender_defense - (attacker_attack * 0.5)));
double dmg_def = var1 * var2;
return dmg_def;
There is a var1
and var2
because I tried to debug the code by splitting the equation.
What I found so far:
- The equation in var 2 works properly (the value is equal to what i get on a Hand-Calculator).
- var 1 could either be working right or not (most of the number should be from 0.1 to 0.9, To.String() rounded the number so just show a 0 on the form).
- dmg_def gets printed as a 0 (It shouldn't be, for example: 0.8 * 173 != 0).
Things that maybe are relevant:
How the function gets called:
double dmg_from = Actor.DefenseFunction(_attacker.Damage, _attacker.Attack, _defender.Defense);
How i print the number on the form:
rtbMessages.Text += dmg_from.ToString() + Enviroment.NewLine;