我正在开发一个基于桌面游戏的练习程序,我遇到了一个问题,我的代码没有正确划分值,或者根本没有。
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);
}
所以killed
变量应该具有受到的伤害量除以枚举类对象的伤口统计量。如果b.wounds
特征是1
,但是如果它是任何其他数字,我得到的结果是有意义的,它基本上返回bDamageTaken / 1
。
我缺少什么/我没有考虑过?