private Result rollHit(int attackerToHit, int defenderArmorClass) { int roll = (int) (PlayN.random() * 20) + 1; if (roll == 1) { return Result.CRITICAL_HIT; } if (roll == 20) { return Result.CRITICAL_MISS; } if (roll > attackerToHit) { return Result.MISSED; } int target = attackerToHit - defenderArmorClass; if (roll > target) { return Result.DEFLECTED; } return Result.HIT; }
private int rollDamage(int attackerDamageDieSize) { int roll = (int) (PlayN.random() * attackerDamageDieSize) + 1; return roll; }