diff --git a/game-app/ai/src/main/java/org/triplea/ai/flowfield/neighbors/NeighborGetter.java b/game-app/ai/src/main/java/org/triplea/ai/flowfield/neighbors/NeighborGetter.java index a909759f549..7e3f932ce8e 100644 --- a/game-app/ai/src/main/java/org/triplea/ai/flowfield/neighbors/NeighborGetter.java +++ b/game-app/ai/src/main/java/org/triplea/ai/flowfield/neighbors/NeighborGetter.java @@ -23,9 +23,9 @@ public class NeighborGetter implements Function public Collection apply(final Territory territory) { final UnitAttachment unitAttachment = unitType.getUnitAttachment(); final PredicateBuilder territoryPredicate = PredicateBuilder.trueBuilder(); - if (unitAttachment.getIsSea()) { + if (unitAttachment.isSea()) { territoryPredicate.and(Territory::isWater); - } else if (!unitAttachment.getIsAir()) { + } else if (!unitAttachment.isAir()) { territoryPredicate.and(Predicate.not(Territory::isWater)); } return gameMap.getNeighbors(territory, territoryPredicate.build()); diff --git a/game-app/game-core/src/main/java/games/strategy/engine/data/unit/ability/UnitAbilityFactory.java b/game-app/game-core/src/main/java/games/strategy/engine/data/unit/ability/UnitAbilityFactory.java index 339eab2fcf6..d0267c587a1 100644 --- a/game-app/game-core/src/main/java/games/strategy/engine/data/unit/ability/UnitAbilityFactory.java +++ b/game-app/game-core/src/main/java/games/strategy/engine/data/unit/ability/UnitAbilityFactory.java @@ -143,7 +143,7 @@ private static void generatePerPlayer(final Parameters parameters, final GamePla private static void generatePerPlayerAndUnit( final Parameters parameters, final GamePlayer player, final UnitType unitType) { final UnitAttachment unitAttachment = unitType.getUnitAttachment(); - if (unitAttachment.getIsAaForCombatOnly()) { + if (unitAttachment.isAaForCombatOnly()) { createAaUnitAbilities(parameters, player, unitType); } createUnitAbilities(parameters, player, unitType); @@ -217,7 +217,7 @@ private static CombatUnitAbility.Suicide calculateSuicideType( ? unitAttachment.getIsSuicideOnAttack() : unitAttachment.getIsSuicideOnDefense()) { return CombatUnitAbility.Suicide.AFTER_FIRE; - } else if (unitAttachment.getIsSuicideOnHit()) { + } else if (unitAttachment.isSuicideOnHit()) { return CombatUnitAbility.Suicide.AFTER_HIT; } else { return CombatUnitAbility.Suicide.NONE; @@ -370,8 +370,7 @@ private static List getTargetsWithoutDestroyer( } private static Predicate isNotInfrastructure() { - return Predicate.not( - possibleTarget -> possibleTarget.getUnitAttachment().getIsInfrastructure()); + return Predicate.not(possibleTarget -> possibleTarget.getUnitAttachment().isInfrastructure()); } private static void createAntiFirstStrikeAbility( @@ -402,7 +401,7 @@ private static void createAntiFirstStrikeAbility( private static Collection getIsDestroyerUnitTypes(final UnitTypeList unitTypeList) { return unitTypeList.stream() - .filter(unitType -> unitType.getUnitAttachment().getIsDestroyer()) + .filter(unitType -> unitType.getUnitAttachment().isDestroyer()) .collect(Collectors.toList()); } diff --git a/game-app/game-core/src/main/java/games/strategy/triplea/ai/AiUtils.java b/game-app/game-core/src/main/java/games/strategy/triplea/ai/AiUtils.java index cb23af49527..f09939f1b61 100644 --- a/game-app/game-core/src/main/java/games/strategy/triplea/ai/AiUtils.java +++ b/game-app/game-core/src/main/java/games/strategy/triplea/ai/AiUtils.java @@ -72,7 +72,7 @@ public static float strength( float strength = 0; for (final Unit u : units) { final UnitAttachment unitAttachment = u.getUnitAttachment(); - if (!unitAttachment.getIsInfrastructure() && unitAttachment.getIsSea() == sea) { + if (!unitAttachment.isInfrastructure() && unitAttachment.isSea() == sea) { // 2 points since we can absorb a hit strength += 2; // two hit diff --git a/game-app/game-core/src/main/java/games/strategy/triplea/ai/pro/ProCombatMoveAi.java b/game-app/game-core/src/main/java/games/strategy/triplea/ai/pro/ProCombatMoveAi.java index 23f4bce42d6..ccc58b2f6b4 100644 --- a/game-app/game-core/src/main/java/games/strategy/triplea/ai/pro/ProCombatMoveAi.java +++ b/game-app/game-core/src/main/java/games/strategy/triplea/ai/pro/ProCombatMoveAi.java @@ -877,7 +877,7 @@ private void determineUnitsToAttackWith( // Set air units in any territory with no AA (don't move planes to empty territories) for (final Unit unit : sortedUnitAttackOptions.keySet()) { - final boolean isAirUnit = unit.getUnitAttachment().getIsAir(); + final boolean isAirUnit = unit.getUnitAttachment().isAir(); if (!isAirUnit) { continue; // skip non-air units } @@ -965,7 +965,7 @@ private void determineUnitsToAttackWith( // Add sea units to any territory that significantly increases TUV gain for (final Unit unit : sortedUnitAttackOptions.keySet()) { - final boolean isSeaUnit = unit.getUnitAttachment().getIsSea(); + final boolean isSeaUnit = unit.getUnitAttachment().isSea(); if (!isSeaUnit) { continue; // skip non-sea units } @@ -1285,7 +1285,7 @@ private Map> tryToAttackTerritories( // Try to set at least one destroyer in each sea territory with subs for (final Unit unit : sortedUnitAttackOptions.keySet()) { - final boolean isDestroyerUnit = unit.getUnitAttachment().getIsDestroyer(); + final boolean isDestroyerUnit = unit.getUnitAttachment().isDestroyer(); if (!isDestroyerUnit) { continue; // skip non-destroyer units } @@ -1306,7 +1306,7 @@ private Map> tryToAttackTerritories( // Set enough land and sea units in territories to have at least a chance of winning for (final Unit unit : sortedUnitAttackOptions.keySet()) { - final boolean isAirUnit = unit.getUnitAttachment().getIsAir(); + final boolean isAirUnit = unit.getUnitAttachment().isAir(); final boolean isExpensiveLandUnit = Matches.unitIsLand().test(unit) && proData.getUnitValue(unit.getType()) > 2 * proData.getMinCostPerHitPoint(); @@ -1346,7 +1346,7 @@ private Map> tryToAttackTerritories( // Set non-air units in territories that can be held for (final Unit unit : sortedUnitAttackOptions.keySet()) { - final boolean isAirUnit = unit.getUnitAttachment().getIsAir(); + final boolean isAirUnit = unit.getUnitAttachment().isAir(); if (isAirUnit || addedUnits.contains(unit)) { continue; // skip air units } @@ -1383,7 +1383,7 @@ private Map> tryToAttackTerritories( // Set air units in territories that can't be held (don't move planes to empty territories) for (final Unit unit : sortedUnitAttackOptions.keySet()) { - final boolean isAirUnit = unit.getUnitAttachment().getIsAir(); + final boolean isAirUnit = unit.getUnitAttachment().isAir(); if (!isAirUnit) { continue; // skip non-air units } @@ -1455,7 +1455,7 @@ private Map> tryToAttackTerritories( if (addedUnits.contains(unit)) { continue; } - final boolean isAirUnit = unit.getUnitAttachment().getIsAir(); + final boolean isAirUnit = unit.getUnitAttachment().isAir(); Territory minWinTerritory = null; double minWinPercentage = proData.getWinPercentage(); for (final Territory t : sortedUnitAttackOptions.get(unit)) { diff --git a/game-app/game-core/src/main/java/games/strategy/triplea/ai/pro/ProNonCombatMoveAi.java b/game-app/game-core/src/main/java/games/strategy/triplea/ai/pro/ProNonCombatMoveAi.java index bde81bbe4ef..096c69506eb 100644 --- a/game-app/game-core/src/main/java/games/strategy/triplea/ai/pro/ProNonCombatMoveAi.java +++ b/game-app/game-core/src/main/java/games/strategy/triplea/ai/pro/ProNonCombatMoveAi.java @@ -763,7 +763,7 @@ private void moveUnitsToDefendTerritories( // Set enough units in territories to have at least a chance of winning for (final Unit unit : sortedUnitMoveOptions.keySet()) { - final boolean isAirUnit = unit.getUnitAttachment().getIsAir(); + final boolean isAirUnit = unit.getUnitAttachment().isAir(); if (isAirUnit || Matches.unitIsCarrier().test(unit) || addedUnits.contains(unit)) { continue; // skip air and carrier units } diff --git a/game-app/game-core/src/main/java/games/strategy/triplea/ai/pro/ProTechAi.java b/game-app/game-core/src/main/java/games/strategy/triplea/ai/pro/ProTechAi.java index 14a3db48d31..ad2072b474f 100644 --- a/game-app/game-core/src/main/java/games/strategy/triplea/ai/pro/ProTechAi.java +++ b/game-app/game-core/src/main/java/games/strategy/triplea/ai/pro/ProTechAi.java @@ -311,8 +311,8 @@ private static float strength( } for (final Unit u : units) { final UnitAttachment unitAttachment = u.getUnitAttachment(); - if (unitAttachment.getIsInfrastructure()) { - if (unitAttachment.getIsSea() == sea) { + if (unitAttachment.isInfrastructure()) { + if (unitAttachment.isSea() == sea) { final int unitAttack = unitAttachment.getAttack(u.getOwner()); // BB = 6.0; AC=2.0/4.0; SUB=3.0; DS=4.0; TR=0.50/2.0; F=4.0/5.0; B=5.0/2.0; // played with this value a good bit @@ -330,7 +330,7 @@ private static float strength( // only allow transport to have 0.35 on defense; none on attack strength -= 0.50F; } - } else if (unitAttachment.getIsAir() == sea) { + } else if (unitAttachment.isAir() == sea) { strength += 1.00F; if (attacking) { strength += diff --git a/game-app/game-core/src/main/java/games/strategy/triplea/ai/pro/data/ProPurchaseOption.java b/game-app/game-core/src/main/java/games/strategy/triplea/ai/pro/data/ProPurchaseOption.java index 734575de298..a5eb4ce42b9 100644 --- a/game-app/game-core/src/main/java/games/strategy/triplea/ai/pro/data/ProPurchaseOption.java +++ b/game-app/game-core/src/main/java/games/strategy/triplea/ai/pro/data/ProPurchaseOption.java @@ -75,13 +75,13 @@ public class ProPurchaseOption { final Resource pus = data.getResourceList().getResource(Constants.PUS); cost = productionRule.getCosts().getInt(pus); costs = productionRule.getCosts(); - isConstruction = unitAttachment.getIsConstruction(); + isConstruction = unitAttachment.isConstruction(); constructionType = unitAttachment.getConstructionType(); constructionTypePerTurn = unitAttachment.getConstructionsPerTerrPerTypePerTurn(); maxConstructionType = unitAttachment.getMaxConstructionsPerTypePerTerr(); movement = unitAttachment.getMovement(player); quantity = productionRule.getResults().totalValues(); - final boolean isInfra = unitAttachment.getIsInfrastructure(); + final boolean isInfra = unitAttachment.isInfrastructure(); hitPoints = unitAttachment.getHitPoints() * quantity; if (isInfra) { hitPoints = 0; @@ -91,9 +91,9 @@ public class ProPurchaseOption { defense = (double) unitAttachment.getDefense(player) * quantity; transportCost = unitAttachment.getTransportCost() * quantity; carrierCost = unitAttachment.getCarrierCost() * quantity; - isAir = unitAttachment.getIsAir(); + isAir = unitAttachment.isAir(); isSub = unitAttachment.getCanEvade(); - isDestroyer = unitAttachment.getIsDestroyer(); + isDestroyer = unitAttachment.isDestroyer(); isTransport = unitAttachment.getTransportCapacity() > 0; isLandTransport = unitAttachment.isLandTransport(); isCarrier = unitAttachment.getCarrierCapacity() > 0; diff --git a/game-app/game-core/src/main/java/games/strategy/triplea/ai/pro/data/ProPurchaseOptionMap.java b/game-app/game-core/src/main/java/games/strategy/triplea/ai/pro/data/ProPurchaseOptionMap.java index 6b105dfbeb0..9df93713b9c 100644 --- a/game-app/game-core/src/main/java/games/strategy/triplea/ai/pro/data/ProPurchaseOptionMap.java +++ b/game-app/game-core/src/main/java/games/strategy/triplea/ai/pro/data/ProPurchaseOptionMap.java @@ -66,8 +66,7 @@ public ProPurchaseOptionMap(final GamePlayer player, final GameData data) { final UnitType unitType = (UnitType) resourceOrUnit; // Add rule to appropriate purchase option list - if (unitType.getUnitAttachment().getIsSuicideOnHit() - || canUnitTypeSuicide(unitType, player)) { + if (unitType.getUnitAttachment().isSuicideOnHit() || canUnitTypeSuicide(unitType, player)) { final ProPurchaseOption ppo = new ProPurchaseOption(rule, unitType, player, data); specialOptions.add(ppo); ProLogger.debug("Special: " + ppo); diff --git a/game-app/game-core/src/main/java/games/strategy/triplea/ai/pro/util/ProSortMoveOptionsUtils.java b/game-app/game-core/src/main/java/games/strategy/triplea/ai/pro/util/ProSortMoveOptionsUtils.java index 9b9dbf35709..e958b10ec4e 100644 --- a/game-app/game-core/src/main/java/games/strategy/triplea/ai/pro/util/ProSortMoveOptionsUtils.java +++ b/game-app/game-core/src/main/java/games/strategy/triplea/ai/pro/util/ProSortMoveOptionsUtils.java @@ -149,7 +149,7 @@ public static Map> sortUnitNeededOptionsThenAttack( final UnitType unitType2 = u2.getType(); // If unit types are equal and are air, then sort by average distance. - if (unitType1.equals(unitType2) && unitType1.getUnitAttachment().getIsAir()) { + if (unitType1.equals(unitType2) && unitType1.getUnitAttachment().isAir()) { final Predicate predicate = ProMatches.territoryCanMoveAirUnitsAndNoAa(data, player, true); final Territory territory1 = unitTerritoryMap.get(u1); @@ -231,7 +231,7 @@ private static double calculateAttackEfficiency( minPower = powerDifference; } } - if (unit.getUnitAttachment().getIsAir()) { + if (unit.getUnitAttachment().isAir()) { minPower *= 10; } final double unitValue = proData.getUnitValue(unit.getType()); diff --git a/game-app/game-core/src/main/java/games/strategy/triplea/ai/weak/WeakAi.java b/game-app/game-core/src/main/java/games/strategy/triplea/ai/weak/WeakAi.java index 4a7f3b2cf25..e318e0dab9e 100644 --- a/game-app/game-core/src/main/java/games/strategy/triplea/ai/weak/WeakAi.java +++ b/game-app/game-core/src/main/java/games/strategy/triplea/ai/weak/WeakAi.java @@ -182,7 +182,7 @@ private List calculateTransportLoad( while (iter.hasNext() && free > 0) { final Unit current = iter.next(); final UnitAttachment ua = current.getUnitAttachment(); - if (ua.getIsAir()) { + if (ua.isAir()) { continue; } if (ua.getTransportCost() <= free) { diff --git a/game-app/game-core/src/main/java/games/strategy/triplea/attachments/UnitAttachment.java b/game-app/game-core/src/main/java/games/strategy/triplea/attachments/UnitAttachment.java index 47914e9e73f..0cea7ef959e 100644 --- a/game-app/game-core/src/main/java/games/strategy/triplea/attachments/UnitAttachment.java +++ b/game-app/game-core/src/main/java/games/strategy/triplea/attachments/UnitAttachment.java @@ -39,6 +39,7 @@ import javax.annotation.Nullable; import lombok.Getter; import lombok.Value; +import lombok.experimental.Accessors; import org.triplea.java.ChangeOnNextMajorRelease; import org.triplea.java.collections.CollectionUtils; import org.triplea.java.collections.IntegerMap; @@ -70,24 +71,45 @@ public class UnitAttachment extends DefaultAttachment { private static final long serialVersionUID = -2946748686268541820L; // movement related + @Accessors(fluent = true) + @Getter private boolean isAir = false; + + @Accessors(fluent = true) + @Getter private boolean isSea = false; + private int movement = 0; private boolean canBlitz = false; + + @Accessors(fluent = true) + @Getter private boolean isKamikaze = false; + // a colon delimited list of transports where this unit may invade from, it supports "none" // and if empty it allows you to invade from all private @Nullable String[] canInvadeOnlyFrom = null; private @Nullable IntegerMap fuelCost = null; private @Nullable IntegerMap fuelFlatCost = null; + + @Accessors(fluent = true) + @Getter private boolean canNotMoveDuringCombatMove = false; + private @Nullable Tuple movementLimit = null; // combat related private int attack = 0; private int defense = 0; + + @Accessors(fluent = true) + @Getter private boolean isInfrastructure = false; + + @Accessors(fluent = true) + @Getter private boolean canBombard = false; + private int bombard = -1; private boolean artillery = false; private boolean artillerySupportable = false; @@ -95,7 +117,11 @@ public class UnitAttachment extends DefaultAttachment { @Getter private int isMarine = 0; private boolean isSuicideOnAttack = false; private boolean isSuicideOnDefense = false; + + @Accessors(fluent = true) + @Getter private boolean isSuicideOnHit = false; + private @Nullable Tuple attackingLimit = null; private int attackRolls = 1; private int defenseRolls = 1; @@ -103,16 +129,28 @@ public class UnitAttachment extends DefaultAttachment { private @Nullable Boolean canRetreatOnStalemate; // sub/destroyer related + @Accessors(fluent = true) + @Getter private boolean canEvade = false; + private boolean isFirstStrike = false; private @Nullable Set canNotTarget = null; private @Nullable Set canNotBeTargetedBy = null; private boolean canMoveThroughEnemies = false; + + @Accessors(fluent = true) + @Getter private boolean canBeMovedThroughByEnemies = false; + + @Accessors(fluent = true) + @Getter private boolean isDestroyer = false; // transportation related + @Accessors(fluent = true) + @Getter private boolean isCombatTransport = false; + // -1 if cant transport @Getter private int transportCapacity = -1; // -1 if cant be transported @@ -121,18 +159,42 @@ public class UnitAttachment extends DefaultAttachment { @Getter private int carrierCapacity = -1; // -1 if cant land on a carrier @Getter private int carrierCost = -1; + + @Accessors(fluent = true) + @Getter private boolean isAirTransport = false; + + @Accessors(fluent = true) + @Getter private boolean isAirTransportable = false; + + @Accessors(fluent = true) + @Getter private boolean isLandTransport = false; + + @Accessors(fluent = true) + @Getter private boolean isLandTransportable = false; // aa related // "isAA" and "isAAmovement" are also valid setters, used as shortcuts for calling multiple aa // related setters. Must keep. + @Accessors(fluent = true) + @Getter private boolean isAaForCombatOnly = false; + + @Accessors(fluent = true) + @Getter private boolean isAaForBombingThisUnitOnly = false; + + @Accessors(fluent = true) + @Getter private boolean isAaForFlyOverOnly = false; + + @Accessors(fluent = true) + @Getter private boolean isRocket = false; + private int attackAa = 1; private int offensiveAttackAa = 0; private int attackAaMaxDieSides = -1; @@ -153,13 +215,27 @@ public class UnitAttachment extends DefaultAttachment { private @Nullable Set willNotFireIfPresent = null; // strategic bombing related + @Accessors(fluent = true) + @Getter private boolean isStrategicBomber = false; + @Getter private int bombingMaxDieSides = -1; @Getter private int bombingBonus = 0; + + @Accessors(fluent = true) + @Getter private boolean canIntercept = false; + private boolean requiresAirBaseToIntercept = false; + + @Accessors(fluent = true) + @Getter private boolean canEscort = false; + + @Accessors(fluent = true) + @Getter private boolean canAirBattle = false; + private int airDefense = 0; private int airAttack = 0; // null means they can target any unit that can be damaged @@ -167,7 +243,10 @@ public class UnitAttachment extends DefaultAttachment { // production related // this has been split into canProduceUnits, isConstruction, canBeDamaged, and isInfrastructure + @Accessors(fluent = true) + @Getter private boolean canProduceUnits = false; + // -1 means either it can't produce any, or it produces at the value of the territory it is // located in @Getter private int canProduceXUnits = -1; @@ -176,16 +255,23 @@ public class UnitAttachment extends DefaultAttachment { // damage related @Getter private int hitPoints = 1; + + @Accessors(fluent = true) + @Getter private boolean canBeDamaged = false; - // this is bombing damage, not hitpoints. default of 2 means that factories will take 2x the + + // this is bombing damage, not hit points. default of 2 means that factories will take 2x the // territory value they are in, of damage. @Getter private int maxDamage = 2; - // -1 if can't be disabled + // -1 for can't be disabled @Getter private int maxOperationalDamage = -1; + + @Accessors(fluent = true) + @Getter private boolean canDieFromReachingMaxDamage = false; // placement related - private boolean isConstruction = false; + @Getter private boolean isConstruction = false; // can be any String except for "none" if isConstruction is true @Getter private String constructionType = "none"; // -1 if not set, is meaningless @@ -210,9 +296,12 @@ public class UnitAttachment extends DefaultAttachment { private @Nullable Tuple placementLimit = null; // scrambling related + @Accessors(fluent = true) + @Getter private boolean canScramble = false; - private boolean isAirBase = false; - // -1 if can't scramble + + @Getter private boolean isAirBase = false; + // -1 for can't scramble @Getter private int maxScrambleDistance = -1; // -1 for infinite @Getter private int maxScrambleCount = -1; @@ -277,10 +366,6 @@ private void setCanIntercept(final Boolean value) { canIntercept = value; } - public boolean getCanIntercept() { - return canIntercept; - } - private void resetCanIntercept() { canIntercept = false; } @@ -309,10 +394,6 @@ private void setCanEscort(final Boolean value) { canEscort = value; } - public boolean getCanEscort() { - return canEscort; - } - private void resetCanEscort() { canEscort = false; } @@ -325,10 +406,6 @@ private void setCanAirBattle(final Boolean value) { canAirBattle = value; } - public boolean getCanAirBattle() { - return canAirBattle; - } - private void resetCanAirBattle() { canAirBattle = false; } @@ -385,10 +462,6 @@ private void setIsAirTransport(final Boolean s) { isAirTransport = s; } - public boolean getIsAirTransport() { - return isAirTransport; - } - private void resetIsAirTransport() { isAirTransport = false; } @@ -401,10 +474,6 @@ private void setIsAirTransportable(final Boolean s) { isAirTransportable = s; } - public boolean getIsAirTransportable() { - return isAirTransportable; - } - private void resetIsAirTransportable() { isAirTransportable = false; } @@ -549,8 +618,7 @@ private void setWhenCapturedSustainsDamage(final int s) { private void setDestroyedWhenCapturedBy(final String initialValue) throws GameParseException { // We can prefix this value with "BY" or "FROM" to change the setting. If no setting, default to - // "BY" since this - // this is called by destroyedWhenCapturedBy + // "BY" since this is called by destroyedWhenCapturedBy String value = initialValue; String byOrFrom = "BY"; if (value.startsWith("BY:") && getData().getPlayerList().getPlayerId("BY") == null) { @@ -721,10 +789,6 @@ private void setIsCombatTransport(final Boolean s) { isCombatTransport = s; } - public boolean getIsCombatTransport() { - return isCombatTransport; - } - private void resetIsCombatTransport() { isCombatTransport = false; } @@ -737,10 +801,6 @@ private void setIsStrategicBomber(final Boolean s) { isStrategicBomber = s; } - public boolean getIsStrategicBomber() { - return isStrategicBomber; - } - private void resetIsStrategicBomber() { isStrategicBomber = false; } @@ -754,10 +814,6 @@ public void setIsDestroyer(final Boolean s) { isDestroyer = s; } - public boolean getIsDestroyer() { - return isDestroyer; - } - private void resetIsDestroyer() { isDestroyer = false; } @@ -792,10 +848,6 @@ public void setIsAir(final Boolean s) { isAir = s; } - public boolean getIsAir() { - return isAir; - } - private void resetIsAir() { isAir = false; } @@ -810,10 +862,6 @@ public UnitAttachment setIsSea(final Boolean s) { return this; } - public boolean getIsSea() { - return isSea; - } - private void resetIsSea() { isSea = false; } @@ -827,7 +875,7 @@ private void setIsFactory(final Boolean s) { setIsInfrastructure(s); setCanProduceUnits(s); setIsConstruction(s); - if (s) { + if (Boolean.TRUE.equals(s)) { setConstructionType(Constants.CONSTRUCTION_TYPE_FACTORY); setMaxConstructionsPerTypePerTerr("1"); setConstructionsPerTerrPerTypePerTurn("1"); @@ -847,10 +895,6 @@ private void setCanProduceUnits(final Boolean s) { canProduceUnits = s; } - public boolean getCanProduceUnits() { - return canProduceUnits; - } - private void resetCanProduceUnits() { canProduceUnits = false; } @@ -913,7 +957,7 @@ private void setUnitPlacementOnlyAllowedIn(final String value) throws GameParseE private void setRepairsUnits(final String value) throws GameParseException { final String[] s = splitOnColon(value); - if (s.length <= 0) { + if (s.length == 0) { throw new GameParseException("repairsUnits cannot be empty" + thisErrorMsg()); } int i = 0; @@ -1196,10 +1240,6 @@ private void setIsConstruction(final Boolean s) { isConstruction = s; } - public boolean getIsConstruction() { - return isConstruction; - } - private void resetIsConstruction() { isConstruction = false; } @@ -1264,10 +1304,6 @@ private void setIsLandTransportable(final Boolean s) { isLandTransportable = s; } - public boolean getIsLandTransportable() { - return isLandTransportable; - } - private void resetIsLandTransportable() { isLandTransportable = false; } @@ -1280,14 +1316,6 @@ private void setIsLandTransport(final Boolean s) { isLandTransport = s; } - public boolean isLandTransport() { - return isLandTransport; - } - - public boolean getIsLandTransport() { - return isLandTransport; - } - private void resetIsLandTransport() { isLandTransport = false; } @@ -1296,6 +1324,10 @@ private void setTransportCapacity(final int s) { transportCapacity = s; } + public boolean isTransportCapacity() { + return (transportCapacity >= 0); + } + private void setIsTwoHit(final String s) { setIsTwoHit(getBool(s)); } @@ -1574,10 +1606,6 @@ private void setCanScramble(final Boolean s) { canScramble = s; } - public boolean getCanScramble() { - return canScramble; - } - private void resetCanScramble() { canScramble = false; } @@ -1650,10 +1678,6 @@ private void setIsAirBase(final Boolean s) { isAirBase = s; } - public boolean getIsAirBase() { - return isAirBase; - } - private void resetIsAirBase() { isAirBase = false; } @@ -1668,10 +1692,6 @@ public UnitAttachment setIsInfrastructure(final Boolean s) { return this; } - public boolean getIsInfrastructure() { - return isInfrastructure; - } - private void resetIsInfrastructure() { isInfrastructure = false; } @@ -1684,10 +1704,6 @@ private void setCanBeDamaged(final Boolean s) { canBeDamaged = s; } - public boolean getCanBeDamaged() { - return canBeDamaged; - } - private void resetCanBeDamaged() { canBeDamaged = false; } @@ -1700,10 +1716,6 @@ private void setCanDieFromReachingMaxDamage(final Boolean s) { canDieFromReachingMaxDamage = s; } - public boolean getCanDieFromReachingMaxDamage() { - return canDieFromReachingMaxDamage; - } - private void resetCanDieFromReachingMaxDamage() { canDieFromReachingMaxDamage = false; } @@ -1751,10 +1763,6 @@ public UnitAttachment setIsSuicideOnHit(final Boolean s) { return this; } - public boolean getIsSuicideOnHit() { - return isSuicideOnHit; - } - private void resetIsSuicideOnHit() { isSuicideOnHit = false; } @@ -1767,10 +1775,6 @@ private void setIsKamikaze(final Boolean s) { isKamikaze = s; } - public boolean getIsKamikaze() { - return isKamikaze; - } - private void resetIsKamikaze() { isKamikaze = false; } @@ -1858,7 +1862,7 @@ private void addToUnitTypeMap( String context, IntegerMap utMap, String value, int minValue) throws GameParseException { final String[] s = splitOnColon(value); - if (s.length <= 0 || s.length > 2) { + if (s.length == 0 || s.length > 2) { throw new GameParseException( context + " cannot be empty or have more than two fields" + thisErrorMsg()); } @@ -2194,10 +2198,6 @@ public UnitAttachment setIsAaForCombatOnly(final Boolean s) { return this; } - public boolean getIsAaForCombatOnly() { - return isAaForCombatOnly; - } - private void resetIsAaForCombatOnly() { isAaForCombatOnly = false; } @@ -2210,10 +2210,6 @@ private void setIsAaForBombingThisUnitOnly(final Boolean s) { isAaForBombingThisUnitOnly = s; } - public boolean getIsAaForBombingThisUnitOnly() { - return isAaForBombingThisUnitOnly; - } - private void resetIsAaForBombingThisUnitOnly() { isAaForBombingThisUnitOnly = false; } @@ -2226,10 +2222,6 @@ private void setIsAaForFlyOverOnly(final Boolean s) { isAaForFlyOverOnly = s; } - public boolean getIsAaForFlyOverOnly() { - return isAaForFlyOverOnly; - } - private void resetIsAaForFlyOverOnly() { isAaForFlyOverOnly = false; } @@ -2242,10 +2234,6 @@ private void setIsRocket(final Boolean s) { isRocket = s; } - public boolean getIsRocket() { - return isRocket; - } - private void resetIsRocket() { isRocket = false; } @@ -2288,7 +2276,7 @@ public Set getTargetsAa(final UnitTypeList unitTypeList) { return Collections.unmodifiableSet(targetsAa); } return unitTypeList.stream() - .filter(ut -> ut.getUnitAttachment().getIsAir()) + .filter(ut -> ut.getUnitAttachment().isAir()) .collect(Collectors.toSet()); } @@ -2338,10 +2326,6 @@ private void setCanNotMoveDuringCombatMove(final Boolean s) { canNotMoveDuringCombatMove = s; } - public boolean getCanNotMoveDuringCombatMove() { - return canNotMoveDuringCombatMove; - } - private void resetCanNotMoveDuringCombatMove() { canNotMoveDuringCombatMove = false; } @@ -2508,7 +2492,7 @@ public void validate(final GameState data) throws GameParseException { "cannot have isCombatTransport on unit without transportCapacity, " + thisErrorMsg()); } if (isSea - && transportCapacity != -1 + && isTransportCapacity() && Properties.getTransportCasualtiesRestricted(data.getProperties()) && (attack > 0 || defense > 0) && !isCombatTransport) { @@ -2627,7 +2611,7 @@ private Collection getListedTerritories(final String[] list) if (territory != null) { territories.add(territory); } else { - // Check if its a territory effect and get all territories + // Check if it's a territory effect and get all territories if (getData().getTerritoryEffectList().containsKey(name)) { for (final Territory t : getData().getMap().getTerritories()) { for (final TerritoryEffect te : TerritoryEffectHelper.getEffects(t)) { @@ -2910,7 +2894,7 @@ public String allUnitStatsForExporter() { } /** - * Displays all unit options in a short description form that's user friendly rather than as XML. + * Displays all unit options in a short description form that's user-friendly rather than as XML. * Shows all except for: constructionType, constructionsPerTerrPerTypePerTurn, * maxConstructionsPerTypePerTerr, canBeGivenByTerritoryTo, destroyedWhenCapturedBy, * canBeCapturedOnEnteringBy. @@ -2919,9 +2903,9 @@ public String toStringShortAndOnlyImportantDifferences(final GamePlayer player) final Formatter formatter = new Formatter(); final UnitType unitType = (UnitType) this.getAttachedTo(); - if (getIsAir()) { + if (isAir()) { formatter.append("Type", "Air"); - } else if (getIsSea()) { + } else if (isSea()) { formatter.append("Type", "Sea"); } else { formatter.append("Type", "Land"); @@ -2936,9 +2920,9 @@ public String toStringShortAndOnlyImportantDifferences(final GamePlayer player) formatter.append("HP", String.valueOf(getHitPoints())); } - if (getCanProduceUnits() && getCanProduceXUnits() < 0) { + if (canProduceUnits() && getCanProduceXUnits() < 0) { formatter.append("Can Produce Units up to Territory Value", ""); - } else if (getCanProduceUnits() && getCanProduceXUnits() > 0) { + } else if (canProduceUnits() && getCanProduceXUnits() > 0) { formatter.append("Can Produce Units", String.valueOf(getCanProduceXUnits())); } addIntegerMapDescription("Creates Units each Turn", getCreatesUnitsList(), formatter); @@ -2955,7 +2939,7 @@ public String toStringShortAndOnlyImportantDifferences(final GamePlayer player) addAaDescription("Targeted Defense", getAttackAa(player), getAttackAaMaxDieSides(), formatter); // TODO: Rework rocket description - if (getIsRocket() && playerHasRockets(player)) { + if (isRocket() && playerHasRockets(player)) { final StringBuilder sb = new StringBuilder(); sb.append("Can Rocket Attack, "); final int bombingBonus = getBombingBonus(); @@ -2974,15 +2958,15 @@ public String toStringShortAndOnlyImportantDifferences(final GamePlayer player) formatter.append(sb.toString(), ""); } - if (getIsInfrastructure()) { + if (isInfrastructure()) { formatter.append("Can be Captured", ""); } - if (getIsConstruction()) { + if (isConstruction()) { formatter.append("Can be Placed Without Factory", ""); } // TODO: Rework damaged description - if (getCanBeDamaged() + if (canBeDamaged() && Properties.getDamageFromBombingDoneToUnitsInsteadOfTerritories( getData().getProperties())) { final StringBuilder sb = new StringBuilder(); @@ -2990,25 +2974,25 @@ public String toStringShortAndOnlyImportantDifferences(final GamePlayer player) if (getMaxOperationalDamage() > -1) { sb.append(getMaxOperationalDamage()).append(" Max Operational Damage, "); } - if (getCanProduceUnits() && getCanProduceXUnits() < 0) { + if (canProduceUnits() && getCanProduceXUnits() < 0) { sb.append("Total Damage up to ") .append(getMaxDamage() > -1 ? getMaxDamage() : 2) .append("x Territory Value, "); } else if (getMaxDamage() > -1) { sb.append(getMaxDamage()).append(" Max Total Damage, "); } - if (getCanDieFromReachingMaxDamage()) { + if (canDieFromReachingMaxDamage()) { sb.append("Dies if Max Damage Reached, "); } formatter.append(sb.toString(), ""); - } else if (getCanBeDamaged()) { + } else if (canBeDamaged()) { formatter.append("Can be Damaged by Raids", ""); } - if (getIsAirBase() && Properties.getScrambleRulesInEffect(getData().getProperties())) { + if (isAirBase() && Properties.getScrambleRulesInEffect(getData().getProperties())) { formatter.append("Allows Scrambling", ""); } - if (getCanScramble() && Properties.getScrambleRulesInEffect(getData().getProperties())) { + if (canScramble() && Properties.getScrambleRulesInEffect(getData().getProperties())) { formatter.append( "Scramble Range", String.valueOf(getMaxScrambleDistance() > 0 ? getMaxScrambleDistance() : 1)); @@ -3075,7 +3059,7 @@ public String toStringShortAndOnlyImportantDifferences(final GamePlayer player) } } - if (getIsStrategicBomber()) { + if (isStrategicBomber()) { final StringBuilder sb = new StringBuilder(); final int bombingBonus = getBombingBonus(); if ((getBombingMaxDieSides() != -1 || bombingBonus != 0) @@ -3093,12 +3077,11 @@ public String toStringShortAndOnlyImportantDifferences(final GamePlayer player) formatter.append("Can Perform Raids", sb.toString()); } - if (getAirAttack(player) > 0 - && (getIsStrategicBomber() || getCanEscort() || getCanAirBattle())) { + if (getAirAttack(player) > 0 && (isStrategicBomber() || canEscort() || canAirBattle())) { formatter.append( "Air Attack", (attackRolls > 1 ? (attackRolls + "x") : "") + getAirAttack(player)); } - if (getAirDefense(player) > 0 && (getCanIntercept() || getCanAirBattle())) { + if (getAirDefense(player) > 0 && (canIntercept() || canAirBattle())) { formatter.append( "Air Defense", (defenseRolls > 1 ? (defenseRolls + "x") : "") + getAirDefense(player)); } @@ -3117,7 +3100,7 @@ public String toStringShortAndOnlyImportantDifferences(final GamePlayer player) } addLabeledUnitTypes("Can't Target", getCanNotTarget(), formatter); addLabeledUnitTypes("Can't Be Targeted By", getCanNotBeTargetedBy(), formatter); - if (getIsDestroyer()) { + if (isDestroyer()) { formatter.append("Is Anti-Stealth", ""); } @@ -3135,38 +3118,37 @@ public String toStringShortAndOnlyImportantDifferences(final GamePlayer player) if (getIsSuicideOnDefense()) { formatter.append("Suicide on Defense Unit", ""); } - if (getIsSuicideOnHit()) { + if (isSuicideOnHit()) { formatter.append("Suicide on Hit Unit", ""); } - if (getIsAir() - && (getIsKamikaze() || Properties.getKamikazeAirplanes(getData().getProperties()))) { + if (isAir() && (isKamikaze() || Properties.getKamikazeAirplanes(getData().getProperties()))) { formatter.append("Is Kamikaze", "Can use all Movement to Attack Target"); } - if (getIsLandTransportable() && playerHasMechInf(player)) { + if (isLandTransportable() && playerHasMechInf(player)) { formatter.append("Can be Land Transported", ""); } - if (getIsLandTransport() && playerHasMechInf(player)) { + if (isLandTransport() && playerHasMechInf(player)) { formatter.append("Is a Land Transport", ""); } - if (getIsAirTransportable() && playerHasParatroopers(player)) { + if (isAirTransportable() && playerHasParatroopers(player)) { formatter.append("Can be Air Transported", ""); } - if (getIsAirTransport() && playerHasParatroopers(player)) { + if (isAirTransport() && playerHasParatroopers(player)) { formatter.append("Is an Air Transport", ""); } - if (getIsCombatTransport() && getTransportCapacity() > 0) { + if (isCombatTransport() && getTransportCapacity() > 0) { formatter.append("Is a Combat Transport", ""); - } else if (getTransportCapacity() > 0 && getIsSea()) { + } else if (getTransportCapacity() > 0 && isSea()) { formatter.append("Is a Sea Transport", ""); } if (getTransportCost() > -1) { formatter.append("Transporting Cost", String.valueOf(getTransportCost())); } if (getTransportCapacity() > 0 - && (getIsSea() - || (getIsAir() && playerHasParatroopers(player)) - || (playerHasMechInf(player) && !getIsSea() && !getIsAir()))) { + && (isSea() + || (isAir() && playerHasParatroopers(player)) + || (playerHasMechInf(player) && !isSea() && !isAir()))) { formatter.append("Transporting Capacity", String.valueOf(getTransportCapacity())); } @@ -3263,7 +3245,7 @@ public String toStringShortAndOnlyImportantDifferences(final GamePlayer player) String.valueOf(getCanOnlyBePlacedInTerritoryValuedAtX())); } - if (getCanNotMoveDuringCombatMove()) { + if (canNotMoveDuringCombatMove()) { formatter.append("Cannot Combat Move", ""); } @@ -3325,8 +3307,7 @@ private static void addIntegerMapDescription( private void addAaDescription( final String startOfKey, final int aa, final int aaMaxDieSides, final Formatter formatter) { - if ((getIsAaForCombatOnly() || getIsAaForBombingThisUnitOnly() || getIsAaForFlyOverOnly()) - && (aa > 0)) { + if ((isAaForCombatOnly() || isAaForBombingThisUnitOnly() || isAaForFlyOverOnly()) && (aa > 0)) { final String string = aa + "/" @@ -3349,7 +3330,7 @@ public int getStackingLimitMax(final Tuple stackingLimit) { } // under certain rules (classic rules) there can only be 1 aa gun in a territory. final GameProperties properties = getData().getProperties(); - if ((getIsAaForBombingThisUnitOnly() || getIsAaForCombatOnly()) + if ((isAaForBombingThisUnitOnly() || isAaForCombatOnly()) && !(Properties.getWW2V2(properties) || Properties.getWW2V3(properties) || Properties.getMultipleAaPerTerritory(properties))) { @@ -3373,19 +3354,19 @@ private void addStackingLimitDescription( } private String getAaKey() { - if (getIsAaForCombatOnly() - && getIsAaForFlyOverOnly() + if (isAaForCombatOnly() + && isAaForFlyOverOnly() && !Properties.getAaTerritoryRestricted(getData().getProperties())) { return " for Combat & Move Through"; - } else if (getIsAaForBombingThisUnitOnly() - && getIsAaForFlyOverOnly() + } else if (isAaForBombingThisUnitOnly() + && isAaForFlyOverOnly() && !Properties.getAaTerritoryRestricted(getData().getProperties())) { return " for Raids & Move Through"; - } else if (getIsAaForCombatOnly()) { + } else if (isAaForCombatOnly()) { return " for Combat"; - } else if (getIsAaForBombingThisUnitOnly()) { + } else if (isAaForBombingThisUnitOnly()) { return " for Raids"; - } else if (getIsAaForFlyOverOnly()) { + } else if (isAaForFlyOverOnly()) { return " for Move Through"; } return ""; @@ -3401,9 +3382,9 @@ private static String joinRequiredUnits(final List units) { public @Nullable MutableProperty getPropertyOrNull(String propertyName) { switch (propertyName) { case "isAir": - return MutableProperty.of(this::setIsAir, this::setIsAir, this::getIsAir, this::resetIsAir); + return MutableProperty.of(this::setIsAir, this::setIsAir, this::isAir, this::resetIsAir); case IS_SEA: - return MutableProperty.of(this::setIsSea, this::setIsSea, this::getIsSea, this::resetIsSea); + return MutableProperty.of(this::setIsSea, this::setIsSea, this::isSea, this::resetIsSea); case "movement": return MutableProperty.of( this::setMovement, this::setMovement, this::getMovement, this::resetMovement); @@ -3412,7 +3393,7 @@ private static String joinRequiredUnits(final List units) { this::setCanBlitz, this::setCanBlitz, this::getCanBlitz, this::resetCanBlitz); case "isKamikaze": return MutableProperty.of( - this::setIsKamikaze, this::setIsKamikaze, this::getIsKamikaze, this::resetIsKamikaze); + this::setIsKamikaze, this::setIsKamikaze, this::isKamikaze, this::resetIsKamikaze); case "canInvadeOnlyFrom": return MutableProperty.of( this::setCanInvadeOnlyFrom, @@ -3432,7 +3413,7 @@ private static String joinRequiredUnits(final List units) { return MutableProperty.of( this::setCanNotMoveDuringCombatMove, this::setCanNotMoveDuringCombatMove, - this::getCanNotMoveDuringCombatMove, + this::canNotMoveDuringCombatMove, this::resetCanNotMoveDuringCombatMove); case "movementLimit": return MutableProperty.of( @@ -3450,7 +3431,7 @@ private static String joinRequiredUnits(final List units) { return MutableProperty.of( this::setIsInfrastructure, this::setIsInfrastructure, - this::getIsInfrastructure, + this::isInfrastructure, this::resetIsInfrastructure); case "canBombard": return MutableProperty.of( @@ -3495,10 +3476,7 @@ private static String joinRequiredUnits(final List units) { () -> false); case "isDestroyer": return MutableProperty.of( - this::setIsDestroyer, - this::setIsDestroyer, - this::getIsDestroyer, - this::resetIsDestroyer); + this::setIsDestroyer, this::setIsDestroyer, this::isDestroyer, this::resetIsDestroyer); case "artillery": return MutableProperty.of( this::setArtillery, this::setArtillery, this::getArtillery, this::resetArtillery); @@ -3536,7 +3514,7 @@ private static String joinRequiredUnits(final List units) { return MutableProperty.of( this::setIsSuicideOnHit, this::setIsSuicideOnHit, - this::getIsSuicideOnHit, + this::isSuicideOnHit, this::resetIsSuicideOnHit); case "attackingLimit": return MutableProperty.of( @@ -3566,7 +3544,7 @@ private static String joinRequiredUnits(final List units) { return MutableProperty.of( this::setIsCombatTransport, this::setIsCombatTransport, - this::getIsCombatTransport, + this::isCombatTransport, this::resetIsCombatTransport); case "transportCapacity": return MutableProperty.ofMapper( @@ -3593,47 +3571,47 @@ private static String joinRequiredUnits(final List units) { return MutableProperty.of( this::setIsAirTransport, this::setIsAirTransport, - this::getIsAirTransport, + this::isAirTransport, this::resetIsAirTransport); case "isAirTransportable": return MutableProperty.of( this::setIsAirTransportable, this::setIsAirTransportable, - this::getIsAirTransportable, + this::isAirTransportable, this::resetIsAirTransportable); case "isLandTransport": return MutableProperty.of( this::setIsLandTransport, this::setIsLandTransport, - this::getIsLandTransport, + this::isLandTransport, this::resetIsLandTransport); case "isLandTransportable": return MutableProperty.of( this::setIsLandTransportable, this::setIsLandTransportable, - this::getIsLandTransportable, + this::isLandTransportable, this::resetIsLandTransportable); case "isAAforCombatOnly": return MutableProperty.of( this::setIsAaForCombatOnly, this::setIsAaForCombatOnly, - this::getIsAaForCombatOnly, + this::isAaForCombatOnly, this::resetIsAaForCombatOnly); case "isAAforBombingThisUnitOnly": return MutableProperty.of( this::setIsAaForBombingThisUnitOnly, this::setIsAaForBombingThisUnitOnly, - this::getIsAaForBombingThisUnitOnly, + this::isAaForBombingThisUnitOnly, this::resetIsAaForBombingThisUnitOnly); case "isAAforFlyOverOnly": return MutableProperty.of( this::setIsAaForFlyOverOnly, this::setIsAaForFlyOverOnly, - this::getIsAaForFlyOverOnly, + this::isAaForFlyOverOnly, this::resetIsAaForFlyOverOnly); case "isRocket": return MutableProperty.of( - this::setIsRocket, this::setIsRocket, this::getIsRocket, this::resetIsRocket); + this::setIsRocket, this::setIsRocket, this::isRocket, this::resetIsRocket); case ATTACK_AA: return MutableProperty.of( this::setAttackAa, this::setAttackAa, this::getAttackAa, this::resetAttackAa); @@ -3694,7 +3672,7 @@ private static String joinRequiredUnits(final List units) { return MutableProperty.of( this::setIsStrategicBomber, this::setIsStrategicBomber, - this::getIsStrategicBomber, + this::isStrategicBomber, this::resetIsStrategicBomber); case "bombingMaxDieSides": return MutableProperty.of( @@ -3712,7 +3690,7 @@ private static String joinRequiredUnits(final List units) { return MutableProperty.of( this::setCanIntercept, this::setCanIntercept, - this::getCanIntercept, + this::canIntercept, this::resetCanIntercept); case "requiresAirbaseToIntercept": return MutableProperty.of( @@ -3722,12 +3700,12 @@ private static String joinRequiredUnits(final List units) { this::resetRequiresAirBaseToIntercept); case "canEscort": return MutableProperty.of( - this::setCanEscort, this::setCanEscort, this::getCanEscort, this::resetCanEscort); + this::setCanEscort, this::setCanEscort, this::canEscort, this::resetCanEscort); case "canAirBattle": return MutableProperty.of( this::setCanAirBattle, this::setCanAirBattle, - this::getCanAirBattle, + this::canAirBattle, this::resetCanAirBattle); case "airDefense": return MutableProperty.of( @@ -3745,7 +3723,7 @@ private static String joinRequiredUnits(final List units) { return MutableProperty.of( this::setCanProduceUnits, this::setCanProduceUnits, - this::getCanProduceUnits, + this::canProduceUnits, this::resetCanProduceUnits); case "canProduceXUnits": return MutableProperty.of( @@ -3772,7 +3750,7 @@ private static String joinRequiredUnits(final List units) { return MutableProperty.of( this::setCanBeDamaged, this::setCanBeDamaged, - this::getCanBeDamaged, + this::canBeDamaged, this::resetCanBeDamaged); case "maxDamage": return MutableProperty.of( @@ -3787,13 +3765,13 @@ private static String joinRequiredUnits(final List units) { return MutableProperty.of( this::setCanDieFromReachingMaxDamage, this::setCanDieFromReachingMaxDamage, - this::getCanDieFromReachingMaxDamage, + this::canDieFromReachingMaxDamage, this::resetCanDieFromReachingMaxDamage); case "isConstruction": return MutableProperty.of( this::setIsConstruction, this::setIsConstruction, - this::getIsConstruction, + this::isConstruction, this::resetIsConstruction); case "constructionType": return MutableProperty.ofString( @@ -3854,13 +3832,10 @@ private static String joinRequiredUnits(final List units) { this::resetPlacementLimit); case "canScramble": return MutableProperty.of( - this::setCanScramble, - this::setCanScramble, - this::getCanScramble, - this::resetCanScramble); + this::setCanScramble, this::setCanScramble, this::canScramble, this::resetCanScramble); case "isAirBase": return MutableProperty.of( - this::setIsAirBase, this::setIsAirBase, this::getIsAirBase, this::resetIsAirBase); + this::setIsAirBase, this::setIsAirBase, this::isAirBase, this::resetIsAirBase); case "maxScrambleDistance": return MutableProperty.of( this::setMaxScrambleDistance, diff --git a/game-app/game-core/src/main/java/games/strategy/triplea/attachments/UnitTypeComparator.java b/game-app/game-core/src/main/java/games/strategy/triplea/attachments/UnitTypeComparator.java index f4f123998a1..01079a38371 100644 --- a/game-app/game-core/src/main/java/games/strategy/triplea/attachments/UnitTypeComparator.java +++ b/game-app/game-core/src/main/java/games/strategy/triplea/attachments/UnitTypeComparator.java @@ -26,12 +26,12 @@ public class UnitTypeComparator implements Comparator, Serializable { @Override public int compare(final UnitType u1, final UnitType u2) { return Comparator.comparing( - UnitType::getUnitAttachment, Comparator.comparing(UnitAttachment::getIsInfrastructure)) + UnitType::getUnitAttachment, Comparator.comparing(UnitAttachment::isInfrastructure)) .thenComparing(Matches.unitTypeIsAaForAnything()::test) .thenComparing( UnitType::getUnitAttachment, - Comparator.comparing(UnitAttachment::getIsAir) - .thenComparing(UnitAttachment::getIsSea) + Comparator.comparing(UnitAttachment::isAir) + .thenComparing(UnitAttachment::isSea) .thenComparingInt(UnitAttachment::getAttack)) .thenComparing(NamedAttachable::getName) .compare(u1, u2); diff --git a/game-app/game-core/src/main/java/games/strategy/triplea/delegate/AbstractPlaceDelegate.java b/game-app/game-core/src/main/java/games/strategy/triplea/delegate/AbstractPlaceDelegate.java index b58f65f4871..9d5f4d16346 100644 --- a/game-app/game-core/src/main/java/games/strategy/triplea/delegate/AbstractPlaceDelegate.java +++ b/game-app/game-core/src/main/java/games/strategy/triplea/delegate/AbstractPlaceDelegate.java @@ -990,7 +990,7 @@ protected void addConstructionUnits( private static int howManyOfConstructionUnit(UnitType ut, IntegerMap constructionsMap) { final UnitAttachment ua = ut.getUnitAttachment(); - if (!ua.getIsConstruction() + if (!ua.isConstruction() || ua.getConstructionsPerTerrPerTypePerTurn() < 1 || ua.getMaxConstructionsPerTypePerTerr() < 1) { return 0; diff --git a/game-app/game-core/src/main/java/games/strategy/triplea/delegate/EndTurnDelegate.java b/game-app/game-core/src/main/java/games/strategy/triplea/delegate/EndTurnDelegate.java index a152541731c..2888a307ae2 100644 --- a/game-app/game-core/src/main/java/games/strategy/triplea/delegate/EndTurnDelegate.java +++ b/game-app/game-core/src/main/java/games/strategy/triplea/delegate/EndTurnDelegate.java @@ -91,9 +91,9 @@ private String createUnits(final IDelegateBridge bridge) { final Collection willBeCreated = createsUnitsMap.keySet(); for (final UnitType ut : willBeCreated) { final UnitAttachment uaToCreate = ut.getUnitAttachment(); - if (uaToCreate.getIsSea() && !t.isWater()) { + if (uaToCreate.isSea() && !t.isWater()) { toAddSea.addAll(ut.create(createsUnitsMap.getInt(ut), player)); - } else if (!uaToCreate.getIsSea() && !uaToCreate.getIsAir() && t.isWater()) { + } else if (!uaToCreate.isSea() && !uaToCreate.isAir() && t.isWater()) { toAddLand.addAll(ut.create(createsUnitsMap.getInt(ut), player)); } else { toAdd.addAll(ut.create(createsUnitsMap.getInt(ut), player)); diff --git a/game-app/game-core/src/main/java/games/strategy/triplea/delegate/InitializationDelegate.java b/game-app/game-core/src/main/java/games/strategy/triplea/delegate/InitializationDelegate.java index 2474190a48d..2a9d90e550d 100644 --- a/game-app/game-core/src/main/java/games/strategy/triplea/delegate/InitializationDelegate.java +++ b/game-app/game-core/src/main/java/games/strategy/triplea/delegate/InitializationDelegate.java @@ -293,7 +293,7 @@ private static void initShipyards(final IDelegateBridge bridge) { continue; } final UnitType unit = data.getUnitTypeList().getUnitType(named.getName()); - final boolean isSea = unit.getUnitAttachment().getIsSea(); + final boolean isSea = unit.getUnitAttachment().isSea(); if (!isSea) { final ProductionRule prodRule = data.getProductionRuleList().getProductionRule(rule.getName()); diff --git a/game-app/game-core/src/main/java/games/strategy/triplea/delegate/Matches.java b/game-app/game-core/src/main/java/games/strategy/triplea/delegate/Matches.java index cde85482a3a..6b731de92b9 100644 --- a/game-app/game-core/src/main/java/games/strategy/triplea/delegate/Matches.java +++ b/game-app/game-core/src/main/java/games/strategy/triplea/delegate/Matches.java @@ -91,7 +91,7 @@ public static Predicate unitHasNotTakenAnyDamage() { } public static Predicate unitIsSea() { - return unit -> unit.getUnitAttachment().getIsSea(); + return unit -> unit.getUnitAttachment().isSea(); } public static Predicate unitHasSubBattleAbilities() { @@ -138,7 +138,7 @@ public static Predicate unitCanNotBeTargetedByAll() { private static Predicate unitIsCombatSeaTransport() { return unit -> { final UnitAttachment ua = unit.getUnitAttachment(); - return ua.getIsCombatTransport() && ua.getIsSea(); + return ua.isCombatTransport() && ua.isSea(); }; } @@ -149,29 +149,29 @@ public static Predicate unitIsNotCombatSeaTransport() { public static Predicate unitIsSeaTransportButNotCombatSeaTransport() { return unit -> { final UnitAttachment ua = unit.getUnitAttachment(); - return ua.getTransportCapacity() != -1 && ua.getIsSea() && !ua.getIsCombatTransport(); + return ua.getTransportCapacity() != -1 && ua.isSea() && !ua.isCombatTransport(); }; } public static Predicate unitIsNotSeaTransportButCouldBeCombatSeaTransport() { return unit -> { final UnitAttachment ua = unit.getUnitAttachment(); - return ua.getTransportCapacity() == -1 || (ua.getIsCombatTransport() && ua.getIsSea()); + return ua.getTransportCapacity() == -1 || (ua.isCombatTransport() && ua.isSea()); }; } public static Predicate unitIsDestroyer() { - return unit -> unit.getUnitAttachment().getIsDestroyer(); + return unit -> unit.getUnitAttachment().isDestroyer(); } public static Predicate unitTypeIsDestroyer() { - return type -> type.getUnitAttachment().getIsDestroyer(); + return type -> type.getUnitAttachment().isDestroyer(); } public static Predicate unitIsSeaTransport() { return unit -> { final UnitAttachment ua = unit.getUnitAttachment(); - return ua.getTransportCapacity() != -1 && ua.getIsSea(); + return ua.getTransportCapacity() != -1 && ua.isSea(); }; } @@ -182,12 +182,12 @@ public static Predicate unitIsNotSeaTransport() { public static Predicate unitIsSeaTransportAndNotDestroyer() { return unit -> { final UnitAttachment ua = unit.getUnitAttachment(); - return !unitIsDestroyer().test(unit) && ua.getTransportCapacity() != -1 && ua.getIsSea(); + return !unitIsDestroyer().test(unit) && ua.getTransportCapacity() != -1 && ua.isSea(); }; } public static Predicate unitTypeIsStrategicBomber() { - return unitType -> unitType.getUnitAttachment().getIsStrategicBomber(); + return unitType -> unitType.getUnitAttachment().isStrategicBomber(); } public static Predicate unitIsStrategicBomber() { @@ -262,30 +262,30 @@ public static Predicate unitIsEnemyOf(final GamePlayer player) { } public static Predicate unitIsNotSea() { - return unit -> !unit.getUnitAttachment().getIsSea(); + return unit -> !unit.getUnitAttachment().isSea(); } public static Predicate unitTypeIsSea() { - return type -> type.getUnitAttachment().getIsSea(); + return type -> type.getUnitAttachment().isSea(); } public static Predicate unitTypeIsNotSea() { - return type -> !type.getUnitAttachment().getIsSea(); + return type -> !type.getUnitAttachment().isSea(); } public static Predicate unitTypeIsSeaOrAir() { return type -> { final UnitAttachment ua = type.getUnitAttachment(); - return ua.getIsSea() || ua.getIsAir(); + return ua.isSea() || ua.isAir(); }; } public static Predicate unitIsAir() { - return unit -> unit.getUnitAttachment().getIsAir(); + return unit -> unit.getUnitAttachment().isAir(); } public static Predicate unitIsNotAir() { - return unit -> !unit.getUnitAttachment().getIsAir(); + return unit -> !unit.getUnitAttachment().isAir(); } public static Predicate unitTypeCanBombard(final GamePlayer gamePlayer) { @@ -350,11 +350,11 @@ private static Predicate unitDestroyedWhenCapturedFrom() { } public static Predicate unitIsAirBase() { - return unit -> unit.getUnitAttachment().getIsAirBase(); + return unit -> unit.getUnitAttachment().isAirBase(); } public static Predicate unitTypeCanBeDamaged() { - return ut -> ut.getUnitAttachment().getCanBeDamaged(); + return ut -> ut.getUnitAttachment().canBeDamaged(); } public static Predicate unitCanBeDamaged() { @@ -364,7 +364,7 @@ public static Predicate unitCanBeDamaged() { public static Predicate unitIsAtMaxDamageOrNotCanBeDamaged(final Territory t) { return unit -> { final UnitAttachment ua = unit.getUnitAttachment(); - if (!ua.getCanBeDamaged()) { + if (!ua.canBeDamaged()) { return true; } if (Properties.getDamageFromBombingDoneToUnitsInsteadOfTerritories( @@ -423,12 +423,12 @@ public static Predicate unitIsNotDisabled() { public static Predicate unitCanDieFromReachingMaxDamage() { return unit -> { final UnitAttachment ua = unit.getUnitAttachment(); - return ua.getCanBeDamaged() && ua.getCanDieFromReachingMaxDamage(); + return ua.canBeDamaged() && ua.canDieFromReachingMaxDamage(); }; } public static Predicate unitTypeIsInfrastructure() { - return ut -> ut.getUnitAttachment().getIsInfrastructure(); + return ut -> ut.getUnitAttachment().isInfrastructure(); } public static Predicate unitIsInfrastructure() { @@ -473,7 +473,7 @@ public static Predicate unitSupportAttachmentCanBeUsedByP } public static Predicate unitCanScramble() { - return unit -> unit.getUnitAttachment().getCanScramble(); + return unit -> unit.getUnitAttachment().canScramble(); } public static Predicate unitWasScrambled() { @@ -493,7 +493,7 @@ public static Predicate unitCanBlitz() { } public static Predicate unitIsLandTransport() { - return unit -> unit.getUnitAttachment().getIsLandTransport(); + return unit -> unit.getUnitAttachment().isLandTransport(); } public static Predicate unitIsLandTransportWithCapacity() { @@ -507,7 +507,7 @@ public static Predicate unitIsLandTransportWithoutCapacity() { public static Predicate unitIsNotInfrastructureAndNotCapturedOnEntering( final GamePlayer player, final Territory territory) { return unit -> - !unit.getUnitAttachment().getIsInfrastructure() + !unit.getUnitAttachment().isInfrastructure() && !unitCanBeCapturedOnEnteringThisTerritory(player, territory).test(unit); } @@ -528,19 +528,19 @@ public static Predicate unitIsSuicideOnDefense() { } public static Predicate unitIsSuicideOnHit() { - return unit -> unit.getUnitAttachment().getIsSuicideOnHit(); + return unit -> unit.getUnitAttachment().isSuicideOnHit(); } public static Predicate unitIsKamikaze() { - return unit -> unit.getUnitAttachment().getIsKamikaze(); + return unit -> unit.getUnitAttachment().isKamikaze(); } public static Predicate unitTypeIsAir() { - return type -> type.getUnitAttachment().getIsAir(); + return type -> type.getUnitAttachment().isAir(); } private static Predicate unitTypeIsNotAir() { - return type -> !type.getUnitAttachment().getIsAir(); + return type -> !type.getUnitAttachment().isAir(); } public static Predicate unitCanLandOnCarrier() { @@ -592,7 +592,7 @@ public static Predicate unitCanTransport() { } public static Predicate unitTypeCanProduceUnits() { - return ut -> ut.getUnitAttachment().getCanProduceUnits(); + return ut -> ut.getUnitAttachment().canProduceUnits(); } public static Predicate unitCanProduceUnits() { @@ -604,7 +604,7 @@ public static Predicate unitTypeHasMaxBuildRestrictions() { } public static Predicate unitTypeIsRocket() { - return ut -> ut.getUnitAttachment().getIsRocket(); + return ut -> ut.getUnitAttachment().isRocket(); } static Predicate unitIsRocket() { @@ -612,7 +612,7 @@ static Predicate unitIsRocket() { } public static Predicate unitTypeCanNotMoveDuringCombatMove() { - return u -> u.getUnitAttachment().getCanNotMoveDuringCombatMove(); + return u -> u.getUnitAttachment().canNotMoveDuringCombatMove(); } public static Predicate unitCanNotMoveDuringCombatMove() { @@ -712,7 +712,7 @@ public static Predicate unitIsAaThatCanFire( } private static Predicate unitTypeIsAaForCombatOnly() { - return ut -> ut.getUnitAttachment().getIsAaForCombatOnly(); + return ut -> ut.getUnitAttachment().isAaForCombatOnly(); } public static Predicate unitIsAaForCombatOnly() { @@ -720,7 +720,7 @@ public static Predicate unitIsAaForCombatOnly() { } public static Predicate unitTypeIsAaForBombingThisUnitOnly() { - return ut -> ut.getUnitAttachment().getIsAaForBombingThisUnitOnly(); + return ut -> ut.getUnitAttachment().isAaForBombingThisUnitOnly(); } public static Predicate unitIsAaForBombingThisUnitOnly() { @@ -728,15 +728,13 @@ public static Predicate unitIsAaForBombingThisUnitOnly() { } static Predicate unitIsAaForFlyOverOnly() { - return u -> u.getUnitAttachment().getIsAaForFlyOverOnly(); + return u -> u.getUnitAttachment().isAaForFlyOverOnly(); } public static Predicate unitTypeIsAaForAnything() { return ut -> { final UnitAttachment ua = ut.getUnitAttachment(); - return ua.getIsAaForBombingThisUnitOnly() - || ua.getIsAaForCombatOnly() - || ua.getIsAaForFlyOverOnly(); + return ua.isAaForBombingThisUnitOnly() || ua.isAaForCombatOnly() || ua.isAaForFlyOverOnly(); }; } @@ -771,7 +769,7 @@ static Predicate unitOffensiveAttackAaIsGreaterThanZeroAndMaxAaAttacksIsNo } public static Predicate unitIsLandTransportable() { - return unit -> unit.getUnitAttachment().getIsLandTransportable(); + return unit -> unit.getUnitAttachment().isLandTransportable(); } public static Predicate unitIsAirTransportable() { @@ -780,7 +778,7 @@ public static Predicate unitIsAirTransportable() { if (!ta.getParatroopers()) { return false; } - return u.getUnitAttachment().getIsAirTransportable(); + return u.getUnitAttachment().isAirTransportable(); }; } @@ -790,7 +788,7 @@ public static Predicate unitIsAirTransport() { if (!ta.getParatroopers()) { return false; } - return u.getUnitAttachment().getIsAirTransport(); + return u.getUnitAttachment().isAirTransport(); }; } @@ -1090,7 +1088,7 @@ public static Predicate unitHasEnoughMovementForRoute(final Route route) { return unit -> { BigDecimal left = unit.getMovementLeft(); final UnitAttachment ua = unit.getUnitAttachment(); - if (ua.getIsAir()) { + if (ua.isAir()) { if (TerritoryAttachment.hasAirBase(route.getStart())) { left = left.add(BigDecimal.ONE); } @@ -1100,7 +1098,7 @@ public static Predicate unitHasEnoughMovementForRoute(final Route route) { } // Apply "AAP" (Pacific) Naval base bonus. Note: In "AAG40" (1940) naval bases are implemented // differently: via a naval base _unit_ that boosts movement rather than territory attachment. - if (ua.getIsSea() && unit.getData().getSequence().getStep().isNonCombat()) { + if (ua.isSea() && unit.getData().getSequence().getStep().isNonCombat()) { // If a zone adjacent to the starting and ending sea zones are allied naval bases, increase // the range. // TODO Still need to be able to handle stops on the way @@ -1149,7 +1147,7 @@ public static Predicate unitTypeIsStatic(final GamePlayer gamePlayer) public static Predicate unitIsLandAndOwnedBy(final GamePlayer player) { return unit -> { final UnitAttachment ua = unit.getUnitAttachment(); - return !ua.getIsSea() && !ua.getIsAir() && unit.isOwnedBy(player); + return !ua.isSea() && !ua.isAir() && unit.isOwnedBy(player); }; } @@ -1720,7 +1718,7 @@ static Predicate territoryIsBlockadeZone() { public static Predicate unitTypeIsConstruction() { return type -> { final UnitAttachment ua = type.getUnitAttachment(); - return ua.getIsConstruction(); + return ua.isConstruction(); }; } @@ -2067,7 +2065,7 @@ public static Predicate unitCanScrambleOnRouteDistance(final Route route) } public static Predicate unitCanIntercept() { - return u -> u.getUnitAttachment().getCanIntercept(); + return u -> u.getUnitAttachment().canIntercept(); } public static Predicate unitRequiresAirBaseToIntercept() { @@ -2075,11 +2073,11 @@ public static Predicate unitRequiresAirBaseToIntercept() { } static Predicate unitCanEscort() { - return u -> u.getUnitAttachment().getCanEscort(); + return u -> u.getUnitAttachment().canEscort(); } public static Predicate unitCanAirBattle() { - return u -> u.getUnitAttachment().getCanAirBattle(); + return u -> u.getUnitAttachment().canAirBattle(); } public static Predicate territoryOwnerRelationshipTypeCanMoveIntoDuringCombatMove( diff --git a/game-app/game-core/src/main/java/games/strategy/triplea/delegate/MovePerformer.java b/game-app/game-core/src/main/java/games/strategy/triplea/delegate/MovePerformer.java index 012849add6b..bde3035c587 100644 --- a/game-app/game-core/src/main/java/games/strategy/triplea/delegate/MovePerformer.java +++ b/game-app/game-core/src/main/java/games/strategy/triplea/delegate/MovePerformer.java @@ -338,7 +338,7 @@ private Change markMovementChange( for (final Unit unit : CollectionUtils.getMatches(units, Matches.unitIsOwnedBy(gamePlayer))) { BigDecimal moved = route.getMovementCost(unit); final UnitAttachment ua = unit.getUnitAttachment(); - if (ua.getIsAir()) { + if (ua.isAir()) { if (TerritoryAttachment.hasAirBase(routeStart) && relationshipTracker.isAllied(routeStart.getOwner(), unit.getOwner())) { moved = moved.subtract(BigDecimal.ONE); diff --git a/game-app/game-core/src/main/java/games/strategy/triplea/delegate/TransportTracker.java b/game-app/game-core/src/main/java/games/strategy/triplea/delegate/TransportTracker.java index 0801c77c9d5..1939406fc9f 100644 --- a/game-app/game-core/src/main/java/games/strategy/triplea/delegate/TransportTracker.java +++ b/game-app/game-core/src/main/java/games/strategy/triplea/delegate/TransportTracker.java @@ -184,7 +184,7 @@ public static int getAvailableCapacity(final Unit unit) { // Check if there are transports available, also check for destroyer capacity (Tokyo Express) if (ua.getTransportCapacity() == -1 || (Properties.getPacificTheater(unit.getData().getProperties()) - && ua.getIsDestroyer() + && ua.isDestroyer() && !unit.getOwner().getName().equals(Constants.PLAYER_NAME_JAPANESE))) { return 0; } diff --git a/game-app/game-core/src/main/java/games/strategy/triplea/delegate/UnitComparator.java b/game-app/game-core/src/main/java/games/strategy/triplea/delegate/UnitComparator.java index 2ac8f9d14a9..62e4fd3ca16 100644 --- a/game-app/game-core/src/main/java/games/strategy/triplea/delegate/UnitComparator.java +++ b/game-app/game-core/src/main/java/games/strategy/triplea/delegate/UnitComparator.java @@ -112,8 +112,8 @@ public static Comparator getMovableUnitsComparator( if (!t1.equals(t2)) { // Land transportable units should have higher priority than non-land transportable ones, // when all else is equal. - final int isLandTransportable1 = t1.getUnitAttachment().getIsLandTransportable() ? 1 : 0; - final int isLandTransportable2 = t2.getUnitAttachment().getIsLandTransportable() ? 1 : 0; + final int isLandTransportable1 = t1.getUnitAttachment().isLandTransportable() ? 1 : 0; + final int isLandTransportable2 = t2.getUnitAttachment().isLandTransportable() ? 1 : 0; if (isLandTransportable1 != isLandTransportable2) { return isLandTransportable2 - isLandTransportable1; } diff --git a/game-app/game-core/src/main/java/games/strategy/triplea/delegate/battle/AirBattle.java b/game-app/game-core/src/main/java/games/strategy/triplea/delegate/battle/AirBattle.java index 96f3efce59f..960efc21277 100644 --- a/game-app/game-core/src/main/java/games/strategy/triplea/delegate/battle/AirBattle.java +++ b/game-app/game-core/src/main/java/games/strategy/triplea/delegate/battle/AirBattle.java @@ -878,7 +878,7 @@ public static boolean territoryCouldPossiblyHaveAirBattleDefenders( if (canScrambleToAirBattle) { for (final UnitType unitType : data.getUnitTypeList()) { final UnitAttachment ua = unitType.getUnitAttachment(); - if (ua.getCanScramble() && maxScrambleDistance < ua.getMaxScrambleDistance()) { + if (ua.canScramble() && maxScrambleDistance < ua.getMaxScrambleDistance()) { maxScrambleDistance = ua.getMaxScrambleDistance(); } } diff --git a/game-app/game-core/src/main/java/games/strategy/triplea/delegate/battle/ScrambleLogic.java b/game-app/game-core/src/main/java/games/strategy/triplea/delegate/battle/ScrambleLogic.java index 0ca9fdab3e0..10a0c5a0b0b 100644 --- a/game-app/game-core/src/main/java/games/strategy/triplea/delegate/battle/ScrambleLogic.java +++ b/game-app/game-core/src/main/java/games/strategy/triplea/delegate/battle/ScrambleLogic.java @@ -80,7 +80,7 @@ private static int computeMaxScrambleDistance(final GameState data) { int maxScrambleDistance = 0; for (final UnitType unitType : data.getUnitTypeList()) { final UnitAttachment ua = unitType.getUnitAttachment(); - if (ua.getCanScramble() && maxScrambleDistance < ua.getMaxScrambleDistance()) { + if (ua.canScramble() && maxScrambleDistance < ua.getMaxScrambleDistance()) { maxScrambleDistance = ua.getMaxScrambleDistance(); } } diff --git a/game-app/game-core/src/main/java/games/strategy/triplea/delegate/battle/StrategicBombingRaidBattle.java b/game-app/game-core/src/main/java/games/strategy/triplea/delegate/battle/StrategicBombingRaidBattle.java index c7389f0ff6d..890bcffe206 100644 --- a/game-app/game-core/src/main/java/games/strategy/triplea/delegate/battle/StrategicBombingRaidBattle.java +++ b/game-app/game-core/src/main/java/games/strategy/triplea/delegate/battle/StrategicBombingRaidBattle.java @@ -239,7 +239,7 @@ public void fight(final IDelegateBridge bridge) { // global1940 rules - each target type fires an AA shot against the planes bombing it steps.addAll( targets.entrySet().stream() - .filter(entry -> entry.getKey().getUnitAttachment().getIsAaForBombingThisUnitOnly()) + .filter(entry -> entry.getKey().getUnitAttachment().isAaForBombingThisUnitOnly()) .map(Entry::getValue) .map(FireAa::new) .collect(Collectors.toList())); diff --git a/game-app/game-core/src/main/java/games/strategy/triplea/delegate/battle/casualty/CasualtyUtil.java b/game-app/game-core/src/main/java/games/strategy/triplea/delegate/battle/casualty/CasualtyUtil.java index 44565f6fae5..4e0ea5fd65c 100644 --- a/game-app/game-core/src/main/java/games/strategy/triplea/delegate/battle/casualty/CasualtyUtil.java +++ b/game-app/game-core/src/main/java/games/strategy/triplea/delegate/battle/casualty/CasualtyUtil.java @@ -18,7 +18,7 @@ public static int getTotalHitpointsLeft(final Collection units) { int totalHitPoints = 0; for (final Unit u : units) { final UnitAttachment ua = u.getUnitAttachment(); - if (!ua.getIsInfrastructure()) { + if (!ua.isInfrastructure()) { totalHitPoints += ua.getHitPoints(); totalHitPoints -= u.getHits(); } diff --git a/game-app/game-core/src/main/java/games/strategy/triplea/delegate/move/validation/MoveValidator.java b/game-app/game-core/src/main/java/games/strategy/triplea/delegate/move/validation/MoveValidator.java index 5f4c47311d9..26a152298a5 100644 --- a/game-app/game-core/src/main/java/games/strategy/triplea/delegate/move/validation/MoveValidator.java +++ b/game-app/game-core/src/main/java/games/strategy/triplea/delegate/move/validation/MoveValidator.java @@ -1070,7 +1070,7 @@ private static Collection getUnitsThatCantGoOnWater(final Collection final Collection retUnits = new ArrayList<>(); for (final Unit unit : units) { final UnitAttachment ua = unit.getUnitAttachment(); - if (!ua.getIsSea() && !ua.getIsAir() && ua.getTransportCost() == -1) { + if (!ua.isSea() && !ua.isAir() && ua.getTransportCost() == -1) { retUnits.add(unit); } } diff --git a/game-app/game-core/src/main/java/games/strategy/triplea/image/UnitImageFactory.java b/game-app/game-core/src/main/java/games/strategy/triplea/image/UnitImageFactory.java index 01a2ce6bca0..078f190ce73 100644 --- a/game-app/game-core/src/main/java/games/strategy/triplea/image/UnitImageFactory.java +++ b/game-app/game-core/src/main/java/games/strategy/triplea/image/UnitImageFactory.java @@ -140,20 +140,20 @@ public String getBaseImageName() { if (!type.getName().endsWith("_hit") && !type.getName().endsWith("_disabled")) { final UnitAttachment ua = type.getUnitAttachment(); if (type.getName().equals(Constants.UNIT_TYPE_AAGUN)) { - if (TechTracker.hasRocket(gamePlayer) && ua.getIsRocket()) { + if (TechTracker.hasRocket(gamePlayer) && ua.isRocket()) { name = new StringBuilder("rockets"); } if (TechTracker.hasAaRadar(gamePlayer) && Matches.unitTypeIsAaForAnything().test(type)) { name.append("_r"); } - } else if (ua.getIsRocket() && Matches.unitTypeIsAaForAnything().test(type)) { + } else if (ua.isRocket() && Matches.unitTypeIsAaForAnything().test(type)) { if (TechTracker.hasRocket(gamePlayer)) { name.append("_rockets"); } if (TechTracker.hasAaRadar(gamePlayer)) { name.append("_r"); } - } else if (ua.getIsRocket()) { + } else if (ua.isRocket()) { if (TechTracker.hasRocket(gamePlayer)) { name.append("_rockets"); } @@ -162,7 +162,7 @@ public String getBaseImageName() { name.append("_r"); } } - if (ua.getIsAir() && !ua.getIsStrategicBomber()) { + if (ua.isAir() && !ua.isStrategicBomber()) { if (TechTracker.hasLongRangeAir(gamePlayer)) { name.append("_lr"); } @@ -171,7 +171,7 @@ public String getBaseImageName() { name.append("_jp"); } } - if (ua.getIsAir() && ua.getIsStrategicBomber()) { + if (ua.isAir() && ua.isStrategicBomber()) { if (TechTracker.hasLongRangeAir(gamePlayer)) { name.append("_lr"); } @@ -185,7 +185,7 @@ public String getBaseImageName() { && TechTracker.hasSuperSubs(gamePlayer)) { name.append("_ss"); } - if ((type.getName().equals(Constants.UNIT_TYPE_FACTORY) || ua.getCanProduceUnits()) + if ((type.getName().equals(Constants.UNIT_TYPE_FACTORY) || ua.canProduceUnits()) && (TechTracker.hasIndustrialTechnology(gamePlayer) || TechTracker.hasIncreasedFactoryProduction(gamePlayer))) { name.append("_it"); diff --git a/game-app/game-core/src/main/java/games/strategy/triplea/printgenerator/UnitInformation.java b/game-app/game-core/src/main/java/games/strategy/triplea/printgenerator/UnitInformation.java index 778773b2693..bf6c1dbc84e 100644 --- a/game-app/game-core/src/main/java/games/strategy/triplea/printgenerator/UnitInformation.java +++ b/game-app/game-core/src/main/java/games/strategy/triplea/printgenerator/UnitInformation.java @@ -68,7 +68,7 @@ void saveToFile( + "," + (!currentAttachment.getArtillerySupportable() ? "-" : "true") + "," - + (!currentAttachment.getCanProduceUnits() ? "-" : "true") + + (!currentAttachment.canProduceUnits() ? "-" : "true") + "," + (currentAttachment.getIsMarine() == 0 ? "-" : currentAttachment.getIsMarine()) + "," @@ -78,15 +78,15 @@ void saveToFile( + "," + (!Matches.unitTypeIsAaForAnything().test(currentType) ? "-" : "true") + "," - + (!currentAttachment.getIsAir() ? "-" : "true") + + (!currentAttachment.isAir() ? "-" : "true") + "," - + (!currentAttachment.getIsStrategicBomber() ? "-" : "true") + + (!currentAttachment.isStrategicBomber() ? "-" : "true") + "," + (currentAttachment.getCarrierCost() == -1 ? "-" : currentAttachment.getCarrierCost()) + "," - + (!currentAttachment.getIsSea() ? "-" : "true") + + (!currentAttachment.isSea() ? "-" : "true") + "," + currentAttachment.getHitPoints() + "," @@ -102,7 +102,7 @@ void saveToFile( ? "-" : "true") + "," - + (!currentAttachment.getIsDestroyer() ? "-" : "true")); + + (!currentAttachment.isDestroyer() ? "-" : "true")); unitInformation.write("\r\n"); } unitInformation.write("\r\n"); diff --git a/game-app/game-core/src/main/java/games/strategy/triplea/ui/TabbedProductionPanel.java b/game-app/game-core/src/main/java/games/strategy/triplea/ui/TabbedProductionPanel.java index ad0a9cdfd32..cf7483e1578 100644 --- a/game-app/game-core/src/main/java/games/strategy/triplea/ui/TabbedProductionPanel.java +++ b/game-app/game-core/src/main/java/games/strategy/triplea/ui/TabbedProductionPanel.java @@ -186,11 +186,11 @@ private List>> getDefaultRuleLists() { } // canProduceUnits isn't checked on purpose, since this category is for units that can be // placed anywhere (placed without needing a factory). - if (attach.getIsConstruction()) { + if (attach.isConstruction()) { constructRules.add(rule); - } else if (attach.getIsSea()) { + } else if (attach.isSea()) { seaRules.add(rule); - } else if (attach.getIsAir()) { + } else if (attach.isAir()) { airRules.add(rule); } else { landRules.add(rule); diff --git a/game-app/game-core/src/main/java/games/strategy/triplea/util/UnitSeparator.java b/game-app/game-core/src/main/java/games/strategy/triplea/util/UnitSeparator.java index 13f6ad371e3..8373c2e50f1 100644 --- a/game-app/game-core/src/main/java/games/strategy/triplea/util/UnitSeparator.java +++ b/game-app/game-core/src/main/java/games/strategy/triplea/util/UnitSeparator.java @@ -255,6 +255,6 @@ && isAirWithHitPointsRemaining(current))) { } private static boolean isAirWithHitPointsRemaining(final Unit unit) { - return unit.getUnitAttachment().getIsAir() && unit.getUnitAttachment().getHitPoints() > 1; + return unit.getUnitAttachment().isAir() && unit.getUnitAttachment().getHitPoints() > 1; } } diff --git a/game-app/game-core/src/test/java/games/strategy/engine/data/gameparser/GameParserTest.java b/game-app/game-core/src/test/java/games/strategy/engine/data/gameparser/GameParserTest.java index 89b692b040f..02945219ff6 100644 --- a/game-app/game-core/src/test/java/games/strategy/engine/data/gameparser/GameParserTest.java +++ b/game-app/game-core/src/test/java/games/strategy/engine/data/gameparser/GameParserTest.java @@ -105,11 +105,9 @@ private void verifyLegacyPropertiesAreUpdated(final GameState gameData) { archerUnitAttachment.getHitPoints(), is(2)); assertThat( - "Verify is paratroop is converted", archerUnitAttachment.getIsAirTransportable(), is(true)); + "Verify is paratroop is converted", archerUnitAttachment.isAirTransportable(), is(true)); assertThat( - "Verify isMechanized is converted", - archerUnitAttachment.getIsLandTransportable(), - is(true)); + "Verify isMechanized is converted", archerUnitAttachment.isLandTransportable(), is(true)); final var axemanUnitAttachment = ((UnitAttachment) @@ -119,7 +117,7 @@ private void verifyLegacyPropertiesAreUpdated(final GameState gameData) { .getAttachment(Constants.UNIT_ATTACHMENT_NAME)); assertThat( - "Verify isInfantry is converted", axemanUnitAttachment.getIsLandTransportable(), is(true)); + "Verify isInfantry is converted", axemanUnitAttachment.isLandTransportable(), is(true)); assertThat( ((RulesAttachment) diff --git a/game-app/game-core/src/test/java/games/strategy/triplea/attachments/UnitAttachmentTest.java b/game-app/game-core/src/test/java/games/strategy/triplea/attachments/UnitAttachmentTest.java index a8b903342a5..3fcb793d831 100644 --- a/game-app/game-core/src/test/java/games/strategy/triplea/attachments/UnitAttachmentTest.java +++ b/game-app/game-core/src/test/java/games/strategy/triplea/attachments/UnitAttachmentTest.java @@ -192,7 +192,7 @@ void relatedPropertiesAreSet() throws MutableProperty.InvalidValueException { when(sub.getAttachment(UNIT_ATTACHMENT_NAME)).thenReturn(mock(UnitAttachment.class)); final UnitType air = mock(UnitType.class); final UnitAttachment airAttachment = mock(UnitAttachment.class); - when(airAttachment.getIsAir()).thenReturn(true); + when(airAttachment.isAir()).thenReturn(true); when(air.getAttachment(UNIT_ATTACHMENT_NAME)).thenReturn(airAttachment); when(unitTypeList.getAllUnitTypes()).thenReturn(Set.of(sub, air)); diff --git a/game-app/game-core/src/test/java/games/strategy/triplea/attachments/UnitTypeComparatorTest.java b/game-app/game-core/src/test/java/games/strategy/triplea/attachments/UnitTypeComparatorTest.java index 77f2ef10160..f85ba5279ce 100644 --- a/game-app/game-core/src/test/java/games/strategy/triplea/attachments/UnitTypeComparatorTest.java +++ b/game-app/game-core/src/test/java/games/strategy/triplea/attachments/UnitTypeComparatorTest.java @@ -33,22 +33,22 @@ void setUp() { when(nullType.getName()).thenReturn(""); final var infrastructureAttachment = mock(UnitAttachment.class); - when(infrastructureAttachment.getIsInfrastructure()).thenReturn(true); + when(infrastructureAttachment.isInfrastructure()).thenReturn(true); when(infrastructure.getAttachment(any())).thenReturn(infrastructureAttachment); when(infrastructure.getName()).thenReturn(""); final var antiAircraftAttachment = mock(UnitAttachment.class); - when(antiAircraftAttachment.getIsAaForBombingThisUnitOnly()).thenReturn(true); + when(antiAircraftAttachment.isAaForBombingThisUnitOnly()).thenReturn(true); when(antiAircraft.getAttachment(any())).thenReturn(antiAircraftAttachment); when(antiAircraft.getName()).thenReturn(""); final var airAttachment = mock(UnitAttachment.class); - when(airAttachment.getIsAir()).thenReturn(true); + when(airAttachment.isAir()).thenReturn(true); when(air.getAttachment(any())).thenReturn(airAttachment); when(air.getName()).thenReturn(""); final var seaAttachment = mock(UnitAttachment.class); - when(seaAttachment.getIsSea()).thenReturn(true); + when(seaAttachment.isSea()).thenReturn(true); when(sea.getAttachment(any())).thenReturn(seaAttachment); when(sea.getName()).thenReturn(""); diff --git a/game-app/game-core/src/test/java/games/strategy/triplea/delegate/battle/steps/BattleStepsTest.java b/game-app/game-core/src/test/java/games/strategy/triplea/delegate/battle/steps/BattleStepsTest.java index 1c2d6ace8c8..7c8c1dc564f 100644 --- a/game-app/game-core/src/test/java/games/strategy/triplea/delegate/battle/steps/BattleStepsTest.java +++ b/game-app/game-core/src/test/java/games/strategy/triplea/delegate/battle/steps/BattleStepsTest.java @@ -98,7 +98,7 @@ public static UnitAndAttachment newUnitAndAttachment() { public static UnitAndAttachment newSeaUnitAndAttachment() { final var result = newUnitAndAttachment(); - lenient().when(result.unitAttachment.getIsSea()).thenReturn(true); + lenient().when(result.unitAttachment.isSea()).thenReturn(true); return result; } @@ -177,8 +177,8 @@ public static Unit givenSeaUnitCanNotBeTargetedBy(final UnitType otherType) { public static Unit givenUnitDestroyer() { final UnitAndAttachment unitAndAttachment = newSeaUnitAndAttachment(); - lenient().when(unitAndAttachment.unitAttachment.getIsDestroyer()).thenReturn(true); - lenient().when(unitAndAttachment.unitAttachment.getIsSea()).thenReturn(true); + lenient().when(unitAndAttachment.unitAttachment.isDestroyer()).thenReturn(true); + lenient().when(unitAndAttachment.unitAttachment.isSea()).thenReturn(true); return unitAndAttachment.unit; } @@ -190,14 +190,14 @@ public static Unit givenUnitSeaTransport() { public static Unit givenUnitAirTransport() { final UnitAndAttachment unitAndAttachment = newUnitAndAttachment(); - when(unitAndAttachment.unitAttachment.getIsAirTransport()).thenReturn(true); + when(unitAndAttachment.unitAttachment.isAirTransport()).thenReturn(true); return unitAndAttachment.unit; } public static Unit givenUnitIsCombatAa() { final UnitAndAttachment unitAndAttachment = newUnitAndAttachment(); when(unitAndAttachment.unitAttachment.getTypeAa()).thenReturn("AntiAirGun"); - when(unitAndAttachment.unitAttachment.getIsAaForCombatOnly()).thenReturn(true); + when(unitAndAttachment.unitAttachment.isAaForCombatOnly()).thenReturn(true); return unitAndAttachment.unit; } @@ -216,7 +216,7 @@ public static Unit givenUnitIsCombatAa( when(unitAndAttachment.unit.getData()).thenReturn(gameData); when(unitAndAttachment.unitAttachment.getTypeAa()).thenReturn(aaType); when(unitAndAttachment.unitAttachment.getTargetsAa(any())).thenReturn(aaTarget); - when(unitAndAttachment.unitAttachment.getIsAaForCombatOnly()).thenReturn(true); + when(unitAndAttachment.unitAttachment.isAaForCombatOnly()).thenReturn(true); when(unitAndAttachment.unitAttachment.getMaxRoundsAa()).thenReturn(-1); when(unitAndAttachment.unitAttachment.getMaxAaAttacks()).thenReturn(1); if (side == BattleState.Side.OFFENSE) { @@ -229,7 +229,7 @@ public static Unit givenUnitIsCombatAa( public static Unit givenUnitIsAir() { final UnitAndAttachment unitAndAttachment = newUnitAndAttachment(); - when(unitAndAttachment.unitAttachment.getIsAir()).thenReturn(true); + when(unitAndAttachment.unitAttachment.isAir()).thenReturn(true); return unitAndAttachment.unit; } @@ -245,7 +245,7 @@ public static Unit givenUnitWasAmphibious() { public static Unit givenUnitIsInfrastructure() { final UnitAndAttachment unitAndAttachment = newUnitAndAttachment(); - when(unitAndAttachment.unitAttachment.getIsInfrastructure()).thenReturn(true); + when(unitAndAttachment.unitAttachment.isInfrastructure()).thenReturn(true); return unitAndAttachment.unit; } diff --git a/game-app/game-core/src/test/java/games/strategy/triplea/delegate/battle/steps/change/MarkNoMovementLeftTest.java b/game-app/game-core/src/test/java/games/strategy/triplea/delegate/battle/steps/change/MarkNoMovementLeftTest.java index d59485886f2..9f4dc67c8c3 100644 --- a/game-app/game-core/src/test/java/games/strategy/triplea/delegate/battle/steps/change/MarkNoMovementLeftTest.java +++ b/game-app/game-core/src/test/java/games/strategy/triplea/delegate/battle/steps/change/MarkNoMovementLeftTest.java @@ -84,7 +84,7 @@ private Unit givenNonAirUnitWithMovementLeft(final BigDecimal movement) { final UnitType unitType = mock(UnitType.class); final UnitAttachment unitAttachment = mock(UnitAttachment.class); when(unitType.getAttachment(UNIT_ATTACHMENT_NAME)).thenReturn(unitAttachment); - when(unitAttachment.getIsAir()).thenReturn(false); + when(unitAttachment.isAir()).thenReturn(false); final Unit unit = spy(new Unit(unitType, mock(GamePlayer.class), givenGameData().build())); doReturn(movement).when(unit).getMovementLeft(); return unit; diff --git a/game-app/game-core/src/test/java/games/strategy/triplea/delegate/battle/steps/change/RemoveUnprotectedUnitsTest.java b/game-app/game-core/src/test/java/games/strategy/triplea/delegate/battle/steps/change/RemoveUnprotectedUnitsTest.java index 7192146e2d4..f7f94c1ef05 100644 --- a/game-app/game-core/src/test/java/games/strategy/triplea/delegate/battle/steps/change/RemoveUnprotectedUnitsTest.java +++ b/game-app/game-core/src/test/java/games/strategy/triplea/delegate/battle/steps/change/RemoveUnprotectedUnitsTest.java @@ -490,7 +490,7 @@ void actionForDefenderIfNoRetreatAndUnitsAndCanNotRollAndOtherSideCanButUnitsAre final Unit unitToNotDie = givenAnyUnit(); final UnitAttachment unitAttachment = (UnitAttachment) unitToNotDie.getType().getAttachment(UNIT_ATTACHMENT_NAME); - when(unitAttachment.getIsInfrastructure()).thenReturn(true); + when(unitAttachment.isInfrastructure()).thenReturn(true); final BattleState battleState = givenBattleStateBuilder() diff --git a/game-app/game-core/src/test/java/games/strategy/triplea/delegate/battle/steps/fire/aa/FiringGroupSplitterAaTest.java b/game-app/game-core/src/test/java/games/strategy/triplea/delegate/battle/steps/fire/aa/FiringGroupSplitterAaTest.java index 47ff2ea2671..1478c035392 100644 --- a/game-app/game-core/src/test/java/games/strategy/triplea/delegate/battle/steps/fire/aa/FiringGroupSplitterAaTest.java +++ b/game-app/game-core/src/test/java/games/strategy/triplea/delegate/battle/steps/fire/aa/FiringGroupSplitterAaTest.java @@ -222,7 +222,7 @@ void separateFiringGroupBySuicideOnHit() { when(fireUnit2.getOwner()).thenReturn(attacker); final UnitAttachment unitAttachment = (UnitAttachment) fireUnit2.getType().getAttachment(UNIT_ATTACHMENT_NAME); - when(unitAttachment.getIsSuicideOnHit()).thenReturn(true); + when(unitAttachment.isSuicideOnHit()).thenReturn(true); final List firingGroups = FiringGroupSplitterAa.of(OFFENSE) diff --git a/game-app/game-core/src/test/java/games/strategy/triplea/delegate/battle/steps/fire/general/FiringGroupSplitterGeneralTest.java b/game-app/game-core/src/test/java/games/strategy/triplea/delegate/battle/steps/fire/general/FiringGroupSplitterGeneralTest.java index 79303002e49..821701973b9 100644 --- a/game-app/game-core/src/test/java/games/strategy/triplea/delegate/battle/steps/fire/general/FiringGroupSplitterGeneralTest.java +++ b/game-app/game-core/src/test/java/games/strategy/triplea/delegate/battle/steps/fire/general/FiringGroupSplitterGeneralTest.java @@ -292,7 +292,7 @@ void excludeInfrastructureTargets() { final Unit targetUnit = givenAnyUnit(); final Unit infrastructureUnit = givenAnyUnit(); final UnitAttachment infrastructureUnitAttachment = infrastructureUnit.getUnitAttachment(); - when(infrastructureUnitAttachment.getIsInfrastructure()).thenReturn(true); + when(infrastructureUnitAttachment.isInfrastructure()).thenReturn(true); final Unit fireUnit = givenAnyUnit(); final List firingGroups = @@ -324,7 +324,7 @@ void excludeInfrastructureTargets() { void noFiringGroupIfAllTargetsAreExcluded() { final Unit targetUnit = givenAnyUnit(); final UnitAttachment infrastructureUnitAttachment = targetUnit.getUnitAttachment(); - when(infrastructureUnitAttachment.getIsInfrastructure()).thenReturn(true); + when(infrastructureUnitAttachment.isInfrastructure()).thenReturn(true); final Unit fireUnit = givenAnyUnit(); final List firingGroups = diff --git a/game-app/game-core/src/test/java/games/strategy/triplea/delegate/battle/steps/retreat/OffensiveGeneralRetreatTest.java b/game-app/game-core/src/test/java/games/strategy/triplea/delegate/battle/steps/retreat/OffensiveGeneralRetreatTest.java index 101b1a693d2..78809e25b8b 100644 --- a/game-app/game-core/src/test/java/games/strategy/triplea/delegate/battle/steps/retreat/OffensiveGeneralRetreatTest.java +++ b/game-app/game-core/src/test/java/games/strategy/triplea/delegate/battle/steps/retreat/OffensiveGeneralRetreatTest.java @@ -74,7 +74,7 @@ void noIfAmphibiousEvenWithWW2V2AndHasPlanes() { final UnitAttachment unitAttachment = (UnitAttachment) unit.getType().getAttachment(UNIT_ATTACHMENT_NAME); // ensure it didn't even try to check if there are planes - verify(unitAttachment, never()).getIsAir(); + verify(unitAttachment, never()).isAir(); } @Test @@ -92,7 +92,7 @@ void yesIfWW2V2AndHasPlanes() { assertThat(offensiveGeneralRetreat.getAllStepDetails(), hasSize(1)); final UnitAttachment unitAttachment = (UnitAttachment) unit.getType().getAttachment(UNIT_ATTACHMENT_NAME); - verify(unitAttachment).getIsAir(); + verify(unitAttachment).isAir(); } @Test diff --git a/game-app/game-core/src/test/java/games/strategy/triplea/odds/calculator/DummyPlayerTest.java b/game-app/game-core/src/test/java/games/strategy/triplea/odds/calculator/DummyPlayerTest.java index 83cf5d3036c..8ee61c232d8 100644 --- a/game-app/game-core/src/test/java/games/strategy/triplea/odds/calculator/DummyPlayerTest.java +++ b/game-app/game-core/src/test/java/games/strategy/triplea/odds/calculator/DummyPlayerTest.java @@ -67,7 +67,7 @@ void setUp() { final var unitAttachment = mock(UnitAttachment.class); when(unitType.getAttachment(any())).thenReturn(unitAttachment); when(unit.getUnitAttachment()).thenReturn(unitAttachment); - when(unitAttachment.getIsAir()).thenReturn(!unit.equals(unitPool.get(0))); + when(unitAttachment.isAir()).thenReturn(!unit.equals(unitPool.get(0))); final var gameData = givenGameData().build(); when(unit.getData()).thenReturn(gameData); final var playerId = mock(GamePlayer.class); diff --git a/game-app/game-headed/src/main/java/games/strategy/triplea/ui/EditPanel.java b/game-app/game-headed/src/main/java/games/strategy/triplea/ui/EditPanel.java index 55be3e766d1..5958dcc5ea4 100644 --- a/game-app/game-headed/src/main/java/games/strategy/triplea/ui/EditPanel.java +++ b/game-app/game-headed/src/main/java/games/strategy/triplea/ui/EditPanel.java @@ -66,6 +66,7 @@ import javax.swing.ListSelectionModel; import javax.swing.SwingUtilities; import javax.swing.border.EmptyBorder; +import org.jetbrains.annotations.NotNull; import org.triplea.java.collections.CollectionUtils; import org.triplea.java.collections.IntegerMap; import org.triplea.swing.IntTextField; @@ -98,17 +99,17 @@ public void actionPerformed(final ActionEvent e) { } }; private final TripleAFrame frame; - private final Action performMoveAction; - private final Action addUnitsAction; - private final Action delUnitsAction; - private final Action changeResourcesAction; - private final Action addTechAction; - private final Action removeTechAction; - private final Action changeUnitHitDamageAction; - private final Action changeUnitBombingDamageAction; - private final Action changeTerritoryOwnerAction; - private final Action changePoliticalRelationships; - private Action currentAction = null; + private final transient Action performMoveAction; + private final transient Action addUnitsAction; + private final transient Action delUnitsAction; + private final transient Action changeResourcesAction; + private final transient Action addTechAction; + private final transient Action removeTechAction; + private final transient Action changeUnitHitDamageAction; + private final transient Action changeUnitBombingDamageAction; + private final transient Action changeTerritoryOwnerAction; + private final transient Action changePoliticalRelationships; + private transient Action currentAction = null; private boolean active = false; private Point mouseSelectedPoint; private Point mouseCurrentPoint; @@ -117,7 +118,7 @@ public void actionPerformed(final ActionEvent e) { private Territory selectedTerritory = null; private Territory currentTerritory = null; - private final UnitSelectionListener unitSelectionListener = + private final transient UnitSelectionListener unitSelectionListener = new UnitSelectionListener() { @Override public void unitsSelected( @@ -166,7 +167,7 @@ private void deselectUnits( } else { // user has clicked on a specific unit // deselect all if control is down if (md.isControlDown() || !Objects.equals(t, selectedTerritory)) { - selectedUnits.removeAll(units); + units.forEach(selectedUnits::remove); } else { // deselect one // remove those with the least movement first for (final Unit unit : units) { @@ -243,7 +244,7 @@ private void selectUnitsToRemove( getMap().setMouseShadowUnits(selectedUnits); } }; - private final MapSelectionListener mapSelectionListener = + private final transient MapSelectionListener mapSelectionListener = new DefaultMapSelectionListener() { @Override public void territorySelected(final Territory territory, final MouseDetails md) { @@ -840,7 +841,7 @@ public void actionPerformed(final ActionEvent event) { + "relationships between players." + "
Please note that none of this is validated by the engine or map, " + "so the results are not guaranteed to be perfectly what you expect." - + "
In addition, any maps that use triggers could be royalled messed " + + "
In addition, any maps that use triggers could be royally messed " + "up by changing editing political relationships:" + "
Example: Take a map where America gets some benefit " + "(like upgraded factories) after it goes to war for the first time, " @@ -858,17 +859,7 @@ public void actionPerformed(final ActionEvent event) { final PoliticalStateOverview pui = new PoliticalStateOverview(getData(), EditPanel.this.frame.getUiContext(), true); panel.add(pui, BorderLayout.CENTER); - final JScrollPane scroll = new JScrollPane(panel); - scroll.setBorder(BorderFactory.createEmptyBorder()); - final Dimension screenResolution = Toolkit.getDefaultToolkit().getScreenSize(); - // not only do we have a start bar, but we also have the message dialog to account for - final int availHeight = screenResolution.height - 120; - // just the scroll bars plus the window sides - final int availWidth = screenResolution.width - 40; - scroll.setPreferredSize( - new Dimension( - Math.min(scroll.getPreferredSize().width, availWidth), - Math.min(scroll.getPreferredSize().height, availHeight))); + final JScrollPane scroll = getScrollPane(panel); final int option = JOptionPane.showConfirmDialog( EditPanel.this.frame, @@ -896,6 +887,22 @@ public void actionPerformed(final ActionEvent event) { } cancelEditAction.actionPerformed(null); } + + @NotNull + private JScrollPane getScrollPane(final JPanel panel) { + final JScrollPane scroll = new JScrollPane(panel); + scroll.setBorder(BorderFactory.createEmptyBorder()); + final Dimension screenResolution = Toolkit.getDefaultToolkit().getScreenSize(); + // not only do we have a start bar, but we also have the message dialog to account for + final int availHeight = screenResolution.height - 120; + // just the scroll bars plus the window sides + final int availWidth = screenResolution.width - 40; + scroll.setPreferredSize( + new Dimension( + Math.min(scroll.getPreferredSize().width, availWidth), + Math.min(scroll.getPreferredSize().height, availHeight))); + return scroll; + } }; actionLabel.setText("Edit Mode Actions"); setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); @@ -970,21 +977,15 @@ private static void sortUnitsToRemove(final List units) { } private static Comparator getRemovableUnitsOrder() { - return (u1, u2) -> { - if (u1.getUnitAttachment().getTransportCapacity() != -1) { - // Sort by decreasing transport capacity - return Comparator.>comparing( + return (u1, u2) -> + // Sort by decreasing transport costs of contained units (if any) + // Then sort by increasing movement left + Comparator.>comparing( Unit::getTransporting, Comparator.comparingInt(TransportUtils::getTransportCost).reversed()) .thenComparing(Unit::getMovementLeft) .thenComparingInt(Object::hashCode) .compare(u1, u2); - } - // Sort by increasing movement left - return Comparator.comparing(Unit::getMovementLeft) - .thenComparingInt(Object::hashCode) - .compare(u1, u2); - }; } private void setWidgetActivation() {