From c2a19499c994df9a577c807cc940f74722fde8d8 Mon Sep 17 00:00:00 2001 From: Loic Prieto Date: Sun, 15 Jun 2025 23:24:57 +0200 Subject: [PATCH] Keep implementing attack resolution --- .../games/fourtykcalculator/AttackScenario.java | 7 +++++-- .../games/fourtykcalculator/WeaponStat.java | 3 ++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/main/java/ninja/thefirearchmage/games/fourtykcalculator/AttackScenario.java b/src/main/java/ninja/thefirearchmage/games/fourtykcalculator/AttackScenario.java index f2d85e8..ed21ecc 100644 --- a/src/main/java/ninja/thefirearchmage/games/fourtykcalculator/AttackScenario.java +++ b/src/main/java/ninja/thefirearchmage/games/fourtykcalculator/AttackScenario.java @@ -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 diff --git a/src/main/java/ninja/thefirearchmage/games/fourtykcalculator/WeaponStat.java b/src/main/java/ninja/thefirearchmage/games/fourtykcalculator/WeaponStat.java index 091800c..79109f5 100644 --- a/src/main/java/ninja/thefirearchmage/games/fourtykcalculator/WeaponStat.java +++ b/src/main/java/ninja/thefirearchmage/games/fourtykcalculator/WeaponStat.java @@ -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),