diff --git a/game-app/game-core/src/main/java/games/strategy/engine/data/GameSequence.java b/game-app/game-core/src/main/java/games/strategy/engine/data/GameSequence.java index 7fd17d3960e..83494d666ff 100644 --- a/game-app/game-core/src/main/java/games/strategy/engine/data/GameSequence.java +++ b/game-app/game-core/src/main/java/games/strategy/engine/data/GameSequence.java @@ -21,9 +21,9 @@ public GameSequence(final GameData data) { } /** - * Only used when we are trying to export the data to a savegame, and we need to change the round - * and step to something other than the current round and step (because we are creating a savegame - * at a certain point in history, for example). + * Only used when we are trying to export the data to a save game, and we need to change the round + * and step to something other than the current round and step (because we are creating a save + * game at a certain point in history, for example). */ public synchronized void setRoundAndStep( final int currentRound, final String stepDisplayName, final GamePlayer player) { diff --git a/game-app/game-core/src/main/java/games/strategy/engine/framework/startup/launcher/ServerLauncher.java b/game-app/game-core/src/main/java/games/strategy/engine/framework/startup/launcher/ServerLauncher.java index 7ca98a6e5d3..07a194fc5f8 100644 --- a/game-app/game-core/src/main/java/games/strategy/engine/framework/startup/launcher/ServerLauncher.java +++ b/game-app/game-core/src/main/java/games/strategy/engine/framework/startup/launcher/ServerLauncher.java @@ -227,7 +227,7 @@ private void launchInternal() { } else { final String errorMessage = "Unrecognized error occurred. If this is a repeatable error, " - + "please make a copy of this savegame and report to:\n" + + "please make a copy of this save game and report to:\n" + UrlConstants.GITHUB_ISSUES; log.error(errorMessage, e); stopGame(); @@ -310,7 +310,7 @@ private void stopGame() { } private void saveAndEndGame(final INode node) { - // a hack, if headless save to the autosave to avoid polluting our savegames folder with a + // a hack, if headless save to the auto save to avoid polluting our save games folder with a // million saves final Path f = launchAction.getAutoSaveFile(); try { diff --git a/game-app/game-core/src/main/java/games/strategy/engine/posted/game/pbem/IEmailSender.java b/game-app/game-core/src/main/java/games/strategy/engine/posted/game/pbem/IEmailSender.java index b799db160af..3eba9735c4b 100644 --- a/game-app/game-core/src/main/java/games/strategy/engine/posted/game/pbem/IEmailSender.java +++ b/game-app/game-core/src/main/java/games/strategy/engine/posted/game/pbem/IEmailSender.java @@ -23,7 +23,7 @@ public interface IEmailSender { * * @param subject the subject of the email * @param htmlMessage the html email body - * @param saveGame the savegame or null + * @param saveGame the save game or null * @throws IOException if an error occurs */ void sendEmail(String subject, String htmlMessage, Path saveGame, String saveGameName) diff --git a/game-app/game-core/src/main/java/games/strategy/engine/posted/game/pbf/NodeBbForumPoster.java b/game-app/game-core/src/main/java/games/strategy/engine/posted/game/pbf/NodeBbForumPoster.java index c51a2570506..6e7b22c99a1 100644 --- a/game-app/game-core/src/main/java/games/strategy/engine/posted/game/pbf/NodeBbForumPoster.java +++ b/game-app/game-core/src/main/java/games/strategy/engine/posted/game/pbf/NodeBbForumPoster.java @@ -162,7 +162,7 @@ private String uploadSaveGame( return parseSaveGameUrlFromJsonResponse(json); } throw new IllegalStateException( - "Failed to upload savegame, server returned Error Code " + "Failed to upload save game, server returned Error Code " + status + "\nMessage:\n" + EntityUtils.toString(response.getEntity())); diff --git a/game-app/game-core/src/main/java/games/strategy/triplea/ai/AbstractAi.java b/game-app/game-core/src/main/java/games/strategy/triplea/ai/AbstractAi.java index 37fd7626ec2..10eab9782cc 100644 --- a/game-app/game-core/src/main/java/games/strategy/triplea/ai/AbstractAi.java +++ b/game-app/game-core/src/main/java/games/strategy/triplea/ai/AbstractAi.java @@ -601,11 +601,12 @@ protected void battle(final IBattleDelegate battleDelegate) { // as in the case of a naval battle preceding an amphibious attack, keep trying to fight every // battle while (true) { - final BattleListing listing = battleDelegate.getBattles(); + final BattleListing listing = battleDelegate.getBattleListing(); if (listing.isEmpty()) { return; } - for (final Entry> entry : listing.getBattles().entrySet()) { + for (final Entry> entry : + listing.getBattlesMap().entrySet()) { for (final Territory current : entry.getValue()) { final String error = battleDelegate.fightBattle(current, entry.getKey().isBombingRun(), entry.getKey()); diff --git a/game-app/game-core/src/main/java/games/strategy/triplea/ai/pro/simulate/ProSimulateTurnUtils.java b/game-app/game-core/src/main/java/games/strategy/triplea/ai/pro/simulate/ProSimulateTurnUtils.java index d85bf011d59..df7a66f8e32 100644 --- a/game-app/game-core/src/main/java/games/strategy/triplea/ai/pro/simulate/ProSimulateTurnUtils.java +++ b/game-app/game-core/src/main/java/games/strategy/triplea/ai/pro/simulate/ProSimulateTurnUtils.java @@ -50,7 +50,7 @@ public static void simulateBattles( final BattleDelegate battleDelegate = data.getBattleDelegate(); final Map> battleTerritories = - battleDelegate.getBattles().getBattles(); + battleDelegate.getBattleListing().getBattlesMap(); for (final Entry> entry : battleTerritories.entrySet()) { for (final Territory t : entry.getValue()) { final IBattle battle = diff --git a/game-app/game-core/src/main/java/games/strategy/triplea/delegate/battle/BattleDelegate.java b/game-app/game-core/src/main/java/games/strategy/triplea/delegate/battle/BattleDelegate.java index b8e065dbe04..a6f8ab5a7ab 100644 --- a/game-app/game-core/src/main/java/games/strategy/triplea/delegate/battle/BattleDelegate.java +++ b/game-app/game-core/src/main/java/games/strategy/triplea/delegate/battle/BattleDelegate.java @@ -193,7 +193,7 @@ public void loadState(final Serializable state) { @Override public boolean delegateCurrentlyRequiresUserInput() { - final BattleListing battles = getBattles(); + final BattleListing battles = getBattleListing(); if (battles.isEmpty()) { final IBattle battle = getCurrentBattle(); return battle != null; @@ -252,8 +252,8 @@ private static String getFightingWord(final IBattle battle) { } @Override - public BattleListing getBattles() { - return battleTracker.getPendingBattleSites(); + public BattleListing getBattleListing() { + return battleTracker.getBattleListingFromPendingBattles(); } /** Add bombardment units to battles. */ @@ -688,7 +688,7 @@ private void doScrambling() { if (!Properties.getScrambleRulesInEffect(data.getProperties())) { return; } - final BattleListing pendingBattleSites = battleTracker.getPendingBattleSites(); + final BattleListing pendingBattleSites = battleTracker.getBattleListingFromPendingBattles(); final Set territoriesWithBattles = pendingBattleSites.getNormalBattlesIncludingAirBattles(); if (Properties.getCanScrambleIntoAirBattles(data.getProperties())) { @@ -1210,7 +1210,8 @@ private void doKamikazeSuicideAttacks() { .and(Matches.unitCanEvade().negate()); final boolean onlyWhereThereAreBattlesOrAmphibious = Properties.getKamikazeSuicideAttacksOnlyWhereBattlesAre(data.getProperties()); - final Collection pendingBattles = battleTracker.getPendingBattleSites(false); + final Collection pendingBattles = + battleTracker.getPendingBattleSitesWithoutBombing(); // create a list of all kamikaze zones, listed by enemy final Map> kamikazeZonesByEnemy = new HashMap<>(); for (final Territory t : data.getMap().getTerritories()) { @@ -1478,7 +1479,7 @@ private static Collection whereCanAirLand( (Properties.getNeutralFlyoverAllowed(data.getProperties()) && !Properties.getNeutralsImpassable(data.getProperties())); final Set canNotLand = new HashSet<>(); - canNotLand.addAll(battleTracker.getPendingBattleSites(false)); + canNotLand.addAll(battleTracker.getPendingBattleSitesWithoutBombing()); canNotLand.addAll( CollectionUtils.getMatches( data.getMap().getTerritories(), Matches.territoryHasEnemyUnits(alliedPlayer))); @@ -1519,7 +1520,7 @@ private static Collection whereCanAirLand( possibleTerrs, Matches.territoryHasUnitsThatMatch(Matches.unitIsAlliedCarrier(alliedPlayer)) .and(Matches.territoryIsWater()))); - availableWater.removeAll(battleTracker.getPendingBattleSites(false)); + availableWater.removeAll(battleTracker.getPendingBattleSitesWithoutBombing()); // simple calculation, either we can take all the air, or we can't, nothing in the middle final int carrierCost = AirMovementValidator.carrierCost(strandedAir); final Iterator waterIter = availableWater.iterator(); diff --git a/game-app/game-core/src/main/java/games/strategy/triplea/delegate/battle/BattleTracker.java b/game-app/game-core/src/main/java/games/strategy/triplea/delegate/battle/BattleTracker.java index f0f0c8fd7ee..283949abd90 100644 --- a/game-app/game-core/src/main/java/games/strategy/triplea/delegate/battle/BattleTracker.java +++ b/game-app/game-core/src/main/java/games/strategy/triplea/delegate/battle/BattleTracker.java @@ -38,6 +38,7 @@ import java.io.Serializable; import java.util.ArrayList; import java.util.Collection; +import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.List; @@ -433,22 +434,23 @@ private void addEmptyBattle( .or(Matches.isTerritoryEnemyAndNotUnownedWaterOrImpassableOrRestricted(gamePlayer)); final Predicate conquerable = Matches.territoryIsEmptyOfCombatUnits(gamePlayer).and(passableLandAndNotRestricted); - final Collection conquered = new ArrayList<>(); + final Collection conqueredTerritories = new ArrayList<>(); if (canConquerMiddleSteps) { - conquered.addAll(route.getMatches(conquerable)); + conqueredTerritories.addAll(route.getMatches(conquerable)); // in case we begin in enemy territory, and blitz out of it, check the first territory if (!route.getStart().equals(route.getEnd()) && conquerable.test(route.getStart())) { - conquered.add(route.getStart()); + conqueredTerritories.add(route.getStart()); } } // we handle the end of the route later - conquered.remove(route.getEnd()); - final Collection blitzed = - CollectionUtils.getMatches(conquered, Matches.territoryIsBlitzable(gamePlayer)); - this.blitzed.addAll(CollectionUtils.getMatches(blitzed, Matches.isTerritoryEnemy(gamePlayer))); + conqueredTerritories.remove(route.getEnd()); + final Collection blitzedTerritories = + CollectionUtils.getMatches(conqueredTerritories, Matches.territoryIsBlitzable(gamePlayer)); + this.blitzed.addAll( + CollectionUtils.getMatches(blitzedTerritories, Matches.isTerritoryEnemy(gamePlayer))); this.conquered.addAll( - CollectionUtils.getMatches(conquered, Matches.isTerritoryEnemy(gamePlayer))); - for (final Territory current : conquered) { + CollectionUtils.getMatches(conqueredTerritories, Matches.isTerritoryEnemy(gamePlayer))); + for (final Territory current : conqueredTerritories) { IBattle nonFight = getPendingBattle(current, BattleType.NORMAL); // TODO: if we ever want to scramble to a blitzed territory, then we need to fix this if (nonFight == null) { @@ -885,8 +887,10 @@ public static void captureOrDestroyUnits( final Map>> map = u.getUnitAttachment().getWhenCapturedChangesInto(); final GamePlayer currentOwner = u.getOwner(); - for (final String value : map.keySet()) { - final String[] s = Iterables.toArray(Splitter.on(':').split(value), String.class); + for (Map.Entry>> mapEntry : + Collections.unmodifiableSet(map.entrySet())) { + final String[] s = + Iterables.toArray(Splitter.on(':').split(mapEntry.getKey()), String.class); if (!(s[0].equals("any") || data.getPlayerList().getPlayerId(s[0]).equals(currentOwner))) { continue; @@ -897,7 +901,7 @@ public static void captureOrDestroyUnits( } final CompositeChange changes = new CompositeChange(); final Collection toAdd = new ArrayList<>(); - final Tuple> toCreate = map.get(value); + final Tuple> toCreate = mapEntry.getValue(); final boolean translateAttributes = toCreate.getFirst().equalsIgnoreCase("true"); for (final UnitType ut : toCreate.getSecond().keySet()) { toAdd.addAll(ut.create(toCreate.getSecond().getInt(ut), newOwner)); @@ -1036,17 +1040,15 @@ public Collection getPendingBattles(BattleType type) { } public Collection getPendingBattles(final Territory t) { - return pendingBattles.stream() - .filter(b -> b.getTerritory().equals(t)) - .collect(Collectors.toSet()); + return CollectionUtils.getMatches(pendingBattles, b -> b.getTerritory().equals(t)); } public boolean hasPendingNonBombingBattle(final Territory t) { - return getPendingBattle(t) != null; + return getPendingNonBombingBattle(t) != null; } @Nullable - public IBattle getPendingBattle(final Territory t) { + public IBattle getPendingNonBombingBattle(final Territory t) { return BattleType.nonBombingBattleTypes().stream() .map(type -> getPendingBattle(t, type)) .filter(Objects::nonNull) @@ -1056,50 +1058,43 @@ public IBattle getPendingBattle(final Territory t) { @Nullable public IBattle getPendingBattle(final Territory t, final BattleType type) { - for (final IBattle battle : pendingBattles) { - if (battle.getTerritory().equals(t) && type == battle.getBattleType()) { - return battle; - } - } - return null; + return pendingBattles.stream() + .filter(b -> b.getBattleType().equals(type) && b.getTerritory().equals(t)) + .findFirst() + .orElse(null); } public IBattle getPendingBattle(final UUID uuid) { if (uuid == null) { return null; } - return pendingBattles.stream().filter(b -> b.getBattleId().equals(uuid)).findAny().orElse(null); } + /** Returns a collection of territories where no bombing battles are pending. */ + public Collection getPendingBattleSitesWithoutBombing() { + return getPendingBattleSites(false); + } + + /** Returns a collection of territories where bombing battles are pending. */ + public Collection getPendingBattleSitesWithBombing() { + return getPendingBattleSites(true); + } + /** * Returns a collection of territories where battles are pending. * - * @param bombing whether only battles where there is bombing. + * @param bombing whether only battles where there is bombing or where there is no bombing. */ - public Collection getPendingBattleSites(final boolean bombing) { - final Collection battles = new ArrayList<>(); - for (final IBattle battle : pendingBattles) { - if (!battle.isEmpty() && battle.getBattleType().isBombingRun() == bombing) { - battles.add(battle.getTerritory()); - } - } - return battles; + private Collection getPendingBattleSites(final boolean bombing) { + return pendingBattles.stream() + .filter(b -> !b.isEmpty() && b.getBattleType().isBombingRun() == bombing) + .map(IBattle::getTerritory) + .collect(Collectors.toSet()); } - public BattleListing getPendingBattleSites() { - final Map> battles = new HashMap<>(); - for (final IBattle battle : pendingBattles) { - if (!battle.isEmpty()) { - Collection territories = battles.get(battle.getBattleType()); - if (territories == null) { - territories = new HashSet<>(); - } - territories.add(battle.getTerritory()); - battles.put(battle.getBattleType(), territories); - } - } - return new BattleListing(battles); + public BattleListing getBattleListingFromPendingBattles() { + return new BattleListing(pendingBattles); } /** @@ -1131,9 +1126,9 @@ public void addDependency(final IBattle blocked, final IBattle blocking) { } private void removeDependency(final IBattle blocked, final IBattle blocking) { - final Collection dependencies = this.dependencies.get(blocked); - dependencies.remove(blocking); - if (dependencies.isEmpty()) { + final Collection dependenciesOfBlocked = this.dependencies.get(blocked); + dependenciesOfBlocked.remove(blocking); + if (dependenciesOfBlocked.isEmpty()) { this.dependencies.remove(blocked); } } @@ -1204,7 +1199,7 @@ void sendBattleRecordsToGameData(final IDelegateBridge bridge) { */ void fightAirRaidsAndStrategicBombing(final IDelegateBridge delegateBridge) { fightAirRaidsAndStrategicBombing( - delegateBridge, () -> getPendingBattleSites(true), this::getPendingBattle); + delegateBridge, this::getPendingBattleSitesWithBombing, this::getPendingBattle); } @VisibleForTesting @@ -1226,7 +1221,7 @@ void fightAirRaidsAndStrategicBombing( } } - // now that we've done all the air battles, do all the SBR's as a second wave. + // now that we've done all the air battles, do all the SBRs as a second wave. for (final Territory t : pendingBattleSiteSupplier.get()) { final IBattle bombingRaid = pendingBattleFunction.apply(t, BattleType.BOMBING_RAID); if (bombingRaid != null) { diff --git a/game-app/game-core/src/main/java/games/strategy/triplea/delegate/data/BattleListing.java b/game-app/game-core/src/main/java/games/strategy/triplea/delegate/data/BattleListing.java index 880c851ac80..965ea418983 100644 --- a/game-app/game-core/src/main/java/games/strategy/triplea/delegate/data/BattleListing.java +++ b/game-app/game-core/src/main/java/games/strategy/triplea/delegate/data/BattleListing.java @@ -1,13 +1,17 @@ package games.strategy.triplea.delegate.data; import games.strategy.engine.data.Territory; +import games.strategy.triplea.delegate.battle.IBattle; import games.strategy.triplea.delegate.battle.IBattle.BattleType; import java.io.Serializable; import java.util.Collection; +import java.util.EnumMap; import java.util.HashSet; import java.util.Map; import java.util.Map.Entry; import java.util.Set; +import java.util.function.BiConsumer; +import java.util.function.Predicate; import lombok.Getter; /** @@ -16,31 +20,40 @@ @Getter public class BattleListing implements Serializable { private static final long serialVersionUID = 2700129486225793827L; - private final Map> battles; + private final Map> battlesMap; /** * Creates new BattleListing. * * @param battles battles to list */ - public BattleListing(final Map> battles) { - this.battles = battles; + public BattleListing(final Set battles) { + this.battlesMap = new EnumMap<>(BattleType.class); + battles.stream() + .filter(b -> !b.isEmpty()) + .forEach( + b -> { + Collection territories = battlesMap.get(b.getBattleType()); + if (territories == null) { + territories = new HashSet<>(); + } + territories.add(b.getTerritory()); + battlesMap.put(b.getBattleType(), territories); + }); } public Set getNormalBattlesIncludingAirBattles() { - final Set territories = new HashSet<>(); - for (final Entry> entry : battles.entrySet()) { - if (!entry.getKey().isBombingRun()) { - territories.addAll(entry.getValue()); - } - } - return territories; + return getBattlesWith(b -> !b.isBombingRun()); } public Set getStrategicBombingRaidsIncludingAirBattles() { + return getBattlesWith(BattleType::isBombingRun); + } + + private Set getBattlesWith(Predicate predicate) { final Set territories = new HashSet<>(); - for (final Entry> entry : battles.entrySet()) { - if (entry.getKey().isBombingRun()) { + for (final Entry> entry : battlesMap.entrySet()) { + if (predicate.test(entry.getKey())) { territories.addAll(entry.getValue()); } } @@ -48,6 +61,16 @@ public Set getStrategicBombingRaidsIncludingAirBattles() { } public boolean isEmpty() { - return battles.isEmpty(); + return battlesMap.isEmpty(); + } + + public void forEachBattle(BiConsumer action) { + for (final Entry> battleTypeCollection : + battlesMap.entrySet()) { + final BattleType battleType = battleTypeCollection.getKey(); + for (final Territory territory : battleTypeCollection.getValue()) { + action.accept(battleType, territory); + } + } } } diff --git a/game-app/game-core/src/main/java/games/strategy/triplea/delegate/remote/IBattleDelegate.java b/game-app/game-core/src/main/java/games/strategy/triplea/delegate/remote/IBattleDelegate.java index aca8eddd5ee..4a3c6f90efc 100644 --- a/game-app/game-core/src/main/java/games/strategy/triplea/delegate/remote/IBattleDelegate.java +++ b/game-app/game-core/src/main/java/games/strategy/triplea/delegate/remote/IBattleDelegate.java @@ -15,7 +15,7 @@ public interface IBattleDelegate extends IRemote, IDelegate { /** Returns the battles currently waiting to be fought. */ @RemoteActionCode(3) - BattleListing getBattles(); + BattleListing getBattleListing(); /** * Fight the battle in the given country. diff --git a/game-app/game-core/src/test/java/games/strategy/triplea/delegate/AirThatCantLandUtilTest.java b/game-app/game-core/src/test/java/games/strategy/triplea/delegate/AirThatCantLandUtilTest.java index b233324c408..47e51f01387 100644 --- a/game-app/game-core/src/test/java/games/strategy/triplea/delegate/AirThatCantLandUtilTest.java +++ b/game-app/game-core/src/test/java/games/strategy/triplea/delegate/AirThatCantLandUtilTest.java @@ -32,7 +32,7 @@ class AirThatCantLandUtilTest extends AbstractClientSettingTestCase { private static void fight(final IBattleDelegate battle, final Territory territory) { for (final Entry> entry : - battle.getBattles().getBattles().entrySet()) { + battle.getBattleListing().getBattlesMap().entrySet()) { if (!entry.getKey().isBombingRun() && entry.getValue().contains(territory)) { battle.fightBattle(territory, false, entry.getKey()); return; diff --git a/game-app/game-core/src/test/java/games/strategy/triplea/delegate/MoveDelegateTest.java b/game-app/game-core/src/test/java/games/strategy/triplea/delegate/MoveDelegateTest.java index 1b915c87272..5ecddcb3a97 100644 --- a/game-app/game-core/src/test/java/games/strategy/triplea/delegate/MoveDelegateTest.java +++ b/game-app/game-core/src/test/java/games/strategy/triplea/delegate/MoveDelegateTest.java @@ -800,9 +800,12 @@ void testAmphibiousAssaultAfterNavalBattle() { results = delegate.move(GameDataTestUtil.getUnits(map, route.getStart()), route); assertValid(results); final IBattle inBrazil = - gameData.getBattleDelegate().getBattleTracker().getPendingBattle(brazil); + gameData.getBattleDelegate().getBattleTracker().getPendingNonBombingBattle(brazil); final IBattle inBrazilSea = - gameData.getBattleDelegate().getBattleTracker().getPendingBattle(southBrazilSeaZone); + gameData + .getBattleDelegate() + .getBattleTracker() + .getPendingNonBombingBattle(southBrazilSeaZone); assertNotNull(inBrazilSea); assertNotNull(inBrazil); assertEquals( @@ -837,9 +840,9 @@ void testReloadTransportAfterRetreatAmphibious() { final int defendingLandSizeInt = defendingLandUnits.size(); // Set up the battles and the dependent battles final IBattle inFinlandNorway = - gameData.getBattleDelegate().getBattleTracker().getPendingBattle(finlandNorway); + gameData.getBattleDelegate().getBattleTracker().getPendingNonBombingBattle(finlandNorway); final IBattle inBalticSeaZone = - gameData.getBattleDelegate().getBattleTracker().getPendingBattle(balticSeaZone); + gameData.getBattleDelegate().getBattleTracker().getPendingNonBombingBattle(balticSeaZone); assertNotNull(balticSeaZone); assertNotNull(finlandNorway); assertEquals( @@ -913,9 +916,9 @@ void testReloadTransportAfterDyingAmphibious() { final int defendingLandSizeInt = defendingLandUnits.size(); // Set up the battles and the dependent battles final IBattle inFinlandNorway = - gameData.getBattleDelegate().getBattleTracker().getPendingBattle(finlandNorway); + gameData.getBattleDelegate().getBattleTracker().getPendingNonBombingBattle(finlandNorway); final IBattle inBalticSeaZone = - gameData.getBattleDelegate().getBattleTracker().getPendingBattle(balticSeaZone); + gameData.getBattleDelegate().getBattleTracker().getPendingNonBombingBattle(balticSeaZone); assertNotNull(balticSeaZone); assertNotNull(finlandNorway); assertEquals( @@ -988,7 +991,7 @@ void testReloadTransportAfterRetreatAllied() { karelia.getUnitCollection().getMatches(Matches.isUnitAllied(british))); // Set up the battles and the dependent battles final IBattle inBalticSeaZone = - gameData.getBattleDelegate().getBattleTracker().getPendingBattle(balticSeaZone); + gameData.getBattleDelegate().getBattleTracker().getPendingNonBombingBattle(balticSeaZone); assertNotNull(balticSeaZone); // Add some defending units in case there aren't any final List defendList = transport.create(1, germans); @@ -1049,7 +1052,7 @@ void testReloadTransportAfterDyingAllied() { karelia.getUnitCollection().getMatches(Matches.isUnitAllied(british))); // Set up the battles and the dependent battles final IBattle inBalticSeaZone = - gameData.getBattleDelegate().getBattleTracker().getPendingBattle(balticSeaZone); + gameData.getBattleDelegate().getBattleTracker().getPendingNonBombingBattle(balticSeaZone); assertNotNull(balticSeaZone); // Add some defending units in case there aren't any final List defendList = transport.create(1, germans); diff --git a/game-app/game-core/src/test/java/games/strategy/triplea/delegate/RevisedTest.java b/game-app/game-core/src/test/java/games/strategy/triplea/delegate/RevisedTest.java index 410cfeb5484..6c11baf48ab 100644 --- a/game-app/game-core/src/test/java/games/strategy/triplea/delegate/RevisedTest.java +++ b/game-app/game-core/src/test/java/games/strategy/triplea/delegate/RevisedTest.java @@ -733,7 +733,7 @@ void testMoveSubAwayFromSubmergedSubsInBattleZone() { moveDelegate.move(sz50.getUnitCollection().getMatches(Matches.unitIsAir()), sz50To45); assertNull(error); final var battleTracker = AbstractMoveDelegate.getBattleTracker(gameData); - assertEquals(1, battleTracker.getPendingBattleSites(false).size()); + assertEquals(1, battleTracker.getPendingBattleSitesWithoutBombing().size()); // we should be able to move the sub out of the sz final Route sz45To50 = new Route(sz45, sz50); final List japSub = @@ -743,14 +743,14 @@ void testMoveSubAwayFromSubmergedSubsInBattleZone() { // make sure no error assertNull(error); // make sure the battle is still there - assertEquals(1, battleTracker.getPendingBattleSites(false).size()); + assertEquals(1, battleTracker.getPendingBattleSitesWithoutBombing().size()); // we should be able to undo the move of the sub error = moveDelegate.undoMove(1); assertNull(error); // undo the move of the fighter, should be no battles now error = moveDelegate.undoMove(0); assertNull(error); - assertEquals(0, battleTracker.getPendingBattleSites(false).size()); + assertEquals(0, battleTracker.getPendingBattleSitesWithoutBombing().size()); } @Test @@ -839,7 +839,8 @@ void testAaOwnership() { assertValid(validResults); moveDelegate(gameData).end(); battle = - (MustFightBattle) AbstractMoveDelegate.getBattleTracker(gameData).getPendingBattle(fic); + (MustFightBattle) + AbstractMoveDelegate.getBattleTracker(gameData).getPendingNonBombingBattle(fic); // fight whenGetRandom(delegateBridge).thenAnswer(withValues(0)).thenAnswer(withValues(5)); battle.fight(delegateBridge); @@ -988,7 +989,7 @@ void testLandBattleNoSneakAttack() { moveDelegate(gameData).end(); final MustFightBattle battle = (MustFightBattle) - AbstractMoveDelegate.getBattleTracker(gameData).getPendingBattle(attacked); + AbstractMoveDelegate.getBattleTracker(gameData).getPendingNonBombingBattle(attacked); final List steps = battle.determineStepStrings(); assertEquals( BattleStepsTest.mergeSteps( @@ -1017,7 +1018,7 @@ void testSeaBattleNoSneakAttack() { moveDelegate(gameData).end(); final MustFightBattle battle = (MustFightBattle) - AbstractMoveDelegate.getBattleTracker(gameData).getPendingBattle(attacked); + AbstractMoveDelegate.getBattleTracker(gameData).getPendingNonBombingBattle(attacked); final List steps = battle.determineStepStrings(); assertEquals( BattleStepsTest.mergeSteps( @@ -1047,7 +1048,7 @@ void testAttackSubsOnSubs() { moveDelegate(gameData).end(); final MustFightBattle battle = (MustFightBattle) - AbstractMoveDelegate.getBattleTracker(gameData).getPendingBattle(attacked); + AbstractMoveDelegate.getBattleTracker(gameData).getPendingNonBombingBattle(attacked); final List steps = battle.determineStepStrings(); assertEquals( BattleStepsTest.mergeSteps( @@ -1092,7 +1093,7 @@ void testAttackSubsOnDestroyer() { moveDelegate(gameData).end(); final MustFightBattle battle = (MustFightBattle) - AbstractMoveDelegate.getBattleTracker(gameData).getPendingBattle(attacked); + AbstractMoveDelegate.getBattleTracker(gameData).getPendingNonBombingBattle(attacked); final List steps = battle.determineStepStrings(); /* * Here are the exact errata clarifications on how REVISED rules subs work: @@ -1163,7 +1164,7 @@ void testAttackSubsAndBattleshipOnDestroyerAndSubs() { moveDelegate(gameData).end(); final MustFightBattle battle = (MustFightBattle) - AbstractMoveDelegate.getBattleTracker(gameData).getPendingBattle(attacked); + AbstractMoveDelegate.getBattleTracker(gameData).getPendingNonBombingBattle(attacked); final List steps = battle.determineStepStrings(); /* * Here are the exact errata clarifications on how REVISED rules subs work: @@ -1233,7 +1234,7 @@ void testAttackDestroyerAndSubsAgainstSub() { moveDelegate(gameData).end(); final MustFightBattle battle = (MustFightBattle) - AbstractMoveDelegate.getBattleTracker(gameData).getPendingBattle(attacked); + AbstractMoveDelegate.getBattleTracker(gameData).getPendingNonBombingBattle(attacked); final List steps = battle.determineStepStrings(); assertEquals( BattleStepsTest.mergeSteps( @@ -1288,7 +1289,7 @@ void testAttackSubsAndDestroyerOnBatleshipAndSubs() { moveDelegate(gameData).end(); final MustFightBattle battle = (MustFightBattle) - AbstractMoveDelegate.getBattleTracker(gameData).getPendingBattle(attacked); + AbstractMoveDelegate.getBattleTracker(gameData).getPendingNonBombingBattle(attacked); final List steps = battle.determineStepStrings(); /* * Here are the exact errata clarifications on how REVISED rules subs work: @@ -1358,7 +1359,7 @@ void testAttackDestroyerAndSubsAgainstSubAndDestroyer() { moveDelegate(gameData).end(); final MustFightBattle battle = (MustFightBattle) - AbstractMoveDelegate.getBattleTracker(gameData).getPendingBattle(attacked); + AbstractMoveDelegate.getBattleTracker(gameData).getPendingNonBombingBattle(attacked); final List steps = battle.determineStepStrings(); assertEquals( BattleStepsTest.mergeSteps( @@ -1520,7 +1521,8 @@ void testTransportsUnloadingToMultipleTerritoriesDie() { new Route(sz6, uk)); // fight the battle moveDelegate(gameData).end(); - final IBattle battle = AbstractMoveDelegate.getBattleTracker(gameData).getPendingBattle(sz6); + final IBattle battle = + AbstractMoveDelegate.getBattleTracker(gameData).getPendingNonBombingBattle(sz6); // everything hits, this will kill both transports whenGetRandom(bridge).thenAnswer(withValues(0, 0)).thenAnswer(withValues(0, 0)); battle.fight(bridge); diff --git a/game-app/game-core/src/test/java/games/strategy/triplea/delegate/WW2V3Year41Test.java b/game-app/game-core/src/test/java/games/strategy/triplea/delegate/WW2V3Year41Test.java index ebba83a73a6..84a5904eaf8 100644 --- a/game-app/game-core/src/test/java/games/strategy/triplea/delegate/WW2V3Year41Test.java +++ b/game-app/game-core/src/test/java/games/strategy/triplea/delegate/WW2V3Year41Test.java @@ -151,7 +151,7 @@ private static void thenRemotePlayerShouldNotBeAskedToRetreat( private static void fight(final BattleDelegate battle, final Territory territory) { for (final Entry> entry : - battle.getBattles().getBattles().entrySet()) { + battle.getBattleListing().getBattlesMap().entrySet()) { if (!entry.getKey().isBombingRun() && entry.getValue().contains(territory)) { battle.fightBattle(territory, false, entry.getKey()); return; @@ -392,7 +392,7 @@ void testDefendingTransportsAutoKilled() { // the transport was not removed automatically assertEquals(3, sz13.getUnitCollection().size()); final BattleDelegate bd = battleDelegate(gameData); - assertFalse(bd.getBattleTracker().getPendingBattleSites(false).isEmpty()); + assertFalse(bd.getBattleTracker().getPendingBattleSitesWithoutBombing().isEmpty()); } @Test @@ -478,7 +478,7 @@ void testInfantryLoadOnlyTransports() { final BattleDelegate battleDelegate = battleDelegate(gameData); battleDelegate.setDelegateBridgeAndPlayer(bridge); battleDelegate.start(); - assertTrue(battleDelegate.getBattles().isEmpty()); + assertTrue(battleDelegate.getBattleListing().isEmpty()); } @Test @@ -535,7 +535,8 @@ void testCanRetreatIntoEmptyEnemyTerritory() { // we should not be able to retreat to east poland! // that territory is still owned by the enemy final MustFightBattle battle = - (MustFightBattle) AbstractMoveDelegate.getBattleTracker(gameData).getPendingBattle(ukraine); + (MustFightBattle) + AbstractMoveDelegate.getBattleTracker(gameData).getPendingNonBombingBattle(ukraine); assertFalse(battle.getAttackerRetreatTerritories().contains(eastPoland)); } @@ -561,7 +562,8 @@ void testCanRetreatIntoBlitzedTerritory() { // we should not be able to retreat to east poland! // that territory was just conquered final MustFightBattle battle = - (MustFightBattle) AbstractMoveDelegate.getBattleTracker(gameData).getPendingBattle(ukraine); + (MustFightBattle) + AbstractMoveDelegate.getBattleTracker(gameData).getPendingNonBombingBattle(ukraine); assertTrue(battle.getAttackerRetreatTerritories().contains(eastPoland)); } @@ -1029,7 +1031,8 @@ void testAttackUndoAndAttackAgain() { // move again move(sz14.getUnitCollection().getMatches(Matches.unitIsNotSeaTransport()), r); final MustFightBattle mfb = - (MustFightBattle) AbstractMoveDelegate.getBattleTracker(gameData).getPendingBattle(sz12); + (MustFightBattle) + AbstractMoveDelegate.getBattleTracker(gameData).getPendingNonBombingBattle(sz12); // only 3 attacking units // the battleship and the two cruisers assertEquals(3, mfb.getAttackingUnits().size()); @@ -1052,7 +1055,10 @@ void testAttackUndoAndBattlesCleared() { // undo it move.undoMove(0); // verify both blitz battles were cleared - assertTrue(AbstractMoveDelegate.getBattleTracker(gameData).getPendingBattleSites().isEmpty()); + assertTrue( + AbstractMoveDelegate.getBattleTracker(gameData) + .getBattleListingFromPendingBattles() + .isEmpty()); } @Test @@ -1074,7 +1080,7 @@ void testAttackSubsOnSubs() { moveDelegate(gameData).end(); final MustFightBattle battle = (MustFightBattle) - AbstractMoveDelegate.getBattleTracker(gameData).getPendingBattle(attacked); + AbstractMoveDelegate.getBattleTracker(gameData).getPendingNonBombingBattle(attacked); final List steps = battle.determineStepStrings(); assertEquals( BattleStepsTest.mergeSteps( @@ -1116,7 +1122,7 @@ void testAttackSubsOnDestroyer() { moveDelegate(gameData).end(); final MustFightBattle battle = (MustFightBattle) - AbstractMoveDelegate.getBattleTracker(gameData).getPendingBattle(attacked); + AbstractMoveDelegate.getBattleTracker(gameData).getPendingNonBombingBattle(attacked); final List steps = battle.determineStepStrings(); assertEquals( BattleStepsTest.mergeSteps( @@ -1163,7 +1169,7 @@ void testAttackDestroyerAndSubsAgainstSub() { moveDelegate(gameData).end(); final MustFightBattle battle = (MustFightBattle) - AbstractMoveDelegate.getBattleTracker(gameData).getPendingBattle(attacked); + AbstractMoveDelegate.getBattleTracker(gameData).getPendingNonBombingBattle(attacked); final List steps = battle.determineStepStrings(); assertEquals( BattleStepsTest.mergeSteps( @@ -1211,7 +1217,7 @@ void testAttackDestroyerAndSubsAgainstSubAndDestroyer() { moveDelegate(gameData).end(); final MustFightBattle battle = (MustFightBattle) - AbstractMoveDelegate.getBattleTracker(gameData).getPendingBattle(attacked); + AbstractMoveDelegate.getBattleTracker(gameData).getPendingNonBombingBattle(attacked); final List steps = battle.determineStepStrings(); assertEquals( BattleStepsTest.mergeSteps( @@ -1278,7 +1284,8 @@ void testLimitBombardToNumberOfUnloaded() { BattleDelegate.doInitialize(battleDelegate(gameData).getBattleTracker(), bridge); battleDelegate(gameData).addBombardmentSources(); final MustFightBattle mfb = - (MustFightBattle) AbstractMoveDelegate.getBattleTracker(gameData).getPendingBattle(eg); + (MustFightBattle) + AbstractMoveDelegate.getBattleTracker(gameData).getPendingNonBombingBattle(eg); // only 2 ships are allowed to bombard (there are 1 battleship and 2 cruisers that COULD // bombard, but only 2 ships may bombard total) assertEquals(2, mfb.getBombardingUnits().size()); @@ -1349,7 +1356,8 @@ void testBombardStrengthVariable() { BattleDelegate.doInitialize(battleDelegate(gameData).getBattleTracker(), bridge); battleDelegate(gameData).addBombardmentSources(); final MustFightBattle mfb = - (MustFightBattle) AbstractMoveDelegate.getBattleTracker(gameData).getPendingBattle(eg); + (MustFightBattle) + AbstractMoveDelegate.getBattleTracker(gameData).getPendingNonBombingBattle(eg); assertNotNull(mfb); // Show that bombard casualties can return fire // destroyer bombard hit/miss on rolls of 4 & 3 @@ -1402,7 +1410,8 @@ void testAmphibiousAttackUndoAndAttackAgainBombard() { BattleDelegate.doInitialize(battleDelegate(gameData).getBattleTracker(), bridge); battleDelegate(gameData).addBombardmentSources(); final MustFightBattle mfb = - (MustFightBattle) AbstractMoveDelegate.getBattleTracker(gameData).getPendingBattle(eg); + (MustFightBattle) + AbstractMoveDelegate.getBattleTracker(gameData).getPendingNonBombingBattle(eg); // only 2 battleships are allowed to bombard assertEquals(2, mfb.getBombardingUnits().size()); } diff --git a/game-app/game-core/src/test/java/games/strategy/triplea/delegate/WW2V3Year42Test.java b/game-app/game-core/src/test/java/games/strategy/triplea/delegate/WW2V3Year42Test.java index aea45068336..4b93eb9cbeb 100644 --- a/game-app/game-core/src/test/java/games/strategy/triplea/delegate/WW2V3Year42Test.java +++ b/game-app/game-core/src/test/java/games/strategy/triplea/delegate/WW2V3Year42Test.java @@ -76,7 +76,7 @@ void testBombAndAttackEmptyTerritory() { new Route(baltic, karrelia)); final BattleTracker battleTracker = MoveDelegate.getBattleTracker(gameData); // we should have a pending land battle, and a pending bombing raid - assertNotNull(battleTracker.getPendingBattle(karrelia)); + assertNotNull(battleTracker.getPendingNonBombingBattle(karrelia)); assertNotNull(battleTracker.getPendingBombingBattle(karrelia)); // the territory should not be conquered assertEquals(karrelia.getOwner(), russians(gameData)); @@ -100,7 +100,7 @@ void testLingeringSeaUnitsJoinBattle() { battleDelegate(gameData).setDelegateBridgeAndPlayer(bridge); BattleDelegate.doInitialize(battleDelegate(gameData).getBattleTracker(), bridge); // all units in sz5 should be involved in the battle - final IBattle battle = MoveDelegate.getBattleTracker(gameData).getPendingBattle(sz5); + final IBattle battle = MoveDelegate.getBattleTracker(gameData).getPendingNonBombingBattle(sz5); assertEquals(5, battle.getAttackingUnits().size()); } @@ -125,7 +125,7 @@ void testLingeringFightersAndAlliedUnitsJoinBattle() { battleDelegate(gameData).setDelegateBridgeAndPlayer(bridge); BattleDelegate.doInitialize(battleDelegate(gameData).getBattleTracker(), bridge); // all units in sz5 should be involved in the battle except the italian carrier - final IBattle battle = MoveDelegate.getBattleTracker(gameData).getPendingBattle(sz5); + final IBattle battle = MoveDelegate.getBattleTracker(gameData).getPendingNonBombingBattle(sz5); assertEquals(6, battle.getAttackingUnits().size()); } @@ -149,7 +149,7 @@ void testLingeringSeaUnitsCanMoveAwayFromBattle() { battleDelegate(gameData).setDelegateBridgeAndPlayer(bridge); BattleDelegate.doInitialize(battleDelegate(gameData).getBattleTracker(), bridge); // all units in sz5 should be involved in the battle - final IBattle battle = MoveDelegate.getBattleTracker(gameData).getPendingBattle(sz5); + final IBattle battle = MoveDelegate.getBattleTracker(gameData).getPendingNonBombingBattle(sz5); assertEquals(4, battle.getAttackingUnits().size()); } } diff --git a/game-app/game-core/src/test/java/games/strategy/triplea/delegate/battle/MustFightBattleTest.java b/game-app/game-core/src/test/java/games/strategy/triplea/delegate/battle/MustFightBattleTest.java index e0514fcf28f..7d0f402477c 100644 --- a/game-app/game-core/src/test/java/games/strategy/triplea/delegate/battle/MustFightBattleTest.java +++ b/game-app/game-core/src/test/java/games/strategy/triplea/delegate/battle/MustFightBattleTest.java @@ -79,7 +79,7 @@ void testFightWithIsSuicideOnHit() { final IDelegateBridge bridge = performCombatMove(usa, sz33.getUnits(), new Route(sz33, sz40)); final IBattle battle = - AbstractMoveDelegate.getBattleTracker(twwGameData).getPendingBattle(sz40); + AbstractMoveDelegate.getBattleTracker(twwGameData).getPendingNonBombingBattle(sz40); assertNotNull(battle); // Set first roll to hit (mine AA) and check that both units are killed @@ -104,7 +104,7 @@ void testFightWithBothZeroStrength() { battleDelegate(twwGameData).setDelegateBridgeAndPlayer(bridge); BattleDelegate.doInitialize(battleDelegate(twwGameData).getBattleTracker(), bridge); final IBattle battle = - AbstractMoveDelegate.getBattleTracker(twwGameData).getPendingBattle(celebes); + AbstractMoveDelegate.getBattleTracker(twwGameData).getPendingNonBombingBattle(celebes); assertNotNull(battle); // Ensure battle ends, both units remain, and has 0 rolls @@ -145,7 +145,8 @@ void testCasualtyDefendersProvideSupport() throws Exception { final IDelegateBridge bridge = performCombatMove(japan(gameData), attackers, new Route(indoChina, burma)); - final IBattle battle = AbstractMoveDelegate.getBattleTracker(gameData).getPendingBattle(burma); + final IBattle battle = + AbstractMoveDelegate.getBattleTracker(gameData).getPendingNonBombingBattle(burma); assertNotNull(battle); // Attacking infantry roll two dice (both hit, killing the defenders). @@ -195,7 +196,7 @@ void testStepNamesChangeDuringCombat() { performCombatMove(chinese(gameData), attackers, new Route(china, indoChina)); final IBattle battle = - AbstractMoveDelegate.getBattleTracker(gameData).getPendingBattle(indoChina); + AbstractMoveDelegate.getBattleTracker(gameData).getPendingNonBombingBattle(indoChina); assertNotNull(battle); whenGetRandom(bridge) @@ -279,7 +280,8 @@ void testCantMoveAfterHitTransform() { final IDelegateBridge bridge = performCombatMove(GameDataTestUtil.germany(gameData), attackers, new Route(sz25, sz23)); - final IBattle battle = AbstractMoveDelegate.getBattleTracker(gameData).getPendingBattle(sz23); + final IBattle battle = + AbstractMoveDelegate.getBattleTracker(gameData).getPendingNonBombingBattle(sz23); assertNotNull(battle); // Attacking battleship rolls a die with a hit, killing the destroyer. // Defenders should roll a die with a hit, damaging the battleship. diff --git a/game-app/game-core/src/test/resources/required-op-codes.csv b/game-app/game-core/src/test/resources/required-op-codes.csv index 9da7f4115c7..8954dfe1246 100644 --- a/game-app/game-core/src/test/resources/required-op-codes.csv +++ b/game-app/game-core/src/test/resources/required-op-codes.csv @@ -127,7 +127,7 @@ 15,games.strategy.triplea.delegate.remote.IAbstractPlaceDelegate,setDelegateBridgeAndPlayer,games.strategy.engine.delegate.IDelegateBridge 0,games.strategy.triplea.delegate.remote.IAbstractPlaceDelegate,delegateCurrentlyRequiresUserInput 2,games.strategy.triplea.delegate.remote.IBattleDelegate,fightBattle,games.strategy.engine.data.Territory,boolean,games.strategy.triplea.delegate.battle.IBattle$BattleType -3,games.strategy.triplea.delegate.remote.IBattleDelegate,getBattles +3,games.strategy.triplea.delegate.remote.IBattleDelegate,getBattleListing 5,games.strategy.triplea.delegate.remote.IBattleDelegate,getCurrentBattle 7,games.strategy.triplea.delegate.remote.IBattleDelegate,getName 1,games.strategy.triplea.delegate.remote.IBattleDelegate,end diff --git a/game-app/game-headed/src/main/java/games/strategy/engine/auto/update/UpdateChecks.java b/game-app/game-headed/src/main/java/games/strategy/engine/auto/update/UpdateChecks.java index a2078fc2631..c9fe8638d40 100644 --- a/game-app/game-headed/src/main/java/games/strategy/engine/auto/update/UpdateChecks.java +++ b/game-app/game-headed/src/main/java/games/strategy/engine/auto/update/UpdateChecks.java @@ -28,7 +28,7 @@ private static void checkForUpdates() { } private static boolean shouldRun() { - // if we are joining a game online, or hosting, or loading straight into a savegame, do not + // if we are joining a game online, or hosting, or loading straight into a save game, do not // check return !System.getProperty(TRIPLEA_SERVER, "false").equalsIgnoreCase("true") && !System.getProperty(TRIPLEA_CLIENT, "false").equalsIgnoreCase("true") diff --git a/game-app/game-headed/src/main/java/games/strategy/engine/posted/game/ForumPosterComponent.java b/game-app/game-headed/src/main/java/games/strategy/engine/posted/game/ForumPosterComponent.java index 55cc816cf4b..68962a477b6 100644 --- a/game-app/game-headed/src/main/java/games/strategy/engine/posted/game/ForumPosterComponent.java +++ b/game-app/game-headed/src/main/java/games/strategy/engine/posted/game/ForumPosterComponent.java @@ -6,7 +6,7 @@ import games.strategy.engine.random.IRandomStats; import games.strategy.triplea.delegate.GameStepPropertiesHelper; import games.strategy.triplea.delegate.remote.IAbstractForumPosterDelegate; -import games.strategy.triplea.ui.ActionButtons; +import games.strategy.triplea.ui.ActionButtonsPanel; import games.strategy.triplea.ui.TripleAFrame; import games.strategy.triplea.ui.history.HistoryLog; import java.util.Collection; @@ -120,7 +120,7 @@ public ForumPosterComponent layoutComponents( new JButtonBuilder() .title("Done") .actionListener(doneAction) - .toolTip(ActionButtons.DONE_BUTTON_TOOLTIP) + .toolTip(ActionButtonsPanel.DONE_BUTTON_TOOLTIP) .build()); validate(); return this; diff --git a/game-app/game-headed/src/main/java/games/strategy/triplea/TripleAPlayer.java b/game-app/game-headed/src/main/java/games/strategy/triplea/TripleAPlayer.java index 26e25ad4aad..ced9cfa8f39 100644 --- a/game-app/game-headed/src/main/java/games/strategy/triplea/TripleAPlayer.java +++ b/game-app/game-headed/src/main/java/games/strategy/triplea/TripleAPlayer.java @@ -134,7 +134,7 @@ private void startImpl(final String name) { } if (ui == null) { // We will get here if we are loading a save game of a map that we do not have. Caller code - // should be doing the error handling, so just return.. + // should be doing the error handling, so just return. return; } // TODO: parsing which UI thing we should run based on the string name of a possibly extended @@ -144,7 +144,7 @@ private void startImpl(final String name) { // This is how we find out our game step: getGameData().getSequence().getStep() // The game step contains information, like the exact delegate and the delegate's class, // that we can further use if needed. This is how we get our communication bridge for affecting - // the gamedata: + // the game data: // (ISomeDelegate) getPlayerBridge().getRemote() // We should never touch the game data directly. All changes to game data are done through the // remote, which then changes the game using the DelegateBridge -> change factory @@ -525,15 +525,15 @@ private void battle() { if (getPlayerBridge().isGameOver()) { return; } - final BattleListing battles = battleDel.getBattles(); - if (battles.isEmpty()) { + final BattleListing battleListing = battleDel.getBattleListing(); + if (battleListing.isEmpty()) { return; } if (!soundPlayedAlreadyBattle) { playSound(SoundPath.CLIP_PHASE_BATTLE); soundPlayedAlreadyBattle = true; } - final FightBattleDetails details = ui.getBattle(gamePlayer, battles.getBattles()); + final FightBattleDetails details = ui.getBattle(gamePlayer, battleListing); if (getPlayerBridge().isGameOver()) { return; } @@ -612,7 +612,7 @@ private void endTurn() { if (!soundPlayedAlreadyEndTurn && TerritoryAttachment.doWeHaveEnoughCapitalsToProduce( this.getGamePlayer(), getGameData().getMap())) { - // do not play if we are reloading a savegame from pbem (gets annoying) + // do not play if we are reloading a save game from pbem (gets annoying) if (!endTurnDelegate.getHasPostedTurnSummary()) { playSound(SoundPath.CLIP_PHASE_END_TURN); } @@ -635,7 +635,7 @@ public CasualtyDetails selectCasualties( final Collection amphibiousLandAttackers, final CasualtyList defaultCasualties, final UUID battleId, - final Territory battlesite, + final Territory battleTerritory, final boolean allowMultipleHitsPerUnit) { return ui.getBattlePanel() .getCasualties( diff --git a/game-app/game-headed/src/main/java/games/strategy/triplea/odds/calculator/BattleCalculatorDialog.java b/game-app/game-headed/src/main/java/games/strategy/triplea/odds/calculator/BattleCalculatorDialog.java index 44877d51d69..0fd0797dd8a 100644 --- a/game-app/game-headed/src/main/java/games/strategy/triplea/odds/calculator/BattleCalculatorDialog.java +++ b/game-app/game-headed/src/main/java/games/strategy/triplea/odds/calculator/BattleCalculatorDialog.java @@ -82,7 +82,7 @@ public void componentResized(final ComponentEvent e) { } }); - taFrame.getTerritoryDetails().addBattleCalculatorKeyBindings(dialog); + taFrame.getTerritoryDetailPanel().addBattleCalculatorKeyBindings(dialog); // close when hitting the escape key SwingKeyBinding.addKeyBinding( dialog, diff --git a/game-app/game-headed/src/main/java/games/strategy/triplea/ui/ActionButtons.java b/game-app/game-headed/src/main/java/games/strategy/triplea/ui/ActionButtonsPanel.java similarity index 97% rename from game-app/game-headed/src/main/java/games/strategy/triplea/ui/ActionButtons.java rename to game-app/game-headed/src/main/java/games/strategy/triplea/ui/ActionButtonsPanel.java index 2189aecf526..b9a58999f65 100644 --- a/game-app/game-headed/src/main/java/games/strategy/triplea/ui/ActionButtons.java +++ b/game-app/game-headed/src/main/java/games/strategy/triplea/ui/ActionButtonsPanel.java @@ -13,7 +13,7 @@ import games.strategy.triplea.attachments.PoliticalActionAttachment; import games.strategy.triplea.attachments.UserActionAttachment; import games.strategy.triplea.delegate.AbstractMoveDelegate.MoveType; -import games.strategy.triplea.delegate.battle.IBattle.BattleType; +import games.strategy.triplea.delegate.data.BattleListing; import games.strategy.triplea.delegate.data.FightBattleDetails; import games.strategy.triplea.delegate.data.TechRoll; import games.strategy.triplea.delegate.remote.IPoliticsDelegate; @@ -40,7 +40,7 @@ import org.triplea.util.Tuple; /** Root panel for all action buttons in a triplea game. */ -public class ActionButtons extends JPanel { +public class ActionButtonsPanel extends JPanel { public static final String DONE_BUTTON_TOOLTIP = "Press ctrl+enter or click this button to end the current turn phase"; private static final long serialVersionUID = 2175685892863042399L; @@ -64,7 +64,7 @@ public class ActionButtons extends JPanel { private @Nullable ActionPanel actionPanel; - public ActionButtons( + public ActionButtonsPanel( final GameData data, final MapPanel map, final MovePanel movePanel, @@ -152,8 +152,7 @@ public void changeToPlace(final GamePlayer gamePlayer) { changeTo(gamePlayer, placePanel); } - public void changeToBattle( - final GamePlayer gamePlayer, final Map> battles) { + public void changeToBattle(final GamePlayer gamePlayer, final BattleListing battles) { if (battlePanel != null) { battlePanel.setBattlesAndBombing(battles); } @@ -190,7 +189,7 @@ private void changeTo(final GamePlayer gamePlayer, final @Nullable ActionPanel n // newCurrent might be null if we are shutting down if (newCurrent != null) { newCurrent.display(gamePlayer); - SwingUtilities.invokeLater(() -> layout.show(ActionButtons.this, newCurrent.toString())); + SwingUtilities.invokeLater(() -> layout.show(ActionButtonsPanel.this, newCurrent.toString())); } } diff --git a/game-app/game-headed/src/main/java/games/strategy/triplea/ui/ActionPanel.java b/game-app/game-headed/src/main/java/games/strategy/triplea/ui/ActionPanel.java index e4b2fa5eff2..e8db17b4538 100644 --- a/game-app/game-headed/src/main/java/games/strategy/triplea/ui/ActionPanel.java +++ b/game-app/game-headed/src/main/java/games/strategy/triplea/ui/ActionPanel.java @@ -126,7 +126,7 @@ protected JButton createDoneButton() { return new JButtonBuilder() .title("Done") .actionListener(this::performDone) - .toolTip(ActionButtons.DONE_BUTTON_TOOLTIP) + .toolTip(ActionButtonsPanel.DONE_BUTTON_TOOLTIP) .build(); } diff --git a/game-app/game-headed/src/main/java/games/strategy/triplea/ui/BattlePanel.java b/game-app/game-headed/src/main/java/games/strategy/triplea/ui/BattlePanel.java index 47103aceccb..331aadc19ea 100644 --- a/game-app/game-headed/src/main/java/games/strategy/triplea/ui/BattlePanel.java +++ b/game-app/game-headed/src/main/java/games/strategy/triplea/ui/BattlePanel.java @@ -8,6 +8,7 @@ import games.strategy.triplea.delegate.DiceRoll; import games.strategy.triplea.delegate.Die; import games.strategy.triplea.delegate.battle.IBattle.BattleType; +import games.strategy.triplea.delegate.data.BattleListing; import games.strategy.triplea.delegate.data.CasualtyDetails; import games.strategy.triplea.delegate.data.CasualtyList; import games.strategy.triplea.delegate.data.FightBattleDetails; @@ -21,7 +22,6 @@ import java.util.Collection; import java.util.List; import java.util.Map; -import java.util.Map.Entry; import java.util.Optional; import java.util.UUID; import java.util.function.Supplier; @@ -54,7 +54,7 @@ public final class BattlePanel extends ActionPanel { // the display is shown on the screen private volatile UUID currentBattleDisplayed; private final JDialog battleWindow; - private Map> battles; + private BattleListing battleListing; BattlePanel(final GameData data, final MapPanel map, final JFrame parent) { super(data, map); @@ -77,8 +77,8 @@ public void windowActivated(final WindowEvent e) { getMap().getUiContext().addShutdownWindow(battleWindow); } - void setBattlesAndBombing(final Map> battles) { - this.battles = battles; + void setBattlesAndBombing(final BattleListing battleListing) { + this.battleListing = battleListing; } @Override @@ -90,11 +90,8 @@ public void display(final GamePlayer gamePlayer) { actionLabel.setText(gamePlayer.getName() + " battle"); setLayout(new BorderLayout()); final JPanel panel = new JPanelBuilder().gridLayout(0, 1).add(actionLabel).build(); - for (final Entry> entry : battles.entrySet()) { - for (final Territory t : entry.getValue()) { - addBattleActions(panel, t, entry.getKey().isBombingRun(), entry.getKey()); - } - } + battleListing.forEachBattle( + (battleType, territory) -> addBattleActions(panel, territory, battleType)); add(panel, BorderLayout.NORTH); refresh.run(); }); @@ -106,10 +103,7 @@ public void performDone() { } private void addBattleActions( - final JPanel panel, - final Territory territory, - final boolean bomb, - final BattleType battleType) { + final JPanel panel, final Territory territory, final BattleType battleType) { panel.add( new JPanelBuilder() @@ -118,7 +112,7 @@ private void addBattleActions( new JButton( SwingAction.of( battleType.toDisplayText() + " in " + territory.getName() + "...", - () -> fightBattleAction(territory, bomb, battleType)))) + () -> fightBattleAction(territory, battleType)))) .addEast( new JButtonBuilder() .title("Center") @@ -133,13 +127,12 @@ private void addBattleActions( .build()); } - private void fightBattleAction( - final Territory territory, final boolean bomb, final BattleType battleType) { + private void fightBattleAction(final Territory territory, final BattleType battleType) { getMap().clearHighlightedTerritory(); fightBattleMessage = FightBattleDetails.builder() .where(territory) - .bombingRaid(bomb) + .bombingRaid(battleType.isBombingRun()) .battleType(battleType) .build(); release(); diff --git a/game-app/game-headed/src/main/java/games/strategy/triplea/ui/TripleAFrame.java b/game-app/game-headed/src/main/java/games/strategy/triplea/ui/TripleAFrame.java index 262d9966dc1..ccb8e919f96 100644 --- a/game-app/game-headed/src/main/java/games/strategy/triplea/ui/TripleAFrame.java +++ b/game-app/game-headed/src/main/java/games/strategy/triplea/ui/TripleAFrame.java @@ -51,9 +51,9 @@ import games.strategy.triplea.delegate.TerritoryEffectHelper; import games.strategy.triplea.delegate.battle.AirBattle; import games.strategy.triplea.delegate.battle.BattleState; -import games.strategy.triplea.delegate.battle.IBattle.BattleType; import games.strategy.triplea.delegate.battle.ScrambleLogic; import games.strategy.triplea.delegate.battle.casualty.CasualtySelector; +import games.strategy.triplea.delegate.data.BattleListing; import games.strategy.triplea.delegate.data.FightBattleDetails; import games.strategy.triplea.delegate.data.TechResults; import games.strategy.triplea.delegate.data.TechRoll; @@ -171,7 +171,7 @@ public final class TripleAFrame extends JFrame implements QuitHandler { @Getter private final MapPanel mapPanel; private final ImageScrollerSmallView smallView; - private final ActionButtons actionButtons; + private final ActionButtonsPanel actionButtonsPanel; private final JPanel gameMainPanel = new JPanel(); private final JPanel rightHandSidePanel = new JPanel(); private final JTabbedPane tabsPanel = new JTabbedPane(); @@ -179,7 +179,7 @@ public final class TripleAFrame extends JFrame implements QuitHandler { private final EconomyPanel economyPanel; private final Runnable clientLeftGame; private @Nullable ObjectivePanel objectivePanel; - @Getter private final TerritoryDetailPanel territoryDetails; + @Getter private final TerritoryDetailPanel territoryDetailPanel; private final JPanel historyComponent = new JPanel(); @Getter private HistoryPanel historyPanel; private final AtomicBoolean inHistory = new AtomicBoolean(false); @@ -368,7 +368,7 @@ public void focusGained(final FocusEvent e) { rightHandSidePanel.add(tabsPanel, BorderLayout.CENTER); final MovePanel movePanel = new MovePanel(data, mapPanel, this); - actionButtons = new ActionButtons(data, mapPanel, movePanel, this); + actionButtonsPanel = new ActionButtonsPanel(data, mapPanel, movePanel, this); final CollapsiblePanel placementsPanel = new PlacementUnitsCollapsiblePanel(data, uiContext).getPanel(); @@ -382,7 +382,7 @@ public void focusGained(final FocusEvent e) { SwingUtilities.invokeLater(() -> mapPanel.addKeyListener(getArrowKeyListener())); - actionButtons.setBorder(null); + actionButtonsPanel.setBorder(null); statsPanel = new StatPanel(data, uiContext); economyPanel = new EconomyPanel(data, uiContext); objectivePanel = new ObjectivePanel(data, uiContext); @@ -390,7 +390,7 @@ public void focusGained(final FocusEvent e) { objectivePanel.removeDataChangeListener(); objectivePanel = null; } - territoryDetails = new TerritoryDetailPanel(mapPanel, data, uiContext, this); + territoryDetailPanel = new TerritoryDetailPanel(mapPanel, data, uiContext, this); editPanel = new EditPanel(data, mapPanel, this); addTabs(null); // Register a change listener @@ -407,10 +407,10 @@ public void focusGained(final FocusEvent e) { try (GameData.Unlocker ignored = data.acquireReadLock()) { player1 = data.getSequence().getStep().getPlayerId(); } - actionButtons.getCurrent().ifPresent(actionPanel -> actionPanel.setActive(false)); + actionButtonsPanel.getCurrent().ifPresent(actionPanel -> actionPanel.setActive(false)); editPanel.display(player1); } else { - actionButtons.getCurrent().ifPresent(actionPanel -> actionPanel.setActive(true)); + actionButtonsPanel.getCurrent().ifPresent(actionPanel -> actionPanel.setActive(true)); editPanel.setActive(false); } }); @@ -532,7 +532,7 @@ private void addTabs(HistoryDetailsPanel historyDetailPanel) { if (historyDetailPanel != null) { tabsPanel.add("History", historyDetailPanel); } else { - addTab("Actions", actionButtons, KeyCode.C); + addTab("Actions", actionButtonsPanel, KeyCode.C); } addTab("Players", statsPanel, KeyCode.P); addTab("Resources", economyPanel, KeyCode.R); @@ -540,7 +540,7 @@ private void addTabs(HistoryDetailsPanel historyDetailPanel) { String objectivePanelName = new ObjectiveProperties(uiContext.getResourceLoader()).getName(); addTab(objectivePanelName, objectivePanel, KeyCode.O); } - addTab("Territory", territoryDetails, KeyCode.T); + addTab("Territory", territoryDetailPanel, KeyCode.T); if (mapPanel.getEditMode()) { showEditMode(); } @@ -635,8 +635,8 @@ public void setStatusWarningMessage(final String msg) { public IntegerMap getProduction( final GamePlayer player, final boolean bid, final boolean keepCurrentPurchase) { messageAndDialogThreadPool.waitForAll(); - actionButtons.changeToProduce(player, keepCurrentPurchase); - return actionButtons.waitForPurchase(bid); + actionButtonsPanel.changeToProduce(player, keepCurrentPurchase); + return actionButtonsPanel.waitForPurchase(bid); } public Map> getRepair( @@ -644,8 +644,8 @@ public Map> getRepair( final boolean bid, final Collection allowedPlayersToRepair) { messageAndDialogThreadPool.waitForAll(); - actionButtons.changeToRepair(player); - return actionButtons.waitForRepair(bid, allowedPlayersToRepair); + actionButtonsPanel.changeToRepair(player); + return actionButtonsPanel.waitForRepair(bid, allowedPlayersToRepair); } public MoveDescription getMove( @@ -654,12 +654,12 @@ public MoveDescription getMove( final boolean nonCombat, final String stepName) { messageAndDialogThreadPool.waitForAll(); - actionButtons.changeToMove(player, nonCombat, stepName); + actionButtonsPanel.changeToMove(player, nonCombat, stepName); // workaround for panel not receiving focus at beginning of n/c move phase if (!getBattlePanel().isBattleShowing()) { requestWindowFocus(); } - return actionButtons.waitForMove(bridge); + return actionButtonsPanel.waitForMove(bridge); } private void requestWindowFocus() { @@ -675,31 +675,30 @@ private void requestWindowFocus() { public PlaceData waitForPlace( final GamePlayer player, final boolean bid, final PlayerBridge bridge) { messageAndDialogThreadPool.waitForAll(); - actionButtons.changeToPlace(player); - return actionButtons.waitForPlace(bid, bridge); + actionButtonsPanel.changeToPlace(player); + return actionButtonsPanel.waitForPlace(bid, bridge); } public void waitForMoveForumPoster(final GamePlayer player, final PlayerBridge bridge) { - if (actionButtons == null) { + if (actionButtonsPanel == null) { return; } - actionButtons.changeToMoveForumPosterPanel(player); - actionButtons.waitForMoveForumPosterPanel(this, bridge); + actionButtonsPanel.changeToMoveForumPosterPanel(player); + actionButtonsPanel.waitForMoveForumPosterPanel(this, bridge); } public void waitForEndTurn(final GamePlayer player, final PlayerBridge bridge) { - if (actionButtons == null) { + if (actionButtonsPanel == null) { return; } - actionButtons.changeToEndTurn(player); - actionButtons.waitForEndTurn(this, bridge); + actionButtonsPanel.changeToEndTurn(player); + actionButtonsPanel.waitForEndTurn(this, bridge); } - public FightBattleDetails getBattle( - final GamePlayer player, final Map> battles) { + public FightBattleDetails getBattle(final GamePlayer player, final BattleListing battles) { messageAndDialogThreadPool.waitForAll(); - actionButtons.changeToBattle(player, battles); - return actionButtons.waitForBattleSelection(); + actionButtonsPanel.changeToBattle(player, battles); + return actionButtonsPanel.waitForBattleSelection(); } /** We do NOT want to block the next player from beginning their turn. */ @@ -1142,19 +1141,20 @@ public Tuple> pickTerritoryAndUnits( } if (tabsPanel.indexOfTab("Actions") == -1) { // add actions tab - tabsPanel.insertTab("Actions", null, actionButtons, null, 0); + tabsPanel.insertTab("Actions", null, actionButtonsPanel, null, 0); } tabsPanel.setSelectedIndex(0); })); - actionButtons.changeToPickTerritoryAndUnits(player); + actionButtonsPanel.changeToPickTerritoryAndUnits(player); final Tuple> territoryAndUnits = - actionButtons.waitForPickTerritoryAndUnits(territoryChoices, unitChoices, unitsPerPick); + actionButtonsPanel.waitForPickTerritoryAndUnits( + territoryChoices, unitChoices, unitsPerPick); final int index = tabsPanel.indexOfTab("Actions"); if (index != -1 && inHistory.get()) { // remove actions tab Interruptibles.await(() -> SwingAction.invokeAndWait(() -> tabsPanel.remove(index))); } - actionButtons.getCurrent().ifPresent(actionPanel -> actionPanel.setActive(false)); + actionButtonsPanel.getCurrent().ifPresent(actionPanel -> actionPanel.setActive(false)); return territoryAndUnits; } @@ -1545,9 +1545,9 @@ public Collection selectUnitsQuery( public PoliticalActionAttachment getPoliticalActionChoice( final GamePlayer player, final boolean firstRun, final IPoliticsDelegate politicsDelegate) { messageAndDialogThreadPool.waitForAll(); - actionButtons.changeToPolitics(player); + actionButtonsPanel.changeToPolitics(player); requestWindowFocus(); - return actionButtons.waitForPoliticalAction(firstRun, politicsDelegate); + return actionButtonsPanel.waitForPoliticalAction(firstRun, politicsDelegate); } public UserActionAttachment getUserActionChoice( @@ -1555,17 +1555,17 @@ public UserActionAttachment getUserActionChoice( final boolean firstRun, final IUserActionDelegate userActionDelegate) { messageAndDialogThreadPool.waitForAll(); - actionButtons.changeToUserActions(player); + actionButtonsPanel.changeToUserActions(player); requestWindowFocus(); - return actionButtons.waitForUserActionAction(firstRun, userActionDelegate); + return actionButtonsPanel.waitForUserActionAction(firstRun, userActionDelegate); } public TechRoll getTechRolls(final GamePlayer gamePlayer) { messageAndDialogThreadPool.waitForAll(); - actionButtons.changeToTech(gamePlayer); + actionButtonsPanel.changeToTech(gamePlayer); // workaround for panel not receiving focus at beginning of tech phase requestWindowFocus(); - return actionButtons.waitForTech(); + return actionButtonsPanel.waitForTech(); } /** @@ -1707,7 +1707,7 @@ private KeyListener getArrowKeyListener() { @Override public void keyPressed(final KeyEvent e) { isCtrlPressed = e.isControlDown(); - // scroll map according to wasd/arrowkeys + // scroll map according to wasd/arrow keys final int diffPixel = computeScrollSpeed(); final int x = mapPanel.getXOffset(); final int y = mapPanel.getYOffset(); @@ -1786,7 +1786,7 @@ private void showHistory() { if (objectivePanel != null && !objectivePanel.isEmpty()) { objectivePanel.setGameData(clonedGameData); } - territoryDetails.setGameData(clonedGameData); + territoryDetailPanel.setGameData(clonedGameData); mapPanel.setGameData(clonedGameData); SwingUtilities.invokeLater( () -> { @@ -1794,7 +1794,7 @@ private void showHistory() { new HistoryDetailsPanel(clonedGameData, mapPanel); tabsPanel.removeAll(); addTabs(historyDetailPanel); - actionButtons.getCurrent().ifPresent(actionPanel -> actionPanel.setActive(false)); + actionButtonsPanel.getCurrent().ifPresent(actionPanel -> actionPanel.setActive(false)); historyComponent.removeAll(); historyComponent.setLayout(new BorderLayout()); // create history tree context menu @@ -1861,8 +1861,8 @@ public void actionPerformed(final ActionEvent ae) { + "beginning of a player's turn, or the beginning of a round." + "\nSaving at any other point, could potentially create errors." + "\nFor example, saving while your current game is in the middle of a " - + "move or battle phase will always create errors in the savegame." - + "\nAnd you will also get errors in the savegame if you try to create a " + + "move or battle phase will always create errors in the save game." + + "\nAnd you will also get errors in the save game if you try to create a " + "save at a point in history such as a move or battle phase.", "Save Game from History", JOptionPane.INFORMATION_MESSAGE); @@ -1871,12 +1871,12 @@ public void actionPerformed(final ActionEvent ae) { GameFileSelector.getSaveGameLocation(TripleAFrame.this, data); if (f.isPresent()) { try (OutputStream fileOutputStream = Files.newOutputStream(f.get())) { - final GameData datacopy = + final GameData gameDataCopy = GameDataUtils.cloneGameData( data, GameDataManager.Options.withEverything()) .orElse(null); - if (datacopy != null) { - datacopy + if (gameDataCopy != null) { + gameDataCopy .getHistory() .removeAllHistoryAfterNode(historyPanel.getCurrentPopupNode()); // TODO: the saved current delegate is still the current delegate, @@ -1885,15 +1885,17 @@ public void actionPerformed(final ActionEvent ae) { // the history popup node // TODO: this could be solved easily if rounds/steps were changes, // but that could greatly increase the file size :( - // TODO: this also does not undo the runcount of each delegate step + // TODO: this also does not undo the run count of each delegate step final Enumeration enumeration = - ((DefaultMutableTreeNode) datacopy.getHistory().getRoot()) + ((DefaultMutableTreeNode) gameDataCopy.getHistory().getRoot()) .preorderEnumeration(); enumeration.nextElement(); int round = 0; - String stepDisplayName = datacopy.getSequence().getStep(0).getDisplayName(); - GamePlayer currentPlayer = datacopy.getSequence().getStep(0).getPlayerId(); - int roundOffset = datacopy.getSequence().getRoundOffset(); + String stepDisplayName = + gameDataCopy.getSequence().getStep(0).getDisplayName(); + GamePlayer currentPlayer = + gameDataCopy.getSequence().getStep(0).getPlayerId(); + int roundOffset = gameDataCopy.getSequence().getRoundOffset(); while (enumeration.hasMoreElements()) { final HistoryNode node = (HistoryNode) enumeration.nextElement(); if (node instanceof Round) { @@ -1905,10 +1907,10 @@ public void actionPerformed(final ActionEvent ae) { stepDisplayName = node.getTitle(); } } - datacopy + gameDataCopy .getSequence() .setRoundAndStep(round, stepDisplayName, currentPlayer); - GameDataManager.saveGame(fileOutputStream, datacopy); + GameDataManager.saveGame(fileOutputStream, gameDataCopy); JOptionPane.showMessageDialog( TripleAFrame.this, "Game Saved", @@ -1956,14 +1958,14 @@ private void showGame() { if (objectivePanel != null && !objectivePanel.isEmpty()) { objectivePanel.setGameData(data); } - territoryDetails.setGameData(data); + territoryDetailPanel.setGameData(data); mapPanel.setGameData(data); data.addDataChangeListener(dataChangeListener); tabsPanel.removeAll(); } setWidgetActivation(); addTabs(null); - actionButtons.getCurrent().ifPresent(actionPanel -> actionPanel.setActive(true)); + actionButtonsPanel.getCurrent().ifPresent(actionPanel -> actionPanel.setActive(true)); gameMainPanel.removeAll(); gameMainPanel.setLayout(new BorderLayout()); gameMainPanel.add(gameCenterPanel, BorderLayout.CENTER); @@ -2050,7 +2052,7 @@ public Collection moveFightersToCarrier( } public BattlePanel getBattlePanel() { - return actionButtons.getBattlePanel(); + return actionButtonsPanel.getBattlePanel(); } /** Displays the map located in the directory/archive {@code mapdir}. */ diff --git a/game-app/game-headless/src/main/java/org/triplea/game/server/HeadlessGameServer.java b/game-app/game-headless/src/main/java/org/triplea/game/server/HeadlessGameServer.java index 25314d9d3e9..47ba72d97a9 100644 --- a/game-app/game-headless/src/main/java/org/triplea/game/server/HeadlessGameServer.java +++ b/game-app/game-headless/src/main/java/org/triplea/game/server/HeadlessGameServer.java @@ -72,7 +72,7 @@ public synchronized void setGameMapTo(final String gameName) { log.info("Changed to game map: {}", gameName); } else if (AutoSaveFileUtils.getAutoSaveFiles().contains(gameName)) { // change to autosave - log.info("Loading {} as a savegame", gameName); + log.info("Loading {} as a save game", gameName); AutoSaveFileUtils.getAutoSavePaths().stream() .filter(p -> p.toFile().getName().equals(gameName)) .findAny() @@ -84,7 +84,7 @@ public synchronized void setGameMapTo(final String gameName) { gameName, AutoSaveFileUtils.getAutoSavePaths())); } else { - log.warn("Unable to find save game as either a new map or a savegame: {}", gameName); + log.warn("Unable to find save game as either a new map or a save game: {}", gameName); } }