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 ecd934877d3..220607ccf00 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 @@ -1,6 +1,7 @@ package games.strategy.triplea.delegate; import static games.strategy.triplea.delegate.move.validation.UnitStackingLimitFilter.PLACEMENT_LIMIT; +import static java.util.function.Predicate.not; import games.strategy.engine.data.Change; import games.strategy.engine.data.CompositeChange; @@ -884,10 +885,10 @@ protected Collection getUnitsToBePlaced( && to.anyUnitsMatch(Matches.enemyUnit(player))) { return null; } - final Collection units = new ArrayList<>(allUnits); // if water, remove land. if land, remove water. - units.removeAll( - CollectionUtils.getMatches(units, water ? Matches.unitIsLand() : Matches.unitIsSea())); + final Collection units = + CollectionUtils.getMatches( + allUnits, water ? not(Matches.unitIsLand()) : not(Matches.unitIsSea())); final Collection placeableUnits = new ArrayList<>(); final Collection unitsAtStartOfTurnInTo = unitsAtStartOfStepInTerritory(to); final Collection allProducedUnits = unitsPlacedInTerritorySoFar(to); @@ -944,17 +945,10 @@ protected Collection getUnitsToBePlaced( } // remove any units that require other units to be consumed on creation, if we don't have enough // to consume (veqryn) - if (placeableUnits.stream().anyMatch(Matches.unitConsumesUnitsOnCreation())) { - final Collection unitsWhichConsume = - CollectionUtils.getMatches(placeableUnits, Matches.unitConsumesUnitsOnCreation()); - for (final Unit unit : unitsWhichConsume) { - if (Matches.unitWhichConsumesUnitsHasRequiredUnits(unitsAtStartOfTurnInTo) - .negate() - .test(unit)) { - placeableUnits.remove(unit); - } - } - } + placeableUnits.removeIf( + Matches.unitConsumesUnitsOnCreation() + .and(not(Matches.unitWhichConsumesUnitsHasRequiredUnits(unitsAtStartOfTurnInTo)))); + final Collection placeableUnits2; if (Properties.getUnitPlacementRestrictions(properties)) { final int territoryProduction = TerritoryAttachment.getProduction(to); diff --git a/game-app/game-core/src/main/java/games/strategy/triplea/delegate/BidPlaceDelegate.java b/game-app/game-core/src/main/java/games/strategy/triplea/delegate/BidPlaceDelegate.java index 98b92ab5b81..107c996b9e1 100644 --- a/game-app/game-core/src/main/java/games/strategy/triplea/delegate/BidPlaceDelegate.java +++ b/game-app/game-core/src/main/java/games/strategy/triplea/delegate/BidPlaceDelegate.java @@ -1,6 +1,7 @@ package games.strategy.triplea.delegate; import static games.strategy.triplea.delegate.move.validation.UnitStackingLimitFilter.PLACEMENT_LIMIT; +import static java.util.function.Predicate.not; import games.strategy.engine.data.GamePlayer; import games.strategy.engine.data.Territory; @@ -147,17 +148,9 @@ protected Collection getUnitsToBePlaced( } } // remove any units that require other units to be consumed on creation (veqryn) - if (placeableUnits.stream().anyMatch(Matches.unitConsumesUnitsOnCreation())) { - final Collection unitsWhichConsume = - CollectionUtils.getMatches(placeableUnits, Matches.unitConsumesUnitsOnCreation()); - for (final Unit unit : unitsWhichConsume) { - if (Matches.unitWhichConsumesUnitsHasRequiredUnits(unitsAtStartOfTurnInTo) - .negate() - .test(unit)) { - placeableUnits.remove(unit); - } - } - } + placeableUnits.removeIf( + Matches.unitConsumesUnitsOnCreation() + .and(not(Matches.unitWhichConsumesUnitsHasRequiredUnits(unitsAtStartOfTurnInTo)))); // now check stacking limits return UnitStackingLimitFilter.filterUnits(placeableUnits, PLACEMENT_LIMIT, player, to); } diff --git a/game-app/game-headed/src/main/java/games/strategy/triplea/ui/PlacePanel.java b/game-app/game-headed/src/main/java/games/strategy/triplea/ui/PlacePanel.java index 0547ef6d405..377ba6067e1 100644 --- a/game-app/game-headed/src/main/java/games/strategy/triplea/ui/PlacePanel.java +++ b/game-app/game-headed/src/main/java/games/strategy/triplea/ui/PlacePanel.java @@ -8,6 +8,7 @@ import games.strategy.engine.data.Territory; import games.strategy.engine.data.Unit; import games.strategy.engine.data.events.GameDataChangeListener; +import games.strategy.engine.data.properties.GameProperties; import games.strategy.engine.player.PlayerBridge; import games.strategy.triplea.Properties; import games.strategy.triplea.attachments.PlayerAttachment; @@ -219,9 +220,10 @@ private PlaceableUnits getUnitsToPlace(final Territory territory) { // get the units that can be placed on this territory. Collection units = getCurrentPlayer().getUnits(); if (territory.isWater()) { - if (!(Properties.getProduceFightersOnCarriers(getData().getProperties()) - || Properties.getProduceNewFightersOnOldCarriers(getData().getProperties()) - || Properties.getLhtrCarrierProductionRules(getData().getProperties()) + GameProperties properties = getData().getProperties(); + if (!(Properties.getProduceFightersOnCarriers(properties) + || Properties.getProduceNewFightersOnOldCarriers(properties) + || Properties.getLhtrCarrierProductionRules(properties) || GameStepPropertiesHelper.isBid(getData()))) { units = CollectionUtils.getMatches(units, Matches.unitIsSea()); } else {