From c3a4b9d781f3dc862ec11419bad01baa417903b4 Mon Sep 17 00:00:00 2001 From: psikomonkie <189469115+psikomonkie@users.noreply.github.com> Date: Sat, 21 Dec 2024 20:45:49 -0500 Subject: [PATCH 1/3] Issue MegaMek 5115: Added Nova CEWS to getExtraC3BV --- megamek/src/megamek/common/Entity.java | 29 +++++++++++++++----------- 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/megamek/src/megamek/common/Entity.java b/megamek/src/megamek/common/Entity.java index 352aff9d36..3338452e18 100644 --- a/megamek/src/megamek/common/Entity.java +++ b/megamek/src/megamek/common/Entity.java @@ -13168,21 +13168,26 @@ public int getExtraC3BV(int baseBV) { // some hackery and magic numbers here. could be better // also, each 'has' loops through all equipment. inefficient to do it 3 times int xbv = 0; - if ((game != null) - && ((hasC3MM() && (calculateFreeC3MNodes() < 2)) + if (game != null) { + int totalForceBV = 0; + double multiplier = 0.05; + if ((hasC3MM() && (calculateFreeC3MNodes() < 2)) || (hasC3M() && (calculateFreeC3Nodes() < 3)) || (hasC3S() && (c3Master > NONE)) - || ((hasC3i() || hasNavalC3()) && (calculateFreeC3Nodes() < 5)))) { - int totalForceBV = 0; - totalForceBV += baseBV; - for (Entity e : game.getC3NetworkMembers(this)) { - if (!equals(e) && onSameC3NetworkAs(e)) { - totalForceBV += e.calculateBattleValue(true, true); + || ((hasC3i() || hasNavalC3()) && (calculateFreeC3Nodes() < 5))) { + + totalForceBV += baseBV; + for (Entity e : game.getC3NetworkMembers(this)) { + if (!equals(e) && onSameC3NetworkAs(e)) { + totalForceBV += e.calculateBattleValue(true, true); + } } - } - double multiplier = 0.05; - if (hasBoostedC3()) { - multiplier = 0.07; + if (hasBoostedC3()) { + multiplier = 0.07; + } + + } else if (hasNovaCEWS()) {//Nova CEWS applies 5% to every mek with Nova on the team { + totalForceBV = game.getEntitiesVector().stream().filter(entity -> !equals(entity) && entity.hasNovaCEWS() && !entity.owner.isEnemyOf(this.owner)).toList().stream().mapToInt(e -> e.calculateBattleValue(true, true)).sum(); } xbv += (int) Math.round(totalForceBV * multiplier); } From 2b66d2950cd994540f4c472ee2ac35e4181eedb7 Mon Sep 17 00:00:00 2001 From: psikomonkie <189469115+psikomonkie@users.noreply.github.com> Date: Sat, 21 Dec 2024 21:54:31 -0500 Subject: [PATCH 2/3] Issue MegaMek 5115: Added Nova CEWS to getExtraC3BV --- megamek/src/megamek/common/Entity.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/megamek/src/megamek/common/Entity.java b/megamek/src/megamek/common/Entity.java index 3338452e18..5f0844fafb 100644 --- a/megamek/src/megamek/common/Entity.java +++ b/megamek/src/megamek/common/Entity.java @@ -13186,8 +13186,15 @@ public int getExtraC3BV(int baseBV) { multiplier = 0.07; } - } else if (hasNovaCEWS()) {//Nova CEWS applies 5% to every mek with Nova on the team { - totalForceBV = game.getEntitiesVector().stream().filter(entity -> !equals(entity) && entity.hasNovaCEWS() && !entity.owner.isEnemyOf(this.owner)).toList().stream().mapToInt(e -> e.calculateBattleValue(true, true)).sum(); + } else if (hasNovaCEWS()) { //Nova CEWS applies 5% to every mek with Nova on the team { + for (Entity entity : game.getEntitiesVector()) { + if (!equals(entity) && entity.hasNovaCEWS() && !(entity.owner.isEnemyOf(this.owner))) { + totalForceBV += entity.calculateBattleValue(true, true); + } + } + if (totalForceBV > 0) { //But only if there's at least one other mek with Nova CEWS + totalForceBV += baseBV; + } } xbv += (int) Math.round(totalForceBV * multiplier); } From 3b7ac025e60a033676ee570666ff9217039f52b5 Mon Sep 17 00:00:00 2001 From: psikomonkie <189469115+psikomonkie@users.noreply.github.com> Date: Sat, 21 Dec 2024 21:58:37 -0500 Subject: [PATCH 3/3] Issue MegaMek 5115: Cleaned Up getExtraC3BV --- megamek/src/megamek/common/Entity.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/megamek/src/megamek/common/Entity.java b/megamek/src/megamek/common/Entity.java index 5f0844fafb..744c06673a 100644 --- a/megamek/src/megamek/common/Entity.java +++ b/megamek/src/megamek/common/Entity.java @@ -13167,7 +13167,8 @@ public int getExtraC3BV(int baseBV) { // extra from c3 networks. a valid network requires at least 2 members // some hackery and magic numbers here. could be better // also, each 'has' loops through all equipment. inefficient to do it 3 times - int xbv = 0; + // Nova CEWS is quirky and handled apart from the other C3 + int extraBV = 0; if (game != null) { int totalForceBV = 0; double multiplier = 0.05; @@ -13175,11 +13176,10 @@ public int getExtraC3BV(int baseBV) { || (hasC3M() && (calculateFreeC3Nodes() < 3)) || (hasC3S() && (c3Master > NONE)) || ((hasC3i() || hasNavalC3()) && (calculateFreeC3Nodes() < 5))) { - totalForceBV += baseBV; - for (Entity e : game.getC3NetworkMembers(this)) { - if (!equals(e) && onSameC3NetworkAs(e)) { - totalForceBV += e.calculateBattleValue(true, true); + for (Entity entity : game.getC3NetworkMembers(this)) { + if (!equals(entity) && onSameC3NetworkAs(entity)) { + totalForceBV += entity.calculateBattleValue(true, true); } } if (hasBoostedC3()) { @@ -13196,9 +13196,9 @@ public int getExtraC3BV(int baseBV) { totalForceBV += baseBV; } } - xbv += (int) Math.round(totalForceBV * multiplier); + extraBV += (int) Math.round(totalForceBV * multiplier); } - return xbv; + return extraBV; } public boolean hasUnloadedUnitsFromBays() {