Keep implementing attack resolution
This commit is contained in:
parent
d93a5c50d1
commit
c2a19499c9
2 changed files with 7 additions and 3 deletions
|
@ -109,10 +109,11 @@ public class AttackScenario {
|
|||
private double calculatePassingHits(Weapon weapon, int amountOfWeapons, int hitRollGoal) {
|
||||
int hitSuccessProbabilityNumerator = calculateProbabilityNumeratorFrom(hitRollGoal);
|
||||
int hitFailureProbabilityNumerator = 6 - hitSuccessProbabilityNumerator;
|
||||
double weaponAttacks = calculateWeaponAttacks(weapon);
|
||||
double weaponAttacks = calculateWeaponAttacks(weapon, amountOfWeapons);
|
||||
|
||||
// Base passing hits without rerolls
|
||||
double passingHits = (weaponAttacks*amountOfWeapons) * ((double) hitSuccessProbabilityNumerator / PROBABILITY_DENOMINATOR_D6);
|
||||
results.setWeaponStat(weapon, WeaponStat.HITS_COUNT_WITHOUT_REROLL, passingHits);
|
||||
|
||||
// Add hits from rerolls
|
||||
var hitRerolls = prepareHitRerolls(hitRollGoal);
|
||||
|
@ -120,6 +121,7 @@ public class AttackScenario {
|
|||
var rerolls = hitRerolls.get();
|
||||
passingHits += rerolls.getProbabilityNumerator() * ((double) hitSuccessProbabilityNumerator / PROBABILITY_DENOMINATOR_D6);
|
||||
}
|
||||
results.setWeaponStat(weapon, WeaponStat.HITS_TOTAL_COUNT, passingHits);
|
||||
|
||||
return passingHits;
|
||||
}
|
||||
|
@ -135,11 +137,12 @@ public class AttackScenario {
|
|||
return Optional.empty();
|
||||
}
|
||||
|
||||
private double calculateWeaponAttacks(Weapon weapon) {
|
||||
private double calculateWeaponAttacks(Weapon weapon, int amountOfWeapons) {
|
||||
double weaponAttacks = weapon.getAttacks();
|
||||
if(weapon.getRapidFire().isPresent() && attackerInRapidFireRange) {
|
||||
weaponAttacks += weapon.getRapidFire().get();
|
||||
}
|
||||
weaponAttacks *= amountOfWeapons;
|
||||
results.setWeaponStat(weapon, WeaponStat.POTENTIAL_HITS_COUNT, weaponAttacks);
|
||||
|
||||
// Add sustained hits
|
||||
|
|
|
@ -4,7 +4,8 @@ import lombok.Getter;
|
|||
|
||||
@Getter
|
||||
public enum WeaponStat {
|
||||
HITS_COUNT(Double.class),
|
||||
HITS_COUNT_WITHOUT_REROLL(Double.class),
|
||||
HITS_TOTAL_COUNT(Double.class),
|
||||
POTENTIAL_HITS_COUNT(Double.class),
|
||||
WOUNDS_COUNT(Double.class),
|
||||
MORTAL_WOUNDS_COUNT(Double.class),
|
||||
|
|
Loading…
Add table
Reference in a new issue