From 0f12026df0edcf813f8c3dab48be596cd194c80c Mon Sep 17 00:00:00 2001 From: Ziggy Date: Sun, 13 Oct 2019 14:44:58 +0200 Subject: [PATCH] 187: Less nesting in CombatCommandAttack#isAttackDevastating() --- .../combat/command/CombatCommandAttack.java | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/projectswg/holocore/services/gameplay/combat/command/CombatCommandAttack.java b/src/main/java/com/projectswg/holocore/services/gameplay/combat/command/CombatCommandAttack.java index 6a6951b2..b71273bd 100644 --- a/src/main/java/com/projectswg/holocore/services/gameplay/combat/command/CombatCommandAttack.java +++ b/src/main/java/com/projectswg/holocore/services/gameplay/combat/command/CombatCommandAttack.java @@ -288,16 +288,15 @@ enum CombatCommandAttack implements CombatCommandHitType { WeaponObject weapon = source.getEquippedWeapon(); WeaponType type = weapon.getType(); - // Only AoE and CoE heavy weapons can qualify for a devastation roll - switch (type) { - case HEAVY_WEAPON: - case DIRECTIONAL_TARGET_WEAPON: - double devastationChance = source.getSkillModValue("expertise_devastation_bonus") / 10; - double roll = ThreadLocalRandom.current().nextDouble(100); // Generate number between 0 and 100 - - return roll <= devastationChance; // If devastation chance is 20%, then the roll should be between 0 and 20 (both inclusive) - default: return false; + if (!WeaponType.HEAVY_WEAPON.equals(type) && !WeaponType.DIRECTIONAL_TARGET_WEAPON.equals(type)) { + // If the weapon type isn't a heavy weapon and isn't a flamethrower, then the weapon cannot roll a devastation + return false; } + + double devastationChance = source.getSkillModValue("expertise_devastation_bonus") / 10; + double roll = ThreadLocalRandom.current().nextDouble(100); // Generate number between 0 and 100 + + return roll <= devastationChance; // If devastation chance is 20%, then the roll should be between 0 and 20 (both inclusive) } }