diff --git a/Mage.Client/src/main/java/mage/client/MageFrame.java b/Mage.Client/src/main/java/mage/client/MageFrame.java index 0190e7af98c..c00eb57c1ed 100644 --- a/Mage.Client/src/main/java/mage/client/MageFrame.java +++ b/Mage.Client/src/main/java/mage/client/MageFrame.java @@ -144,10 +144,10 @@ public class MageFrame extends javax.swing.JFrame implements MageClient { private static final String TITLE_NAME = "XMage"; - private static final Logger logger = Logger.getLogger(MageFrame.class); - private static final String liteModeArg = "-lite"; - private static final String grayModeArg = "-gray"; - private static final String fullscreenArg = "-fullscreen"; + private static final Logger LOGGER = Logger.getLogger(MageFrame.class); + private static final String LITE_MODE_ARG = "-lite"; + private static final String GRAY_MODE_ARG = "-gray"; + private static final String FILL_SCREEN_ARG = "-fullscreen"; private static MageFrame instance; @@ -155,10 +155,10 @@ public class MageFrame extends javax.swing.JFrame implements MageClient { private ConnectDialog connectDialog; private final ErrorDialog errorDialog; private static CallbackClient callbackClient; - private static final Preferences prefs = Preferences.userNodeForPackage(MageFrame.class); + private static final Preferences PREFS = Preferences.userNodeForPackage(MageFrame.class); private JLabel title; private Rectangle titleRectangle; - private static final MageVersion version = new MageVersion(MageVersion.MAGE_VERSION_MAJOR, MageVersion.MAGE_VERSION_MINOR, MageVersion.MAGE_VERSION_PATCH, MageVersion.MAGE_VERSION_MINOR_PATCH, MageVersion.MAGE_VERSION_INFO); + private static final MageVersion VERSION = new MageVersion(MageVersion.MAGE_VERSION_MAJOR, MageVersion.MAGE_VERSION_MINOR, MageVersion.MAGE_VERSION_PATCH, MageVersion.MAGE_VERSION_MINOR_PATCH, MageVersion.MAGE_VERSION_INFO); private UUID clientId; private static MagePane activeFrame; private static boolean liteMode = false; @@ -166,12 +166,12 @@ public class MageFrame extends javax.swing.JFrame implements MageClient { private static boolean grayMode = false; private static boolean fullscreenMode = false; - private static final Map chats = new HashMap<>(); - private static final Map games = new HashMap<>(); - private static final Map drafts = new HashMap<>(); - private static final MageUI ui = new MageUI(); + private static final Map CHATS = new HashMap<>(); + private static final Map GAMES = new HashMap<>(); + private static final Map DRAFTS = new HashMap<>(); + private static final MageUI UI = new MageUI(); - private static final ScheduledExecutorService pingTaskExecutor = Executors.newSingleThreadScheduledExecutor(); + private static final ScheduledExecutorService PING_TASK_EXECUTOR = Executors.newSingleThreadScheduledExecutor(); private static UpdateMemUsageTask updateMemUsageTask; private static long startTime; @@ -188,7 +188,7 @@ public class MageFrame extends javax.swing.JFrame implements MageClient { } public static Preferences getPreferences() { - return prefs; + return PREFS; } public static boolean isLite() { @@ -201,7 +201,7 @@ public class MageFrame extends javax.swing.JFrame implements MageClient { @Override public MageVersion getVersion() { - return version; + return VERSION; } public static MageFrame getInstance() { @@ -231,7 +231,7 @@ public class MageFrame extends javax.swing.JFrame implements MageClient { UIManager.put("desktop", new Color(0, 0, 0, 0)); UIManager.setLookAndFeel("com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel"); } catch (Exception ex) { - logger.fatal(null, ex); + LOGGER.fatal(null, ex); } ManaSymbols.loadImages(); @@ -253,9 +253,9 @@ public class MageFrame extends javax.swing.JFrame implements MageClient { errorDialog = new ErrorDialog(); errorDialog.setLocation(100, 100); desktopPane.add(errorDialog, JLayeredPane.POPUP_LAYER); - ui.addComponent(MageComponents.DESKTOP_PANE, desktopPane); + UI.addComponent(MageComponents.DESKTOP_PANE, desktopPane); - pingTaskExecutor.scheduleAtFixedRate(new Runnable() { + PING_TASK_EXECUTOR.scheduleAtFixedRate(new Runnable() { @Override public void run() { session.ping(); @@ -269,7 +269,7 @@ public class MageFrame extends javax.swing.JFrame implements MageClient { desktopPane.add(tablesPane, javax.swing.JLayeredPane.DEFAULT_LAYER); tablesPane.setMaximum(true); } catch (PropertyVetoException ex) { - logger.fatal(null, ex); + LOGGER.fatal(null, ex); } addTooltipContainer(); @@ -343,7 +343,7 @@ public class MageFrame extends javax.swing.JFrame implements MageClient { label.setBounds(0, 0, 180, 30); } - ui.addButton(MageComponents.TABLES_MENU_BUTTON, btnGames); + UI.addButton(MageComponents.TABLES_MENU_BUTTON, btnGames); SwingUtilities.invokeLater(new Runnable() { @Override @@ -353,7 +353,7 @@ public class MageFrame extends javax.swing.JFrame implements MageClient { checkForNewImages(); } updateMemUsageTask.execute(); - logger.info("Client start up time: " + ((System.currentTimeMillis() - startTime) / 1000 + " seconds")); + LOGGER.info("Client start up time: " + ((System.currentTimeMillis() - startTime) / 1000 + " seconds")); if (autoConnect()) { enableButtons(); } else { @@ -373,7 +373,7 @@ public class MageFrame extends javax.swing.JFrame implements MageClient { private void setWindowTitle() { setTitle(TITLE_NAME + " Client: " - + (version == null ? "" : version.toString()) + " Server: " + + (VERSION == null ? "" : VERSION.toString()) + " Server: " + ((session != null && session.isConnected()) ? session.getVersionInfo() : "")); } @@ -397,8 +397,8 @@ public class MageFrame extends javax.swing.JFrame implements MageClient { desktopPane.add(popupContainer, JLayeredPane.POPUP_LAYER); - ui.addComponent(MageComponents.CARD_INFO_PANE, cardInfoPane); - ui.addComponent(MageComponents.POPUP_CONTAINER, popupContainer); + UI.addComponent(MageComponents.CARD_INFO_PANE, cardInfoPane); + UI.addComponent(MageComponents.POPUP_CONTAINER, popupContainer); // preview panel normal JPanel cardPreviewContainer = new JPanel(); @@ -413,8 +413,8 @@ public class MageFrame extends javax.swing.JFrame implements MageClient { cardPreviewContainer.setVisible(false); cardPreviewContainer.setBounds(0, 0, 320 + 80, 500 + 30); - ui.addComponent(MageComponents.CARD_PREVIEW_PANE, bigCard); - ui.addComponent(MageComponents.CARD_PREVIEW_CONTAINER, cardPreviewContainer); + UI.addComponent(MageComponents.CARD_PREVIEW_PANE, bigCard); + UI.addComponent(MageComponents.CARD_PREVIEW_CONTAINER, cardPreviewContainer); desktopPane.add(cardPreviewContainer, JLayeredPane.POPUP_LAYER); @@ -430,8 +430,8 @@ public class MageFrame extends javax.swing.JFrame implements MageClient { cardPreviewContainerRotated.setVisible(false); cardPreviewContainerRotated.setBounds(0, 0, 500 + 80, 420 + 30); - ui.addComponent(MageComponents.CARD_PREVIEW_PANE_ROTATED, bigCard); - ui.addComponent(MageComponents.CARD_PREVIEW_CONTAINER_ROTATED, cardPreviewContainerRotated); + UI.addComponent(MageComponents.CARD_PREVIEW_PANE_ROTATED, bigCard); + UI.addComponent(MageComponents.CARD_PREVIEW_CONTAINER_ROTATED, cardPreviewContainerRotated); desktopPane.add(cardPreviewContainerRotated, JLayeredPane.POPUP_LAYER); @@ -453,7 +453,7 @@ public class MageFrame extends javax.swing.JFrame implements MageClient { backgroundPane.setSize(1024, 768); desktopPane.add(backgroundPane, JLayeredPane.DEFAULT_LAYER); } catch (IOException e) { - logger.fatal("Error while setting background.", e); + LOGGER.fatal("Error while setting background.", e); } } @@ -476,7 +476,7 @@ public class MageFrame extends javax.swing.JFrame implements MageClient { backgroundPane.add(title); } } catch (IOException e) { - logger.fatal("Error while adding mage label.", e); + LOGGER.fatal("Error while adding mage label.", e); } } @@ -546,11 +546,11 @@ public class MageFrame extends javax.swing.JFrame implements MageClient { private void checkForNewImages() { long beforeCall = System.currentTimeMillis(); List cards = CardRepository.instance.findCards(new CardCriteria()); - logger.info("Card pool load time: " + ((System.currentTimeMillis() - beforeCall) / 1000 + " seconds")); + LOGGER.info("Card pool load time: " + ((System.currentTimeMillis() - beforeCall) / 1000 + " seconds")); beforeCall = System.currentTimeMillis(); if (DownloadPictures.checkForNewCards(cards)) { - logger.info("Card images checking time: " + ((System.currentTimeMillis() - beforeCall) / 1000 + " seconds")); + LOGGER.info("Card images checking time: " + ((System.currentTimeMillis() - beforeCall) / 1000 + " seconds")); if (JOptionPane.showConfirmDialog(this, "New cards are available. Do you want to download the images?", "New images available", JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) { DownloadPictures.startDownload(null, cards); } @@ -574,7 +574,7 @@ public class MageFrame extends javax.swing.JFrame implements MageClient { activeFrame = null; return; } - logger.debug("Setting " + frame.getTitle() + " active"); + LOGGER.debug("Setting " + frame.getTitle() + " active"); if (activeFrame != null) { activeFrame.deactivated(); } @@ -584,7 +584,7 @@ public class MageFrame extends javax.swing.JFrame implements MageClient { try { activeFrame.setSelected(true); } catch (PropertyVetoException ex) { - logger.error("Error setting " + frame.getTitle() + " active"); + LOGGER.error("Error setting " + frame.getTitle() + " active"); } activeFrame.activated(); ArrowBuilder.getBuilder().hideAllPanels(); @@ -737,7 +737,7 @@ public class MageFrame extends javax.swing.JFrame implements MageClient { } public boolean autoConnect() { - boolean autoConnectParamValue = Boolean.parseBoolean(prefs.get("autoConnect", "false")); + boolean autoConnectParamValue = Boolean.parseBoolean(PREFS.get("autoConnect", "false")); boolean status = false; if (autoConnectParamValue) { status = performConnect(); @@ -750,11 +750,11 @@ public class MageFrame extends javax.swing.JFrame implements MageClient { int port = MagePreferences.getServerPort(); String userName = MagePreferences.getUserName(server); String password = MagePreferences.getPassword(server); - String proxyServer = prefs.get("proxyAddress", ""); - int proxyPort = Integer.parseInt(prefs.get("proxyPort", "0")); - ProxyType proxyType = ProxyType.valueByText(prefs.get("proxyType", "None")); - String proxyUsername = prefs.get("proxyUsername", ""); - String proxyPassword = prefs.get("proxyPassword", ""); + String proxyServer = PREFS.get("proxyAddress", ""); + int proxyPort = Integer.parseInt(PREFS.get("proxyPort", "0")); + ProxyType proxyType = ProxyType.valueByText(PREFS.get("proxyType", "None")); + String proxyUsername = PREFS.get("proxyUsername", ""); + String proxyPassword = PREFS.get("proxyPassword", ""); try { setCursor(new Cursor(Cursor.WAIT_CURSOR)); Connection connection = new Connection(); @@ -770,7 +770,7 @@ public class MageFrame extends javax.swing.JFrame implements MageClient { setUserPrefsToConnection(connection); - logger.debug("connecting (auto): " + proxyType + " " + proxyServer + " " + proxyPort + " " + proxyUsername); + LOGGER.debug("connecting (auto): " + proxyType + " " + proxyServer + " " + proxyPort + " " + proxyUsername); if (MageFrame.connect(connection)) { showGames(false); return true; @@ -981,7 +981,7 @@ public class MageFrame extends javax.swing.JFrame implements MageClient { } AboutDialog aboutDialog = new AboutDialog(); desktopPane.add(aboutDialog, JLayeredPane.POPUP_LAYER); - aboutDialog.showDialog(version); + aboutDialog.showDialog(VERSION); }//GEN-LAST:event_btnAboutActionPerformed private void btnCollectionViewerActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCollectionViewerActionPerformed @@ -1006,10 +1006,8 @@ public class MageFrame extends javax.swing.JFrame implements MageClient { return; } session.disconnect(false); - } else { - if (JOptionPane.showConfirmDialog(this, "Are you sure you want to exit?", "Confirm exit", JOptionPane.YES_NO_OPTION) != JOptionPane.YES_OPTION) { - return; - } + } else if (JOptionPane.showConfirmDialog(this, "Are you sure you want to exit?", "Confirm exit", JOptionPane.YES_NO_OPTION) != JOptionPane.YES_OPTION) { + return; } CardRepository.instance.closeDB(); tablesPane.cleanUp(); @@ -1044,8 +1042,8 @@ public class MageFrame extends javax.swing.JFrame implements MageClient { } if (setActive) { setActive(tablesPane); - } else { - // if other panel was already shown, mamke sure it's topmost again + } else // if other panel was already shown, mamke sure it's topmost again + { if (topPanebefore != null) { setActive(topPanebefore); } @@ -1107,7 +1105,7 @@ public class MageFrame extends javax.swing.JFrame implements MageClient { deckEditorPane.show(mode, deck, name, tableId, time); setActive(deckEditorPane); } catch (PropertyVetoException ex) { - logger.fatal(null, ex); + LOGGER.fatal(null, ex); } } @@ -1158,7 +1156,7 @@ public class MageFrame extends javax.swing.JFrame implements MageClient { collectionViewerPane.setVisible(true); setActive(collectionViewerPane); } catch (PropertyVetoException ex) { - logger.fatal(null, ex); + LOGGER.fatal(null, ex); } } @@ -1176,27 +1174,27 @@ public class MageFrame extends javax.swing.JFrame implements MageClient { public static void main(final String args[]) { // Workaround for #451 System.setProperty("java.util.Arrays.useLegacyMergeSort", "true"); - logger.info("Starting MAGE client version " + version); - logger.info("Logging level: " + logger.getEffectiveLevel()); + LOGGER.info("Starting MAGE client version " + VERSION); + LOGGER.info("Logging level: " + LOGGER.getEffectiveLevel()); startTime = System.currentTimeMillis(); Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { @Override public void uncaughtException(Thread t, Throwable e) { - logger.fatal(null, e); + LOGGER.fatal(null, e); } }); SwingUtilities.invokeLater(new Runnable() { @Override public void run() { for (String arg : args) { - if (arg.startsWith(liteModeArg)) { + if (arg.startsWith(LITE_MODE_ARG)) { liteMode = true; } - if (arg.startsWith(grayModeArg)) { + if (arg.startsWith(GRAY_MODE_ARG)) { grayMode = true; } - if (arg.startsWith(fullscreenArg)) { + if (arg.startsWith(FILL_SCREEN_ARG)) { fullscreenMode = true; } } @@ -1250,47 +1248,47 @@ public class MageFrame extends javax.swing.JFrame implements MageClient { } public static MageUI getUI() { - return ui; + return UI; } public static ChatPanelBasic getChat(UUID chatId) { - return chats.get(chatId); + return CHATS.get(chatId); } public static void addChat(UUID chatId, ChatPanelBasic chatPanel) { - chats.put(chatId, chatPanel); + CHATS.put(chatId, chatPanel); } public static void removeChat(UUID chatId) { - chats.remove(chatId); + CHATS.remove(chatId); } public static void addGame(UUID gameId, GamePanel gamePanel) { - games.put(gameId, gamePanel); + GAMES.put(gameId, gamePanel); } public static GamePanel getGame(UUID gameId) { - return games.get(gameId); + return GAMES.get(gameId); } public static void removeGame(UUID gameId) { - games.remove(gameId); + GAMES.remove(gameId); } public static DraftPanel getDraft(UUID draftId) { - return drafts.get(draftId); + return DRAFTS.get(draftId); } public static void removeDraft(UUID draftId) { - DraftPanel draftPanel = drafts.get(draftId); + DraftPanel draftPanel = DRAFTS.get(draftId); if (draftPanel != null) { - drafts.remove(draftId); + DRAFTS.remove(draftId); draftPanel.hideDraft(); } } public static void addDraft(UUID draftId, DraftPanel draftPanel) { - drafts.put(draftId, draftPanel); + DRAFTS.put(draftId, draftPanel); } @Override @@ -1312,13 +1310,13 @@ public class MageFrame extends javax.swing.JFrame implements MageClient { @Override public void disconnected(final boolean errorCall) { if (SwingUtilities.isEventDispatchThread()) { // Returns true if the current thread is an AWT event dispatching thread. - logger.info("DISCONNECTED (Event Dispatch Thread)"); + LOGGER.info("DISCONNECTED (Event Dispatch Thread)"); setStatusText("Not connected"); disableButtons(); hideGames(); hideTables(); } else { - logger.info("DISCONNECTED (NO Event Dispatch Thread)"); + LOGGER.info("DISCONNECTED (NO Event Dispatch Thread)"); SwingUtilities.invokeLater(new Runnable() { @Override public void run() { diff --git a/Mage.Client/src/main/java/mage/client/table/TablesPanel.java b/Mage.Client/src/main/java/mage/client/table/TablesPanel.java index 63e2b2c2cec..b1534720591 100644 --- a/Mage.Client/src/main/java/mage/client/table/TablesPanel.java +++ b/Mage.Client/src/main/java/mage/client/table/TablesPanel.java @@ -26,7 +26,7 @@ * or implied, of BetaSteward_at_googlemail.com. */ -/* + /* * TablesPanel.java * * Created on 15-Dec-2009, 10:54:01 PM @@ -384,10 +384,8 @@ public class TablesPanel extends javax.swing.JPanel { updateMatchesTask = new UpdateMatchesTask(session, roomId, this); updateMatchesTask.execute(); } - } else { - if (updateMatchesTask != null) { - updateMatchesTask.cancel(true); - } + } else if (updateMatchesTask != null) { + updateMatchesTask.cancel(true); } } } @@ -1138,6 +1136,7 @@ public class TablesPanel extends javax.swing.JPanel { options.setFreeMulligans(2); options.setSkillLevel(SkillLevel.CASUAL); options.setRollbackTurnsAllowed(true); + options.setQuitRatio(100); table = session.createTable(roomId, options); session.joinTable(roomId, table.getTableId(), "Human", "Human", 1, DeckImporterUtil.importDeck("test.dck"), ""); @@ -1499,12 +1498,10 @@ class MatchesTableModel extends AbstractTableModel { case 6: if (matches[arg0].isTournament()) { return "Show"; + } else if (matches[arg0].isReplayAvailable()) { + return "Replay"; } else { - if (matches[arg0].isReplayAvailable()) { - return "Replay"; - } else { - return "None"; - } + return "None"; } case 7: return matches[arg0].getGames(); diff --git a/Mage.Server/src/main/java/mage/server/UserManager.java b/Mage.Server/src/main/java/mage/server/UserManager.java index cc33fd001a6..09edbf26697 100644 --- a/Mage.Server/src/main/java/mage/server/UserManager.java +++ b/Mage.Server/src/main/java/mage/server/UserManager.java @@ -54,12 +54,12 @@ public class UserManager { protected static ScheduledExecutorService expireExecutor = Executors.newSingleThreadScheduledExecutor(); - private static final Logger logger = Logger.getLogger(UserManager.class); + private static final Logger LOGGER = Logger.getLogger(UserManager.class); private final ConcurrentHashMap users = new ConcurrentHashMap<>(); private final ConcurrentHashMap usersByName = new ConcurrentHashMap<>(); - private static final ExecutorService callExecutor = ThreadExecutor.getInstance().getCallExecutor(); + private static final ExecutorService CALL_EXECUTOR = ThreadExecutor.getInstance().getCallExecutor(); private static final UserManager INSTANCE = new UserManager(); @@ -136,14 +136,14 @@ public class UserManager { if (userId != null) { final User user = users.get(userId); if (user != null) { - callExecutor.execute( + CALL_EXECUTOR.execute( new Runnable() { @Override public void run() { try { - logger.info("USER REMOVE - " + user.getName() + " (" + reason.toString() + ") userId: " + userId); + LOGGER.info("USER REMOVE - " + user.getName() + " (" + reason.toString() + ") userId: " + userId); user.remove(reason); - logger.debug("USER REMOVE END - " + user.getName()); + LOGGER.debug("USER REMOVE END - " + user.getName()); } catch (Exception ex) { handleException(ex); } finally { @@ -154,7 +154,7 @@ public class UserManager { } ); } else { - logger.warn("Trying to remove userId: " + userId + " - but it does not exist."); + LOGGER.warn("Trying to remove userId: " + userId + " - but it does not exist."); } } } @@ -188,13 +188,13 @@ public class UserManager { public void handleException(Exception ex) { if (ex != null) { - logger.fatal("User manager exception " + (ex.getMessage() == null ? "null" : ex.getMessage())); + LOGGER.fatal("User manager exception " + (ex.getMessage() == null ? "null" : ex.getMessage())); if (ex.getCause() != null) { - logger.debug("- Cause: " + (ex.getCause().getMessage() == null ? "null" : ex.getCause().getMessage())); + LOGGER.debug("- Cause: " + (ex.getCause().getMessage() == null ? "null" : ex.getCause().getMessage())); } ex.printStackTrace(); } else { - logger.fatal("User manager exception - null"); + LOGGER.fatal("User manager exception - null"); } } @@ -211,7 +211,7 @@ public class UserManager { } public void updateUserHistory() { - callExecutor.execute(new Runnable() { + CALL_EXECUTOR.execute(new Runnable() { @Override public void run() { for (String updatedUser : UserStatsRepository.instance.updateUserStats()) { diff --git a/Mage.Sets/src/mage/sets/alarareborn/LordOfExtinction.java b/Mage.Sets/src/mage/sets/alarareborn/LordOfExtinction.java index abcb06b0024..64b7413990b 100644 --- a/Mage.Sets/src/mage/sets/alarareborn/LordOfExtinction.java +++ b/Mage.Sets/src/mage/sets/alarareborn/LordOfExtinction.java @@ -75,7 +75,7 @@ class LordOfExtinctionDynamicCount implements DynamicValue { @Override public int calculate(Game game, Ability sourceAbility, Effect effect) { int count = 0; - for (UUID playerId : game.getPlayer(sourceAbility.getControllerId()).getInRange()) { + for (UUID playerId : game.getState().getPlayersInRange(sourceAbility.getControllerId(), game)) { Player player = game.getPlayer(playerId); if (player != null) { count += player.getGraveyard().size(); diff --git a/Mage.Sets/src/mage/sets/alarareborn/Soulquake.java b/Mage.Sets/src/mage/sets/alarareborn/Soulquake.java index 0c3cbcf3c79..4998f03024c 100644 --- a/Mage.Sets/src/mage/sets/alarareborn/Soulquake.java +++ b/Mage.Sets/src/mage/sets/alarareborn/Soulquake.java @@ -95,7 +95,7 @@ class SoulquakeEffect extends OneShotEffect { for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)) { permanent.moveToZone(Zone.HAND, source.getSourceId(), game, true); } - for (UUID playerId : game.getPlayer(source.getControllerId()).getInRange()) { + for (UUID playerId : game.getState().getPlayersInRange(source.getControllerId(), game)) { Player player = game.getPlayer(playerId); if (player != null) { for (Card card : player.getGraveyard().getCards(filter2, game)) { diff --git a/Mage.Sets/src/mage/sets/alliances/DiminishingReturns.java b/Mage.Sets/src/mage/sets/alliances/DiminishingReturns.java index 9c64ff4659d..cf62afcf157 100644 --- a/Mage.Sets/src/mage/sets/alliances/DiminishingReturns.java +++ b/Mage.Sets/src/mage/sets/alliances/DiminishingReturns.java @@ -78,7 +78,7 @@ class DiminishingReturnsEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { - for (UUID playerId : controller.getInRange()) { + for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) { Player player = game.getPlayer(playerId); if (player != null) { for (Card card: player.getHand().getCards(game)) { @@ -95,7 +95,7 @@ class DiminishingReturnsEffect extends OneShotEffect { controller.moveCardToExileWithInfo(card, null, "", source.getSourceId(), game, Zone.LIBRARY, true); } - for (UUID playerId : controller.getInRange()) { + for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) { Player player = game.getPlayer(playerId); if (player != null) { int cardsToDrawCount = player.getAmount(0, 7, "How many cards to draw (up to 7)?", game); diff --git a/Mage.Sets/src/mage/sets/apocalypse/PutridWarrior.java b/Mage.Sets/src/mage/sets/apocalypse/PutridWarrior.java index 5c166fb112d..2b07d7a4523 100644 --- a/Mage.Sets/src/mage/sets/apocalypse/PutridWarrior.java +++ b/Mage.Sets/src/mage/sets/apocalypse/PutridWarrior.java @@ -132,7 +132,7 @@ class PutridWarriorGainLifeEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - for(UUID playerId: game.getPlayer(source.getControllerId()).getInRange()) { + for(UUID playerId: game.getState().getPlayersInRange(source.getControllerId(), game)) { Player player = game.getPlayer(playerId); if(player != null) { player.gainLife(1, game); diff --git a/Mage.Sets/src/mage/sets/avacynrestored/KillingWave.java b/Mage.Sets/src/mage/sets/avacynrestored/KillingWave.java index 8b81ec6c96e..cb84fe6f3ad 100644 --- a/Mage.Sets/src/mage/sets/avacynrestored/KillingWave.java +++ b/Mage.Sets/src/mage/sets/avacynrestored/KillingWave.java @@ -98,7 +98,7 @@ class KillingWaveEffect extends OneShotEffect { HashMap lifePaidAmounts = new HashMap(); FilterCreaturePermanent filter = new FilterCreaturePermanent(); - for (UUID playerId : controller.getInRange()) { + for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) { Player player = game.getPlayer(playerId); List creatures = game.getBattlefield().getAllActivePermanents(filter, playerId, game); @@ -117,7 +117,7 @@ class KillingWaveEffect extends OneShotEffect { lifePaidAmounts.put(playerId, lifePaid); } - for (UUID playerId : controller.getInRange()) { + for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) { int lifePaid = lifePaidAmounts.get(playerId); if (lifePaid > 0) { Player player = game.getPlayer(playerId); diff --git a/Mage.Sets/src/mage/sets/avacynrestored/OtherworldAtlas.java b/Mage.Sets/src/mage/sets/avacynrestored/OtherworldAtlas.java index 5be9f81ae1f..43594a8956f 100644 --- a/Mage.Sets/src/mage/sets/avacynrestored/OtherworldAtlas.java +++ b/Mage.Sets/src/mage/sets/avacynrestored/OtherworldAtlas.java @@ -93,7 +93,7 @@ class OtherworldAtlasDrawEffect extends OneShotEffect { if (permanent != null) { int amount = permanent.getCounters().getCount(CounterType.CHARGE); if (amount > 0) { - for (UUID playerId : sourcePlayer.getInRange()) { + for (UUID playerId : game.getState().getPlayersInRange(sourcePlayer.getId(), game)) { Player player = game.getPlayer(playerId); if (player != null) { player.drawCards(amount, game); diff --git a/Mage.Sets/src/mage/sets/avacynrestored/RiteOfRuin.java b/Mage.Sets/src/mage/sets/avacynrestored/RiteOfRuin.java index 7a2a69f37aa..db07fa923e5 100644 --- a/Mage.Sets/src/mage/sets/avacynrestored/RiteOfRuin.java +++ b/Mage.Sets/src/mage/sets/avacynrestored/RiteOfRuin.java @@ -113,7 +113,7 @@ class RiteOfRuinEffect extends OneShotEffect { FilterControlledPermanent filter = new FilterControlledPermanent(cardType + " permanent you control"); filter.add(new CardTypePredicate(cardType)); - for (UUID playerId : controller.getInRange()) { + for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) { int amount = Math.min(count, game.getBattlefield().countAll(filter, playerId, game)); TargetControlledPermanent target = new TargetControlledPermanent(amount, amount, filter, false); Player player = game.getPlayer(playerId); diff --git a/Mage.Sets/src/mage/sets/betrayersofkamigawa/HeartlessHidetsugu.java b/Mage.Sets/src/mage/sets/betrayersofkamigawa/HeartlessHidetsugu.java index c2bc22ae7bb..b06fb9e87b8 100644 --- a/Mage.Sets/src/mage/sets/betrayersofkamigawa/HeartlessHidetsugu.java +++ b/Mage.Sets/src/mage/sets/betrayersofkamigawa/HeartlessHidetsugu.java @@ -92,7 +92,7 @@ class HeartlessHidetsuguDamageEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { - for (UUID playerId : controller.getInRange()) { + for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) { Player player = game.getPlayer(playerId); if (player != null) { int damage = player.getLife() / 2; diff --git a/Mage.Sets/src/mage/sets/betrayersofkamigawa/KitsunePalliator.java b/Mage.Sets/src/mage/sets/betrayersofkamigawa/KitsunePalliator.java index 9af055fbbd3..457dcda2a5b 100644 --- a/Mage.Sets/src/mage/sets/betrayersofkamigawa/KitsunePalliator.java +++ b/Mage.Sets/src/mage/sets/betrayersofkamigawa/KitsunePalliator.java @@ -98,7 +98,7 @@ class KitsunePalliatorEffect extends OneShotEffect { effect.setTargetPointer(new FixedTarget(permanent.getId())); game.addEffect(effect, source); } - for (UUID playerId: game.getPlayer(source.getControllerId()).getInRange()) { + for (UUID playerId: game.getState().getPlayersInRange(source.getControllerId(), game)) { Player player = game.getPlayer(playerId); if (player != null) { effect.setTargetPointer(new FixedTarget(player.getId())); diff --git a/Mage.Sets/src/mage/sets/blessedvscursed/MindbreakerDemon.java b/Mage.Sets/src/mage/sets/blessedvscursed/MindbreakerDemon.java index 8cd5514f9cd..984cf54d500 100644 --- a/Mage.Sets/src/mage/sets/blessedvscursed/MindbreakerDemon.java +++ b/Mage.Sets/src/mage/sets/blessedvscursed/MindbreakerDemon.java @@ -99,7 +99,7 @@ class TwentyGraveyardCreatureCondition implements Condition { MageObject target = game.getObject(source.getSourceId()); if (target != null) { HashSet foundCardTypes = new HashSet<>(); - for (UUID playerId : controller.getInRange()) { + for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) { Player player = game.getPlayer(playerId); if (player != null) { for (Card card : player.getGraveyard().getCards(game)) { diff --git a/Mage.Sets/src/mage/sets/bornofthegods/WhimsOfTheFates.java b/Mage.Sets/src/mage/sets/bornofthegods/WhimsOfTheFates.java index 448bfea2e8c..ed54027b806 100644 --- a/Mage.Sets/src/mage/sets/bornofthegods/WhimsOfTheFates.java +++ b/Mage.Sets/src/mage/sets/bornofthegods/WhimsOfTheFates.java @@ -120,7 +120,7 @@ class WhimsOfTheFateEffect extends OneShotEffect { continue; } // if player is in range of controller he chooses 3 piles with all its permanents - if (currentPlayer != null && controller.getInRange().contains(currentPlayer.getId())) { + if (currentPlayer != null && game.getState().getPlayersInRange(controller.getId(), game).contains(currentPlayer.getId())) { Map> playerPiles = new HashMap<>(); for (int i = 1; i < 4; i++) { playerPiles.put(i, new LinkedHashSet()); diff --git a/Mage.Sets/src/mage/sets/championsofkamigawa/ReverseTheSands.java b/Mage.Sets/src/mage/sets/championsofkamigawa/ReverseTheSands.java index d9abe7b87cd..dcf73dca7e0 100644 --- a/Mage.Sets/src/mage/sets/championsofkamigawa/ReverseTheSands.java +++ b/Mage.Sets/src/mage/sets/championsofkamigawa/ReverseTheSands.java @@ -88,14 +88,14 @@ class ReverseTheSandsEffect extends OneShotEffect { if (controller != null) { Choice lifeChoice = new ChoiceImpl(true); Set choices = new HashSet(); - for (UUID playerId : controller.getInRange()) { + for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) { Player player = game.getPlayer(playerId); if (player != null) { choices.add(new StringBuilder(Integer.toString(player.getLife())).append(" life of ").append(player.getLogName()).toString()); } } lifeChoice.setChoices(choices); - for (UUID playersId : controller.getInRange()) { + for (UUID playersId : game.getState().getPlayersInRange(controller.getId(), game)) { Player player = game.getPlayer(playersId); if (player != null) { String selectedChoice; diff --git a/Mage.Sets/src/mage/sets/commander/AllianceOfArms.java b/Mage.Sets/src/mage/sets/commander/AllianceOfArms.java index 107b3b3d4bc..e15ff17ae8a 100644 --- a/Mage.Sets/src/mage/sets/commander/AllianceOfArms.java +++ b/Mage.Sets/src/mage/sets/commander/AllianceOfArms.java @@ -90,7 +90,7 @@ class AllianceOfArmsEffect extends OneShotEffect { if (controller != null) { int xSum = 0; xSum += playerPaysXGenericMana(controller, source, game); - for(UUID playerId : controller.getInRange()) { + for(UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) { if (playerId != controller.getId()) { Player player = game.getPlayer(playerId); if (player != null) { @@ -100,7 +100,7 @@ class AllianceOfArmsEffect extends OneShotEffect { } } if (xSum > 0) { - for(UUID playerId : controller.getInRange()) { + for(UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) { Effect effect = new CreateTokenTargetEffect(new SoldierToken(), xSum); effect.setTargetPointer(new FixedTarget(playerId)); effect.apply(game, source); diff --git a/Mage.Sets/src/mage/sets/commander/CollectiveVoyage.java b/Mage.Sets/src/mage/sets/commander/CollectiveVoyage.java index b0a485f4df8..311d9dc066b 100644 --- a/Mage.Sets/src/mage/sets/commander/CollectiveVoyage.java +++ b/Mage.Sets/src/mage/sets/commander/CollectiveVoyage.java @@ -90,7 +90,7 @@ class CollectiveVoyageEffect extends OneShotEffect { if (controller != null) { int xSum = 0; xSum += playerPaysXGenericMana(controller, source, game); - for(UUID playerId : controller.getInRange()) { + for(UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) { if (playerId != controller.getId()) { Player player = game.getPlayer(playerId); if (player != null) { @@ -99,7 +99,7 @@ class CollectiveVoyageEffect extends OneShotEffect { } } } - for(UUID playerId : controller.getInRange()) { + for(UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) { Player player = game.getPlayer(playerId); if (player != null) { TargetCardInLibrary target = new TargetCardInLibrary(0, xSum, new FilterBasicLandCard()); diff --git a/Mage.Sets/src/mage/sets/commander/DeathByDragons.java b/Mage.Sets/src/mage/sets/commander/DeathByDragons.java index 60572acafe6..41f6bf37bfc 100644 --- a/Mage.Sets/src/mage/sets/commander/DeathByDragons.java +++ b/Mage.Sets/src/mage/sets/commander/DeathByDragons.java @@ -87,7 +87,7 @@ class DeathByDragonsEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { - for (UUID playerId : controller.getInRange()) { + for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) { if (!playerId.equals(this.getTargetPointer().getFirst(game, source))) { Token token = new DragonToken2(); token.putOntoBattlefield(1, game, source.getSourceId(), playerId); diff --git a/Mage.Sets/src/mage/sets/commander/ManaChargedDragon.java b/Mage.Sets/src/mage/sets/commander/ManaChargedDragon.java index 81a21388da1..8b062955159 100644 --- a/Mage.Sets/src/mage/sets/commander/ManaChargedDragon.java +++ b/Mage.Sets/src/mage/sets/commander/ManaChargedDragon.java @@ -129,7 +129,7 @@ class ManaChargedDragonEffect extends OneShotEffect { if (controller != null) { int xSum = 0; xSum += playerPaysXGenericMana(controller, source, game); - for (UUID playerId : controller.getInRange()) { + for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) { if (playerId != controller.getId()) { Player player = game.getPlayer(playerId); if (player != null) { diff --git a/Mage.Sets/src/mage/sets/commander/MindsAglow.java b/Mage.Sets/src/mage/sets/commander/MindsAglow.java index 70fb1b32591..85b2b48fa5a 100644 --- a/Mage.Sets/src/mage/sets/commander/MindsAglow.java +++ b/Mage.Sets/src/mage/sets/commander/MindsAglow.java @@ -87,7 +87,7 @@ class MindsAglowEffect extends OneShotEffect { if (controller != null) { int xSum = 0; xSum += playerPaysXGenericMana(controller, source, game); - for(UUID playerId : controller.getInRange()) { + for(UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) { if (playerId != controller.getId()) { Player player = game.getPlayer(playerId); if (player != null) { @@ -97,7 +97,7 @@ class MindsAglowEffect extends OneShotEffect { } } if (xSum > 0) { - for(UUID playerId : controller.getInRange()) { + for(UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) { Player player = game.getPlayer(playerId); if (player != null) { player.drawCards(xSum, game); diff --git a/Mage.Sets/src/mage/sets/commander/SharedTrauma.java b/Mage.Sets/src/mage/sets/commander/SharedTrauma.java index b26fa0f05a3..867bc7b2f6b 100644 --- a/Mage.Sets/src/mage/sets/commander/SharedTrauma.java +++ b/Mage.Sets/src/mage/sets/commander/SharedTrauma.java @@ -89,7 +89,7 @@ class SharedTraumaEffect extends OneShotEffect { if (controller != null) { int xSum = 0; xSum += playerPaysXGenericMana(controller, source, game); - for(UUID playerId : controller.getInRange()) { + for(UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) { if (playerId != controller.getId()) { Player player = game.getPlayer(playerId); if (player != null) { @@ -99,7 +99,7 @@ class SharedTraumaEffect extends OneShotEffect { } } if (xSum > 0) { - for(UUID playerId : controller.getInRange()) { + for(UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) { Effect effect = new PutTopCardOfLibraryIntoGraveTargetEffect(xSum); effect.setTargetPointer(new FixedTarget(playerId)); effect.apply(game, source); diff --git a/Mage.Sets/src/mage/sets/commander/VeteranExplorer.java b/Mage.Sets/src/mage/sets/commander/VeteranExplorer.java index 7644250ea4c..2f824305546 100644 --- a/Mage.Sets/src/mage/sets/commander/VeteranExplorer.java +++ b/Mage.Sets/src/mage/sets/commander/VeteranExplorer.java @@ -97,7 +97,7 @@ class VeteranExplorerEffect extends OneShotEffect { if (controller != null) { List usingPlayers = new ArrayList<>(); this.chooseAndSearchLibrary(usingPlayers, controller, source, game); - for (UUID playerId: controller.getInRange()) { + for (UUID playerId: game.getState().getPlayersInRange(controller.getId(), game)) { if (!playerId.equals(controller.getId())) { Player player = game.getPlayer(playerId); if (player != null) { diff --git a/Mage.Sets/src/mage/sets/commander2013/BroodingSaurian.java b/Mage.Sets/src/mage/sets/commander2013/BroodingSaurian.java index 54e0a497b22..f392a0de16c 100644 --- a/Mage.Sets/src/mage/sets/commander2013/BroodingSaurian.java +++ b/Mage.Sets/src/mage/sets/commander2013/BroodingSaurian.java @@ -106,7 +106,7 @@ class BroodingSaurianControlEffect extends ContinuousEffectImpl { // add all creatures in range Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { - for (UUID playerId : controller.getInRange()) { + for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) { FilterPermanent playerFilter = filter.copy(); playerFilter.add(new OwnerIdPredicate(playerId)); for (Permanent permanent :game.getBattlefield().getActivePermanents(playerFilter, playerId, game)) { diff --git a/Mage.Sets/src/mage/sets/commander2013/FromTheAshes.java b/Mage.Sets/src/mage/sets/commander2013/FromTheAshes.java index 94d4e0bd125..dcb24b8bb0d 100644 --- a/Mage.Sets/src/mage/sets/commander2013/FromTheAshes.java +++ b/Mage.Sets/src/mage/sets/commander2013/FromTheAshes.java @@ -101,7 +101,7 @@ class FromTheAshesEffect extends OneShotEffect { Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { Map playerAmount = new HashMap<>(); - for (UUID playerId : controller.getInRange()) { + for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) { Player player = game.getPlayer(playerId); if (player != null) { int amount = 0; diff --git a/Mage.Sets/src/mage/sets/commander2013/HomewardPath.java b/Mage.Sets/src/mage/sets/commander2013/HomewardPath.java index 8b752542d26..851d1497719 100644 --- a/Mage.Sets/src/mage/sets/commander2013/HomewardPath.java +++ b/Mage.Sets/src/mage/sets/commander2013/HomewardPath.java @@ -103,7 +103,7 @@ class HomewardPathControlEffect extends ContinuousEffectImpl { // add all creatures in range Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { - for (UUID playerId : controller.getInRange()) { + for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) { FilterPermanent playerFilter = filter.copy(); playerFilter.add(new OwnerIdPredicate(playerId)); for (Permanent permanent :game.getBattlefield().getActivePermanents(playerFilter, playerId, game)) { diff --git a/Mage.Sets/src/mage/sets/commander2013/HoodedHorror.java b/Mage.Sets/src/mage/sets/commander2013/HoodedHorror.java index af011eb9784..c23f2bd949e 100644 --- a/Mage.Sets/src/mage/sets/commander2013/HoodedHorror.java +++ b/Mage.Sets/src/mage/sets/commander2013/HoodedHorror.java @@ -96,7 +96,7 @@ class HoodedHorrorCantBeBlockedEffect extends RestrictionEffect { if (controller != null) { int maxCreatures = 0; UUID playerIdWithMax = null; - for (UUID playerId : controller.getInRange()) { + for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) { int creatures = game.getBattlefield().countAll(filter, playerId, game); if (creatures > maxCreatures || (creatures == maxCreatures && playerId.equals(blocker.getControllerId())) ) { maxCreatures = creatures; diff --git a/Mage.Sets/src/mage/sets/commander2013/JelevaNephaliasScourge.java b/Mage.Sets/src/mage/sets/commander2013/JelevaNephaliasScourge.java index 965cb69fd59..3808a36d455 100644 --- a/Mage.Sets/src/mage/sets/commander2013/JelevaNephaliasScourge.java +++ b/Mage.Sets/src/mage/sets/commander2013/JelevaNephaliasScourge.java @@ -112,7 +112,7 @@ class JelevaNephaliasScourgeEffect extends OneShotEffect { if (watcher != null) { int xValue = watcher.getManaSpentToCastLastTime(sourceCard.getZoneChangeCounter(game) - 1); if (xValue > 0) { - for (UUID playerId : controller.getInRange()) { + for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) { Player player = game.getPlayer(playerId); if (player != null) { int cardsToExile = Math.min(player.getLibrary().size(), xValue); diff --git a/Mage.Sets/src/mage/sets/commander2013/MysticBarrier.java b/Mage.Sets/src/mage/sets/commander2013/MysticBarrier.java index 51cbccf2b28..74eecc6c947 100644 --- a/Mage.Sets/src/mage/sets/commander2013/MysticBarrier.java +++ b/Mage.Sets/src/mage/sets/commander2013/MysticBarrier.java @@ -186,7 +186,7 @@ class MysticBarrierReplacementEffect extends ReplacementEffectImpl { if (game.getPlayers().size() > 2) { Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { - if (controller.getInRange().contains(event.getPlayerId())) { + if (game.getState().getPlayersInRange(controller.getId(), game).contains(event.getPlayerId())) { String allowedDirection = (String) game.getState().getValue(new StringBuilder("attack_direction_").append(source.getSourceId()).toString()); if (allowedDirection != null) { Player defender = game.getPlayer(event.getTargetId()); diff --git a/Mage.Sets/src/mage/sets/commander2013/NayaSoulbeast.java b/Mage.Sets/src/mage/sets/commander2013/NayaSoulbeast.java index 64a2febb12e..44f8451b041 100644 --- a/Mage.Sets/src/mage/sets/commander2013/NayaSoulbeast.java +++ b/Mage.Sets/src/mage/sets/commander2013/NayaSoulbeast.java @@ -105,7 +105,7 @@ class NayaSoulbeastCastEffect extends OneShotEffect { MageObject sourceObject = source.getSourceObject(game); if (controller != null && sourceObject != null) { int cmc = 0; - for (UUID playerId : controller.getInRange()) { + for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) { Player player = game.getPlayer(playerId); if (player != null) { if (player.getLibrary().size() > 0) { diff --git a/Mage.Sets/src/mage/sets/commander2013/OrderOfSuccession.java b/Mage.Sets/src/mage/sets/commander2013/OrderOfSuccession.java index e62790e6d4c..388d105c650 100644 --- a/Mage.Sets/src/mage/sets/commander2013/OrderOfSuccession.java +++ b/Mage.Sets/src/mage/sets/commander2013/OrderOfSuccession.java @@ -120,7 +120,7 @@ class OrderOfSuccessionEffect extends OneShotEffect { continue; } // if player is in range he chooses a creature to control - if (currentPlayer != null && controller.getInRange().contains(currentPlayer.getId())) { + if (currentPlayer != null && game.getState().getPlayersInRange(controller.getId(), game).contains(currentPlayer.getId())) { FilterCreaturePermanent filter = new FilterCreaturePermanent(new StringBuilder("creature controlled by ").append(nextPlayer.getLogName()).toString()); filter.add(new ControllerIdPredicate(nextPlayer.getId())); Target target = new TargetCreaturePermanent(filter); diff --git a/Mage.Sets/src/mage/sets/commander2013/ShattergangBrothers.java b/Mage.Sets/src/mage/sets/commander2013/ShattergangBrothers.java index 63db2258aba..558f6b5f70e 100644 --- a/Mage.Sets/src/mage/sets/commander2013/ShattergangBrothers.java +++ b/Mage.Sets/src/mage/sets/commander2013/ShattergangBrothers.java @@ -120,7 +120,7 @@ class ShattergangBrothersEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { - for(UUID playerId : controller.getInRange()) { + for(UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) { if (playerId != source.getControllerId()) { Player player = game.getPlayer(playerId); if (player != null) { diff --git a/Mage.Sets/src/mage/sets/commander2013/SurveyorsScope.java b/Mage.Sets/src/mage/sets/commander2013/SurveyorsScope.java index 274c964ddfd..1ee8403d2fc 100644 --- a/Mage.Sets/src/mage/sets/commander2013/SurveyorsScope.java +++ b/Mage.Sets/src/mage/sets/commander2013/SurveyorsScope.java @@ -93,7 +93,7 @@ class SurveyorsScopeEffect extends OneShotEffect { if (controller != null) { int numberOfLands = 0; int ownLands = game.getBattlefield().countAll(new FilterLandPermanent(), controller.getId(), game); - for (UUID playerId: controller.getInRange()) { + for (UUID playerId: game.getState().getPlayersInRange(controller.getId(), game)) { if (!playerId.equals(controller.getId())) { if (game.getBattlefield().countAll(new FilterLandPermanent(), playerId, game) > ownLands + 1) { numberOfLands++; diff --git a/Mage.Sets/src/mage/sets/commander2014/BrineElemental.java b/Mage.Sets/src/mage/sets/commander2014/BrineElemental.java index 2df36999f66..690553ebf24 100644 --- a/Mage.Sets/src/mage/sets/commander2014/BrineElemental.java +++ b/Mage.Sets/src/mage/sets/commander2014/BrineElemental.java @@ -94,7 +94,7 @@ class BrineElementalEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { - for (UUID playerId: controller.getInRange()) { + for (UUID playerId: game.getState().getPlayersInRange(controller.getId(), game)) { if (controller.hasOpponent(playerId, game)) { game.getState().getTurnMods().add(new TurnMod(playerId, PhaseStep.UNTAP)); } diff --git a/Mage.Sets/src/mage/sets/commander2014/GraveSifter.java b/Mage.Sets/src/mage/sets/commander2014/GraveSifter.java index e9dd6df2171..1c3230575b7 100644 --- a/Mage.Sets/src/mage/sets/commander2014/GraveSifter.java +++ b/Mage.Sets/src/mage/sets/commander2014/GraveSifter.java @@ -101,7 +101,7 @@ class GraveSifterEffect extends OneShotEffect { typeChoice.setChoices(CardRepository.instance.getCreatureTypes()); Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { - for (UUID playerId : controller.getInRange()) { + for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) { Player player = game.getPlayer(playerId); if (player != null) { typeChoice.clearChoice(); diff --git a/Mage.Sets/src/mage/sets/commander2014/InciteRebellion.java b/Mage.Sets/src/mage/sets/commander2014/InciteRebellion.java index a6c9772caf5..2692cd114bd 100644 --- a/Mage.Sets/src/mage/sets/commander2014/InciteRebellion.java +++ b/Mage.Sets/src/mage/sets/commander2014/InciteRebellion.java @@ -86,7 +86,7 @@ class InciteRebellionEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { - for (UUID playerId: controller.getInRange()) { + for (UUID playerId: game.getState().getPlayersInRange(controller.getId(), game)) { Player player = game.getPlayer(playerId); if (player != null) { int count = game.getBattlefield().countAll(filter, playerId, game); diff --git a/Mage.Sets/src/mage/sets/commander2014/StitcherGeralf.java b/Mage.Sets/src/mage/sets/commander2014/StitcherGeralf.java index d625fa7b221..aafcc1aab2c 100644 --- a/Mage.Sets/src/mage/sets/commander2014/StitcherGeralf.java +++ b/Mage.Sets/src/mage/sets/commander2014/StitcherGeralf.java @@ -102,7 +102,7 @@ class StitcherGeralfEffect extends OneShotEffect { Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { Cards cards = new CardsImpl(); - for (UUID playerId: controller.getInRange()) { + for (UUID playerId: game.getState().getPlayersInRange(controller.getId(), game)) { Player player = game.getPlayer(playerId); if (player != null) { cards.addAll(player.getLibrary().getTopCards(game, 3)); diff --git a/Mage.Sets/src/mage/sets/commander2014/WaveOfVitriol.java b/Mage.Sets/src/mage/sets/commander2014/WaveOfVitriol.java index bb5bb951b94..896954128fd 100644 --- a/Mage.Sets/src/mage/sets/commander2014/WaveOfVitriol.java +++ b/Mage.Sets/src/mage/sets/commander2014/WaveOfVitriol.java @@ -111,7 +111,7 @@ class WaveOfVitriolEffect extends OneShotEffect { Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { Map sacrificedLands = new HashMap<>(); - for (UUID playerId : controller.getInRange()) { + for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) { Player player = game.getPlayer(playerId); if (player != null) { int count = 0; diff --git a/Mage.Sets/src/mage/sets/commander2014/WolfcallersHowl.java b/Mage.Sets/src/mage/sets/commander2014/WolfcallersHowl.java index 28597b1821a..efbd2a0bd10 100644 --- a/Mage.Sets/src/mage/sets/commander2014/WolfcallersHowl.java +++ b/Mage.Sets/src/mage/sets/commander2014/WolfcallersHowl.java @@ -88,7 +88,7 @@ class WolfcallersHowlEffect extends OneShotEffect { Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { int count = 0; - for(UUID playerId :controller.getInRange()) { + for(UUID playerId :game.getState().getPlayersInRange(controller.getId(), game)) { if (controller.hasOpponent(playerId, game)) { Player opponent = game.getPlayer(playerId); if (opponent != null) { diff --git a/Mage.Sets/src/mage/sets/conflux/BloodTyrant.java b/Mage.Sets/src/mage/sets/conflux/BloodTyrant.java index 1bb4dd28be4..c2463162daa 100644 --- a/Mage.Sets/src/mage/sets/conflux/BloodTyrant.java +++ b/Mage.Sets/src/mage/sets/conflux/BloodTyrant.java @@ -139,7 +139,7 @@ class BloodTyrantEffect extends OneShotEffect { int counters = 0; Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { - for (UUID playerId : controller.getInRange()) { + for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) { Player player = game.getPlayer(playerId); if (player != null) { if (player.loseLife(1, game) > 0) { diff --git a/Mage.Sets/src/mage/sets/conspiracy/StrongholdDiscipline.java b/Mage.Sets/src/mage/sets/conspiracy/StrongholdDiscipline.java index f6d258cf6e9..19482607b39 100644 --- a/Mage.Sets/src/mage/sets/conspiracy/StrongholdDiscipline.java +++ b/Mage.Sets/src/mage/sets/conspiracy/StrongholdDiscipline.java @@ -82,7 +82,7 @@ class StrongholdDisciplineEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { - for (UUID playerId : controller.getInRange()) { + for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) { final int count = game.getBattlefield().getAllActivePermanents(new FilterCreaturePermanent(), playerId, game).size(); if (count > 0) { Player player = game.getPlayer(playerId); diff --git a/Mage.Sets/src/mage/sets/darkascension/ChillOfForeboding.java b/Mage.Sets/src/mage/sets/darkascension/ChillOfForeboding.java index 88ee72413c7..cdbba21b309 100644 --- a/Mage.Sets/src/mage/sets/darkascension/ChillOfForeboding.java +++ b/Mage.Sets/src/mage/sets/darkascension/ChillOfForeboding.java @@ -88,7 +88,7 @@ class ChillOfForebodingEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player sourcePlayer = game.getPlayer(source.getControllerId()); - for (UUID playerId : sourcePlayer.getInRange()) { + for (UUID playerId : game.getState().getPlayersInRange(sourcePlayer.getId(), game)) { Player player = game.getPlayer(playerId); if (player != null) { player.moveCards(player.getLibrary().getTopCards(game, 5), Zone.LIBRARY, Zone.GRAVEYARD, source, game); diff --git a/Mage.Sets/src/mage/sets/darksteel/MycosynthLattice.java b/Mage.Sets/src/mage/sets/darksteel/MycosynthLattice.java index 4696750cc39..595529e0a62 100644 --- a/Mage.Sets/src/mage/sets/darksteel/MycosynthLattice.java +++ b/Mage.Sets/src/mage/sets/darksteel/MycosynthLattice.java @@ -139,7 +139,7 @@ class EverythingIsColorlessEffect extends ContinuousEffectImpl { for (CommandObject commandObject : game.getState().getCommand()) { commandObject.getColor(game).setColor(colorless); } - for (UUID playerId : controller.getInRange()) { + for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) { Player player = game.getPlayer(playerId); if (player != null) { // hand @@ -186,7 +186,7 @@ class ManaCanBeSpentAsAnyColorEffect extends AsThoughEffectImpl implements AsTho @Override public boolean applies(UUID objectId, Ability source, UUID affectedControllerId, Game game) { Player controller = game.getPlayer(source.getControllerId()); - return controller != null && controller.getInRange().contains(affectedControllerId); + return controller != null && game.getState().getPlayersInRange(controller.getId(), game).contains(affectedControllerId); } @Override diff --git a/Mage.Sets/src/mage/sets/darksteel/PulseOfTheFields.java b/Mage.Sets/src/mage/sets/darksteel/PulseOfTheFields.java index a6ee275f3b7..f6666588e51 100644 --- a/Mage.Sets/src/mage/sets/darksteel/PulseOfTheFields.java +++ b/Mage.Sets/src/mage/sets/darksteel/PulseOfTheFields.java @@ -85,7 +85,7 @@ class PulseOfTheFieldsReturnToHandEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { - for (UUID playerId : controller.getInRange()) { + for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) { Player player = game.getPlayer(playerId); if (player != null && player.getLife() > controller.getLife()) { Card card = game.getCard(source.getSourceId()); diff --git a/Mage.Sets/src/mage/sets/darksteel/PulseOfTheGrid.java b/Mage.Sets/src/mage/sets/darksteel/PulseOfTheGrid.java index 1e8179a260f..3bdc335ca2c 100644 --- a/Mage.Sets/src/mage/sets/darksteel/PulseOfTheGrid.java +++ b/Mage.Sets/src/mage/sets/darksteel/PulseOfTheGrid.java @@ -85,7 +85,7 @@ class PulseOfTheGridReturnToHandEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { - for (UUID playerId : controller.getInRange()) { + for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) { Player player = game.getPlayer(playerId); if (player != null && player.getHand().size() > controller.getHand().size()) { Card card = game.getCard(source.getSourceId()); diff --git a/Mage.Sets/src/mage/sets/dragonsmaze/BloodBaronOfVizkopa.java b/Mage.Sets/src/mage/sets/dragonsmaze/BloodBaronOfVizkopa.java index d675c36e768..149039cb52e 100644 --- a/Mage.Sets/src/mage/sets/dragonsmaze/BloodBaronOfVizkopa.java +++ b/Mage.Sets/src/mage/sets/dragonsmaze/BloodBaronOfVizkopa.java @@ -131,10 +131,10 @@ class BloodBaronOfVizkopaEffect extends ContinuousEffectImpl { } protected boolean conditionState(Ability source, Game game) { - Player player = game.getPlayer(source.getControllerId()); - if (player != null && player.getLife() >= 30) { - for (UUID opponentId : player.getInRange()) { - if (player.hasOpponent(opponentId, game)) { + Player controller = game.getPlayer(source.getControllerId()); + if (controller != null && controller.getLife() >= 30) { + for (UUID opponentId : game.getState().getPlayersInRange(controller.getId(), game)) { + if (controller.hasOpponent(opponentId, game)) { Player opponent = game.getPlayer(opponentId); if (opponent != null && opponent.getLife() < 11) { return true; diff --git a/Mage.Sets/src/mage/sets/dragonsmaze/CatchRelease.java b/Mage.Sets/src/mage/sets/dragonsmaze/CatchRelease.java index e40d9d7265f..abdf5f13963 100644 --- a/Mage.Sets/src/mage/sets/dragonsmaze/CatchRelease.java +++ b/Mage.Sets/src/mage/sets/dragonsmaze/CatchRelease.java @@ -109,7 +109,7 @@ class ReleaseSacrificeEffect extends OneShotEffect { if (controller == null) { return false; } - for (UUID playerId : controller.getInRange()) { + for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) { Player player = game.getPlayer(playerId); Target target1 = new TargetControlledPermanent(1, 1, new FilterControlledArtifactPermanent(), true); diff --git a/Mage.Sets/src/mage/sets/dragonsmaze/SireOfInsanity.java b/Mage.Sets/src/mage/sets/dragonsmaze/SireOfInsanity.java index 93599c4e256..72f8a170319 100644 --- a/Mage.Sets/src/mage/sets/dragonsmaze/SireOfInsanity.java +++ b/Mage.Sets/src/mage/sets/dragonsmaze/SireOfInsanity.java @@ -91,7 +91,7 @@ class SireOfInsanityEffect extends OneShotEffect { if (sourcePlayer == null) { return false; } - for (UUID playerId : sourcePlayer.getInRange()) { + for (UUID playerId : game.getState().getPlayersInRange(sourcePlayer.getId(), game)) { Player player = game.getPlayer(playerId); if (player != null) { for (Card c : player.getHand().getCards(game)) { diff --git a/Mage.Sets/src/mage/sets/dragonsoftarkir/ShamanOfForgottenWays.java b/Mage.Sets/src/mage/sets/dragonsoftarkir/ShamanOfForgottenWays.java index 67e613b9388..e1a4f9f0b4b 100644 --- a/Mage.Sets/src/mage/sets/dragonsoftarkir/ShamanOfForgottenWays.java +++ b/Mage.Sets/src/mage/sets/dragonsoftarkir/ShamanOfForgottenWays.java @@ -143,7 +143,7 @@ class ShamanOfForgottenWaysEffect extends OneShotEffect { Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { FilterPermanent filter = new FilterCreaturePermanent(); - for(UUID playerId : controller.getInRange()) { + for(UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) { Player player = game.getPlayer(playerId); if (player != null){ int numberCreatures = game.getBattlefield().getAllActivePermanents(filter, playerId, game).size(); diff --git a/Mage.Sets/src/mage/sets/eventide/BatwingBrume.java b/Mage.Sets/src/mage/sets/eventide/BatwingBrume.java index b388a18eb20..79d60ad0ef0 100644 --- a/Mage.Sets/src/mage/sets/eventide/BatwingBrume.java +++ b/Mage.Sets/src/mage/sets/eventide/BatwingBrume.java @@ -97,7 +97,7 @@ class BatwingBrumeEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { - for (UUID playerId : controller.getInRange()) { + for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) { final int amount = game.getBattlefield().getAllActivePermanents(new FilterAttackingCreature(), playerId, game).size(); if (amount > 0) { Player player = game.getPlayer(playerId); diff --git a/Mage.Sets/src/mage/sets/exodus/PriceOfProgress.java b/Mage.Sets/src/mage/sets/exodus/PriceOfProgress.java index 93fce5e509f..7890823b3d7 100644 --- a/Mage.Sets/src/mage/sets/exodus/PriceOfProgress.java +++ b/Mage.Sets/src/mage/sets/exodus/PriceOfProgress.java @@ -91,7 +91,7 @@ class PriceOfProgressEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { - for (UUID playerId : controller.getInRange()) { + for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) { int amount = game.getBattlefield().countAll(filter , playerId, game); if (amount > 0) { Player player = game.getPlayer(playerId); diff --git a/Mage.Sets/src/mage/sets/fifthdawn/EonHub.java b/Mage.Sets/src/mage/sets/fifthdawn/EonHub.java index c8cc0436d51..e0eb5fb35fb 100644 --- a/Mage.Sets/src/mage/sets/fifthdawn/EonHub.java +++ b/Mage.Sets/src/mage/sets/fifthdawn/EonHub.java @@ -65,6 +65,6 @@ class SkipUpkeepStepEffect extends ContinuousRuleModifyingEffectImpl { @Override public boolean applies(GameEvent event, Ability source, Game game) { Player controller = game.getPlayer(source.getControllerId()); - return controller != null && controller.getInRange().contains(event.getPlayerId()); + return controller != null && game.getState().getPlayersInRange(controller.getId(), game).contains(event.getPlayerId()); } } diff --git a/Mage.Sets/src/mage/sets/fifthedition/Pox.java b/Mage.Sets/src/mage/sets/fifthedition/Pox.java index 24d95c732c3..402adba798f 100644 --- a/Mage.Sets/src/mage/sets/fifthedition/Pox.java +++ b/Mage.Sets/src/mage/sets/fifthedition/Pox.java @@ -90,7 +90,7 @@ class PoxEffect extends OneShotEffect { Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { // Each player loses a third of his or her life, - for (UUID playerId : controller.getInRange()) { + for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) { Player player = game.getPlayer(playerId); if (player != null) { int lifeToLose = (int) Math.ceil(player.getLife() / 3.0); @@ -98,7 +98,7 @@ class PoxEffect extends OneShotEffect { } } // then discards a third of the cards in his or her hand, - for (UUID playerId : controller.getInRange()) { + for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) { Player player = game.getPlayer(playerId); if (player != null) { int cardsToDiscard = (int) Math.ceil(player.getHand().size() / 3.0); @@ -108,7 +108,7 @@ class PoxEffect extends OneShotEffect { } } // then sacrifices a third of the creatures he or she controls, - for (UUID playerId : controller.getInRange()) { + for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) { Player player = game.getPlayer(playerId); if (player != null) { FilterControlledCreaturePermanent filter = new FilterControlledCreaturePermanent(); @@ -126,7 +126,7 @@ class PoxEffect extends OneShotEffect { } } // then sacrifices a third of the lands he or she controls. - for (UUID playerId : controller.getInRange()) { + for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) { Player player = game.getPlayer(playerId); if (player != null) { FilterControlledLandPermanent filter = new FilterControlledLandPermanent(); diff --git a/Mage.Sets/src/mage/sets/fifthedition/Stasis.java b/Mage.Sets/src/mage/sets/fifthedition/Stasis.java index 4cd54133f3c..923c1f587ad 100644 --- a/Mage.Sets/src/mage/sets/fifthedition/Stasis.java +++ b/Mage.Sets/src/mage/sets/fifthedition/Stasis.java @@ -94,6 +94,6 @@ class SkipUntapStepEffect extends ContinuousRuleModifyingEffectImpl { Player controller = game.getPlayer(source.getControllerId()); return event.getType() == GameEvent.EventType.UNTAP_STEP && controller != null - && controller.getInRange().contains(event.getPlayerId()); + && game.getState().getPlayersInRange(controller.getId(), game).contains(event.getPlayerId()); } } diff --git a/Mage.Sets/src/mage/sets/futuresight/HomingSliver.java b/Mage.Sets/src/mage/sets/futuresight/HomingSliver.java index 31541ddd248..a83c8b17d4f 100644 --- a/Mage.Sets/src/mage/sets/futuresight/HomingSliver.java +++ b/Mage.Sets/src/mage/sets/futuresight/HomingSliver.java @@ -112,7 +112,7 @@ class HomingSliverEffect extends ContinuousEffectImpl { public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { - for (UUID playerId: controller.getInRange()) { + for (UUID playerId: game.getState().getPlayersInRange(controller.getId(), game)) { Player player = game.getPlayer(playerId); if (player != null) { for (Card card : player.getHand().getCards(filter, game)) { diff --git a/Mage.Sets/src/mage/sets/futuresight/Tarmogoyf.java b/Mage.Sets/src/mage/sets/futuresight/Tarmogoyf.java index d4824f85f57..bff78ef9093 100644 --- a/Mage.Sets/src/mage/sets/futuresight/Tarmogoyf.java +++ b/Mage.Sets/src/mage/sets/futuresight/Tarmogoyf.java @@ -97,7 +97,7 @@ class TarmogoyfEffect extends ContinuousEffectImpl { MageObject target = game.getObject(source.getSourceId()); if (target != null) { HashSet foundCardTypes = new HashSet<>(); - for (UUID playerId : controller.getInRange()) { + for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) { Player player = game.getPlayer(playerId); if (player != null) { for (Card card : player.getGraveyard().getCards(game)) { diff --git a/Mage.Sets/src/mage/sets/futuresight/YixlidJailer.java b/Mage.Sets/src/mage/sets/futuresight/YixlidJailer.java index dd701feb7e7..dd9a93f0c2b 100644 --- a/Mage.Sets/src/mage/sets/futuresight/YixlidJailer.java +++ b/Mage.Sets/src/mage/sets/futuresight/YixlidJailer.java @@ -94,7 +94,7 @@ public class YixlidJailer extends CardImpl { if (layer == Layer.AbilityAddingRemovingEffects_6) { Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { - for (UUID playerId : controller.getInRange()) { + for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) { Player player = game.getPlayer(playerId); if (player != null) { for (Card card : player.getGraveyard().getCards(game)) { diff --git a/Mage.Sets/src/mage/sets/gatecrash/WhisperingMadness.java b/Mage.Sets/src/mage/sets/gatecrash/WhisperingMadness.java index dbe8d2fd1f3..8f7c3fd959d 100644 --- a/Mage.Sets/src/mage/sets/gatecrash/WhisperingMadness.java +++ b/Mage.Sets/src/mage/sets/gatecrash/WhisperingMadness.java @@ -84,7 +84,7 @@ class WhisperingMadnessEffect extends OneShotEffect { if (sourcePlayer == null) { return false; } - for (UUID playerId : sourcePlayer.getInRange()) { + for (UUID playerId : game.getState().getPlayersInRange(sourcePlayer.getId(), game)) { Player player = game.getPlayer(playerId); if (player != null) { int discarded = 0; @@ -98,7 +98,7 @@ class WhisperingMadnessEffect extends OneShotEffect { } } } - for (UUID playerId : sourcePlayer.getInRange()) { + for (UUID playerId : game.getState().getPlayersInRange(sourcePlayer.getId(), game)) { Player player = game.getPlayer(playerId); if (player != null) { player.drawCards(maxDiscarded, game); diff --git a/Mage.Sets/src/mage/sets/iceage/Lhurgoyf.java b/Mage.Sets/src/mage/sets/iceage/Lhurgoyf.java index 7f7bcacc82a..903a70f4ab5 100644 --- a/Mage.Sets/src/mage/sets/iceage/Lhurgoyf.java +++ b/Mage.Sets/src/mage/sets/iceage/Lhurgoyf.java @@ -96,7 +96,7 @@ class LhurgoyfEffect extends ContinuousEffectImpl { MageObject mageObject = game.getObject(source.getSourceId()); if (mageObject != null) { int number = 0; - for (UUID playerId : controller.getInRange()) { + for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) { Player player = game.getPlayer(playerId); if (player != null) { number += player.getGraveyard().count(new FilterCreatureCard(), game); diff --git a/Mage.Sets/src/mage/sets/invasion/YawgmothsAgenda.java b/Mage.Sets/src/mage/sets/invasion/YawgmothsAgenda.java index 94605a43478..284febb69ad 100644 --- a/Mage.Sets/src/mage/sets/invasion/YawgmothsAgenda.java +++ b/Mage.Sets/src/mage/sets/invasion/YawgmothsAgenda.java @@ -103,7 +103,7 @@ class YawgmothsAgendaCanPlayCardsFromGraveyardEffect extends ContinuousEffectImp public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { - for (UUID playerId: controller.getInRange()) { + for (UUID playerId: game.getState().getPlayersInRange(controller.getId(), game)) { Player player = game.getPlayer(playerId); if (player != null) { diff --git a/Mage.Sets/src/mage/sets/jacevsvraska/SadisticAugermage.java b/Mage.Sets/src/mage/sets/jacevsvraska/SadisticAugermage.java index c741bf448b4..cafd654e8dd 100644 --- a/Mage.Sets/src/mage/sets/jacevsvraska/SadisticAugermage.java +++ b/Mage.Sets/src/mage/sets/jacevsvraska/SadisticAugermage.java @@ -90,7 +90,7 @@ class WidespreadPanicEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { - for (UUID playerId: controller.getInRange()) { + for (UUID playerId: game.getState().getPlayersInRange(controller.getId(), game)) { Player player = game.getPlayer(playerId); if (player != null) { if (player.getHand().size() > 0) { diff --git a/Mage.Sets/src/mage/sets/journeyintonyx/DakraMystic.java b/Mage.Sets/src/mage/sets/journeyintonyx/DakraMystic.java index 627a22afca9..9a2114d4fdd 100644 --- a/Mage.Sets/src/mage/sets/journeyintonyx/DakraMystic.java +++ b/Mage.Sets/src/mage/sets/journeyintonyx/DakraMystic.java @@ -97,14 +97,14 @@ class DakraMysticEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { - for(UUID playerId: controller.getInRange()) { + for(UUID playerId: game.getState().getPlayersInRange(controller.getId(), game)) { Player player = game.getPlayer(playerId); if (player != null && player.getLibrary().size() > 0) { player.revealCards(player.getLogName(), new CardsImpl(player.getLibrary().getFromTop(game)), game); } } if (controller.chooseUse(outcome, "Put revealed cards into graveyard?", source, game)) { - for(UUID playerId: controller.getInRange()) { + for(UUID playerId: game.getState().getPlayersInRange(controller.getId(), game)) { Player player = game.getPlayer(playerId); if (player != null && player.getLibrary().size() > 0) { player.moveCards(player.getLibrary().getFromTop(game), Zone.LIBRARY, Zone.GRAVEYARD, source, game); diff --git a/Mage.Sets/src/mage/sets/khansoftarkir/CracklingDoom.java b/Mage.Sets/src/mage/sets/khansoftarkir/CracklingDoom.java index 39d2fb0fadd..cb112a403f4 100644 --- a/Mage.Sets/src/mage/sets/khansoftarkir/CracklingDoom.java +++ b/Mage.Sets/src/mage/sets/khansoftarkir/CracklingDoom.java @@ -95,7 +95,7 @@ class CracklingDoomEffect extends OneShotEffect { Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { ArrayList toSacrifice = new ArrayList<>(); - for (UUID playerId: controller.getInRange()) { + for (UUID playerId: game.getState().getPlayersInRange(controller.getId(), game)) { if (controller.hasOpponent(playerId, game)) { Player opponent = game.getPlayer(playerId); if (opponent != null) { diff --git a/Mage.Sets/src/mage/sets/legions/GoblinAssassin.java b/Mage.Sets/src/mage/sets/legions/GoblinAssassin.java index 308da29ac93..ffe7911af59 100644 --- a/Mage.Sets/src/mage/sets/legions/GoblinAssassin.java +++ b/Mage.Sets/src/mage/sets/legions/GoblinAssassin.java @@ -123,7 +123,7 @@ class GoblinAssassinTriggeredEffect extends OneShotEffect { List perms = new ArrayList<>(); Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { - for (UUID playerId : controller.getInRange()) { + for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) { Player player = game.getPlayer(playerId); if (player != null && !player.flipCoin(game)) { TargetControlledCreaturePermanent target = new TargetControlledCreaturePermanent(); diff --git a/Mage.Sets/src/mage/sets/limitedbeta/Balance.java b/Mage.Sets/src/mage/sets/limitedbeta/Balance.java index f6e28cc32bb..5089b1bbcbc 100644 --- a/Mage.Sets/src/mage/sets/limitedbeta/Balance.java +++ b/Mage.Sets/src/mage/sets/limitedbeta/Balance.java @@ -57,7 +57,6 @@ public class Balance extends CardImpl { super(ownerId, 188, "Balance", Rarity.RARE, new CardType[]{CardType.SORCERY}, "{1}{W}"); this.expansionSetCode = "LEB"; - // Each player chooses a number of lands he or she controls equal to the number of lands controlled by the player who controls the fewest, then sacrifices the rest. Players discard cards and sacrifice creatures the same way. this.getSpellAbility().addEffect(new BalanceEffect()); } @@ -95,7 +94,7 @@ class BalanceEffect extends OneShotEffect { //Lands int minLand = Integer.MAX_VALUE; Cards landsToSacrifice = new CardsImpl(); - for (UUID playerId : controller.getInRange()) { + for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) { Player player = game.getPlayer(playerId); if (player != null) { int count = game.getBattlefield().countAll(new FilterControlledLandPermanent(), player.getId(), game); @@ -104,8 +103,8 @@ class BalanceEffect extends OneShotEffect { } } } - - for (UUID playerId : controller.getInRange()) { + + for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) { Player player = game.getPlayer(playerId); if (player != null) { TargetControlledPermanent target = new TargetControlledPermanent(minLand, minLand, new FilterControlledLandPermanent("lands to keep"), true); @@ -118,7 +117,7 @@ class BalanceEffect extends OneShotEffect { } } } - + for (UUID cardId : landsToSacrifice) { Permanent permanent = game.getPermanent(cardId); if (permanent != null) { @@ -129,7 +128,7 @@ class BalanceEffect extends OneShotEffect { //Creatures int minCreature = Integer.MAX_VALUE; Cards creaturesToSacrifice = new CardsImpl(); - for (UUID playerId : controller.getInRange()) { + for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) { Player player = game.getPlayer(playerId); if (player != null) { int count = game.getBattlefield().countAll(new FilterControlledCreaturePermanent(), player.getId(), game); @@ -139,7 +138,7 @@ class BalanceEffect extends OneShotEffect { } } - for (UUID playerId : controller.getInRange()) { + for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) { Player player = game.getPlayer(playerId); if (player != null) { TargetControlledPermanent target = new TargetControlledPermanent(minCreature, minCreature, new FilterControlledCreaturePermanent("creatures to keep"), true); @@ -152,18 +151,18 @@ class BalanceEffect extends OneShotEffect { } } } - + for (UUID cardId : creaturesToSacrifice) { Permanent permanent = game.getPermanent(cardId); if (permanent != null) { permanent.sacrifice(source.getSourceId(), game); } } - + //Cards in hand int minCard = Integer.MAX_VALUE; HashMap cardsToDiscard = new HashMap<>(2); - for (UUID playerId : controller.getInRange()) { + for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) { Player player = game.getPlayer(playerId); if (player != null) { int count = player.getHand().size(); @@ -173,7 +172,7 @@ class BalanceEffect extends OneShotEffect { } } - for (UUID playerId : controller.getInRange()) { + for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) { Player player = game.getPlayer(playerId); if (player != null) { Cards cards = new CardsImpl(); @@ -188,8 +187,8 @@ class BalanceEffect extends OneShotEffect { } } } - - for (UUID playerId : controller.getInRange()) { + + for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) { Player player = game.getPlayer(playerId); if (player != null && cardsToDiscard.get(playerId) != null) { for (UUID cardId : cardsToDiscard.get(playerId)) { @@ -204,4 +203,4 @@ class BalanceEffect extends OneShotEffect { } return false; } -} \ No newline at end of file +} diff --git a/Mage.Sets/src/mage/sets/magic2010/LilianaVess.java b/Mage.Sets/src/mage/sets/magic2010/LilianaVess.java index 7ab2a913ae9..cde58614437 100644 --- a/Mage.Sets/src/mage/sets/magic2010/LilianaVess.java +++ b/Mage.Sets/src/mage/sets/magic2010/LilianaVess.java @@ -97,7 +97,7 @@ class LilianaVessEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); - for (UUID playerId : controller.getInRange()) { + for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) { Player player = game.getPlayer(playerId); if (player != null) { Set creatureCards = new LinkedHashSet<>(); diff --git a/Mage.Sets/src/mage/sets/magic2012/VisionsOfBeyond.java b/Mage.Sets/src/mage/sets/magic2012/VisionsOfBeyond.java index b3cadb96a61..1dd1cafa636 100644 --- a/Mage.Sets/src/mage/sets/magic2012/VisionsOfBeyond.java +++ b/Mage.Sets/src/mage/sets/magic2012/VisionsOfBeyond.java @@ -78,7 +78,7 @@ class VisionsOfBeyondEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { Player sourcePlayer = game.getPlayer(source.getControllerId()); int count = 1; - for (UUID playerId: sourcePlayer.getInRange()) { + for (UUID playerId: game.getState().getPlayersInRange(sourcePlayer.getId(), game)) { Player player = game.getPlayer(playerId); if (player != null) { if (player.getGraveyard().size() >= 20) { diff --git a/Mage.Sets/src/mage/sets/magic2014/RiseOfTheDarkRealms.java b/Mage.Sets/src/mage/sets/magic2014/RiseOfTheDarkRealms.java index 208ad4469d4..63055e8ca65 100644 --- a/Mage.Sets/src/mage/sets/magic2014/RiseOfTheDarkRealms.java +++ b/Mage.Sets/src/mage/sets/magic2014/RiseOfTheDarkRealms.java @@ -82,7 +82,7 @@ class RiseOfTheDarkRealmsEffect extends OneShotEffect { if (controller != null) { Set creatureCards = new LinkedHashSet<>(); - for (UUID playerId : controller.getInRange()) { + for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) { Player player = game.getPlayer(playerId); if (player != null) { for (Card card : player.getGraveyard().getCards(game)) { diff --git a/Mage.Sets/src/mage/sets/magic2015/JaceTheLivingGuildpact.java b/Mage.Sets/src/mage/sets/magic2015/JaceTheLivingGuildpact.java index 7d4c32fbbaa..796b76aab92 100644 --- a/Mage.Sets/src/mage/sets/magic2015/JaceTheLivingGuildpact.java +++ b/Mage.Sets/src/mage/sets/magic2015/JaceTheLivingGuildpact.java @@ -110,7 +110,7 @@ class JaceTheLivingGuildpactEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { - for (UUID playerId : controller.getInRange()) { + for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) { Player player = game.getPlayer(playerId); if (player != null) { for (Card card : player.getHand().getCards(game)) { diff --git a/Mage.Sets/src/mage/sets/mediainserts/MagisterOfWorth.java b/Mage.Sets/src/mage/sets/mediainserts/MagisterOfWorth.java index 0c293502e33..b1e88e49b04 100644 --- a/Mage.Sets/src/mage/sets/mediainserts/MagisterOfWorth.java +++ b/Mage.Sets/src/mage/sets/mediainserts/MagisterOfWorth.java @@ -173,7 +173,7 @@ class MagisterOfWorthReturnFromGraveyardEffect extends OneShotEffect { Player controller = game.getPlayer(source.getControllerId()); MageObject sourceObject = game.getObject(source.getSourceId()); if (controller != null && sourceObject != null) { - for (UUID playerId : controller.getInRange()) { + for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) { Player player = game.getPlayer(playerId); if (player != null) { player.moveCards(player.getGraveyard().getCards(new FilterCreatureCard(), game), Zone.BATTLEFIELD, source, game); diff --git a/Mage.Sets/src/mage/sets/mirage/WaitingInTheWeeds.java b/Mage.Sets/src/mage/sets/mirage/WaitingInTheWeeds.java index 5bde63fc273..acfcdfd9fbd 100644 --- a/Mage.Sets/src/mage/sets/mirage/WaitingInTheWeeds.java +++ b/Mage.Sets/src/mage/sets/mirage/WaitingInTheWeeds.java @@ -96,7 +96,7 @@ class WaitingInTheWeedsEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { - for (UUID playerId : controller.getInRange()) { + for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) { Token token = new CatToken(); int amount = game.getBattlefield().getAllActivePermanents(filter, playerId, game).size(); token.putOntoBattlefield(amount, game, source.getSourceId(), playerId); diff --git a/Mage.Sets/src/mage/sets/mirrodin/TemporalCascade.java b/Mage.Sets/src/mage/sets/mirrodin/TemporalCascade.java index 7767cfbe069..608423f382f 100644 --- a/Mage.Sets/src/mage/sets/mirrodin/TemporalCascade.java +++ b/Mage.Sets/src/mage/sets/mirrodin/TemporalCascade.java @@ -87,7 +87,7 @@ class TemporalCascadeShuffleEffect extends OneShotEffect { @java.lang.Override public boolean apply(Game game, Ability source) { Player sourcePlayer = game.getPlayer(source.getControllerId()); - for (UUID playerId: sourcePlayer.getInRange()) { + for (UUID playerId: game.getState().getPlayersInRange(sourcePlayer.getId(), game)) { Player player = game.getPlayer(playerId); if (player != null) { for (Card card: player.getHand().getCards(game)) { @@ -124,7 +124,7 @@ class TemporalCascadeDrawEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { Player sourcePlayer = game.getPlayer(source.getControllerId()); game.getState().handleSimultaneousEvent(game); // needed here so state based triggered effects - for (UUID playerId: sourcePlayer.getInRange()) { + for (UUID playerId: game.getState().getPlayersInRange(sourcePlayer.getId(), game)) { Player player = game.getPlayer(playerId); if (player != null) { player.drawCards(7, game); diff --git a/Mage.Sets/src/mage/sets/mirrodinbesieged/KnowledgePool.java b/Mage.Sets/src/mage/sets/mirrodinbesieged/KnowledgePool.java index 57fc2668225..8e5c3114ca5 100644 --- a/Mage.Sets/src/mage/sets/mirrodinbesieged/KnowledgePool.java +++ b/Mage.Sets/src/mage/sets/mirrodinbesieged/KnowledgePool.java @@ -97,7 +97,7 @@ class KnowledgePoolEffect1 extends OneShotEffect { if (controller == null || sourceObject == null) { return false; } - for (UUID playerId : controller.getInRange()) { + for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) { Player player = game.getPlayer(playerId); if (player != null) { player.moveCardsToExile(player.getLibrary().getTopCards(game, 3), source, game, true, diff --git a/Mage.Sets/src/mage/sets/modernmasters/MoltenDisaster.java b/Mage.Sets/src/mage/sets/modernmasters/MoltenDisaster.java index a128aceb257..8bf15c284ec 100644 --- a/Mage.Sets/src/mage/sets/modernmasters/MoltenDisaster.java +++ b/Mage.Sets/src/mage/sets/modernmasters/MoltenDisaster.java @@ -159,7 +159,7 @@ class MoltenDisasterEffect extends OneShotEffect { for (Permanent permanent: game.getBattlefield().getActivePermanents(filter, source.getControllerId(), game)) { permanent.damage(amount, source.getSourceId(), game, false, true); } - for (UUID playerId: game.getPlayer(source.getControllerId()).getInRange()) { + for (UUID playerId: game.getState().getPlayersInRange(source.getControllerId(), game)) { Player player = game.getPlayer(playerId); if (player != null) { player.damage(amount, source.getSourceId(), game, false, true); diff --git a/Mage.Sets/src/mage/sets/ninthedition/GravePact.java b/Mage.Sets/src/mage/sets/ninthedition/GravePact.java index c501bccf124..6084024755d 100644 --- a/Mage.Sets/src/mage/sets/ninthedition/GravePact.java +++ b/Mage.Sets/src/mage/sets/ninthedition/GravePact.java @@ -130,7 +130,7 @@ class GravePactEffect extends OneShotEffect { List perms = new ArrayList<>(); Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { - for (UUID playerId : controller.getInRange()) { + for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) { Player player = game.getPlayer(playerId); if (player != null && !playerId.equals(source.getControllerId())) { TargetControlledCreaturePermanent target = new TargetControlledCreaturePermanent(); diff --git a/Mage.Sets/src/mage/sets/ninthedition/HuntedWumpus.java b/Mage.Sets/src/mage/sets/ninthedition/HuntedWumpus.java index 83d5ebc28b9..b26dbd88cce 100644 --- a/Mage.Sets/src/mage/sets/ninthedition/HuntedWumpus.java +++ b/Mage.Sets/src/mage/sets/ninthedition/HuntedWumpus.java @@ -92,7 +92,7 @@ class HuntedWumpusEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { - for(UUID playerId: controller.getInRange()) { + for(UUID playerId: game.getState().getPlayersInRange(controller.getId(), game)) { if (!playerId.equals(controller.getId())) { Player player = game.getPlayer(playerId); if (player != null) { diff --git a/Mage.Sets/src/mage/sets/odyssey/AEtherBurst.java b/Mage.Sets/src/mage/sets/odyssey/AEtherBurst.java index 0a14568ad49..6452f273f94 100644 --- a/Mage.Sets/src/mage/sets/odyssey/AEtherBurst.java +++ b/Mage.Sets/src/mage/sets/odyssey/AEtherBurst.java @@ -72,7 +72,7 @@ public class AEtherBurst extends CardImpl { Player controller = game.getPlayer(ability.getControllerId()); int amount = 0; if (controller != null) { - for (UUID playerId : controller.getInRange()) { + for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) { Player player = game.getPlayer(playerId); if (player != null) { amount += player.getGraveyard().getCards(filter, game).size(); diff --git a/Mage.Sets/src/mage/sets/odyssey/BalancingAct.java b/Mage.Sets/src/mage/sets/odyssey/BalancingAct.java index f399fc67871..e3dd9602c2e 100644 --- a/Mage.Sets/src/mage/sets/odyssey/BalancingAct.java +++ b/Mage.Sets/src/mage/sets/odyssey/BalancingAct.java @@ -93,7 +93,7 @@ class BalancingActEffect extends OneShotEffect { if (controller != null) { int minPermanent = Integer.MAX_VALUE, minCard = Integer.MAX_VALUE; // count minimal permanets - for(UUID playerId : controller.getInRange()){ + for(UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)){ Player player = game.getPlayer(playerId); if(player != null){ int count = game.getBattlefield().getActivePermanents(new FilterControlledPermanent(), player.getId(), source.getSourceId(), game).size(); @@ -103,7 +103,7 @@ class BalancingActEffect extends OneShotEffect { } } // sacrifice permanents over the minimum - for(UUID playerId : controller.getInRange()){ + for(UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)){ Player player = game.getPlayer(playerId); if(player != null){ TargetControlledPermanent target = new TargetControlledPermanent(minPermanent, minPermanent, new FilterControlledPermanent(), true); @@ -118,7 +118,7 @@ class BalancingActEffect extends OneShotEffect { } // count minimal cards in hand - for(UUID playerId : controller.getInRange()){ + for(UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)){ Player player = game.getPlayer(playerId); if(player != null){ int count = player.getHand().size(); @@ -129,7 +129,7 @@ class BalancingActEffect extends OneShotEffect { } // discard cards over the minimum - for(UUID playerId : controller.getInRange()){ + for(UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)){ Player player = game.getPlayer(playerId); if(player != null){ TargetCardInHand target = new TargetCardInHand(minCard, new FilterCard()); diff --git a/Mage.Sets/src/mage/sets/odyssey/WordsOfWisdom.java b/Mage.Sets/src/mage/sets/odyssey/WordsOfWisdom.java index e0dfe85b015..eab204cadd5 100644 --- a/Mage.Sets/src/mage/sets/odyssey/WordsOfWisdom.java +++ b/Mage.Sets/src/mage/sets/odyssey/WordsOfWisdom.java @@ -85,7 +85,7 @@ class WordsOfWisdomEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { - for(UUID playerId: controller.getInRange()) { + for(UUID playerId: game.getState().getPlayersInRange(controller.getId(), game)) { if (!playerId.equals(controller.getId())) { Player player = game.getPlayer(playerId); if (player != null) { diff --git a/Mage.Sets/src/mage/sets/onslaught/SoullessOne.java b/Mage.Sets/src/mage/sets/onslaught/SoullessOne.java index ad8771e5595..3beda6fdca3 100644 --- a/Mage.Sets/src/mage/sets/onslaught/SoullessOne.java +++ b/Mage.Sets/src/mage/sets/onslaught/SoullessOne.java @@ -85,7 +85,7 @@ class SoullessOneDynamicCount implements DynamicValue { zombiesInGraveyard.add(new SubtypePredicate("Zombie")); int count = game.getBattlefield().count(zombiesBattlefield, sourceAbility.getSourceId(), sourceAbility.getControllerId(), game); - for (UUID playerId : game.getPlayer(sourceAbility.getControllerId()).getInRange()) { + for (UUID playerId : game.getState().getPlayersInRange(sourceAbility.getControllerId(), game)) { Player player = game.getPlayer(playerId); if (player != null) { count += player.getGraveyard().count(zombiesInGraveyard, game); diff --git a/Mage.Sets/src/mage/sets/onslaught/WeirdHarvest.java b/Mage.Sets/src/mage/sets/onslaught/WeirdHarvest.java index 788ec1f3ab5..2818d332799 100644 --- a/Mage.Sets/src/mage/sets/onslaught/WeirdHarvest.java +++ b/Mage.Sets/src/mage/sets/onslaught/WeirdHarvest.java @@ -94,7 +94,7 @@ class WeirdHarvestEffect extends OneShotEffect { if (xValue > 0) { List usingPlayers = new ArrayList<>(); this.chooseAndSearchLibrary(usingPlayers, controller, xValue, source, sourceObject, game); - for (UUID playerId : controller.getInRange()) { + for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) { if (!playerId.equals(controller.getId())) { Player player = game.getPlayer(playerId); if (player != null) { diff --git a/Mage.Sets/src/mage/sets/planarchaos/Detritivore.java b/Mage.Sets/src/mage/sets/planarchaos/Detritivore.java index bfa18d8ca8a..889f88f041a 100644 --- a/Mage.Sets/src/mage/sets/planarchaos/Detritivore.java +++ b/Mage.Sets/src/mage/sets/planarchaos/Detritivore.java @@ -137,7 +137,7 @@ class NonBasicLandsInOpponentsGraveyards implements DynamicValue { int amount = 0; Player controller = game.getPlayer(sourceAbility.getControllerId()); if (controller != null) { - for (UUID playerUUID : controller.getInRange()) { + for (UUID playerUUID : game.getState().getPlayersInRange(controller.getId(), game)) { if (controller.hasOpponent(playerUUID, game)) { Player player = game.getPlayer(playerUUID); if (player != null) { diff --git a/Mage.Sets/src/mage/sets/planarchaos/RoilingHorror.java b/Mage.Sets/src/mage/sets/planarchaos/RoilingHorror.java index 7330a1cdcbc..c151e3dd031 100644 --- a/Mage.Sets/src/mage/sets/planarchaos/RoilingHorror.java +++ b/Mage.Sets/src/mage/sets/planarchaos/RoilingHorror.java @@ -129,7 +129,7 @@ class RoilingHorrorDynamicValue implements DynamicValue { int opponentsMostLife = Integer.MIN_VALUE; Player controller = game.getPlayer(sourceAbility.getControllerId()); if (controller != null) { - for (UUID playerUUID : controller.getInRange()) { + for (UUID playerUUID : game.getState().getPlayersInRange(controller.getId(), game)) { if (controller.hasOpponent(playerUUID, game)) { Player opponent = game.getPlayer(playerUUID); if (opponent != null && opponent.getLife() > opponentsMostLife) { diff --git a/Mage.Sets/src/mage/sets/planarchaos/ShivanWumpus.java b/Mage.Sets/src/mage/sets/planarchaos/ShivanWumpus.java index c84a23e79f0..8a8e2061c94 100644 --- a/Mage.Sets/src/mage/sets/planarchaos/ShivanWumpus.java +++ b/Mage.Sets/src/mage/sets/planarchaos/ShivanWumpus.java @@ -95,7 +95,7 @@ class ShivanWumpusEffect extends PutOnLibrarySourceEffect { Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { boolean costPaid = false; - for (UUID playerId : controller.getInRange()) { + for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) { Cost cost = new SacrificeTargetCost(new TargetControlledPermanent(new FilterControlledLandPermanent())); Player player = game.getPlayer(playerId); if (player != null diff --git a/Mage.Sets/src/mage/sets/ravnica/MnemonicNexus.java b/Mage.Sets/src/mage/sets/ravnica/MnemonicNexus.java index 09ae87683b8..6cbfa4b855a 100644 --- a/Mage.Sets/src/mage/sets/ravnica/MnemonicNexus.java +++ b/Mage.Sets/src/mage/sets/ravnica/MnemonicNexus.java @@ -77,7 +77,7 @@ class MnemonicNexusEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player sourcePlayer = game.getPlayer(source.getControllerId()); - for (UUID playerId: sourcePlayer.getInRange()) { + for (UUID playerId: game.getState().getPlayersInRange(sourcePlayer.getId(), game)) { Player player = game.getPlayer(playerId); if (player != null) { for (Card card: player.getGraveyard().getCards(game)) { diff --git a/Mage.Sets/src/mage/sets/ravnica/SavraQueenOfTheGolgari.java b/Mage.Sets/src/mage/sets/ravnica/SavraQueenOfTheGolgari.java index f007a3ce821..3cbadb09445 100644 --- a/Mage.Sets/src/mage/sets/ravnica/SavraQueenOfTheGolgari.java +++ b/Mage.Sets/src/mage/sets/ravnica/SavraQueenOfTheGolgari.java @@ -138,7 +138,7 @@ class SavraSacrificeEffect extends OneShotEffect { List perms = new ArrayList<>(); Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { - for (UUID playerId : controller.getInRange()) { + for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) { Player player = game.getPlayer(playerId); if (player != null && !playerId.equals(source.getControllerId())) { TargetControlledCreaturePermanent target = new TargetControlledCreaturePermanent(); diff --git a/Mage.Sets/src/mage/sets/returntoravnica/JaceArchitectOfThought.java b/Mage.Sets/src/mage/sets/returntoravnica/JaceArchitectOfThought.java index 56ca27938e5..3625172df12 100644 --- a/Mage.Sets/src/mage/sets/returntoravnica/JaceArchitectOfThought.java +++ b/Mage.Sets/src/mage/sets/returntoravnica/JaceArchitectOfThought.java @@ -297,7 +297,7 @@ class JaceArchitectOfThoughtEffect3 extends OneShotEffect { if (controller == null || sourcePermanent == null) { return false; } - for (UUID playerId : controller.getInRange()) { + for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) { Player player = game.getPlayer(playerId); String playerName = new StringBuilder(player.getLogName()).append("'s").toString(); if (source.getControllerId().equals(player.getId())) { diff --git a/Mage.Sets/src/mage/sets/returntoravnica/SkullRend.java b/Mage.Sets/src/mage/sets/returntoravnica/SkullRend.java index b267409c6c7..ad405446813 100644 --- a/Mage.Sets/src/mage/sets/returntoravnica/SkullRend.java +++ b/Mage.Sets/src/mage/sets/returntoravnica/SkullRend.java @@ -79,7 +79,7 @@ public class SkullRend extends CardImpl { public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { - for (UUID playerId: controller.getInRange()) { + for (UUID playerId: game.getState().getPlayersInRange(controller.getId(), game)) { if (playerId != source.getControllerId()) { Player opponent = game.getPlayer(playerId); if (opponent != null) { diff --git a/Mage.Sets/src/mage/sets/saviorsofkamigawa/SokenzanRenegade.java b/Mage.Sets/src/mage/sets/saviorsofkamigawa/SokenzanRenegade.java index 08c08995814..6074eacf1d2 100644 --- a/Mage.Sets/src/mage/sets/saviorsofkamigawa/SokenzanRenegade.java +++ b/Mage.Sets/src/mage/sets/saviorsofkamigawa/SokenzanRenegade.java @@ -109,7 +109,7 @@ class SokenzanRenegadeEffect extends OneShotEffect { if (controller != null && sourcePermanent != null) { int max = Integer.MIN_VALUE; Player newController = null; - for(UUID playerId : controller.getInRange()) { + for(UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) { Player player = game.getPlayer(playerId); if (player != null) { if (player.getLife() > max) { @@ -146,7 +146,7 @@ class OnePlayerHasTheMostCards implements Condition { if (controller != null) { int max = Integer.MIN_VALUE; boolean onlyOnePlayer = false; - for(UUID playerId : controller.getInRange()) { + for(UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) { Player player = game.getPlayer(playerId); if (player != null) { if (player.getLife() > max) { diff --git a/Mage.Sets/src/mage/sets/saviorsofkamigawa/ThoughtsOfRuin.java b/Mage.Sets/src/mage/sets/saviorsofkamigawa/ThoughtsOfRuin.java index 43fa08caaba..7756bb475f4 100644 --- a/Mage.Sets/src/mage/sets/saviorsofkamigawa/ThoughtsOfRuin.java +++ b/Mage.Sets/src/mage/sets/saviorsofkamigawa/ThoughtsOfRuin.java @@ -96,7 +96,7 @@ class ThoughtsOfRuinEffect extends OneShotEffect { if (amount > 0) { List permanentsToSacrifice = new ArrayList(); // select all lands to sacrifice - for (UUID playerId : controller.getInRange()) { + for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) { Player player = game.getPlayer(playerId); if (player != null) { int lands = game.getState().getBattlefield().countAll(filter, playerId, game); diff --git a/Mage.Sets/src/mage/sets/seventhedition/NaturesResurgence.java b/Mage.Sets/src/mage/sets/seventhedition/NaturesResurgence.java index 0686fc8fb61..90799cbdfee 100644 --- a/Mage.Sets/src/mage/sets/seventhedition/NaturesResurgence.java +++ b/Mage.Sets/src/mage/sets/seventhedition/NaturesResurgence.java @@ -86,7 +86,7 @@ class NaturesResurgenceEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { Player sourcePlayer = game.getPlayer(source.getControllerId()); if (sourcePlayer != null) { - for (UUID playerId : sourcePlayer.getInRange()) { + for (UUID playerId : game.getState().getPlayersInRange(sourcePlayer.getId(), game)) { Player player = game.getPlayer(playerId); if (player != null) { int amount = player.getGraveyard().count(filter, game); diff --git a/Mage.Sets/src/mage/sets/shadowmoor/AdviceFromTheFae.java b/Mage.Sets/src/mage/sets/shadowmoor/AdviceFromTheFae.java index 7cb1a0c1b45..a5791ef4023 100644 --- a/Mage.Sets/src/mage/sets/shadowmoor/AdviceFromTheFae.java +++ b/Mage.Sets/src/mage/sets/shadowmoor/AdviceFromTheFae.java @@ -102,7 +102,7 @@ class AdviceFromTheFaeEffect extends OneShotEffect { } controller.lookAtCards(mageObject.getIdName(), cardsFromLibrary, game); int max = 0; - for (UUID playerId : controller.getInRange()) { + for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) { FilterCreaturePermanent filter = new FilterCreaturePermanent(); filter.add(new ControllerIdPredicate(playerId)); if (playerId != controller.getId()) { diff --git a/Mage.Sets/src/mage/sets/shadowmoor/PaintersServant.java b/Mage.Sets/src/mage/sets/shadowmoor/PaintersServant.java index 8ec07fbc98f..ec780359bf0 100644 --- a/Mage.Sets/src/mage/sets/shadowmoor/PaintersServant.java +++ b/Mage.Sets/src/mage/sets/shadowmoor/PaintersServant.java @@ -119,7 +119,7 @@ class PaintersServantEffect extends ContinuousEffectImpl { } } - for (UUID playerId : controller.getInRange()) { + for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) { Player player = game.getPlayer(playerId); if (player != null) { // Hand diff --git a/Mage.Sets/src/mage/sets/shadowmoor/PlagueOfVermin.java b/Mage.Sets/src/mage/sets/shadowmoor/PlagueOfVermin.java index a494bd2cb7e..e15b62115a2 100644 --- a/Mage.Sets/src/mage/sets/shadowmoor/PlagueOfVermin.java +++ b/Mage.Sets/src/mage/sets/shadowmoor/PlagueOfVermin.java @@ -103,7 +103,7 @@ class PlagueOfVerminEffect extends OneShotEffect { if (firstInactivePlayer == null) { firstInactivePlayer = currentPlayer.getId(); } - if (currentPlayer != null && currentPlayer.canRespond() && controller.getInRange().contains(currentPlayer.getId())) { + if (currentPlayer != null && currentPlayer.canRespond() && game.getState().getPlayersInRange(controller.getId(), game).contains(currentPlayer.getId())) { currentLifePaid = 0; totalPaidLife = 0; if (currentPlayer.chooseUse(Outcome.AIDontUseIt, "Pay life?", source, game)) { diff --git a/Mage.Sets/src/mage/sets/shardsofalara/SphinxSovereign.java b/Mage.Sets/src/mage/sets/shardsofalara/SphinxSovereign.java index 1e0ef0846bb..7dbef6b8fce 100644 --- a/Mage.Sets/src/mage/sets/shardsofalara/SphinxSovereign.java +++ b/Mage.Sets/src/mage/sets/shardsofalara/SphinxSovereign.java @@ -95,7 +95,7 @@ class SphinxSovereignEffect extends OneShotEffect { if (!permanent.isTapped()) { controller.gainLife(3, game); } else { - for (UUID opponentId : controller.getInRange()) { + for (UUID opponentId : game.getState().getPlayersInRange(controller.getId(), game)) { if (controller.hasOpponent(opponentId, game)) { Player opponent = game.getPlayer(opponentId); if (opponent != null) { diff --git a/Mage.Sets/src/mage/sets/stronghold/DreamHalls.java b/Mage.Sets/src/mage/sets/stronghold/DreamHalls.java index e0a0b4c45ff..f1e05b98c6b 100644 --- a/Mage.Sets/src/mage/sets/stronghold/DreamHalls.java +++ b/Mage.Sets/src/mage/sets/stronghold/DreamHalls.java @@ -101,7 +101,7 @@ class DreamHallsEffect extends ContinuousEffectImpl { public boolean apply(Layer layer, SubLayer sublayer, Ability source, Game game) { Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { - for (UUID playerId : controller.getInRange()) { + for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) { Player player = game.getPlayer(playerId); if (player != null) { player.getAlternativeSourceCosts().add(alternativeCastingCostAbility); diff --git a/Mage.Sets/src/mage/sets/tempest/Aluren.java b/Mage.Sets/src/mage/sets/tempest/Aluren.java index baba29b103a..8ed92bf23c4 100644 --- a/Mage.Sets/src/mage/sets/tempest/Aluren.java +++ b/Mage.Sets/src/mage/sets/tempest/Aluren.java @@ -123,7 +123,7 @@ class AlurenRuleEffect extends ContinuousEffectImpl { public boolean apply(Layer layer, SubLayer sublayer, Ability source, Game game) { Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { - for (UUID playerId: controller.getInRange()){ + for (UUID playerId: game.getState().getPlayersInRange(controller.getId(), game)){ Player player = game.getPlayer(playerId); if (player != null) { player.getAlternativeSourceCosts().add(alternativeCastingCostAbility); diff --git a/Mage.Sets/src/mage/sets/tenthedition/Upwelling.java b/Mage.Sets/src/mage/sets/tenthedition/Upwelling.java index 131e69ac3ac..3cceea39376 100644 --- a/Mage.Sets/src/mage/sets/tenthedition/Upwelling.java +++ b/Mage.Sets/src/mage/sets/tenthedition/Upwelling.java @@ -90,7 +90,7 @@ class UpwellingRuleEffect extends ContinuousEffectImpl { public boolean apply(Layer layer, SubLayer sublayer, Ability source, Game game) { Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { - for (UUID playerId: controller.getInRange()) { + for (UUID playerId: game.getState().getPlayersInRange(controller.getId(), game)) { Player player = game.getPlayer(playerId); if (player != null){ ManaPool pool = player.getManaPool(); diff --git a/Mage.Sets/src/mage/sets/theros/PyxisOfPandemonium.java b/Mage.Sets/src/mage/sets/theros/PyxisOfPandemonium.java index ae89cc24db2..e80bad947a4 100644 --- a/Mage.Sets/src/mage/sets/theros/PyxisOfPandemonium.java +++ b/Mage.Sets/src/mage/sets/theros/PyxisOfPandemonium.java @@ -111,7 +111,7 @@ class PyxisOfPandemoniumExileEffect extends OneShotEffect { game.getState().setValue(valueKey, exileIds); } - for (UUID playerId : controller.getInRange()) { + for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) { Player player = game.getPlayer(playerId); if (player != null) { diff --git a/Mage.Sets/src/mage/sets/timespiral/Hypergenesis.java b/Mage.Sets/src/mage/sets/timespiral/Hypergenesis.java index d2b840b0cb1..054e25cbb1e 100644 --- a/Mage.Sets/src/mage/sets/timespiral/Hypergenesis.java +++ b/Mage.Sets/src/mage/sets/timespiral/Hypergenesis.java @@ -111,7 +111,7 @@ class HypergenesisEffect extends OneShotEffect { Target target = new TargetCardInHand(filter); while (controller.canRespond()) { - if (currentPlayer != null && currentPlayer.canRespond() && controller.getInRange().contains(currentPlayer.getId())) { + if (currentPlayer != null && currentPlayer.canRespond() && game.getState().getPlayersInRange(controller.getId(), game).contains(currentPlayer.getId())) { if (firstInactivePlayer == null) { firstInactivePlayer = currentPlayer.getId(); } diff --git a/Mage.Sets/src/mage/sets/timespiral/RestoreBalance.java b/Mage.Sets/src/mage/sets/timespiral/RestoreBalance.java index 3706375f0ee..335dc7da95f 100644 --- a/Mage.Sets/src/mage/sets/timespiral/RestoreBalance.java +++ b/Mage.Sets/src/mage/sets/timespiral/RestoreBalance.java @@ -102,7 +102,7 @@ class RestoreBalanceEffect extends OneShotEffect { //Lands int minLand = Integer.MAX_VALUE; Cards landsToSacrifice = new CardsImpl(); - for (UUID playerId : controller.getInRange()) { + for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) { Player player = game.getPlayer(playerId); if (player != null) { int count = game.getBattlefield().countAll(new FilterControlledLandPermanent(), player.getId(), game); @@ -112,7 +112,7 @@ class RestoreBalanceEffect extends OneShotEffect { } } - for (UUID playerId : controller.getInRange()) { + for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) { Player player = game.getPlayer(playerId); if (player != null) { TargetControlledPermanent target = new TargetControlledPermanent(minLand, minLand, new FilterControlledLandPermanent(), true); @@ -136,7 +136,7 @@ class RestoreBalanceEffect extends OneShotEffect { //Creatures int minCreature = Integer.MAX_VALUE; Cards creaturesToSacrifice = new CardsImpl(); - for (UUID playerId : controller.getInRange()) { + for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) { Player player = game.getPlayer(playerId); if (player != null) { int count = game.getBattlefield().countAll(new FilterControlledCreaturePermanent(), player.getId(), game); @@ -146,7 +146,7 @@ class RestoreBalanceEffect extends OneShotEffect { } } - for (UUID playerId : controller.getInRange()) { + for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) { Player player = game.getPlayer(playerId); if (player != null) { TargetControlledPermanent target = new TargetControlledPermanent(minCreature, minCreature, new FilterControlledCreaturePermanent(), true); @@ -170,7 +170,7 @@ class RestoreBalanceEffect extends OneShotEffect { //Cards in hand int minCard = Integer.MAX_VALUE; HashMap cardsToDiscard = new HashMap<>(2); - for (UUID playerId : controller.getInRange()) { + for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) { Player player = game.getPlayer(playerId); if (player != null) { int count = player.getHand().size(); @@ -180,7 +180,7 @@ class RestoreBalanceEffect extends OneShotEffect { } } - for (UUID playerId : controller.getInRange()) { + for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) { Player player = game.getPlayer(playerId); if (player != null) { Cards cards = new CardsImpl(); @@ -196,7 +196,7 @@ class RestoreBalanceEffect extends OneShotEffect { } } - for (UUID playerId : controller.getInRange()) { + for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) { Player player = game.getPlayer(playerId); if (player != null && cardsToDiscard.get(playerId) != null) { for (UUID cardId : cardsToDiscard.get(playerId)) { diff --git a/Mage.Sets/src/mage/sets/timespiral/UrborgSyphonMage.java b/Mage.Sets/src/mage/sets/timespiral/UrborgSyphonMage.java index c437d0a420a..9388d501ce9 100644 --- a/Mage.Sets/src/mage/sets/timespiral/UrborgSyphonMage.java +++ b/Mage.Sets/src/mage/sets/timespiral/UrborgSyphonMage.java @@ -91,7 +91,7 @@ class UrborgSyphonMageEffect extends OneShotEffect { int damage = 0; Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { - for (UUID playerId : controller.getInRange()) { + for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) { if (playerId != source.getControllerId()) { Player player = game.getPlayer(playerId); if (player != null) { diff --git a/Mage.Sets/src/mage/sets/urzaslegacy/MemoryJar.java b/Mage.Sets/src/mage/sets/urzaslegacy/MemoryJar.java index 7096f318a4d..7546dd79e2f 100644 --- a/Mage.Sets/src/mage/sets/urzaslegacy/MemoryJar.java +++ b/Mage.Sets/src/mage/sets/urzaslegacy/MemoryJar.java @@ -97,7 +97,7 @@ class MemoryJarEffect extends OneShotEffect { { Cards cards = new CardsImpl(); //Exile hand - for (UUID playerId: game.getPlayer(source.getControllerId()).getInRange()) { + for (UUID playerId: game.getState().getPlayersInRange(source.getControllerId(), game)) { Player player = game.getPlayer(playerId); if (player != null) { @@ -114,7 +114,7 @@ class MemoryJarEffect extends OneShotEffect { } } //Draw 7 cards - for (UUID playerId: game.getPlayer(source.getControllerId()).getInRange()) { + for (UUID playerId: game.getState().getPlayersInRange(source.getControllerId(), game)) { Player player = game.getPlayer(playerId); if (player != null) { @@ -162,7 +162,7 @@ class MemoryJarDelayedEffect extends OneShotEffect { if(cards != null) { //Discard - for (UUID playerId: game.getPlayer(source.getControllerId()).getInRange()) { + for (UUID playerId: game.getState().getPlayersInRange(source.getControllerId(), game)) { Player player = game.getPlayer(playerId); if (player != null) { diff --git a/Mage.Sets/src/mage/sets/urzassaga/AcidicSoil.java b/Mage.Sets/src/mage/sets/urzassaga/AcidicSoil.java index 1baa9aee39b..cadf79ed453 100644 --- a/Mage.Sets/src/mage/sets/urzassaga/AcidicSoil.java +++ b/Mage.Sets/src/mage/sets/urzassaga/AcidicSoil.java @@ -80,7 +80,7 @@ class AcidicSoilEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { List permanents = game.getBattlefield().getActivePermanents(new FilterLandPermanent(), source.getControllerId(), source.getSourceId(), game); - for (UUID playerId : game.getPlayer(source.getControllerId()).getInRange()) { + for (UUID playerId : game.getState().getPlayersInRange(source.getControllerId(), game)) { Player player = game.getPlayer(playerId); if (player != null) { int amount = 0; diff --git a/Mage.Sets/src/mage/sets/urzassaga/ArgothianWurm.java b/Mage.Sets/src/mage/sets/urzassaga/ArgothianWurm.java index a98359478a6..4f05f4b7923 100644 --- a/Mage.Sets/src/mage/sets/urzassaga/ArgothianWurm.java +++ b/Mage.Sets/src/mage/sets/urzassaga/ArgothianWurm.java @@ -95,7 +95,7 @@ class ArgothianWurmEffect extends PutOnLibrarySourceEffect { Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { boolean costPaid = false; - for (UUID playerId : controller.getInRange()) { + for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) { Cost cost = new SacrificeTargetCost(new TargetControlledPermanent(new FilterControlledLandPermanent())); Player player = game.getPlayer(playerId); if (player != null diff --git a/Mage.Sets/src/mage/sets/urzassaga/FaultLine.java b/Mage.Sets/src/mage/sets/urzassaga/FaultLine.java index be9be709887..04b8a9fb067 100644 --- a/Mage.Sets/src/mage/sets/urzassaga/FaultLine.java +++ b/Mage.Sets/src/mage/sets/urzassaga/FaultLine.java @@ -94,7 +94,7 @@ class FaultLineEffect extends OneShotEffect { for (Permanent permanent: game.getBattlefield().getActivePermanents(filter, source.getControllerId(), game)) { permanent.damage(amount, source.getSourceId(), game, false, true); } - for (UUID playerId: game.getPlayer(source.getControllerId()).getInRange()) { + for (UUID playerId: game.getState().getPlayersInRange(source.getControllerId(), game)) { Player player = game.getPlayer(playerId); if (player != null) player.damage(amount, source.getSourceId(), game, false, true); diff --git a/Mage.Sets/src/mage/sets/urzassaga/TimeSpiral.java b/Mage.Sets/src/mage/sets/urzassaga/TimeSpiral.java index fff482faff9..46765bbacfe 100644 --- a/Mage.Sets/src/mage/sets/urzassaga/TimeSpiral.java +++ b/Mage.Sets/src/mage/sets/urzassaga/TimeSpiral.java @@ -86,7 +86,7 @@ class TimeSpiralEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player sourcePlayer = game.getPlayer(source.getControllerId()); - for (UUID playerId : sourcePlayer.getInRange()) { + for (UUID playerId : game.getState().getPlayersInRange(sourcePlayer.getId(), game)) { Player player = game.getPlayer(playerId); if (player != null) { for (Card card : player.getHand().getCards(game)) { diff --git a/Mage.Sets/src/mage/sets/vintagemasters/Eureka.java b/Mage.Sets/src/mage/sets/vintagemasters/Eureka.java index d5dbfa28e5e..364d0afc1f0 100644 --- a/Mage.Sets/src/mage/sets/vintagemasters/Eureka.java +++ b/Mage.Sets/src/mage/sets/vintagemasters/Eureka.java @@ -99,7 +99,7 @@ class EurekaEffect extends OneShotEffect { if (firstInactivePlayer == null) { firstInactivePlayer = currentPlayer.getId(); } - if (currentPlayer != null && currentPlayer.canRespond() && controller.getInRange().contains(currentPlayer.getId())) { + if (currentPlayer != null && currentPlayer.canRespond() && game.getState().getPlayersInRange(controller.getId(), game).contains(currentPlayer.getId())) { target.clearChosen(); if (target.canChoose(source.getSourceId(), currentPlayer.getId(), game) diff --git a/Mage.Sets/src/mage/sets/vintagemasters/ScourgeOfTheThrone.java b/Mage.Sets/src/mage/sets/vintagemasters/ScourgeOfTheThrone.java index 77362f43213..ab968af0a42 100644 --- a/Mage.Sets/src/mage/sets/vintagemasters/ScourgeOfTheThrone.java +++ b/Mage.Sets/src/mage/sets/vintagemasters/ScourgeOfTheThrone.java @@ -107,7 +107,7 @@ class ScourgeOfTheThroneAttacksTriggeredAbility extends TriggeredAbilityImpl { Player controller = game.getPlayer(getControllerId()); if (attackedPlayer != null && controller != null) { int mostLife = Integer.MIN_VALUE; - for (UUID playerId : controller.getInRange()) { + for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) { Player player = game.getPlayer(playerId); if (player != null) { if (player.getLife() > mostLife) { diff --git a/Mage/src/main/java/mage/abilities/condition/common/CardsInAnyLibraryCondition.java b/Mage/src/main/java/mage/abilities/condition/common/CardsInAnyLibraryCondition.java index 0fba54d9613..8c0b7366c0b 100644 --- a/Mage/src/main/java/mage/abilities/condition/common/CardsInAnyLibraryCondition.java +++ b/Mage/src/main/java/mage/abilities/condition/common/CardsInAnyLibraryCondition.java @@ -25,7 +25,6 @@ * authors and should not be interpreted as representing official policies, either expressed * or implied, of BetaSteward_at_googlemail.com. */ - package mage.abilities.condition.common; import java.util.UUID; @@ -52,10 +51,10 @@ public class CardsInAnyLibraryCondition implements Condition { public final boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { - for (UUID playerId: controller.getInRange()) { + for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) { Player player = game.getPlayer(playerId); if (player != null) { - switch(type) { + switch (type) { case GreaterThan: if (player.getLibrary().size() > value) { return true; @@ -81,15 +80,15 @@ public class CardsInAnyLibraryCondition implements Condition { @Override public String toString() { StringBuilder sb = new StringBuilder("a library has "); - switch(type) { + switch (type) { case GreaterThan: - sb.append(value+1).append(" or more cards in it "); + sb.append(value + 1).append(" or more cards in it "); break; case Equal: sb.append(value).append(" cards in it "); break; case LessThan: - sb.append(value-1).append(" or fewer cards in it "); + sb.append(value - 1).append(" or fewer cards in it "); break; } return sb.toString(); diff --git a/Mage/src/main/java/mage/abilities/condition/common/CardsInHandCondition.java b/Mage/src/main/java/mage/abilities/condition/common/CardsInHandCondition.java index b5219ca2026..d4b74cce61f 100644 --- a/Mage/src/main/java/mage/abilities/condition/common/CardsInHandCondition.java +++ b/Mage/src/main/java/mage/abilities/condition/common/CardsInHandCondition.java @@ -47,7 +47,7 @@ public class CardsInHandCondition implements Condition { public static enum CountType { MORE_THAN, FEWER_THAN, EQUAL_TO }; - + private Condition condition; private CountType type; private int count; @@ -60,7 +60,7 @@ public class CardsInHandCondition implements Condition { public CardsInHandCondition(CountType type, int count) { this(type, count, null); } - + public CardsInHandCondition(CountType type, int count, Condition conditionToDecorate) { this(type, count, conditionToDecorate, TargetController.YOU); } @@ -73,7 +73,7 @@ public class CardsInHandCondition implements Condition { } @Override - public boolean apply(Game game, Ability source) { + public boolean apply(Game game, Ability source) { boolean conditionApplies = false; Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { @@ -95,7 +95,7 @@ public class CardsInHandCondition implements Condition { boolean conflict = false; switch (this.type) { case FEWER_THAN: - for (UUID playerId :controller.getInRange()) { + for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) { Player player = game.getPlayer(playerId); if (player != null) { if (player.getHand().size() >= this.count) { @@ -103,10 +103,10 @@ public class CardsInHandCondition implements Condition { break; } } - } + } break; case MORE_THAN: - for (UUID playerId :controller.getInRange()) { + for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) { Player player = game.getPlayer(playerId); if (player != null) { if (player.getHand().size() <= this.count) { @@ -114,10 +114,10 @@ public class CardsInHandCondition implements Condition { break; } } - } + } break; case EQUAL_TO: - for (UUID playerId :controller.getInRange()) { + for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) { Player player = game.getPlayer(playerId); if (player != null) { if (player.getHand().size() != this.count) { @@ -127,11 +127,11 @@ public class CardsInHandCondition implements Condition { } } break; - } + } conditionApplies = !conflict; break; default: - throw new UnsupportedOperationException("Value of TargetController not supported for this class."); + throw new UnsupportedOperationException("Value of TargetController not supported for this class."); } //If a decorated condition exists, check it as well and apply them together. @@ -163,7 +163,7 @@ public class CardsInHandCondition implements Condition { case MORE_THAN: sb.append(" more than "); break; - case EQUAL_TO: + case EQUAL_TO: sb.append(" exactly "); break; } @@ -171,9 +171,9 @@ public class CardsInHandCondition implements Condition { sb.append("no"); } else { sb.append(CardUtil.numberToText(workCount)); - } + } sb.append(" cards in hand"); return sb.toString(); } - + } diff --git a/Mage/src/main/java/mage/abilities/costs/common/GainLifePlayersCost.java b/Mage/src/main/java/mage/abilities/costs/common/GainLifePlayersCost.java index 825f4f88a4e..473673b761b 100644 --- a/Mage/src/main/java/mage/abilities/costs/common/GainLifePlayersCost.java +++ b/Mage/src/main/java/mage/abilities/costs/common/GainLifePlayersCost.java @@ -25,7 +25,6 @@ * authors and should not be interpreted as representing official policies, either expressed * or implied, of BetaSteward_at_googlemail.com. */ - package mage.abilities.costs.common; import java.util.UUID; @@ -57,7 +56,7 @@ public class GainLifePlayersCost extends CostImpl { public boolean canPay(Ability ability, UUID sourceId, UUID controllerId, Game game) { Player controller = game.getPlayer(controllerId); if (controller != null) { - for (UUID playerId: controller.getInRange()) { + for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) { if (!playerId.equals(controllerId)) { Player player = game.getPlayer(playerId); if (player != null && !player.isCanGainLife()) { @@ -67,7 +66,7 @@ public class GainLifePlayersCost extends CostImpl { } } - } + } return true; } @@ -75,7 +74,7 @@ public class GainLifePlayersCost extends CostImpl { public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana, Cost costToPay) { Player controller = game.getPlayer(controllerId); if (controller != null) { - for (UUID playerId: controller.getInRange()) { + for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) { if (!playerId.equals(controllerId)) { Player player = game.getPlayer(playerId); if (player != null) { diff --git a/Mage/src/main/java/mage/abilities/dynamicvalue/common/CardsInAllGraveyardsCount.java b/Mage/src/main/java/mage/abilities/dynamicvalue/common/CardsInAllGraveyardsCount.java index 901845974a5..102ac8bda29 100644 --- a/Mage/src/main/java/mage/abilities/dynamicvalue/common/CardsInAllGraveyardsCount.java +++ b/Mage/src/main/java/mage/abilities/dynamicvalue/common/CardsInAllGraveyardsCount.java @@ -60,7 +60,7 @@ public class CardsInAllGraveyardsCount implements DynamicValue { int amount = 0; Player controller = game.getPlayer(sourceAbility.getControllerId()); if (controller != null) { - for (UUID playerUUID : controller.getInRange()) { + for (UUID playerUUID : game.getState().getPlayersInRange(controller.getId(), game)) { Player player = game.getPlayer(playerUUID); if (player != null) { amount += player.getGraveyard().count(filter, sourceAbility.getSourceId(), sourceAbility.getControllerId(), game); diff --git a/Mage/src/main/java/mage/abilities/dynamicvalue/common/CardsInAllHandsCount.java b/Mage/src/main/java/mage/abilities/dynamicvalue/common/CardsInAllHandsCount.java index 143e8f01135..5587ba0194d 100644 --- a/Mage/src/main/java/mage/abilities/dynamicvalue/common/CardsInAllHandsCount.java +++ b/Mage/src/main/java/mage/abilities/dynamicvalue/common/CardsInAllHandsCount.java @@ -43,7 +43,7 @@ public class CardsInAllHandsCount implements DynamicValue { @Override public int calculate(Game game, Ability sourceAbility, Effect effect) { int count = 0; - for (UUID playerId : game.getPlayer(sourceAbility.getControllerId()).getInRange()) { + for (UUID playerId : game.getState().getPlayersInRange(sourceAbility.getControllerId(), game)) { Player player = game.getPlayer(playerId); if (player != null) { diff --git a/Mage/src/main/java/mage/abilities/effects/common/DamageEverythingEffect.java b/Mage/src/main/java/mage/abilities/effects/common/DamageEverythingEffect.java index cb5fab6149f..f24d5791708 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/DamageEverythingEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/DamageEverythingEffect.java @@ -89,7 +89,7 @@ public class DamageEverythingEffect extends OneShotEffect { for (Permanent permanent: permanents) { permanent.damage(damage, damageSource == null ? source.getSourceId(): damageSource, game, false, true); } - for (UUID playerId: game.getPlayer(source.getControllerId()).getInRange()) { + for (UUID playerId: game.getState().getPlayersInRange(source.getControllerId(), game)) { Player player = game.getPlayer(playerId); if (player != null) { player.damage(damage, damageSource == null ? source.getSourceId(): damageSource, game, false, true); diff --git a/Mage/src/main/java/mage/abilities/effects/common/DamagePlayersEffect.java b/Mage/src/main/java/mage/abilities/effects/common/DamagePlayersEffect.java index c1ad07a6025..4ec652807ba 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/DamagePlayersEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/DamagePlayersEffect.java @@ -75,7 +75,7 @@ public class DamagePlayersEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { switch (controller) { case ANY: - for (UUID playerId: game.getPlayer(source.getControllerId()).getInRange()) { + for (UUID playerId: game.getState().getPlayersInRange(source.getControllerId(), game)) { Player player = game.getPlayer(playerId); if (player != null) { player.damage(amount.calculate(game, source, this), source.getSourceId(), game, false, true); diff --git a/Mage/src/main/java/mage/abilities/effects/common/DoUnlessAnyPlayerPaysEffect.java b/Mage/src/main/java/mage/abilities/effects/common/DoUnlessAnyPlayerPaysEffect.java index 5062f785630..24fb8efbaa3 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/DoUnlessAnyPlayerPaysEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/DoUnlessAnyPlayerPaysEffect.java @@ -45,8 +45,8 @@ import mage.util.CardUtil; * * @author LevelX2 */ - public class DoUnlessAnyPlayerPaysEffect extends OneShotEffect { + protected Effects executingEffects = new Effects(); private final Cost cost; private String chooseUseText; @@ -81,7 +81,7 @@ public class DoUnlessAnyPlayerPaysEffect extends OneShotEffect { String message; if (chooseUseText == null) { String effectText = executingEffects.getText(source.getModes().getMode()); - message = "Pay " + cost.getText() + " to prevent (" + effectText.substring(0, effectText.length() -1) + ")?"; + message = "Pay " + cost.getText() + " to prevent (" + effectText.substring(0, effectText.length() - 1) + ")?"; } else { message = chooseUseText; } @@ -89,13 +89,14 @@ public class DoUnlessAnyPlayerPaysEffect extends OneShotEffect { boolean result = true; boolean doEffect = true; // check if any player is willing to pay - for (UUID playerId: controller.getInRange()) { + for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) { Player player = game.getPlayer(playerId); if (player != null && cost.canPay(source, source.getSourceId(), player.getId(), game) && player.chooseUse(Outcome.Detriment, message, source, game)) { cost.clearPaid(); if (cost.pay(source, game, source.getSourceId(), player.getId(), false, null)) { - if (!game.isSimulation()) + if (!game.isSimulation()) { game.informPlayers(player.getLogName() + " pays the cost to prevent the effect"); + } doEffect = false; break; } @@ -103,12 +104,11 @@ public class DoUnlessAnyPlayerPaysEffect extends OneShotEffect { } // do the effects if nobody paid if (doEffect) { - for(Effect effect: executingEffects) { + for (Effect effect : executingEffects) { effect.setTargetPointer(this.targetPointer); if (effect instanceof OneShotEffect) { result &= effect.apply(game, source); - } - else { + } else { game.addEffect((ContinuousEffect) effect, source); } } @@ -128,11 +128,11 @@ public class DoUnlessAnyPlayerPaysEffect extends OneShotEffect { return staticText; } String effectsText = executingEffects.getText(mode); - return effectsText.substring(0, effectsText.length() -1) + " unless any player pays " + cost.getText(); + return effectsText.substring(0, effectsText.length() - 1) + " unless any player pays " + cost.getText(); } @Override public DoUnlessAnyPlayerPaysEffect copy() { return new DoUnlessAnyPlayerPaysEffect(this); } -} \ No newline at end of file +} diff --git a/Mage/src/main/java/mage/abilities/effects/common/DrawCardAllEffect.java b/Mage/src/main/java/mage/abilities/effects/common/DrawCardAllEffect.java index 919c245d373..e90b71ada3a 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/DrawCardAllEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/DrawCardAllEffect.java @@ -1,16 +1,16 @@ /* * Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions in binary form must reproduce the above copyright notice, this list * of conditions and the following disclaimer in the documentation and/or other materials * provided with the distribution. - * + * * THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR @@ -20,12 +20,11 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of BetaSteward_at_googlemail.com. */ - package mage.abilities.effects.common; import java.util.UUID; @@ -51,7 +50,7 @@ public class DrawCardAllEffect extends OneShotEffect { public DrawCardAllEffect(int amount) { this(amount, TargetController.ANY); } - + public DrawCardAllEffect(DynamicValue amount) { this(amount, TargetController.ANY); } @@ -80,10 +79,10 @@ public class DrawCardAllEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - Player sourcePlayer = game.getPlayer(source.getControllerId()); - switch(targetController) { + Player controller = game.getPlayer(source.getControllerId()); + switch (targetController) { case ANY: - for (UUID playerId: sourcePlayer.getInRange()) { + for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) { Player player = game.getPlayer(playerId); if (player != null) { player.drawCards(amount.calculate(game, source, this), game); @@ -91,12 +90,12 @@ public class DrawCardAllEffect extends OneShotEffect { } break; case OPPONENT: - for (UUID playerId: game.getOpponents(sourcePlayer.getId())) { + for (UUID playerId : game.getOpponents(controller.getId())) { Player player = game.getPlayer(playerId); if (player != null) { player.drawCards(amount.calculate(game, source, this), game); } - } + } break; } return true; @@ -104,7 +103,7 @@ public class DrawCardAllEffect extends OneShotEffect { private String setText() { StringBuilder sb = new StringBuilder("Each "); - switch(targetController) { + switch (targetController) { case ANY: sb.append("player"); break; @@ -115,9 +114,9 @@ public class DrawCardAllEffect extends OneShotEffect { throw new UnsupportedOperationException("Not supported value for targetController"); } sb.append(" draws "); - sb.append(CardUtil.numberToText(amount.toString(),"a")); + sb.append(CardUtil.numberToText(amount.toString(), "a")); sb.append(" card"); - sb.append(amount.toString().equals("1")?"":"s"); + sb.append(amount.toString().equals("1") ? "" : "s"); return sb.toString(); } } diff --git a/Mage/src/main/java/mage/abilities/effects/common/ExileGraveyardAllPlayersEffect.java b/Mage/src/main/java/mage/abilities/effects/common/ExileGraveyardAllPlayersEffect.java index d5b8e67c35a..ac7883cdbf6 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/ExileGraveyardAllPlayersEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/ExileGraveyardAllPlayersEffect.java @@ -41,16 +41,17 @@ import mage.players.Player; * @author Jgod */ public class ExileGraveyardAllPlayersEffect extends OneShotEffect { + public ExileGraveyardAllPlayersEffect() { super(Outcome.Detriment); staticText = "exile all cards from all graveyards"; } - + @Override public ExileGraveyardAllPlayersEffect copy() { return new ExileGraveyardAllPlayersEffect(); } - + @Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); @@ -58,7 +59,7 @@ public class ExileGraveyardAllPlayersEffect extends OneShotEffect { return false; } - for (UUID playerId : controller.getInRange()) { + for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) { Player player = game.getPlayer(playerId); if (player != null) { for (UUID cid : player.getGraveyard().copy()) { @@ -71,4 +72,4 @@ public class ExileGraveyardAllPlayersEffect extends OneShotEffect { } return true; } -} \ No newline at end of file +} diff --git a/Mage/src/main/java/mage/abilities/effects/common/LoseLifeAllPlayersEffect.java b/Mage/src/main/java/mage/abilities/effects/common/LoseLifeAllPlayersEffect.java index 39cf9bcc801..9183a367c00 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/LoseLifeAllPlayersEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/LoseLifeAllPlayersEffect.java @@ -68,7 +68,7 @@ public class LoseLifeAllPlayersEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - for (UUID playerId: game.getPlayer(source.getControllerId()).getInRange()) { + for (UUID playerId: game.getState().getPlayersInRange(source.getControllerId(), game)) { Player player = game.getPlayer(playerId); if (player != null) { player.loseLife(amount.calculate(game, source, this), game); diff --git a/Mage/src/main/java/mage/abilities/effects/common/PreventAllDamageToPlayersEffect.java b/Mage/src/main/java/mage/abilities/effects/common/PreventAllDamageToPlayersEffect.java index 64a4eccfc09..6e89505e33f 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/PreventAllDamageToPlayersEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/PreventAllDamageToPlayersEffect.java @@ -25,7 +25,6 @@ * authors and should not be interpreted as representing official policies, either expressed * or implied, of BetaSteward_at_googlemail.com. */ - package mage.abilities.effects.common; import mage.abilities.Ability; @@ -39,8 +38,6 @@ import mage.players.Player; * * @author LevelX2 */ - - public class PreventAllDamageToPlayersEffect extends PreventionEffectImpl { public PreventAllDamageToPlayersEffect(Duration duration, boolean onlyCombat) { @@ -66,7 +63,7 @@ public class PreventAllDamageToPlayersEffect extends PreventionEffectImpl { public boolean applies(GameEvent event, Ability source, Game game) { if (super.applies(event, source, game) && event.getType().equals(GameEvent.EventType.DAMAGE_PLAYER)) { Player controller = game.getPlayer(source.getControllerId()); - if (controller != null && controller.getInRange().contains(event.getTargetId())){ + if (controller != null && game.getState().getPlayersInRange(controller.getId(), game).contains(event.getTargetId())) { return true; } } diff --git a/Mage/src/main/java/mage/abilities/effects/common/ReturnToHandFromGraveyardAllEffect.java b/Mage/src/main/java/mage/abilities/effects/common/ReturnToHandFromGraveyardAllEffect.java index 3b7bc7a5fde..bc4079753a6 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/ReturnToHandFromGraveyardAllEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/ReturnToHandFromGraveyardAllEffect.java @@ -35,14 +35,12 @@ import mage.constants.Outcome; import mage.constants.Zone; import mage.filter.FilterCard; import mage.game.Game; -import mage.game.permanent.Permanent; import mage.players.Player; /** * * @author LevelX2 */ - public class ReturnToHandFromGraveyardAllEffect extends OneShotEffect { private final FilterCard filter; @@ -62,10 +60,10 @@ public class ReturnToHandFromGraveyardAllEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { - for (UUID playerId : controller.getInRange()) { + for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) { Player player = game.getPlayer(playerId); if (player != null) { - for (Card card :player.getGraveyard().getCards(filter, source.getSourceId(), source.getControllerId(), game)) { + for (Card card : player.getGraveyard().getCards(filter, source.getSourceId(), source.getControllerId(), game)) { card.moveToZone(Zone.HAND, playerId, game, false); } } diff --git a/Mage/src/main/java/mage/abilities/effects/common/SacrificeAllEffect.java b/Mage/src/main/java/mage/abilities/effects/common/SacrificeAllEffect.java index f00f0433c0a..2b9d29d91f4 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/SacrificeAllEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/SacrificeAllEffect.java @@ -1,16 +1,16 @@ /* * Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions in binary form must reproduce the above copyright notice, this list * of conditions and the following disclaimer in the documentation and/or other materials * provided with the distribution. - * + * * THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR @@ -20,12 +20,11 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of BetaSteward_at_googlemail.com. */ - package mage.abilities.effects.common; import java.util.ArrayList; @@ -43,7 +42,6 @@ import mage.players.Player; import mage.target.common.TargetControlledPermanent; import mage.util.CardUtil; - /** * * @author BetaSteward_at_googlemail.com @@ -56,6 +54,7 @@ public class SacrificeAllEffect extends OneShotEffect { public SacrificeAllEffect(FilterControlledPermanent filter) { this(1, filter); } + public SacrificeAllEffect(int amount, FilterControlledPermanent filter) { this(new StaticValue(amount), filter); } @@ -86,7 +85,7 @@ public class SacrificeAllEffect extends OneShotEffect { } List perms = new ArrayList<>(); - for (UUID playerId : controller.getInRange()) { + for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) { Player player = game.getPlayer(playerId); if (player != null) { int numTargets = Math.min(amount.calculate(game, source, this), game.getBattlefield().countAll(filter, player.getId(), game)); diff --git a/Mage/src/main/java/mage/abilities/effects/common/SetPlayerLifeAllEffect.java b/Mage/src/main/java/mage/abilities/effects/common/SetPlayerLifeAllEffect.java index 5f54db01260..6133845209b 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/SetPlayerLifeAllEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/SetPlayerLifeAllEffect.java @@ -58,10 +58,10 @@ public class SetPlayerLifeAllEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - Player sourcePlayer = game.getPlayer(source.getControllerId()); + Player controller = game.getPlayer(source.getControllerId()); switch (targetController) { case ANY: - for (UUID playerId : sourcePlayer.getInRange()) { + for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) { Player player = game.getPlayer(playerId); if (player != null) { player.setLife(amount.calculate(game, source, this), game); @@ -69,7 +69,7 @@ public class SetPlayerLifeAllEffect extends OneShotEffect { } break; case OPPONENT: - for (UUID playerId : game.getOpponents(sourcePlayer.getId())) { + for (UUID playerId : game.getOpponents(controller.getId())) { Player player = game.getPlayer(playerId); if (player != null) { player.setLife(amount.calculate(game, source, this), game); diff --git a/Mage/src/main/java/mage/abilities/effects/common/continuous/CantGainLifeAllEffect.java b/Mage/src/main/java/mage/abilities/effects/common/continuous/CantGainLifeAllEffect.java index ff4c157bfc3..4323f41b8f2 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/continuous/CantGainLifeAllEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/continuous/CantGainLifeAllEffect.java @@ -43,13 +43,13 @@ import mage.players.Player; * @author LevelX2 */ public class CantGainLifeAllEffect extends ContinuousEffectImpl { - + private TargetController targetController; - + public CantGainLifeAllEffect() { this(Duration.WhileOnBattlefield); } - + public CantGainLifeAllEffect(Duration duration) { this(duration, TargetController.ANY); } @@ -58,7 +58,7 @@ public class CantGainLifeAllEffect extends ContinuousEffectImpl { super(duration, Layer.PlayerEffects, SubLayer.NA, Outcome.Benefit); this.targetController = targetController; staticText = setText(); - + } public CantGainLifeAllEffect(final CantGainLifeAllEffect effect) { @@ -74,21 +74,21 @@ public class CantGainLifeAllEffect extends ContinuousEffectImpl { @Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); - if (controller != null) { + if (controller != null) { switch (targetController) { case YOU: controller.setCanGainLife(false); - break; + break; case NOT_YOU: - for (UUID playerId: controller.getInRange()) { + for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) { Player player = game.getPlayer(playerId); if (player != null && !player.equals(controller)) { player.setCanGainLife(false); } } - break; + break; case OPPONENT: - for (UUID playerId: controller.getInRange()) { + for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) { if (controller.hasOpponent(playerId, game)) { Player player = game.getPlayer(playerId); if (player != null) { @@ -96,15 +96,15 @@ public class CantGainLifeAllEffect extends ContinuousEffectImpl { } } } - break; + break; case ANY: - for (UUID playerId: controller.getInRange()) { + for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) { Player player = game.getPlayer(playerId); if (player != null) { player.setCanGainLife(false); } } - break; + break; } return true; } @@ -116,17 +116,17 @@ public class CantGainLifeAllEffect extends ContinuousEffectImpl { switch (targetController) { case YOU: sb.append("You"); - break; + break; case NOT_YOU: sb.append("Other players"); - break; + break; case OPPONENT: sb.append("Your opponents"); - break; + break; case ANY: sb.append("Players"); - break; - } + break; + } sb.append(" can't gain life"); if (!this.duration.toString().isEmpty()) { sb.append(" "); @@ -135,8 +135,8 @@ public class CantGainLifeAllEffect extends ContinuousEffectImpl { } else { sb.append(duration.toString()); } - + } - return sb.toString(); + return sb.toString(); } } diff --git a/Mage/src/main/java/mage/abilities/effects/common/continuous/MaximumHandSizeControllerEffect.java b/Mage/src/main/java/mage/abilities/effects/common/continuous/MaximumHandSizeControllerEffect.java index f665c3e77bf..77d633b11e9 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/continuous/MaximumHandSizeControllerEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/continuous/MaximumHandSizeControllerEffect.java @@ -28,13 +28,13 @@ package mage.abilities.effects.common.continuous; import java.util.UUID; +import mage.abilities.Ability; +import mage.abilities.effects.ContinuousEffectImpl; import mage.constants.Duration; import mage.constants.Layer; import mage.constants.Outcome; import mage.constants.SubLayer; import mage.constants.TargetController; -import mage.abilities.Ability; -import mage.abilities.effects.ContinuousEffectImpl; import mage.game.Game; import mage.players.Player; import mage.util.CardUtil; @@ -44,7 +44,9 @@ import mage.util.CardUtil; */ public class MaximumHandSizeControllerEffect extends ContinuousEffectImpl { - public static enum HandSizeModification { SET, INCREASE, REDUCE }; + public static enum HandSizeModification { + SET, INCREASE, REDUCE + }; protected int handSize; protected HandSizeModification handSizeModification; @@ -54,14 +56,14 @@ public class MaximumHandSizeControllerEffect extends ContinuousEffectImpl { * @param handSize Maximum hand size to set or to reduce by * @param duration Effect duration * @param handSizeModification SET, INCREASE, REDUCE - * + * */ public MaximumHandSizeControllerEffect(int handSize, Duration duration, HandSizeModification handSizeModification) { this(handSize, duration, handSizeModification, TargetController.YOU); } public MaximumHandSizeControllerEffect(int handSize, Duration duration, HandSizeModification handSizeModification, TargetController targetController) { - super(duration, Layer.PlayerEffects, SubLayer.NA, defineOutcome(handSizeModification, targetController)); + super(duration, Layer.PlayerEffects, SubLayer.NA, defineOutcome(handSizeModification, targetController)); this.handSize = handSize; this.handSizeModification = handSizeModification; this.targetController = targetController; @@ -79,7 +81,7 @@ public class MaximumHandSizeControllerEffect extends ContinuousEffectImpl { public MaximumHandSizeControllerEffect copy() { return new MaximumHandSizeControllerEffect(this); } - + protected static Outcome defineOutcome(HandSizeModification handSizeModification, TargetController targetController) { Outcome newOutcome = Outcome.Benefit; if ((targetController.equals(TargetController.YOU) || targetController.equals(TargetController.ANY)) @@ -93,14 +95,14 @@ public class MaximumHandSizeControllerEffect extends ContinuousEffectImpl { public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { - switch(targetController) { + switch (targetController) { case ANY: - for (UUID playerId: controller.getInRange()) { + for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) { setHandSize(game, playerId); } break; case OPPONENT: - for (UUID playerId: game.getOpponents(source.getControllerId())) { + for (UUID playerId : game.getOpponents(source.getControllerId())) { setHandSize(game, playerId); } break; @@ -118,7 +120,7 @@ public class MaximumHandSizeControllerEffect extends ContinuousEffectImpl { private void setHandSize(Game game, UUID playerId) { Player player = game.getPlayer(playerId); if (player != null) { - switch(handSizeModification) { + switch (handSizeModification) { case SET: player.setMaxHandSize(handSize); break; @@ -134,7 +136,7 @@ public class MaximumHandSizeControllerEffect extends ContinuousEffectImpl { private void setText() { StringBuilder sb = new StringBuilder(); - switch(targetController) { + switch (targetController) { case ANY: if (handSize == Integer.MAX_VALUE) { sb.append("All players have no "); @@ -158,9 +160,9 @@ public class MaximumHandSizeControllerEffect extends ContinuousEffectImpl { break; } sb.append("maximum hand size"); - if (handSizeModification.equals(HandSizeModification.INCREASE)){ + if (handSizeModification.equals(HandSizeModification.INCREASE)) { sb.append(" is increased by "); - } else if (handSizeModification.equals(HandSizeModification.REDUCE)){ + } else if (handSizeModification.equals(HandSizeModification.REDUCE)) { sb.append(" is reduced by "); } else if (handSize != Integer.MAX_VALUE) { sb.append(" is "); diff --git a/Mage/src/main/java/mage/abilities/effects/common/continuous/PlayWithHandRevealedEffect.java b/Mage/src/main/java/mage/abilities/effects/common/continuous/PlayWithHandRevealedEffect.java index ebbb47260b8..4ae3e82e0d2 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/continuous/PlayWithHandRevealedEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/continuous/PlayWithHandRevealedEffect.java @@ -63,15 +63,15 @@ public class PlayWithHandRevealedEffect extends ContinuousEffectImpl { Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { Iterable affectedPlayers; - switch(who) { + switch (who) { case ANY: - affectedPlayers = controller.getInRange(); + affectedPlayers = game.getState().getPlayersInRange(controller.getId(), game); break; case OPPONENT: affectedPlayers = game.getOpponents(source.getControllerId()); break; case YOU: - ArrayList tmp = new ArrayList(); + ArrayList tmp = new ArrayList<>(); tmp.add(source.getControllerId()); affectedPlayers = tmp; break; @@ -79,7 +79,7 @@ public class PlayWithHandRevealedEffect extends ContinuousEffectImpl { return false; } - for(UUID playerID: affectedPlayers) { + for (UUID playerID : affectedPlayers) { Player player = game.getPlayer(playerID); if (player != null) { player.revealCards(player.getName() + "'s hand cards", player.getHand(), game, false); @@ -100,7 +100,7 @@ public class PlayWithHandRevealedEffect extends ContinuousEffectImpl { if (staticText != null && !staticText.isEmpty()) { return staticText; } - switch(who) { + switch (who) { case ANY: return "Players play with their hands revealed"; case OPPONENT: diff --git a/Mage/src/main/java/mage/abilities/effects/common/continuous/PlayWithTheTopCardRevealedEffect.java b/Mage/src/main/java/mage/abilities/effects/common/continuous/PlayWithTheTopCardRevealedEffect.java index c7f6a8a0be7..7331374117f 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/continuous/PlayWithTheTopCardRevealedEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/continuous/PlayWithTheTopCardRevealedEffect.java @@ -53,8 +53,7 @@ public class PlayWithTheTopCardRevealedEffect extends ContinuousEffectImpl { this.allPlayers = allPlayers; if (allPlayers) { staticText = "Players play with the top card of their libraries revealed."; - } - else { + } else { staticText = "Play with the top card of your library revealed"; } } @@ -69,14 +68,13 @@ public class PlayWithTheTopCardRevealedEffect extends ContinuousEffectImpl { Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { if (allPlayers) { - for (UUID playerId : controller.getInRange()) { + for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) { Player player = game.getPlayer(playerId); if (player != null) { player.setTopCardRevealed(true); } } - } - else { + } else { controller.setTopCardRevealed(true); } return true; diff --git a/Mage/src/main/java/mage/abilities/effects/common/discard/DiscardEachPlayerEffect.java b/Mage/src/main/java/mage/abilities/effects/common/discard/DiscardEachPlayerEffect.java index 912186fe395..720c493973a 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/discard/DiscardEachPlayerEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/discard/DiscardEachPlayerEffect.java @@ -97,7 +97,7 @@ public class DiscardEachPlayerEffect extends OneShotEffect { } } // discard all choosen cards - for (UUID playerId : controller.getInRange()) { + for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) { Player player = game.getPlayer(playerId); if (player != null) { Cards cardsPlayer = cardsToDiscard.get(playerId); diff --git a/Mage/src/main/java/mage/abilities/keyword/DethroneAbility.java b/Mage/src/main/java/mage/abilities/keyword/DethroneAbility.java index 340564d4075..9e3c1e31e89 100644 --- a/Mage/src/main/java/mage/abilities/keyword/DethroneAbility.java +++ b/Mage/src/main/java/mage/abilities/keyword/DethroneAbility.java @@ -25,7 +25,6 @@ * authors and should not be interpreted as representing official policies, either expressed * or implied, of BetaSteward_at_googlemail.com. */ - package mage.abilities.keyword; import java.util.UUID; @@ -38,13 +37,16 @@ import mage.game.events.GameEvent; import mage.players.Player; /** - * Dethrone triggers whenever a creature with dethrone attacks the player with the most life or tied - * for the most life. When the ability resolves, you put a +1/+1 counter on the creature. This happens - * before blockers are declared. Once the ability triggers, it doesn't matter what happens to anybody's - * life total. If the defending player doesn't have the most life when the ability resolves, the creature - * will still get the +1/+1 counter. Note that dethrone won't trigger if the creature attacks a Planeswalker. - * You're going after the crown, after all, not the royal advisors. If you have the most life, your dethrone - * abilities won't trigger, but you may find a few choice ways to avoid that situation. + * Dethrone triggers whenever a creature with dethrone attacks the player with + * the most life or tied for the most life. When the ability resolves, you put a + * +1/+1 counter on the creature. This happens before blockers are declared. + * Once the ability triggers, it doesn't matter what happens to anybody's life + * total. If the defending player doesn't have the most life when the ability + * resolves, the creature will still get the +1/+1 counter. Note that dethrone + * won't trigger if the creature attacks a Planeswalker. You're going after the + * crown, after all, not the royal advisors. If you have the most life, your + * dethrone abilities won't trigger, but you may find a few choice ways to avoid + * that situation. * * @author LevelX2 */ @@ -76,7 +78,7 @@ public class DethroneAbility extends TriggeredAbilityImpl { Player controller = game.getPlayer(getControllerId()); if (attackedPlayer != null && controller != null) { int mostLife = Integer.MIN_VALUE; - for (UUID playerId: controller.getInRange()) { + for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) { Player player = game.getPlayer(playerId); if (player != null) { if (player.getLife() > mostLife) { diff --git a/Mage/src/main/java/mage/filter/predicate/permanent/DamagedPlayerThisTurnPredicate.java b/Mage/src/main/java/mage/filter/predicate/permanent/DamagedPlayerThisTurnPredicate.java index 62d91ba08cd..45e294fcc60 100644 --- a/Mage/src/main/java/mage/filter/predicate/permanent/DamagedPlayerThisTurnPredicate.java +++ b/Mage/src/main/java/mage/filter/predicate/permanent/DamagedPlayerThisTurnPredicate.java @@ -33,14 +33,12 @@ import mage.filter.predicate.ObjectPlayer; import mage.filter.predicate.ObjectPlayerPredicate; import mage.game.Controllable; import mage.game.Game; -import mage.players.Player; import mage.watchers.common.PlayerDamagedBySourceWatcher; /** * * @author LevelX2 */ - public class DamagedPlayerThisTurnPredicate implements ObjectPlayerPredicate> { private final TargetController controller; @@ -56,40 +54,34 @@ public class DamagedPlayerThisTurnPredicate implements ObjectPlayerPredicate getOpponents(UUID playerId) { Set opponents = new HashSet<>(); - for (UUID opponentId : this.getPlayer(playerId).getInRange()) { + for (UUID opponentId : getState().getPlayersInRange(playerId, this)) { if (!opponentId.equals(playerId)) { opponents.add(opponentId); } diff --git a/Mage/src/main/java/mage/game/GameImpl.java b/Mage/src/main/java/mage/game/GameImpl.java index 6af9ce25fde..89872ea178f 100644 --- a/Mage/src/main/java/mage/game/GameImpl.java +++ b/Mage/src/main/java/mage/game/GameImpl.java @@ -2734,9 +2734,11 @@ public abstract class GameImpl implements Game, Serializable { public void setDraw(UUID playerId) { Player player = getPlayer(playerId); if (player != null) { - for (UUID playerToSetId : player.getInRange()) { + for (UUID playerToSetId : getState().getPlayersInRange(playerId, this)) { Player playerToDraw = getPlayer(playerToSetId); - playerToDraw.lostForced(this); + if (playerToDraw != null) { + playerToDraw.lostForced(this); + } } } } diff --git a/Mage/src/main/java/mage/game/GameTinyLeadersImpl.java b/Mage/src/main/java/mage/game/GameTinyLeadersImpl.java index 4c4b887bbdb..98460aa9a25 100644 --- a/Mage/src/main/java/mage/game/GameTinyLeadersImpl.java +++ b/Mage/src/main/java/mage/game/GameTinyLeadersImpl.java @@ -25,7 +25,6 @@ * authors and should not be interpreted as representing official policies, either expressed * or implied, of BetaSteward_at_googlemail.com. */ - package mage.game; import java.util.HashSet; @@ -57,8 +56,8 @@ import mage.watchers.common.CommanderInfoWatcher; * * @author JRHerlehy */ -public abstract class GameTinyLeadersImpl extends GameImpl{ - +public abstract class GameTinyLeadersImpl extends GameImpl { + protected boolean alsoHand; // replace also commander going to library protected boolean alsoLibrary; // replace also commander going to library protected boolean startingPlayerSkipsDraw = true; @@ -72,14 +71,14 @@ public abstract class GameTinyLeadersImpl extends GameImpl{ this.alsoHand = game.alsoHand; this.startingPlayerSkipsDraw = game.startingPlayerSkipsDraw; } - + @Override protected void init(UUID choosingPlayerId) { Ability ability = new SimpleStaticAbility(Zone.COMMAND, new InfoEffect("Commander effects")); //Move tiny leader to command zone - for (UUID playerId: state.getPlayerList(startingPlayerId)) { + for (UUID playerId : state.getPlayerList(startingPlayerId)) { Player player = getPlayer(playerId); - if (player != null){ + if (player != null) { Card commander = getCommanderCard(player.getMatchPlayer().getDeck().getName(), player.getId()); if (commander != null) { Set cards = new HashSet<>(); @@ -95,7 +94,7 @@ public abstract class GameTinyLeadersImpl extends GameImpl{ getState().getWatchers().add(watcher); watcher.addCardInfoToCommander(this); } else { - throw new UnknownError("Commander card could not be created. Name: [" + player.getMatchPlayer().getDeck().getName() +"]"); + throw new UnknownError("Commander card could not be created. Name: [" + player.getMatchPlayer().getDeck().getName() + "]"); } } @@ -109,14 +108,14 @@ public abstract class GameTinyLeadersImpl extends GameImpl{ /** * Name of Tiny Leader comes from the deck name (it's not in the sideboard) - * Additionally, it was taken into account that WOTC had missed a few color combinations - * when making Legendary Creatures at 3 CMC. There are two Commanders available to use - * for the missing color identities: - * Sultai [UBG 3/3] and Glass [colorless 3/3] + * Additionally, it was taken into account that WOTC had missed a few color + * combinations when making Legendary Creatures at 3 CMC. There are two + * Commanders available to use for the missing color identities: Sultai [UBG + * 3/3] and Glass [colorless 3/3] * * @param commanderName * @param ownerId - * @return + * @return */ public static Card getCommanderCard(String commanderName, UUID ownerId) { Card commander = null; @@ -141,7 +140,7 @@ public abstract class GameTinyLeadersImpl extends GameImpl{ @Override public Set getOpponents(UUID playerId) { Set opponents = new HashSet<>(); - for (UUID opponentId: this.getPlayer(playerId).getInRange()) { + for (UUID opponentId : getState().getPlayersInRange(playerId, this)) { if (!opponentId.equals(playerId)) { opponents.add(opponentId); } @@ -151,7 +150,7 @@ public abstract class GameTinyLeadersImpl extends GameImpl{ @Override public boolean isOpponent(Player player, UUID playerToCheck) { - return !player.getId().equals(playerToCheck); + return !player.getId().equals(playerToCheck); } public void setAlsoHand(boolean alsoHand) { diff --git a/Mage/src/main/java/mage/target/TargetCard.java b/Mage/src/main/java/mage/target/TargetCard.java index bd60ede0132..92d00489275 100644 --- a/Mage/src/main/java/mage/target/TargetCard.java +++ b/Mage/src/main/java/mage/target/TargetCard.java @@ -87,7 +87,7 @@ public class TargetCard extends TargetObject { @Override public boolean canChoose(UUID sourceId, UUID sourceControllerId, Game game) { int possibleTargets = 0; - for (UUID playerId: game.getPlayer(sourceControllerId).getInRange()) { + for (UUID playerId: game.getState().getPlayersInRange(sourceControllerId, game)) { Player player = game.getPlayer(playerId); if (player != null) { switch (zone) { @@ -156,7 +156,7 @@ public class TargetCard extends TargetObject { @Override public Set possibleTargets(UUID sourceId, UUID sourceControllerId, Game game) { Set possibleTargets = new HashSet<>(); - for (UUID playerId : game.getPlayer(sourceControllerId).getInRange()) { + for (UUID playerId : game.getState().getPlayersInRange(sourceControllerId, game)) { Player player = game.getPlayer(playerId); if (player != null) { switch (zone) { diff --git a/Mage/src/main/java/mage/target/TargetPlayer.java b/Mage/src/main/java/mage/target/TargetPlayer.java index 944b49fc7b6..3d962a9d902 100644 --- a/Mage/src/main/java/mage/target/TargetPlayer.java +++ b/Mage/src/main/java/mage/target/TargetPlayer.java @@ -89,7 +89,7 @@ public class TargetPlayer extends TargetImpl { public boolean canChoose(UUID sourceId, UUID sourceControllerId, Game game) { int count = 0; MageObject targetSource = game.getObject(sourceId); - for (UUID playerId: game.getPlayer(sourceControllerId).getInRange()) { + for (UUID playerId: game.getState().getPlayersInRange(sourceControllerId, game)) { Player player = game.getPlayer(playerId); if (player != null && !player.hasLeft() && filter.match(player, sourceId, sourceControllerId, game)) { if (player.canBeTargetedBy(targetSource, sourceControllerId, game)) { @@ -114,7 +114,7 @@ public class TargetPlayer extends TargetImpl { @Override public boolean canChoose(UUID sourceControllerId, Game game) { int count = 0; - for (UUID playerId: game.getPlayer(sourceControllerId).getInRange()) { + for (UUID playerId: game.getState().getPlayersInRange(sourceControllerId, game)) { Player player = game.getPlayer(playerId); if (player != null && !player.hasLeft() && filter.match(player, game)) { count++; @@ -130,7 +130,7 @@ public class TargetPlayer extends TargetImpl { public Set possibleTargets(UUID sourceId, UUID sourceControllerId, Game game) { Set possibleTargets = new HashSet<>(); MageObject targetSource = game.getObject(sourceId); - for (UUID playerId: game.getPlayer(sourceControllerId).getInRange()) { + for (UUID playerId: game.getState().getPlayersInRange(sourceControllerId, game)) { Player player = game.getPlayer(playerId); if (player != null && !player.hasLeft() && filter.match(player, sourceId, sourceControllerId, game)) { if (isNotTarget() || player.canBeTargetedBy(targetSource, sourceControllerId, game)) { @@ -144,7 +144,7 @@ public class TargetPlayer extends TargetImpl { @Override public Set possibleTargets(UUID sourceControllerId, Game game) { Set possibleTargets = new HashSet<>(); - for (UUID playerId: game.getPlayer(sourceControllerId).getInRange()) { + for (UUID playerId: game.getState().getPlayersInRange(sourceControllerId, game)) { Player player = game.getPlayer(playerId); if (player != null && !player.hasLeft() && filter.match(player, game)) { possibleTargets.add(playerId); diff --git a/Mage/src/main/java/mage/target/TargetSource.java b/Mage/src/main/java/mage/target/TargetSource.java index 84b9c5bf6a4..fa60757d701 100644 --- a/Mage/src/main/java/mage/target/TargetSource.java +++ b/Mage/src/main/java/mage/target/TargetSource.java @@ -113,7 +113,7 @@ public class TargetSource extends TargetObject { public boolean canChoose(UUID sourceControllerId, Game game) { int count = 0; for (StackObject stackObject: game.getStack()) { - if (game.getPlayer(sourceControllerId).getInRange().contains(stackObject.getControllerId()) && filter.match(stackObject, game)) { + if (game.getState().getPlayersInRange(sourceControllerId, game).contains(stackObject.getControllerId()) && filter.match(stackObject, game)) { count++; if (count >= this.minNumberOfTargets) { return true; @@ -158,7 +158,7 @@ public class TargetSource extends TargetObject { public Set possibleTargets(UUID sourceControllerId, Game game) { Set possibleTargets = new HashSet<>(); for (StackObject stackObject: game.getStack()) { - if (game.getPlayer(sourceControllerId).getInRange().contains(stackObject.getControllerId()) && filter.match(stackObject, game)) { + if (game.getState().getPlayersInRange(sourceControllerId, game).contains(stackObject.getControllerId()) && filter.match(stackObject, game)) { possibleTargets.add(stackObject.getId()); } } diff --git a/Mage/src/main/java/mage/target/TargetSpell.java b/Mage/src/main/java/mage/target/TargetSpell.java index a070bbc3b7c..525811a24a7 100644 --- a/Mage/src/main/java/mage/target/TargetSpell.java +++ b/Mage/src/main/java/mage/target/TargetSpell.java @@ -134,7 +134,7 @@ public class TargetSpell extends TargetObject { private boolean canBeChosen(StackObject stackObject, UUID sourceID, UUID sourceControllerId, Game game) { return stackObject instanceof Spell - && game.getPlayer(sourceControllerId).getInRange().contains(stackObject.getControllerId()) + && game.getState().getPlayersInRange(sourceControllerId, game).contains(stackObject.getControllerId()) && filter.match((Spell) stackObject, sourceID, sourceControllerId, game); } } diff --git a/Mage/src/main/java/mage/target/TargetStackObject.java b/Mage/src/main/java/mage/target/TargetStackObject.java index 467565ee72d..a4033f5c5f3 100644 --- a/Mage/src/main/java/mage/target/TargetStackObject.java +++ b/Mage/src/main/java/mage/target/TargetStackObject.java @@ -89,7 +89,7 @@ public class TargetStackObject extends TargetObject { public boolean canChoose(UUID sourceId, UUID sourceControllerId, Game game) { int count = 0; for (StackObject stackObject: game.getStack()) { - if (game.getPlayer(sourceControllerId).getInRange().contains(stackObject.getControllerId()) && filter.match(stackObject, sourceId, sourceControllerId, game)) { + if (game.getState().getPlayersInRange(sourceControllerId, game).contains(stackObject.getControllerId()) && filter.match(stackObject, sourceId, sourceControllerId, game)) { count++; if (count >= this.minNumberOfTargets) { return true; @@ -108,7 +108,7 @@ public class TargetStackObject extends TargetObject { public Set possibleTargets(UUID sourceId, UUID sourceControllerId, Game game) { Set possibleTargets = new HashSet<>(); for (StackObject stackObject: game.getStack()) { - if (game.getPlayer(sourceControllerId).getInRange().contains(stackObject.getControllerId()) && filter.match(stackObject, sourceId, sourceControllerId, game)) { + if (game.getState().getPlayersInRange(sourceControllerId, game).contains(stackObject.getControllerId()) && filter.match(stackObject, sourceId, sourceControllerId, game)) { possibleTargets.add(stackObject.getId()); } } diff --git a/Mage/src/main/java/mage/target/common/TargetActivatedAbility.java b/Mage/src/main/java/mage/target/common/TargetActivatedAbility.java index 9cc07a1165a..3a2b52de55c 100644 --- a/Mage/src/main/java/mage/target/common/TargetActivatedAbility.java +++ b/Mage/src/main/java/mage/target/common/TargetActivatedAbility.java @@ -76,7 +76,7 @@ public class TargetActivatedAbility extends TargetObject { for (StackObject stackObject : game.getStack()) { if (stackObject.getStackAbility() != null && stackObject.getStackAbility().getAbilityType().equals(AbilityType.ACTIVATED) - && game.getPlayer(sourceControllerId).getInRange().contains(stackObject.getStackAbility().getControllerId())) { + && game.getState().getPlayersInRange(sourceControllerId, game).contains(stackObject.getStackAbility().getControllerId())) { return true; } } @@ -92,7 +92,7 @@ public class TargetActivatedAbility extends TargetObject { public Set possibleTargets(UUID sourceControllerId, Game game) { Set possibleTargets = new HashSet<>(); for (StackObject stackObject : game.getStack()) { - if (stackObject.getStackAbility().getAbilityType().equals(AbilityType.ACTIVATED) && game.getPlayer(sourceControllerId).getInRange().contains(stackObject.getStackAbility().getControllerId())) { + if (stackObject.getStackAbility().getAbilityType().equals(AbilityType.ACTIVATED) && game.getState().getPlayersInRange(sourceControllerId, game).contains(stackObject.getStackAbility().getControllerId())) { possibleTargets.add(stackObject.getStackAbility().getId()); } } diff --git a/Mage/src/main/java/mage/target/common/TargetCardInOpponentsGraveyard.java b/Mage/src/main/java/mage/target/common/TargetCardInOpponentsGraveyard.java index 202572c0b54..175bb63a290 100644 --- a/Mage/src/main/java/mage/target/common/TargetCardInOpponentsGraveyard.java +++ b/Mage/src/main/java/mage/target/common/TargetCardInOpponentsGraveyard.java @@ -68,7 +68,7 @@ public class TargetCardInOpponentsGraveyard extends TargetCard { @Override public boolean canChoose(UUID sourceId, UUID sourceControllerId, Game game) { int possibleTargets = 0; - for (UUID playerId: game.getPlayer(sourceControllerId).getInRange()) { + for (UUID playerId: game.getState().getPlayersInRange(sourceControllerId, game)) { if (!playerId.equals(sourceControllerId)) { Player player = game.getPlayer(playerId); if (player != null) { diff --git a/Mage/src/main/java/mage/target/common/TargetCreatureOrPlayer.java b/Mage/src/main/java/mage/target/common/TargetCreatureOrPlayer.java index 842c34c85ef..3b55514126c 100644 --- a/Mage/src/main/java/mage/target/common/TargetCreatureOrPlayer.java +++ b/Mage/src/main/java/mage/target/common/TargetCreatureOrPlayer.java @@ -135,7 +135,7 @@ public class TargetCreatureOrPlayer extends TargetImpl { public boolean canChoose(UUID sourceId, UUID sourceControllerId, Game game) { int count = 0; MageObject targetSource = game.getObject(sourceId); - for (UUID playerId: game.getPlayer(sourceControllerId).getInRange()) { + for (UUID playerId: game.getState().getPlayersInRange(sourceControllerId, game)) { Player player = game.getPlayer(playerId); if (player != null && player.canBeTargetedBy(targetSource, sourceControllerId, game) && filter.match(player, game)) { count++; @@ -166,7 +166,7 @@ public class TargetCreatureOrPlayer extends TargetImpl { @Override public boolean canChoose(UUID sourceControllerId, Game game) { int count = 0; - for (UUID playerId: game.getPlayer(sourceControllerId).getInRange()) { + for (UUID playerId: game.getState().getPlayersInRange(sourceControllerId, game)) { Player player = game.getPlayer(playerId); if (player != null && filter.match(player, game)) { count++; @@ -190,7 +190,7 @@ public class TargetCreatureOrPlayer extends TargetImpl { public Set possibleTargets(UUID sourceId, UUID sourceControllerId, Game game) { Set possibleTargets = new HashSet<>(); MageObject targetSource = game.getObject(sourceId); - for (UUID playerId: game.getPlayer(sourceControllerId).getInRange()) { + for (UUID playerId: game.getState().getPlayersInRange(sourceControllerId, game)) { Player player = game.getPlayer(playerId); if (player != null && player.canBeTargetedBy(targetSource, sourceControllerId, game) @@ -210,7 +210,7 @@ public class TargetCreatureOrPlayer extends TargetImpl { @Override public Set possibleTargets(UUID sourceControllerId, Game game) { Set possibleTargets = new HashSet<>(); - for (UUID playerId: game.getPlayer(sourceControllerId).getInRange()) { + for (UUID playerId: game.getState().getPlayersInRange(sourceControllerId, game)) { Player player = game.getPlayer(playerId); if (player != null && filter.getPlayerFilter().match(player, game)) { possibleTargets.add(playerId); diff --git a/Mage/src/main/java/mage/target/common/TargetCreatureOrPlayerAmount.java b/Mage/src/main/java/mage/target/common/TargetCreatureOrPlayerAmount.java index 33ea4c44808..25b1c076ff4 100644 --- a/Mage/src/main/java/mage/target/common/TargetCreatureOrPlayerAmount.java +++ b/Mage/src/main/java/mage/target/common/TargetCreatureOrPlayerAmount.java @@ -123,7 +123,7 @@ public class TargetCreatureOrPlayerAmount extends TargetAmount { public boolean canChoose(UUID sourceId, UUID sourceControllerId, Game game) { int count = 0; MageObject targetSource = game.getObject(sourceId); - for (UUID playerId : game.getPlayer(sourceControllerId).getInRange()) { + for (UUID playerId : game.getState().getPlayersInRange(sourceControllerId, game)) { Player player = game.getPlayer(playerId); if (player != null && player.canBeTargetedBy(targetSource, sourceControllerId, game) && filter.match(player, game)) { count++; @@ -146,7 +146,7 @@ public class TargetCreatureOrPlayerAmount extends TargetAmount { @Override public boolean canChoose(UUID sourceControllerId, Game game) { int count = 0; - for (UUID playerId : game.getPlayer(sourceControllerId).getInRange()) { + for (UUID playerId : game.getState().getPlayersInRange(sourceControllerId, game)) { Player player = game.getPlayer(playerId); if (player != null && filter.match(player, game)) { count++; @@ -170,7 +170,7 @@ public class TargetCreatureOrPlayerAmount extends TargetAmount { public Set possibleTargets(UUID sourceId, UUID sourceControllerId, Game game) { Set possibleTargets = new HashSet<>(); MageObject targetSource = game.getObject(sourceId); - for (UUID playerId : game.getPlayer(sourceControllerId).getInRange()) { + for (UUID playerId : game.getState().getPlayersInRange(sourceControllerId, game)) { Player player = game.getPlayer(playerId); if (player != null && player.canBeTargetedBy(targetSource, sourceControllerId, game) && filter.match(player, game)) { possibleTargets.add(playerId); @@ -187,7 +187,7 @@ public class TargetCreatureOrPlayerAmount extends TargetAmount { @Override public Set possibleTargets(UUID sourceControllerId, Game game) { Set possibleTargets = new HashSet<>(); - for (UUID playerId : game.getPlayer(sourceControllerId).getInRange()) { + for (UUID playerId : game.getState().getPlayersInRange(sourceControllerId, game)) { Player player = game.getPlayer(playerId); if (player != null && filter.match(player, game)) { possibleTargets.add(playerId); diff --git a/Mage/src/main/java/mage/target/common/TargetDefender.java b/Mage/src/main/java/mage/target/common/TargetDefender.java index 9c1df7addcb..55dcfec22b9 100644 --- a/Mage/src/main/java/mage/target/common/TargetDefender.java +++ b/Mage/src/main/java/mage/target/common/TargetDefender.java @@ -84,7 +84,7 @@ public class TargetDefender extends TargetImpl { public boolean canChoose(UUID sourceId, UUID sourceControllerId, Game game) { int count = 0; MageObject targetSource = game.getObject(sourceId); - for (UUID playerId: game.getPlayer(sourceControllerId).getInRange()) { + for (UUID playerId: game.getState().getPlayersInRange(sourceControllerId, game)) { Player player = game.getPlayer(playerId); // removed canBeTargeted because it's not correct to check it for attacking target if (player != null && player.canBeTargetedBy(targetSource, sourceControllerId, game) && filter.match(player, game)) { @@ -109,7 +109,7 @@ public class TargetDefender extends TargetImpl { @Override public boolean canChoose(UUID sourceControllerId, Game game) { int count = 0; - for (UUID playerId: game.getPlayer(sourceControllerId).getInRange()) { + for (UUID playerId: game.getState().getPlayersInRange(sourceControllerId, game)) { Player player = game.getPlayer(playerId); if (player != null && filter.match(player, game)) { count++; @@ -133,7 +133,7 @@ public class TargetDefender extends TargetImpl { public Set possibleTargets(UUID sourceId, UUID sourceControllerId, Game game) { Set possibleTargets = new HashSet<>(); MageObject targetSource = game.getObject(sourceId); - for (UUID playerId: game.getPlayer(sourceControllerId).getInRange()) { + for (UUID playerId: game.getState().getPlayersInRange(sourceControllerId, game)) { Player player = game.getPlayer(playerId); if (player != null && player.canBeTargetedBy(targetSource, sourceControllerId, game) && filter.match(player, game)) { possibleTargets.add(playerId); @@ -150,7 +150,7 @@ public class TargetDefender extends TargetImpl { @Override public Set possibleTargets(UUID sourceControllerId, Game game) { Set possibleTargets = new HashSet<>(); - for (UUID playerId: game.getPlayer(sourceControllerId).getInRange()) { + for (UUID playerId: game.getState().getPlayersInRange(sourceControllerId, game)) { Player player = game.getPlayer(playerId); if (player != null && filter.match(player, game)) { possibleTargets.add(playerId); diff --git a/Mage/src/main/java/mage/target/common/TargetPermanentOrPlayer.java b/Mage/src/main/java/mage/target/common/TargetPermanentOrPlayer.java index 9fddd067f79..e2b8175b341 100644 --- a/Mage/src/main/java/mage/target/common/TargetPermanentOrPlayer.java +++ b/Mage/src/main/java/mage/target/common/TargetPermanentOrPlayer.java @@ -156,7 +156,7 @@ public class TargetPermanentOrPlayer extends TargetImpl { public boolean canChoose(UUID sourceId, UUID sourceControllerId, Game game) { int count = 0; MageObject targetSource = game.getObject(sourceId); - for (UUID playerId: game.getPlayer(sourceControllerId).getInRange()) { + for (UUID playerId: game.getState().getPlayersInRange(sourceControllerId, game)) { Player player = game.getPlayer(playerId); if (player != null && player.canBeTargetedBy(targetSource, sourceControllerId, game) && filter.match(player, game)) { count++; @@ -187,7 +187,7 @@ public class TargetPermanentOrPlayer extends TargetImpl { @Override public boolean canChoose(UUID sourceControllerId, Game game) { int count = 0; - for (UUID playerId: game.getPlayer(sourceControllerId).getInRange()) { + for (UUID playerId: game.getState().getPlayersInRange(sourceControllerId, game)) { Player player = game.getPlayer(playerId); if (player != null && filter.match(player, game)) { count++; @@ -211,7 +211,7 @@ public class TargetPermanentOrPlayer extends TargetImpl { public Set possibleTargets(UUID sourceId, UUID sourceControllerId, Game game) { Set possibleTargets = new HashSet<>(); MageObject targetSource = game.getObject(sourceId); - for (UUID playerId: game.getPlayer(sourceControllerId).getInRange()) { + for (UUID playerId: game.getState().getPlayersInRange(sourceControllerId, game)) { Player player = game.getPlayer(playerId); if (player != null && (notTarget || player.canBeTargetedBy(targetSource, sourceControllerId, game)) && filter.match(player, game)) { possibleTargets.add(playerId); @@ -228,7 +228,7 @@ public class TargetPermanentOrPlayer extends TargetImpl { @Override public Set possibleTargets(UUID sourceControllerId, Game game) { Set possibleTargets = new HashSet<>(); - for (UUID playerId: game.getPlayer(sourceControllerId).getInRange()) { + for (UUID playerId: game.getState().getPlayersInRange(sourceControllerId, game)) { Player player = game.getPlayer(playerId); if (player != null && filter.match(player, game)) { possibleTargets.add(playerId);