I'm working on a practice program based on a tabletop game and I ran into a snag where my code is not dividing the value correctly, or really at all.
public void damageCalculation(int successfulWounds, Unit a, Unit b) {
int damageDealt = successfulWounds * a.getDamageDealt();
b.woundsTaken = b.woundsTaken + damageDealt;
killModels(b.woundsTaken, b);
System.out.printf("After kill units: %s\n", b.unitSize);
System.out.printf("Does the unit have lingering wounds: %s\n", b.woundsTaken);
}
private void killModels(int bDamageTaken, Unit b) {
//For every bit of damage where damage is equal to the defender's wound stat, kill a model
int killed = (bDamageTaken / b.wounds);
b.unitSize = b.unitSize - killed;
b.woundsTaken = bDamageTaken % b.wounds;
System.out.printf("Killed %s models\n", killed);
}
so the killed
variable is supposed to have the amount of damage taken divided by the wounds statistic of an enum class object. The result that I get would make sense if the b.wounds
characteristic is 1
but if it is any other number, it returns bDamageTaken / 1
essentially.
What am I missing/have I not considered?