Merge pull request #2896 from kubikrubikvkube/master

Inner classes should be static. It reduces memory usage and gives perfomance boost + DeckImporter rollback
This commit is contained in:
ingmargoudt 2017-02-28 12:24:19 +01:00 committed by GitHub
commit aa01db1432
268 changed files with 1319 additions and 1759 deletions

View file

@ -27,84 +27,19 @@
*/
package mage.client;
import java.awt.AWTEvent;
import java.awt.AlphaComposite;
import java.awt.Color;
import java.awt.Component;
import java.awt.Cursor;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.Graphics2D;
import java.awt.Image;
import java.awt.Rectangle;
import java.awt.SplashScreen;
import java.awt.Toolkit;
import java.awt.event.ComponentAdapter;
import java.awt.event.ComponentEvent;
import java.awt.event.ItemEvent;
import java.awt.event.KeyEvent;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.awt.image.BufferedImage;
import java.beans.PropertyVetoException;
import java.io.IOException;
import java.io.InputStream;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
import java.util.prefs.Preferences;
import javax.imageio.ImageIO;
import javax.swing.AbstractButton;
import javax.swing.ImageIcon;
import javax.swing.InputMap;
import javax.swing.JButton;
import javax.swing.JCheckBoxMenuItem;
import javax.swing.JComponent;
import javax.swing.JDesktopPane;
import javax.swing.JEditorPane;
import javax.swing.JFrame;
import javax.swing.JInternalFrame;
import javax.swing.JLabel;
import javax.swing.JLayeredPane;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JPopupMenu;
import javax.swing.JToggleButton;
import javax.swing.KeyStroke;
import javax.swing.SwingConstants;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;
import javax.swing.event.PopupMenuEvent;
import javax.swing.event.PopupMenuListener;
import mage.cards.decks.Deck;
import mage.cards.repository.CardCriteria;
import mage.cards.repository.CardInfo;
import mage.cards.repository.CardRepository;
import mage.client.cards.BigCard;
import mage.client.chat.ChatPanelBasic;
import mage.client.components.MageComponents;
import mage.client.components.MageDesktopManager;
import mage.client.components.MageJDesktop;
import mage.client.components.MageRoundPane;
import mage.client.components.MageUI;
import mage.client.components.*;
import mage.client.components.ext.dlg.DialogManager;
import mage.client.components.tray.MageTray;
import mage.client.constants.Constants.DeckEditorMode;
import mage.client.deckeditor.DeckEditorPane;
import mage.client.deckeditor.collection.viewer.CollectionViewerPane;
import mage.client.dialog.AboutDialog;
import mage.client.dialog.ConnectDialog;
import mage.client.dialog.ErrorDialog;
import mage.client.dialog.FeedbackDialog;
import mage.client.dialog.GameEndDialog;
import mage.client.dialog.MageDialog;
import mage.client.dialog.PreferencesDialog;
import mage.client.dialog.TableWaitingDialog;
import mage.client.dialog.UserRequestDialog;
import mage.client.dialog.*;
import mage.client.draft.DraftPane;
import mage.client.draft.DraftPanel;
import mage.client.game.GamePane;
@ -114,11 +49,7 @@ import mage.client.preference.MagePreferences;
import mage.client.remote.CallbackClientImpl;
import mage.client.table.TablesPane;
import mage.client.tournament.TournamentPane;
import mage.client.util.EDTExceptionHandler;
import mage.client.util.GUISizeHelper;
import mage.client.util.ImageCaches;
import mage.client.util.SettingsManager;
import mage.client.util.SystemUtil;
import mage.client.util.*;
import mage.client.util.audio.MusicPlayer;
import mage.client.util.gui.ArrowBuilder;
import mage.client.util.gui.countryBox.CountryUtil;
@ -145,6 +76,25 @@ import org.mage.plugins.card.images.DownloadPictures;
import org.mage.plugins.card.info.CardInfoPaneImpl;
import org.mage.plugins.card.utils.impl.ImageManagerImpl;
import javax.imageio.ImageIO;
import javax.swing.*;
import javax.swing.event.PopupMenuEvent;
import javax.swing.event.PopupMenuListener;
import java.awt.*;
import java.awt.event.*;
import java.awt.image.BufferedImage;
import java.beans.PropertyVetoException;
import java.io.IOException;
import java.io.InputStream;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
import java.util.prefs.Preferences;
/**
* @author BetaSteward_at_googlemail.com
*/
@ -472,7 +422,7 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
String filename = "/background.jpg";
try {
if (Plugins.getInstance().isThemePluginLoaded()) {
backgroundPane = (ImagePanel) Plugins.getInstance().updateTablePanel(new HashMap<String, JComponent>());
backgroundPane = (ImagePanel) Plugins.getInstance().updateTablePanel(new HashMap<>());
} else {
InputStream is = this.getClass().getResourceAsStream(filename);
BufferedImage background = ImageIO.read(is);

View file

@ -1,10 +1,5 @@
package mage.client.components.ability;
import java.awt.*;
import java.awt.event.*;
import java.util.*;
import java.util.List;
import javax.swing.*;
import mage.client.SessionHandler;
import mage.client.util.ImageHelper;
import mage.client.util.SettingsManager;
@ -19,6 +14,12 @@ import org.jsoup.Jsoup;
import org.mage.card.arcane.ManaSymbols;
import org.mage.card.arcane.UI;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.util.*;
import java.util.List;
/**
* Dialog for choosing abilities.
*
@ -91,7 +92,7 @@ public class AbilityPicker extends JXPanel implements MouseWheelListener {
}
public void show(AbilityPickerView choices, Point p) {
this.choices = new ArrayList<Object>();
this.choices = new ArrayList<>();
this.selected = true; // to stop previous modal
for (Map.Entry<UUID, String> choice : choices.getChoices().entrySet()) {
@ -233,9 +234,9 @@ public class AbilityPicker extends JXPanel implements MouseWheelListener {
action.actionPerformed(null);
}
public class ImageRenderer2 extends JEditorPane implements ListCellRenderer {
public static class ImageRenderer2 extends JEditorPane implements ListCellRenderer {
public final Map<String, String> cache = new HashMap<String, String>();
public final Map<String, String> cache = new HashMap<>();
@Override
public Component getListCellRendererComponent(
@ -397,7 +398,7 @@ public class AbilityPicker extends JXPanel implements MouseWheelListener {
JFrame jframe = new JFrame("Test");
List<Object> objectList = new ArrayList<Object>();
List<Object> objectList = new ArrayList<>();
objectList.add("T: add {R} to your mana pool. 111111111111111111111111111");
objectList.add("T: add {B} to your mana pool. {source} deals 1 damage to you.");
objectList.add("{T}: add {B} to your mana pool");

View file

@ -38,7 +38,7 @@ public class DlgParams {
boolean isAI = false;
public HashSet<String> manaChoices = new HashSet<String>();
public HashSet<String> manaChoices = new HashSet<>();
public int getPlayerID() {
return playerID;

View file

@ -9,18 +9,18 @@ import mage.client.components.ext.dlg.DialogManager;
import mage.client.components.ext.dlg.DlgParams;
import mage.client.components.ext.dlg.IDialogPanel;
import mage.client.plugins.impl.Plugins;
import mage.client.util.audio.AudioManager;
import mage.client.util.Command;
import mage.client.util.SettingsManager;
import mage.client.util.audio.AudioManager;
import mage.view.CardView;
import mage.view.CardsView;
import org.mage.card.arcane.CardPanel;
import org.mage.plugins.card.utils.impl.ImageManagerImpl;
import javax.swing.*;
import java.awt.*;
import java.util.ArrayList;
import java.util.UUID;
import org.mage.card.arcane.CardPanel;
/**
* @author mw, noxx
@ -130,7 +130,7 @@ public class ChoiceDialog extends IDialogPanel {
return;
}
java.util.List<Component> toRemove = new ArrayList<Component>();
java.util.List<Component> toRemove = new ArrayList<>();
for (int i = getComponentCount() - 1; i > 0; i--) {
Component o = getComponent(i);
if (o instanceof MageCard) {
@ -141,7 +141,7 @@ public class ChoiceDialog extends IDialogPanel {
remove(toRemove.get(i));
}
java.util.List<CardView> cardList = new ArrayList<CardView>(cards.values());
java.util.List<CardView> cardList = new ArrayList<>(cards.values());
int width = SettingsManager.getInstance().getCardSize().width;
int height = SettingsManager.getInstance().getCardSize().height;

View file

@ -36,7 +36,7 @@ public class StackDialog extends IDialogPanel {
private final UUID gameId;
private class CustomLabel extends JLabel {
private static class CustomLabel extends JLabel {
@Override
public void paintComponent(Graphics g) {

View file

@ -30,7 +30,7 @@ package mage.client.deck.generator;
import javax.swing.*;
import java.awt.*;
import java.util.*;
import java.util.ArrayList;
import java.util.List;
/**
@ -42,7 +42,7 @@ public class RatioAdjustingSliderPanel extends JPanel {
private final List<JLabel> textLabels = new ArrayList<>();
private AdjustingSliderGroup sg;
private class JStorageSlider extends JSlider {
private static class JStorageSlider extends JSlider {
// Slider stores its initial value to revert to when reset
private final int defaultValue;
@ -74,7 +74,7 @@ public class RatioAdjustingSliderPanel extends JPanel {
}
private class AdjustingSliderGroup
private static class AdjustingSliderGroup
{
private final ArrayList<JStorageSlider> storageSliders;
private int sliderIndex = 0;

View file

@ -33,19 +33,6 @@
*/
package mage.client.deckeditor;
import java.awt.Color;
import java.awt.Cursor;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ComponentEvent;
import java.awt.event.ComponentListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.util.*;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JTable;
import javax.swing.SwingUtilities;
import javax.swing.table.DefaultTableCellRenderer;
import mage.MageObject;
import mage.ObjectColor;
import mage.cards.Card;
@ -72,6 +59,13 @@ import mage.filter.predicate.other.ExpansionSetPredicate;
import mage.view.CardView;
import mage.view.CardsView;
import javax.swing.*;
import javax.swing.table.DefaultTableCellRenderer;
import java.awt.*;
import java.awt.event.*;
import java.util.*;
import java.util.List;
/**
*
* @author BetaSteward_at_googlemail.com, nantuko
@ -442,7 +436,7 @@ public class CardSelector extends javax.swing.JPanel implements ComponentListene
tbWhite = new javax.swing.JToggleButton();
tbColorless = new javax.swing.JToggleButton();
jSeparator1 = new javax.swing.JToolBar.Separator();
cbExpansionSet = new javax.swing.JComboBox<String>();
cbExpansionSet = new javax.swing.JComboBox<>();
jSeparator2 = new javax.swing.JToolBar.Separator();
btnBooster = new javax.swing.JButton();
btnClear = new javax.swing.JButton();
@ -457,7 +451,7 @@ public class CardSelector extends javax.swing.JPanel implements ComponentListene
jSeparator6 = new javax.swing.JToolBar.Separator();
chkPiles = new javax.swing.JCheckBox();
jSeparator3 = new javax.swing.JToolBar.Separator();
cbSortBy = new javax.swing.JComboBox<SortBy>();
cbSortBy = new javax.swing.JComboBox<>();
jSeparator4 = new javax.swing.JToolBar.Separator();
jToggleListView = new javax.swing.JToggleButton();
jToggleCardView = new javax.swing.JToggleButton();

View file

@ -27,13 +27,14 @@
*/
package mage.client.deckeditor.collection.viewer;
import java.awt.Component;
import java.util.HashMap;
import java.util.Map;
import javax.swing.JComponent;
import mage.client.MagePane;
import mage.client.plugins.impl.Plugins;
import javax.swing.*;
import java.awt.*;
import java.util.HashMap;
import java.util.Map;
/**
* Collection viewer pane.
* Contains background and components container.
@ -46,7 +47,7 @@ public class CollectionViewerPane extends MagePane {
boolean initialized = false;
this.setTitle("Collection Viewer");
if (Plugins.getInstance().isThemePluginLoaded()) {
Map<String, JComponent> uiComponents = new HashMap<String, JComponent>();
Map<String, JComponent> uiComponents = new HashMap<>();
JComponent container = Plugins.getInstance().updateTablePanel(uiComponents);
if (container != null) {
collectionViewerPanel = new CollectionViewerPanel();

View file

@ -27,19 +27,6 @@
*/
package mage.client.deckeditor.collection.viewer;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Image;
import java.awt.Rectangle;
import java.awt.image.BufferedImage;
import java.io.FileNotFoundException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import javax.imageio.ImageIO;
import javax.swing.*;
import mage.cards.Card;
import mage.cards.CardDimensions;
import mage.cards.MageCard;
@ -63,6 +50,16 @@ import org.apache.log4j.Logger;
import org.mage.card.arcane.GlowText;
import org.mage.card.arcane.ManaSymbols;
import javax.imageio.ImageIO;
import javax.swing.*;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.FileNotFoundException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
/**
* Mage book with cards and page flipping.
*
@ -362,7 +359,7 @@ public class MageBook extends JComponent {
public static final int GAP_Y = 45;
}
abstract class Configuration {
abstract static class Configuration {
public int CARDS_PER_PAGE;
public int CARD_ROWS;

View file

@ -34,14 +34,15 @@
package mage.client.table;
import java.io.File;
import java.io.IOException;
import javax.swing.JFileChooser;
import javax.swing.filechooser.FileFilter;
import mage.client.MageFrame;
import mage.client.deck.generator.DeckGenerator;
import mage.client.util.Config;
import javax.swing.*;
import javax.swing.filechooser.FileFilter;
import java.io.File;
import java.io.IOException;
/**
*
* @author BetaSteward_at_googlemail.com
@ -150,18 +151,10 @@ public class NewPlayerPanel extends javax.swing.JPanel {
lblPlayerDeck.setText("Deck:");
btnPlayerDeck.setText("...");
btnPlayerDeck.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnPlayerDeckActionPerformed(evt);
}
});
btnPlayerDeck.addActionListener(evt -> btnPlayerDeckActionPerformed(evt));
btnGenerate.setText("Generate");
btnGenerate.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnGenerateActionPerformed(evt);
}
});
btnGenerate.addActionListener(evt -> btnGenerateActionPerformed(evt));
lblLevel.setText("Skill:");

View file

@ -33,28 +33,8 @@
*/
package mage.client.table;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.event.MouseEvent;
import java.awt.event.MouseMotionAdapter;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.swing.Icon;
import javax.swing.JLabel;
import javax.swing.JTable;
import javax.swing.border.EmptyBorder;
import javax.swing.table.AbstractTableModel;
import javax.swing.table.JTableHeader;
import javax.swing.table.TableColumn;
import javax.swing.table.TableColumnModel;
import mage.client.MageFrame;
import mage.client.chat.ChatPanelBasic;
import static mage.client.chat.ChatPanelBasic.CHAT_ALPHA;
import static mage.client.dialog.PreferencesDialog.KEY_USERS_COLUMNS_ORDER;
import static mage.client.dialog.PreferencesDialog.KEY_USERS_COLUMNS_WIDTH;
import mage.client.util.GUISizeHelper;
import mage.client.util.MageTableRowSorter;
import mage.client.util.gui.TableUtil;
@ -64,6 +44,22 @@ import mage.view.RoomUsersView;
import mage.view.UsersView;
import net.java.balloontip.utils.ToolTipUtils;
import javax.swing.*;
import javax.swing.border.EmptyBorder;
import javax.swing.table.AbstractTableModel;
import javax.swing.table.JTableHeader;
import javax.swing.table.TableColumn;
import javax.swing.table.TableColumnModel;
import java.awt.*;
import java.awt.event.MouseEvent;
import java.awt.event.MouseMotionAdapter;
import java.util.*;
import java.util.List;
import static mage.client.chat.ChatPanelBasic.CHAT_ALPHA;
import static mage.client.dialog.PreferencesDialog.KEY_USERS_COLUMNS_ORDER;
import static mage.client.dialog.PreferencesDialog.KEY_USERS_COLUMNS_WIDTH;
/**
*
* @author BetaSteward_at_googlemail.com, nantuko
@ -391,7 +387,7 @@ public class PlayersChatPanel extends javax.swing.JPanel {
private javax.swing.JTable jTablePlayers;
// End of variables declaration//GEN-END:variables
class ColumnHeaderToolTips extends MouseMotionAdapter {
static class ColumnHeaderToolTips extends MouseMotionAdapter {
int curCol;
final Map<Integer, String> tips = new HashMap<>();

View file

@ -636,7 +636,7 @@ public class TablesPanel extends javax.swing.JPanel {
List<RowFilter<Object, Object>> ignoreListFilterList = new ArrayList<>();
String serverAddress = SessionHandler.getSession().getServerHostname().orElseGet(() -> "");
final Set<String> ignoreListCopy = IgnoreList.ignoreList(serverAddress);
if (ignoreListCopy.size() > 0) {
if (!ignoreListCopy.isEmpty()) {
ignoreListFilterList.add(new RowFilter<Object, Object>() {
@Override
public boolean include(Entry<? extends Object, ? extends Object> entry) {

View file

@ -34,12 +34,12 @@
package mage.client.table;
import java.util.UUID;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JComboBox;
import mage.cards.decks.DeckCardLists;
import mage.client.SessionHandler;
import javax.swing.*;
import java.util.UUID;
/**
*
* @author BetaSteward_at_googlemail.com
@ -99,11 +99,7 @@ public class TournamentPlayerPanel extends javax.swing.JPanel {
jLabel1.setText("Type:");
cbPlayerType.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
cbPlayerType.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
cbPlayerTypeActionPerformed(evt);
}
});
cbPlayerType.addActionListener(evt -> cbPlayerTypeActionPerformed(evt));
lblPlayerNum.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
lblPlayerNum.setText("Player Num:");

View file

@ -2,7 +2,7 @@
package mage.client.unusedFiles;
//package mage.client.thread;
import java.awt.Component;
import java.awt.*;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
@ -18,7 +18,7 @@ public class DelayedViewerThread extends Thread {
private final Map<Component, Long> delayedViewers;
protected DelayedViewerThread() {
delayedViewers = new HashMap<Component, Long>();
delayedViewers = new HashMap<>();
start();
}

View file

@ -36,7 +36,7 @@ public final class IgnoreList {
}
public static String ignore(String serverAddress, String user) {
if (user == null || user.length() == 0) {
if (user == null || user.isEmpty()) {
return ignoreListString(serverAddress);
}
@ -71,7 +71,7 @@ public final class IgnoreList {
}
public static String unignore(String serverAddress, String user) {
if (user == null || user.length() == 0) {
if (user == null || user.isEmpty()) {
return usage();
}
if (MagePreferences.removeIgnoredUser(serverAddress, user)) {

View file

@ -30,9 +30,9 @@ public class ArrowBuilder {
/**
* Stores arrow panels per game
*/
private final Map<UUID, JPanel> arrowPanels = new HashMap<UUID, JPanel>();
private final Map<UUID, JPanel> arrowPanels = new HashMap<>();
private final Map<UUID, Map<Type, List<Arrow>>> map = new HashMap<UUID, Map<Type, java.util.List<Arrow>>>();
private final Map<UUID, Map<Type, List<Arrow>>> map = new HashMap<>();
private int currentWidth;
private int currentHeight;
@ -103,16 +103,8 @@ public class ArrowBuilder {
synchronized (map) {
p.add(arrow);
Map<Type, java.util.List<Arrow>> innerMap = map.get(gameId);
if (innerMap == null) {
innerMap = new HashMap<Type, List<Arrow>>();
map.put(gameId, innerMap);
}
java.util.List<Arrow> arrows = innerMap.get(type);
if (arrows == null) {
arrows = new ArrayList<Arrow>();
innerMap.put(type, arrows);
}
Map<Type, java.util.List<Arrow>> innerMap = map.computeIfAbsent(gameId, k -> new HashMap<>());
java.util.List<Arrow> arrows = innerMap.computeIfAbsent(type, k -> new ArrayList<>());
arrows.add(arrow);
}
@ -143,13 +135,13 @@ public class ArrowBuilder {
if (map.containsKey(gameId)) {
Map<Type, List<Arrow>> innerMap = map.get(gameId);
java.util.List<Arrow> arrows = innerMap.get(type);
if (arrows != null && arrows.size() > 0) {
if (arrows != null && !arrows.isEmpty()) {
JPanel p = getArrowsPanel(gameId);
synchronized (map) {
for (Arrow arrow : arrows) {
p.remove(arrow);
}
innerMap.put(type, new ArrayList<Arrow>());
innerMap.put(type, new ArrayList<>());
}
p.revalidate();
p.repaint();

View file

@ -72,7 +72,7 @@ public class BufferedImageBuilder {
}
}
class ImageLoadStatus {
static class ImageLoadStatus {
public boolean widthDone = false;
public boolean heightDone = false;
}

View file

@ -2,24 +2,6 @@ package org.mage.card.arcane;
import com.google.common.base.Function;
import com.google.common.collect.MapMaker;
import java.awt.AlphaComposite;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Image;
import java.awt.RenderingHints;
import java.awt.image.BufferedImage;
import java.io.File;
import java.util.Map;
import java.util.StringTokenizer;
import java.util.UUID;
import javax.swing.BorderFactory;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;
import mage.cards.action.ActionCallback;
import mage.client.dialog.PreferencesDialog;
import mage.client.util.ImageCaches;
@ -34,11 +16,20 @@ import mage.view.StackAbilityView;
import net.java.truevfs.access.TFile;
import org.apache.log4j.Logger;
import org.jdesktop.swingx.graphics.GraphicsUtilities;
import static org.mage.plugins.card.constants.Constants.THUMBNAIL_SIZE_FULL;
import org.mage.plugins.card.dl.sources.DirectLinksForDownload;
import org.mage.plugins.card.images.ImageCache;
import org.mage.plugins.card.utils.impl.ImageManagerImpl;
import javax.swing.*;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.File;
import java.util.Map;
import java.util.StringTokenizer;
import java.util.UUID;
import static org.mage.plugins.card.constants.Constants.THUMBNAIL_SIZE_FULL;
/**
* Class for drawing the mage card object by using a form based JComponent approach
*
@ -84,7 +75,7 @@ public class CardPanelComponentImpl extends CardPanel {
private final static Map<Key, BufferedImage> IMAGE_CACHE;
class Key {
static class Key {
final int width;
final int height;
@ -341,7 +332,7 @@ public class CardPanelComponentImpl extends CardPanel {
g2d.drawImage(
IMAGE_CACHE.get(
new Key(getWidth(), getHeight(), getCardWidth(), getCardHeight(), getCardXOffset(), getCardYOffset(),
new Key(getWidth(), getHeight(), getCardWidth(), getCardHeight(), getCardXOffset(), getCardYOffset(),
hasImage, isSelected(), isChoosable(), gameCard.isPlayable(), gameCard.isCanAttack())),
0, 0, null);
g2d.dispose();

View file

@ -1,14 +1,6 @@
package org.mage.card.arcane;
import com.google.common.collect.MapMaker;
import java.awt.Dimension;
import java.awt.Graphics2D;
import java.awt.Image;
import java.awt.RenderingHints;
import java.awt.image.BufferedImage;
import java.io.File;
import java.util.Map;
import java.util.UUID;
import mage.cards.action.ActionCallback;
import mage.constants.CardType;
import mage.view.CardView;
@ -18,10 +10,17 @@ import mage.view.StackAbilityView;
import net.java.truevfs.access.TFile;
import org.apache.log4j.Logger;
import org.jdesktop.swingx.graphics.GraphicsUtilities;
import static org.mage.plugins.card.constants.Constants.THUMBNAIL_SIZE_FULL;
import org.mage.plugins.card.dl.sources.DirectLinksForDownload;
import org.mage.plugins.card.images.ImageCache;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.File;
import java.util.Map;
import java.util.UUID;
import static org.mage.plugins.card.constants.Constants.THUMBNAIL_SIZE_FULL;
public class CardPanelRenderImpl extends CardPanel {
private static final Logger LOGGER = Logger.getLogger(CardPanelRenderImpl.class);
@ -114,7 +113,7 @@ public class CardPanelRenderImpl extends CardPanel {
return true;
}
class ImageKey {
static class ImageKey {
final BufferedImage artImage;
final int width;
@ -258,8 +257,8 @@ public class CardPanelRenderImpl extends CardPanel {
// Try to get card image from cache based on our card characteristics
ImageKey key
= new ImageKey(gameCard, artImage,
getCardWidth(), getCardHeight(),
isChoosable(), isSelected());
getCardWidth(), getCardHeight(),
isChoosable(), isSelected());
cardImage = IMAGE_CACHE.computeIfAbsent(key, k -> renderCard());
// No cached copy exists? Render one and cache it

View file

@ -5,12 +5,17 @@
*/
package org.mage.card.arcane;
import mage.ObjectColor;
import mage.cards.FrameStyle;
import mage.client.dialog.PreferencesDialog;
import mage.constants.CardType;
import mage.view.CardView;
import mage.view.PermanentView;
import org.apache.log4j.Logger;
import javax.swing.*;
import java.awt.*;
import java.awt.font.FontRenderContext;
import java.awt.font.LineBreakMeasurer;
import java.awt.font.TextAttribute;
import java.awt.font.TextLayout;
import java.awt.font.TextMeasurer;
import java.awt.font.*;
import java.awt.geom.Rectangle2D;
import java.awt.image.BufferedImage;
import java.awt.image.RasterFormatException;
@ -22,14 +27,6 @@ import java.text.CharacterIterator;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import javax.swing.ImageIcon;
import mage.ObjectColor;
import mage.cards.FrameStyle;
import mage.client.dialog.PreferencesDialog;
import mage.constants.CardType;
import mage.view.CardView;
import mage.view.PermanentView;
import org.apache.log4j.Logger;
/*
@ -721,7 +718,7 @@ public class ModernCardRenderer extends CardRenderer {
// Draw the card's textbox in a given rect
protected boolean loyaltyAbilityColorToggle = false;
private class RuleLayout {
private static class RuleLayout {
public List<AttributedString> attributedRules;
public int remainingHeight;
@ -770,7 +767,7 @@ public class ModernCardRenderer extends CardRenderer {
// Add the keyword rule if there are any keywords
if (!textboxKeywords.isEmpty()) {
String keywordRulesString = getKeywordRulesString();
TextboxRule keywordsRule = new TextboxRule(keywordRulesString, new ArrayList<TextboxRule.AttributeRegion>());
TextboxRule keywordsRule = new TextboxRule(keywordRulesString, new ArrayList<>());
allRules.add(0, keywordsRule);
}

View file

@ -9,12 +9,10 @@ import com.google.common.base.Function;
import com.google.common.collect.AbstractIterator;
import com.google.common.collect.Iterables;
import com.google.common.collect.Lists;
import java.util.ArrayList;
import static java.util.Arrays.*;
import java.util.EventListener;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.*;
import static java.util.Arrays.asList;
/**
* The class EventListenerList.
@ -35,13 +33,13 @@ public class EventListenerList extends javax.swing.event.EventListenerList {
*/
public <T extends EventListener> Iterable<T> getIterable(final Class<? extends T>... listenerClass) {
//transform class -> iterable
List<Iterable<T>> l = Lists.transform(asList(listenerClass), new ClassToIterableFunction<T>());
List<Iterable<T>> l = Lists.transform(asList(listenerClass), new ClassToIterableFunction<>());
//compose iterable (use an arraylist to memoize the function's results)
final Iterable<T> it = Iterables.concat(new ArrayList<Iterable<T>>(l));
final Iterable<T> it = Iterables.concat(new ArrayList<>(l));
//transform to singleton iterators
return () -> new SingletonIterator<T>(it.iterator());
return () -> new SingletonIterator<>(it.iterator());
}
/**
@ -92,7 +90,7 @@ public class EventListenerList extends javax.swing.event.EventListenerList {
private class ClassToIterableFunction<T> implements Function<Class<? extends T>, Iterable<T>> {
public Iterable<T> apply(final Class<? extends T> from) {
return () -> new ListenerIterator<T>(from);
return () -> new ListenerIterator<>(from);
}
}
@ -103,7 +101,7 @@ public class EventListenerList extends javax.swing.event.EventListenerList {
private static class SingletonIterator<T> extends AbstractIterator<T> {
private final Iterator<T> it;
private final HashSet<T> previous = new HashSet<T>();
private final HashSet<T> previous = new HashSet<>();
public SingletonIterator(Iterator<T> it) {
this.it = it;

View file

@ -8,16 +8,7 @@ package org.mage.plugins.card.dl.beans.collections;
import java.io.Serializable;
import java.util.AbstractList;
import java.util.AbstractMap;
import java.util.AbstractSequentialList;
import java.util.AbstractSet;
import java.util.Iterator;
import java.util.List;
import java.util.ListIterator;
import java.util.Map;
import java.util.RandomAccess;
import java.util.Set;
import java.util.*;
/**
@ -34,18 +25,18 @@ public final class ListenableCollections {
public static <E> List<E> listenableList(List<E> list, ListListener<E> listener) {
if (list instanceof RandomAccess) {
return new ListenableList<E>(list, listener);
return new ListenableList<>(list, listener);
} else {
return new ListenableSequentialList<E>(list, listener);
return new ListenableSequentialList<>(list, listener);
}
}
public static <E> Set<E> listenableSet(Set<E> set, SetListener<E> listener) {
return new ListenableSet<E>(set, listener);
return new ListenableSet<>(set, listener);
}
public static <K, V> Map<K, V> listenableMap(Map<K, V> map, MapListener<K, V> listener) {
return new ListenableMap<K, V>(map, listener);
return new ListenableMap<>(map, listener);
}
public interface ListListener<E> extends Serializable {

View file

@ -7,13 +7,9 @@
package org.mage.plugins.card.dl.beans.properties;
import static java.util.Arrays.*;
import java.util.*;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Set;
import static java.util.Arrays.asList;
/**
@ -31,7 +27,7 @@ public class CompoundProperties extends AbstractProperties {
}
public CompoundProperties(List<Properties> delegates) {
this.delegates = new ArrayList<Properties>(delegates);
this.delegates = new ArrayList<>(delegates);
Collections.reverse(this.delegates);
}

View file

@ -7,17 +7,15 @@
package org.mage.plugins.card.dl.beans.properties.bound;
import static org.mage.plugins.card.dl.beans.collections.ListenableCollections.listenableList;
import static org.mage.plugins.card.dl.beans.collections.ListenableCollections.listenableMap;
import static org.mage.plugins.card.dl.beans.collections.ListenableCollections.listenableSet;
import org.mage.plugins.card.dl.beans.PropertyChangeSupport;
import org.mage.plugins.card.dl.beans.properties.AbstractProperties;
import org.mage.plugins.card.dl.beans.properties.Property;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.mage.plugins.card.dl.beans.PropertyChangeSupport;
import org.mage.plugins.card.dl.beans.properties.AbstractProperties;
import org.mage.plugins.card.dl.beans.properties.Property;
import static org.mage.plugins.card.dl.beans.collections.ListenableCollections.*;
/**
@ -39,18 +37,18 @@ public class BoundProperties extends AbstractProperties {
}
public <T> Property<T> property(String name, Property<T> property) {
return new BoundProperty<T>(s, name, property);
return new BoundProperty<>(s, name, property);
}
public <E> List<E> list(String name, List<E> list) {
return listenableList(list, new PropertyChangeListListener<E>(s, name));
return listenableList(list, new PropertyChangeListListener<>(s, name));
}
public <E> Set<E> set(String name, Set<E> set) {
return listenableSet(set, new PropertyChangeSetListener<E>(s, set, name));
return listenableSet(set, new PropertyChangeSetListener<>(s, set, name));
}
public <K, V> Map<K, V> map(String name, Map<K, V> map) {
return listenableMap(map, new PropertyChangeMapListener<K, V>(s, map, name));
return listenableMap(map, new PropertyChangeMapListener<>(s, map, name));
}
}

View file

@ -7,12 +7,12 @@
package org.mage.plugins.card.dl.beans.properties.bound;
import java.beans.PropertyChangeEvent;
import java.util.Map;
import org.mage.plugins.card.dl.beans.PropertyChangeSupport;
import org.mage.plugins.card.dl.beans.collections.ListenableCollections.MapListener;
import java.beans.PropertyChangeEvent;
import java.util.Map;
/**
* The class PropertyChangeMapListener. This listener alway fires events with {@link Map} -> {@link Map} as the
@ -35,15 +35,15 @@ public class PropertyChangeMapListener<K, V> implements MapListener<K, V> {
}
public void put(K key, V newValue) {
s.firePropertyChange(new MapPutEvent<K, V>(s.getSourceBean(), propertyName, map, key, newValue));
s.firePropertyChange(new MapPutEvent<>(s.getSourceBean(), propertyName, map, key, newValue));
}
public void set(K key, V oldValue, V newValue) {
s.firePropertyChange(new MapSetEvent<K, V>(s.getSourceBean(), propertyName, map, key, oldValue, newValue));
s.firePropertyChange(new MapSetEvent<>(s.getSourceBean(), propertyName, map, key, oldValue, newValue));
}
public void remove(K key, V oldValue) {
s.firePropertyChange(new MapRemoveEvent<K, V>(s.getSourceBean(), propertyName, map, key, oldValue));
s.firePropertyChange(new MapRemoveEvent<>(s.getSourceBean(), propertyName, map, key, oldValue));
}
public static abstract class MapEvent<K, V> extends PropertyChangeEvent {

View file

@ -7,12 +7,12 @@
package org.mage.plugins.card.dl.beans.properties.bound;
import java.beans.PropertyChangeEvent;
import java.util.Set;
import org.mage.plugins.card.dl.beans.PropertyChangeSupport;
import org.mage.plugins.card.dl.beans.collections.ListenableCollections.SetListener;
import java.beans.PropertyChangeEvent;
import java.util.Set;
/**
* The class PropertyChangeSetListener. This listener always fires events with {@link Set} -> {@link Set} as the
@ -35,11 +35,11 @@ public class PropertyChangeSetListener<E> implements SetListener<E> {
}
public void add(E newValue) {
s.firePropertyChange(new SetAddEvent<E>(s.getSourceBean(), propertyName, set, newValue));
s.firePropertyChange(new SetAddEvent<>(s.getSourceBean(), propertyName, set, newValue));
}
public void remove(E oldValue) {
s.firePropertyChange(new SetRemoveEvent<E>(s.getSourceBean(), propertyName, set, oldValue));
s.firePropertyChange(new SetRemoveEvent<>(s.getSourceBean(), propertyName, set, oldValue));
}
public static abstract class SetEvent<E> extends PropertyChangeEvent {

View file

@ -27,11 +27,12 @@
*/
package org.mage.plugins.card.dl.sources;
import java.io.IOException;
import java.util.HashMap;
import org.apache.log4j.Logger;
import org.mage.plugins.card.images.CardDownloadData;
import java.io.IOException;
import java.util.HashMap;
/**
*
* @author spjspj
@ -104,9 +105,9 @@ public class AltMtgOnlTokensImageSource implements CardImageSource {
if (copyUrlToImage != null) {
return;
}
copyUrlToImage = new HashMap<String, String>();
copyImageToUrl = new HashMap<String, String>();
copyUrlToImageDone = new HashMap<String, Integer>();
copyUrlToImage = new HashMap<>();
copyImageToUrl = new HashMap<>();
copyUrlToImageDone = new HashMap<>();
copyUrlToImage.put("SCG_CC_002-Penguin.jpg", "BIRD.WU.BIRD.CREATURE.1.1.full.jpg");
copyUrlToImage.put("SCG_CC_005-Vampire.jpg", "VAMPIRE.B.VAMPIRE.CREATURE.1.1.full.jpg");

View file

@ -27,11 +27,12 @@
*/
package org.mage.plugins.card.dl.sources;
import java.io.IOException;
import java.util.HashMap;
import org.apache.log4j.Logger;
import org.mage.plugins.card.images.CardDownloadData;
import java.io.IOException;
import java.util.HashMap;
/**
*
* @author spjspj
@ -104,9 +105,9 @@ public class MtgOnlTokensImageSource implements CardImageSource {
if (copyUrlToImage != null) {
return;
}
copyUrlToImage = new HashMap<String, String>();
copyImageToUrl = new HashMap<String, String>();
copyUrlToImageDone = new HashMap<String, Integer>();
copyUrlToImage = new HashMap<>();
copyImageToUrl = new HashMap<>();
copyUrlToImageDone = new HashMap<>();
copyUrlToImage.put("Angel_B_3_3.jpg", "ANGEL.B.ANGEL.CREATURE.3.3.full.jpg");
copyUrlToImage.put("Angel_W_3_3.jpg", "ANGEL.W.ANGEL.CREATURE.3.3.full.jpg");
copyUrlToImage.put("Angel_W_4_4.jpg", "ANGEL.W.ANGEL.CREATURE.4.4.full.jpg");

View file

@ -265,7 +265,7 @@ public class TokensMtgImageSource implements CardImageSource {
return newTokensData;
}
final class TokenData {
static final class TokenData {
final private String name;
final private String number;

View file

@ -37,7 +37,7 @@ public class MultiConnectTest {
private final Object sync = new Object();
private MageUI ui;
private class ClientMock implements MageClient {
private static class ClientMock implements MageClient {
private Session session;
private final String username;
@ -105,20 +105,12 @@ public class MultiConnectTest {
}
private void connect(final int index) throws Exception {
Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {
@Override
public void uncaughtException(Thread t, Throwable e) {
logger.fatal(null, e);
}
});
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
String username = "player" + index;
ClientMock client = new ClientMock(username);
client.connect();
latch.countDown();
}
Thread.setDefaultUncaughtExceptionHandler((t, e) -> logger.fatal(null, e));
SwingUtilities.invokeLater(() -> {
String username = "player" + index;
ClientMock client = new ClientMock(username);
client.connect();
latch.countDown();
});
}

View file

@ -1,12 +1,13 @@
package mage.client.game;
import javax.swing.SwingUtilities;
import mage.client.MageFrame;
import mage.client.components.MageComponents;
import mage.client.components.MageUI;
import org.apache.log4j.Logger;
import org.junit.Ignore;
import javax.swing.*;
/**
* @author ayratn
*/
@ -42,18 +43,12 @@ public class StartMultiGamesTest {
private void startGame() throws Exception {
frame = null;
Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {
public void uncaughtException(Thread t, Throwable e) {
logger.fatal(null, e);
}
});
SwingUtilities.invokeLater(new Runnable() {
public void run() {
synchronized (sync) {
frame = new MageFrame();
frame.setVisible(true);
sync.notify();
}
Thread.setDefaultUncaughtExceptionHandler((t, e) -> logger.fatal(null, e));
SwingUtilities.invokeLater(() -> {
synchronized (sync) {
frame = new MageFrame();
frame.setVisible(true);
sync.notify();
}
});
synchronized (sync) {

View file

@ -49,7 +49,7 @@ public enum EntityManager {
}
public List<Log> getAllLogs() {
List<Log> logs = new ArrayList<Log>();
List<Log> logs = new ArrayList<>();
try {
logs = logDao.queryForAll();
} catch (SQLException ex) {
@ -64,7 +64,7 @@ public enum EntityManager {
}
public List<Feedback> getAllFeedbacks() {
List<Feedback> feedbacks = new ArrayList<Feedback>();
List<Feedback> feedbacks = new ArrayList<>();
try {
feedbacks = feedbackDao.queryForAll();
} catch (SQLException ex) {

View file

@ -33,7 +33,7 @@ public final class Statistics {
private static List<Integer> displayTop3(Map<String, Integer> nicknames) {
Collection<Integer> values = nicknames.values();
List<Integer> games = new ArrayList<Integer>();
List<Integer> games = new ArrayList<>();
games.addAll(values);
Collections.sort(games, new Comparator<Integer>() {
@Override
@ -43,7 +43,7 @@ public final class Statistics {
});
// Top-3
List<Integer> numbersToFind = new ArrayList<Integer>();
List<Integer> numbersToFind = new ArrayList<>();
for (Integer numberOfGames : games) {
numbersToFind.add(numberOfGames);
if (numbersToFind.size() == 3) {
@ -51,7 +51,7 @@ public final class Statistics {
}
}
Map<Integer, String> players = new LinkedHashMap<Integer, String>();
Map<Integer, String> players = new LinkedHashMap<>();
for (Map.Entry<String, Integer> entry : nicknames.entrySet()) {
if (check(numbersToFind, entry.getValue())) {
players.put(entry.getValue(), entry.getKey());
@ -70,7 +70,7 @@ public final class Statistics {
private static Map<String, Integer> displayCommonNumbers(List<Log> logs) {
int count = 0;
Map<String, Integer> nicknames = new HashMap<String, Integer>();
Map<String, Integer> nicknames = new HashMap<>();
for (Log log : logs) {
if (log.getKey().equals("gameStarted")) {
if (log.getArguments() != null) {

View file

@ -2,6 +2,7 @@ package mage.db.model;
import com.j256.ormlite.field.DatabaseField;
import com.j256.ormlite.table.DatabaseTable;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
@ -54,7 +55,7 @@ public class Log {
}
public List<String> getArguments() {
ArrayList<String> arguments = new ArrayList<String>();
ArrayList<String> arguments = new ArrayList<>();
if (arg0 != null) {
arguments.add(arg0);
}

View file

@ -34,7 +34,12 @@
package mage.server.console;
import java.awt.Cursor;
import mage.remote.Connection;
import mage.remote.Connection.ProxyType;
import org.apache.log4j.Logger;
import javax.swing.*;
import java.awt.*;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.URL;
@ -43,13 +48,6 @@ import java.util.Arrays;
import java.util.List;
import java.util.concurrent.CancellationException;
import java.util.concurrent.ExecutionException;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JDialog;
import javax.swing.JOptionPane;
import javax.swing.SwingWorker;
import mage.remote.Connection;
import mage.remote.Connection.ProxyType;
import org.apache.log4j.Logger;
/**
*
@ -166,40 +164,20 @@ public class ConnectDialog extends JDialog {
});
btnConnect.setText("Connect");
btnConnect.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnConnectActionPerformed(evt);
}
});
btnConnect.addActionListener(evt -> btnConnectActionPerformed(evt));
btnCancel.setText("Cancel");
btnCancel.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnCancelActionPerformed(evt);
}
});
btnCancel.addActionListener(evt -> btnCancelActionPerformed(evt));
chkAutoConnect.setText("Automatically connect to this server next time");
chkAutoConnect.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
chkAutoConnectActionPerformed(evt);
}
});
chkAutoConnect.addActionListener(evt -> chkAutoConnectActionPerformed(evt));
jButton1.setText("Find...");
jButton1.setToolTipText("Find public server");
jButton1.setName("findServerBtn"); // NOI18N
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
findPublicServerActionPerformed(evt);
}
});
jButton1.addActionListener(evt -> findPublicServerActionPerformed(evt));
cbProxyType.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
cbProxyTypeActionPerformed(evt);
}
});
cbProxyType.addActionListener(evt -> cbProxyTypeActionPerformed(evt));
lblProxyType.setLabelFor(cbProxyType);
lblProxyType.setText("Proxy:");
@ -254,11 +232,7 @@ public class ConnectDialog extends JDialog {
lblProxyPassword.setText("Password:");
txtPasswordField.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
txtPasswordFieldActionPerformed(evt);
}
});
txtPasswordField.addActionListener(evt -> txtPasswordFieldActionPerformed(evt));
javax.swing.GroupLayout pnlProxyAuthLayout = new javax.swing.GroupLayout(pnlProxyAuth);
pnlProxyAuth.setLayout(pnlProxyAuthLayout);

View file

@ -34,16 +34,6 @@
package mage.server.console;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
import java.util.prefs.Preferences;
import javax.swing.Box;
import javax.swing.JOptionPane;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;
import mage.interfaces.MageClient;
import mage.interfaces.callback.ClientCallback;
import mage.remote.Connection;
@ -52,6 +42,14 @@ import mage.remote.SessionImpl;
import mage.utils.MageVersion;
import org.apache.log4j.Logger;
import javax.swing.*;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
import java.util.prefs.Preferences;
/**
*
* @author BetaSteward_at_googlemail.com
@ -101,12 +99,7 @@ public class ConsoleFrame extends javax.swing.JFrame implements MageClient {
logger.fatal("", ex);
}
pingTaskExecutor.scheduleAtFixedRate(new Runnable() {
@Override
public void run() {
session.ping();
}
}, 60, 60, TimeUnit.SECONDS);
pingTaskExecutor.scheduleAtFixedRate(() -> session.ping(), 60, 60, TimeUnit.SECONDS);
}
public boolean connect(Connection connection) {
@ -157,11 +150,7 @@ public class ConsoleFrame extends javax.swing.JFrame implements MageClient {
btnConnect.setFocusable(false);
btnConnect.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
btnConnect.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
btnConnect.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnConnectActionPerformed(evt);
}
});
btnConnect.addActionListener(evt -> btnConnectActionPerformed(evt));
jToolBar1.add(btnConnect);
btnSendMessage.setActionCommand("SendMessage");
@ -170,11 +159,7 @@ public class ConsoleFrame extends javax.swing.JFrame implements MageClient {
btnSendMessage.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
btnSendMessage.setText("Send Message");
btnSendMessage.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
btnSendMessage.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnSendMessageActionPerformed(evt);
}
});
btnSendMessage.addActionListener(evt -> btnSendMessageActionPerformed(evt));
jToolBar1.add(btnSendMessage);
lblStatus.setText("Not Connected");
@ -224,12 +209,9 @@ public class ConsoleFrame extends javax.swing.JFrame implements MageClient {
logger.info("Starting MAGE server console version " + version);
logger.info("Logging level: " + logger.getEffectiveLevel());
java.awt.EventQueue.invokeLater(new Runnable() {
@Override
public void run() {
new ConsoleFrame().setVisible(true);
logger.info("Started MAGE server console");
}
java.awt.EventQueue.invokeLater(() -> {
new ConsoleFrame().setVisible(true);
logger.info("Started MAGE server console");
});
}
@ -252,12 +234,9 @@ public class ConsoleFrame extends javax.swing.JFrame implements MageClient {
enableButtons();
}
else {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
setStatusText(message);
enableButtons();
}
SwingUtilities.invokeLater(() -> {
setStatusText(message);
enableButtons();
});
}
}
@ -270,13 +249,10 @@ public class ConsoleFrame extends javax.swing.JFrame implements MageClient {
disableButtons();
}
else {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
consolePanel1.stop();
setStatusText("Not connected");
disableButtons();
}
SwingUtilities.invokeLater(() -> {
consolePanel1.stop();
setStatusText("Not connected");
disableButtons();
});
}
}
@ -287,12 +263,7 @@ public class ConsoleFrame extends javax.swing.JFrame implements MageClient {
JOptionPane.showMessageDialog(this, message);
}
else {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
JOptionPane.showMessageDialog(getFrame(), message);
}
});
SwingUtilities.invokeLater(() -> JOptionPane.showMessageDialog(getFrame(), message));
}
}
@ -302,12 +273,7 @@ public class ConsoleFrame extends javax.swing.JFrame implements MageClient {
JOptionPane.showMessageDialog(this, message, "Error", JOptionPane.ERROR_MESSAGE);
}
else {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
JOptionPane.showMessageDialog(getFrame(), message, "Error", JOptionPane.ERROR_MESSAGE);
}
});
SwingUtilities.invokeLater(() -> JOptionPane.showMessageDialog(getFrame(), message, "Error", JOptionPane.ERROR_MESSAGE));
}
}

View file

@ -33,25 +33,23 @@
*/
package mage.server.console;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import java.util.concurrent.CancellationException;
import java.util.concurrent.ExecutionException;
import static javax.swing.JTable.AUTO_RESIZE_NEXT_COLUMN;
import static javax.swing.JTable.AUTO_RESIZE_OFF;
import javax.swing.SwingWorker;
import javax.swing.table.AbstractTableModel;
import javax.swing.table.TableRowSorter;
import mage.remote.Session;
import mage.view.TableView;
import mage.view.UserView;
import org.apache.log4j.Logger;
import javax.swing.*;
import javax.swing.table.AbstractTableModel;
import javax.swing.table.TableRowSorter;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.concurrent.CancellationException;
import java.util.concurrent.ExecutionException;
import static javax.swing.JTable.AUTO_RESIZE_NEXT_COLUMN;
import static javax.swing.JTable.AUTO_RESIZE_OFF;
/**
*
* @author BetaSteward_at_googlemail.com
@ -161,42 +159,22 @@ public class ConsolePanel extends javax.swing.JPanel {
jPanel4.setVerifyInputWhenFocusTarget(false);
btnDisconnect.setText("Disconnect");
btnDisconnect.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnDisconnectActionPerformed(evt);
}
});
btnDisconnect.addActionListener(evt -> btnDisconnectActionPerformed(evt));
btnEndSession.setText("End session");
btnEndSession.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnEndSessionActionPerformed(evt);
}
});
btnEndSession.addActionListener(evt -> btnEndSessionActionPerformed(evt));
btnMuteUser.setText("Mute user");
btnMuteUser.setActionCommand("Mute 1h");
btnMuteUser.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnMuteUserActionPerformed(evt);
}
});
btnMuteUser.addActionListener(evt -> btnMuteUserActionPerformed(evt));
btnDeActivate.setText("(de)activate");
btnDeActivate.setActionCommand("Mute 1h");
btnDeActivate.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnDeActivateActionPerformed(evt);
}
});
btnDeActivate.addActionListener(evt -> btnDeActivateActionPerformed(evt));
btnLockUser.setText("Lock user");
btnLockUser.setActionCommand("Mute 1h");
btnLockUser.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnLockUserActionPerformed(evt);
}
});
btnLockUser.addActionListener(evt -> btnLockUserActionPerformed(evt));
lblMinutes.setText("Minutes");
@ -277,11 +255,7 @@ public class ConsolePanel extends javax.swing.JPanel {
);
btnRemoveTable.setText("Remove Table");
btnRemoveTable.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnRemoveTableActionPerformed(evt);
}
});
btnRemoveTable.addActionListener(evt -> btnRemoveTableActionPerformed(evt));
javax.swing.GroupLayout jPanel6Layout = new javax.swing.GroupLayout(jPanel6);
jPanel6.setLayout(jPanel6Layout);

View file

@ -67,7 +67,7 @@ public class CanadianHighlander extends Constructed {
valid = false;
}
if (deck.getSideboard().size() > 0) {
if (!deck.getSideboard().isEmpty()) {
invalid.put("Deck", "Sideboard can't contain any cards: has " + (deck.getSideboard().size()) + " cards");
valid = false;
}

View file

@ -1,5 +1,5 @@
#Generated by Maven
#Wed Feb 15 19:18:14 MSK 2017
#Tue Feb 28 12:32:48 MSK 2017
version=1.4.21
groupId=org.mage
artifactId=mage-game-canadianhighlanderduel

View file

@ -28,10 +28,11 @@
package mage.player.ai;
import mage.game.permanent.Permanent;
import java.util.ArrayList;
import java.util.List;
import java.util.TreeMap;
import mage.game.permanent.Permanent;
/**
*
@ -40,7 +41,7 @@ import mage.game.permanent.Permanent;
public class Attackers2 extends TreeMap<Integer, List<Permanent>> {
public List<Permanent> getAttackers() {
List<Permanent> attackers = new ArrayList<Permanent>();
List<Permanent> attackers = new ArrayList<>();
for (List<Permanent> l: this.values()) {
for (Permanent permanent: l) {
attackers.add(permanent);

View file

@ -12,12 +12,12 @@ import java.util.Map;
*/
public class CombatInfo {
private Map<Permanent, List<Permanent>> combat = new HashMap<Permanent, List<Permanent>>();
private Map<Permanent, List<Permanent>> combat = new HashMap<>();
public void addPair(Permanent attacker, Permanent blocker) {
List<Permanent> blockers = combat.get(attacker);
if (blockers == null) {
blockers = new ArrayList<Permanent>();
blockers = new ArrayList<>();
combat.put(attacker, blockers);
}
blockers.add(blocker);

View file

@ -23,7 +23,7 @@ import java.util.*;
*/
public final class CombatUtil {
private static final List<Permanent> emptyList = new ArrayList<Permanent>();
private static final List<Permanent> emptyList = new ArrayList<>();
private static final Logger log = Logger.getLogger(CombatUtil.class);
@ -32,8 +32,8 @@ public final class CombatUtil {
public static List<Permanent> canKillOpponent(Game game, List<Permanent> attackersList, List<Permanent> blockersList,
Player defender) {
List<Permanent> blockableAttackers = new ArrayList<Permanent>(blockersList);
List<Permanent> unblockableAttackers = new ArrayList<Permanent>();
List<Permanent> blockableAttackers = new ArrayList<>(blockersList);
List<Permanent> unblockableAttackers = new ArrayList<>();
for (Permanent attacker : attackersList) {
if (!canBeBlocked(game, attacker, blockersList)) {
unblockableAttackers.add(attacker);
@ -44,7 +44,7 @@ public final class CombatUtil {
sortByPower(blockableAttackers, true);
// imagine that most powerful will be blocked as 1-vs-1
List<Permanent> attackersThatWontBeBlocked = new ArrayList<Permanent>(blockableAttackers);
List<Permanent> attackersThatWontBeBlocked = new ArrayList<>(blockableAttackers);
for (int i = 0; (i < blockersList.size() && i < blockableAttackers.size()); i++) {
attackersThatWontBeBlocked.remove(blockableAttackers.get(i));
}
@ -147,7 +147,7 @@ public final class CombatUtil {
* @return true if attacker can be blocked by any blocker
*/
public static List<Permanent> getPossibleBlockers(Game game, Permanent attacker, List<Permanent> blockersList) {
List<Permanent> canBlock = new ArrayList<Permanent>();
List<Permanent> canBlock = new ArrayList<>();
for (Permanent blocker : blockersList) {
if (blocker.canBlock(attacker.getId(), game)) {
canBlock.add(blocker);
@ -184,7 +184,7 @@ public final class CombatUtil {
}
private static List<Permanent> getBlockersThatWillSurvive(Game game, UUID attackerId, UUID defenderId, Permanent attacker, List<Permanent> possibleBlockers) {
List<Permanent> blockers = new ArrayList<Permanent>();
List<Permanent> blockers = new ArrayList<>();
for (Permanent blocker : possibleBlockers) {
SurviveInfo info = willItSurvive(game, attackerId, defenderId, attacker, blocker);
//if (info.isAttackerDied() && !info.isBlockerDied()) {
@ -321,7 +321,7 @@ public final class CombatUtil {
}
private static List<Permanent> getBlockersThatWillSurvive2(Game game, UUID attackerId, UUID defenderId, Permanent attacker, List<Permanent> possibleBlockers) {
List<Permanent> blockers = new ArrayList<Permanent>();
List<Permanent> blockers = new ArrayList<>();
for (Permanent blocker : possibleBlockers) {
SurviveInfo info = willItSurvive2(game, attackerId, defenderId, attacker, blocker);
//if (info.isAttackerDied() && !info.isBlockerDied()) {

View file

@ -28,15 +28,16 @@
package mage.player.ai;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
import mage.abilities.keyword.DoubleStrikeAbility;
import mage.abilities.keyword.FirstStrikeAbility;
import mage.abilities.keyword.TrampleAbility;
import mage.game.Game;
import mage.game.permanent.Permanent;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
/**
*
* @author BetaSteward_at_googlemail.com
@ -44,7 +45,7 @@ import mage.game.permanent.Permanent;
public class CombatEvaluator {
//preserve calculations for efficiency
private Map<UUID, Integer> values = new HashMap<UUID, Integer>();
private Map<UUID, Integer> values = new HashMap<>();
public int evaluate(Permanent creature, Game game) {
if (!values.containsKey(creature.getId())) {

View file

@ -27,49 +27,15 @@
*/
package mage.player.ai;
import java.io.IOException;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import java.util.TreeMap;
import java.util.UUID;
import mage.MageObject;
import mage.Mana;
import mage.abilities.Ability;
import mage.abilities.ActivatedAbility;
import mage.abilities.Mode;
import mage.abilities.Modes;
import mage.abilities.SpellAbility;
import mage.abilities.TriggeredAbility;
import mage.abilities.*;
import mage.abilities.costs.VariableCost;
import mage.abilities.costs.mana.ColoredManaCost;
import mage.abilities.costs.mana.ColorlessManaCost;
import mage.abilities.costs.mana.GenericManaCost;
import mage.abilities.costs.mana.HybridManaCost;
import mage.abilities.costs.mana.ManaCost;
import mage.abilities.costs.mana.ManaCosts;
import mage.abilities.costs.mana.MonoHybridManaCost;
import mage.abilities.costs.mana.PhyrexianManaCost;
import mage.abilities.costs.mana.*;
import mage.abilities.effects.Effect;
import mage.abilities.effects.common.DamageTargetEffect;
import mage.abilities.effects.common.continuous.BecomesCreatureSourceEffect;
import mage.abilities.keyword.DoubleStrikeAbility;
import mage.abilities.keyword.EquipAbility;
import mage.abilities.keyword.FirstStrikeAbility;
import mage.abilities.keyword.FlashAbility;
import mage.abilities.keyword.TrampleAbility;
import mage.abilities.keyword.*;
import mage.abilities.mana.ActivatedManaAbilityImpl;
import mage.abilities.mana.ManaOptions;
import mage.cards.Card;
@ -81,21 +47,9 @@ import mage.cards.repository.CardInfo;
import mage.cards.repository.CardRepository;
import mage.choices.Choice;
import mage.choices.ChoiceColor;
import mage.constants.AsThoughEffectType;
import mage.constants.CardType;
import mage.constants.ColoredManaSymbol;
import mage.constants.Outcome;
import mage.constants.RangeOfInfluence;
import mage.constants.Rarity;
import mage.constants.Zone;
import mage.constants.*;
import mage.filter.FilterPermanent;
import mage.filter.common.FilterCreatureForCombatBlock;
import mage.filter.common.FilterCreatureOrPlayer;
import mage.filter.common.FilterCreaturePermanent;
import mage.filter.common.FilterLandCard;
import mage.filter.common.FilterNonlandCard;
import mage.filter.common.FilterPermanentOrPlayer;
import mage.filter.common.FilterPlaneswalkerPermanent;
import mage.filter.common.*;
import mage.filter.predicate.permanent.ControllerIdPredicate;
import mage.game.Game;
import mage.game.combat.CombatGroup;
@ -115,31 +69,19 @@ import mage.players.Player;
import mage.players.PlayerImpl;
import mage.players.net.UserData;
import mage.players.net.UserGroup;
import mage.target.Target;
import mage.target.TargetAmount;
import mage.target.TargetCard;
import mage.target.TargetPermanent;
import mage.target.TargetPlayer;
import mage.target.TargetSource;
import mage.target.TargetSpell;
import mage.target.common.TargetCardInASingleGraveyard;
import mage.target.common.TargetCardInExile;
import mage.target.common.TargetCardInGraveyard;
import mage.target.common.TargetCardInHand;
import mage.target.common.TargetCardInLibrary;
import mage.target.common.TargetCardInOpponentsGraveyard;
import mage.target.common.TargetCardInYourGraveyard;
import mage.target.common.TargetControlledPermanent;
import mage.target.common.TargetCreatureOrPlayer;
import mage.target.common.TargetCreatureOrPlayerAmount;
import mage.target.common.TargetDefender;
import mage.target.common.TargetDiscard;
import mage.target.common.TargetOpponent;
import mage.target.common.TargetPermanentOrPlayer;
import mage.target.common.TargetSpellOrPermanent;
import mage.util.*;
import mage.target.*;
import mage.target.common.*;
import mage.util.Copier;
import mage.util.RandomUtil;
import mage.util.TournamentUtil;
import mage.util.TreeNode;
import org.apache.log4j.Logger;
import java.io.IOException;
import java.io.Serializable;
import java.util.*;
import java.util.Map.Entry;
/**
*
* suitable for two player games and some multiplayer games
@ -675,9 +617,7 @@ public class ComputerPlayer extends PlayerImpl implements Player {
}
if (target.getOriginalTarget() instanceof TargetSpell) {
if (!game.getStack().isEmpty()) {
Iterator<StackObject> it = game.getStack().iterator();
while (it.hasNext()) {
StackObject o = it.next();
for (StackObject o : game.getStack()) {
if (o instanceof Spell && !source.getId().equals(o.getStackAbility().getId())) {
target.addTarget(o.getId(), source, game);
return true;
@ -709,9 +649,7 @@ public class ComputerPlayer extends PlayerImpl implements Player {
}
}
if (!game.getStack().isEmpty()) {
Iterator<StackObject> it = game.getStack().iterator();
while (it.hasNext()) {
StackObject stackObject = it.next();
for (StackObject stackObject : game.getStack()) {
if (stackObject instanceof Spell && source != null && !source.getId().equals(stackObject.getStackAbility().getId())) {
if (((TargetSpellOrPermanent) target).getFilter().match(stackObject, game)) {
target.addTarget(stackObject.getId(), source, game);
@ -1941,7 +1879,7 @@ public class ComputerPlayer extends PlayerImpl implements Player {
return null;
}
private class PickedCard {
private static class PickedCard {
public Card card;
public Integer score;

View file

@ -28,8 +28,6 @@
package mage.player.ai.simulators;
import java.util.ArrayList;
import java.util.List;
import mage.abilities.ActivatedAbility;
import mage.cards.Card;
import mage.game.Game;
@ -38,6 +36,9 @@ import mage.player.ai.ComputerPlayer;
import mage.player.ai.PermanentEvaluator;
import mage.players.Player;
import java.util.ArrayList;
import java.util.List;
/**
*
* @author BetaSteward_at_googlemail.com
@ -45,8 +46,8 @@ import mage.players.Player;
public class ActionSimulator {
private ComputerPlayer player;
private List<Card> playableInstants = new ArrayList<Card>();
private List<ActivatedAbility> playableAbilities = new ArrayList<ActivatedAbility>();
private List<Card> playableInstants = new ArrayList<>();
private List<ActivatedAbility> playableAbilities = new ArrayList<>();
private Game game;

View file

@ -28,20 +28,21 @@
package mage.player.ai.simulators;
import mage.game.Game;
import mage.game.permanent.Permanent;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import mage.game.Game;
import mage.game.permanent.Permanent;
/**
*
* @author BetaSteward_at_googlemail.com
*/
public class CombatGroupSimulator implements Serializable {
public List<CreatureSimulator> attackers = new ArrayList<CreatureSimulator>();
public List<CreatureSimulator> blockers = new ArrayList<CreatureSimulator>();
public List<CreatureSimulator> attackers = new ArrayList<>();
public List<CreatureSimulator> blockers = new ArrayList<>();
public UUID defenderId;
public boolean defenderIsPlaneswalker;
public int unblockedDamage;

View file

@ -28,30 +28,26 @@
package mage.player.ai.simulators;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.UUID;
import mage.counters.CounterType;
import mage.game.Game;
import mage.game.combat.CombatGroup;
import mage.game.permanent.Permanent;
import mage.players.Player;
import java.io.Serializable;
import java.util.*;
import java.util.Map.Entry;
/**
*
* @author BetaSteward_at_googlemail.com
*/
public class CombatSimulator implements Serializable {
public List<CombatGroupSimulator> groups = new ArrayList<CombatGroupSimulator>();
public List<UUID> defenders = new ArrayList<UUID>();
public Map<UUID, Integer> playersLife = new HashMap<UUID, Integer>();
public Map<UUID, Integer> planeswalkerLoyalty = new HashMap<UUID, Integer>();
public List<CombatGroupSimulator> groups = new ArrayList<>();
public List<UUID> defenders = new ArrayList<>();
public Map<UUID, Integer> playersLife = new HashMap<>();
public Map<UUID, Integer> planeswalkerLoyalty = new HashMap<>();
public UUID attackerId;
public int rating = 0;
@ -89,7 +85,7 @@ public class CombatSimulator implements Serializable {
}
public int evaluate() {
Map<UUID, Integer> damage = new HashMap<UUID, Integer>();
Map<UUID, Integer> damage = new HashMap<>();
int result = 0;
for (CombatGroupSimulator group: groups) {
if (!damage.containsKey(group.defenderId)) {

View file

@ -191,7 +191,7 @@ public final class RateCard {
}
return 2 * (converted - colorPenalty + 1);
}
final Map<String, Integer> singleCount = new HashMap<String, Integer>();
final Map<String, Integer> singleCount = new HashMap<>();
int maxSingleCount = 0;
for (String symbol : card.getManaCost().getSymbols()) {
int count = 0;
@ -257,7 +257,7 @@ public final class RateCard {
* @return
*/
public static int getDifferentColorManaCount(Card card) {
Set<String> symbols = new HashSet<String>();
Set<String> symbols = new HashSet<>();
for (String symbol : card.getManaCost().getSymbols()) {
if (isColoredMana(symbol)) {
symbols.add(symbol);

View file

@ -78,7 +78,7 @@ public class MCTSPlayer extends ComputerPlayer {
}
public List<Ability> getPlayableOptions(Game game) {
List<Ability> all = new ArrayList<Ability>();
List<Ability> all = new ArrayList<>();
List<Ability> playables = getPlayableAbilities(game);
for (Ability ability: playables) {
List<Ability> options = game.getPlayer(playerId).getPlayableOptions(ability, game);
@ -122,7 +122,7 @@ public class MCTSPlayer extends ComputerPlayer {
}
public List<List<UUID>> getAttacks(Game game) {
List<List<UUID>> engagements = new ArrayList<List<UUID>>();
List<List<UUID>> engagements = new ArrayList<>();
List<Permanent> attackersList = super.getAvailableAttackers(game);
//use binary digits to calculate powerset of attackers
int powerElements = (int) Math.pow(2, attackersList.size());
@ -133,7 +133,7 @@ public class MCTSPlayer extends ComputerPlayer {
while (binary.length() < attackersList.size()) {
binary.insert(0, '0');
}
List<UUID> engagement = new ArrayList<UUID>();
List<UUID> engagement = new ArrayList<>();
for (int j = 0; j < attackersList.size(); j++) {
if (binary.charAt(j) == '1') {
engagement.add(attackersList.get(j).getId());
@ -145,14 +145,14 @@ public class MCTSPlayer extends ComputerPlayer {
}
public List<List<List<UUID>>> getBlocks(Game game) {
List<List<List<UUID>>> engagements = new ArrayList<List<List<UUID>>>();
List<List<List<UUID>>> engagements = new ArrayList<>();
int numGroups = game.getCombat().getGroups().size();
if (numGroups == 0) {
return engagements;
}
//add a node with no blockers
List<List<UUID>> engagement = new ArrayList<List<UUID>>();
List<List<UUID>> engagement = new ArrayList<>();
for (int i = 0; i < numGroups; i++) {
engagement.add(new ArrayList<UUID>());
}
@ -165,9 +165,9 @@ public class MCTSPlayer extends ComputerPlayer {
}
private List<List<UUID>> copyEngagement(List<List<UUID>> engagement) {
List<List<UUID>> newEngagement = new ArrayList<List<UUID>>();
List<List<UUID>> newEngagement = new ArrayList<>();
for (List<UUID> group: engagement) {
newEngagement.add(new ArrayList<UUID>(group));
newEngagement.add(new ArrayList<>(group));
}
return newEngagement;
}

View file

@ -28,10 +28,11 @@
package mage.player.ai;
import mage.game.permanent.Permanent;
import java.util.ArrayList;
import java.util.List;
import java.util.TreeMap;
import mage.game.permanent.Permanent;
/**
*
@ -40,7 +41,7 @@ import mage.game.permanent.Permanent;
public class Attackers extends TreeMap<Integer, List<Permanent>> {
public List<Permanent> getAttackers() {
List<Permanent> attackers = new ArrayList<Permanent>();
List<Permanent> attackers = new ArrayList<>();
for (List<Permanent> l: this.values()) {
for (Permanent permanent: l) {
attackers.add(permanent);

View file

@ -28,9 +28,6 @@
package mage.player.ai;
import mage.constants.Outcome;
import mage.constants.PhaseStep;
import mage.constants.RangeOfInfluence;
import mage.abilities.Ability;
import mage.abilities.ActivatedAbility;
import mage.abilities.common.PassAbility;
@ -38,6 +35,9 @@ import mage.abilities.effects.Effect;
import mage.abilities.effects.SearchEffect;
import mage.cards.Cards;
import mage.choices.Choice;
import mage.constants.Outcome;
import mage.constants.PhaseStep;
import mage.constants.RangeOfInfluence;
import mage.game.Game;
import mage.game.combat.Combat;
import mage.game.combat.CombatGroup;
@ -163,7 +163,7 @@ public class ComputerPlayer2 extends ComputerPlayer implements Player {
logger.info(name + " simulated " + nodeCount + " nodes in " + thinkTime/1000000000.0 + "s - average " + nodeCount/(thinkTime/1000000000.0) + " nodes/s");
if (!root.children.isEmpty()) {
root = root.children.get(0);
actions = new LinkedList<Ability>(root.abilities);
actions = new LinkedList<>(root.abilities);
combat = root.combat;
if (logger.isDebugEnabled())
logger.debug("adding actions:" + actions);
@ -184,7 +184,7 @@ public class ComputerPlayer2 extends ComputerPlayer implements Player {
logger.debug("simlating -- game value:" + game.getState().getValue(true) + " test value:" + test.gameValue);
if (root.playerId.equals(playerId) && root.abilities != null && game.getState().getValue(true).hashCode() == test.gameValue) {
logger.debug("simulating -- continuing previous action chain");
actions = new LinkedList<Ability>(root.abilities);
actions = new LinkedList<>(root.abilities);
combat = root.combat;
return true;
}
@ -284,10 +284,9 @@ public class ComputerPlayer2 extends ComputerPlayer implements Player {
}
protected void addActionsTimed() {
FutureTask<Integer> task = new FutureTask<Integer>(new Callable<Integer>() {
FutureTask<Integer> task = new FutureTask<>(new Callable<Integer>() {
@Override
public Integer call() throws Exception
{
public Integer call() throws Exception {
return addActions(root, Integer.MIN_VALUE, Integer.MAX_VALUE);
}
});

View file

@ -30,7 +30,6 @@ package mage.player.ai;
import mage.constants.PhaseStep;
import mage.constants.RangeOfInfluence;
import mage.abilities.Ability;
import mage.game.Game;
import mage.game.combat.Combat;
import mage.game.combat.CombatGroup;
@ -141,7 +140,7 @@ public class ComputerPlayer3 extends ComputerPlayer2 implements Player {
logger.info(name + " simulated " + nodeCount + " nodes in " + thinkTime/1000000000.0 + "s - average " + nodeCount/(thinkTime/1000000000.0) + " nodes/s");
if (!root.children.isEmpty()) {
root = root.children.get(0);
actions = new LinkedList<Ability>(root.abilities);
actions = new LinkedList<>(root.abilities);
combat = root.combat;
if (logger.isDebugEnabled())
logger.debug("adding pre-combat actions:" + actions);
@ -165,7 +164,7 @@ public class ComputerPlayer3 extends ComputerPlayer2 implements Player {
logger.info(name + " simulated " + nodeCount + " nodes in " + thinkTime/1000000000.0 + "s - average " + nodeCount/(thinkTime/1000000000.0) + " nodes/s");
if (!root.children.isEmpty()) {
root = root.children.get(0);
actions = new LinkedList<Ability>(root.abilities);
actions = new LinkedList<>(root.abilities);
combat = root.combat;
if (logger.isDebugEnabled())
logger.debug("adding post-combat actions:" + actions);

View file

@ -28,8 +28,6 @@
package mage.player.ai;
import java.util.*;
import java.util.concurrent.ConcurrentLinkedQueue;
import mage.abilities.Ability;
import mage.abilities.SpellAbility;
import mage.abilities.TriggeredAbility;
@ -43,6 +41,9 @@ import mage.game.stack.StackAbility;
import mage.target.Target;
import org.apache.log4j.Logger;
import java.util.*;
import java.util.concurrent.ConcurrentLinkedQueue;
/**
*
* @author BetaSteward_at_googlemail.com
@ -73,12 +74,12 @@ public class SimulatedPlayer extends ComputerPlayer {
}
public List<Ability> simulatePriority(Game game) {
allActions = new ConcurrentLinkedQueue<Ability>();
allActions = new ConcurrentLinkedQueue<>();
Game sim = game.copy();
simulateOptions(sim, pass);
ArrayList<Ability> list = new ArrayList<Ability>(allActions);
ArrayList<Ability> list = new ArrayList<>(allActions);
//Collections.shuffle(list);
Collections.reverse(list);
return list;
@ -160,7 +161,7 @@ public class SimulatedPlayer extends ComputerPlayer {
}*/
public List<Combat> addAttackers(Game game) {
Map<Integer, Combat> engagements = new HashMap<Integer, Combat>();
Map<Integer, Combat> engagements = new HashMap<>();
//useful only for two player games - will only attack first opponent
UUID defenderId = game.getOpponents(playerId).iterator().next();
List<Permanent> attackersList = super.getAvailableAttackers(defenderId, game);
@ -189,13 +190,13 @@ public class SimulatedPlayer extends ComputerPlayer {
logger.debug("simulating -- attack:" + sim.getCombat().getGroups().size());
}
}
return new ArrayList<Combat>(engagements.values());
return new ArrayList<>(engagements.values());
}
public List<Combat> addBlockers(Game game) {
Map<Integer, Combat> engagements = new HashMap<Integer, Combat>();
Map<Integer, Combat> engagements = new HashMap<>();
int numGroups = game.getCombat().getGroups().size();
if (numGroups == 0) return new ArrayList<Combat>();
if (numGroups == 0) return new ArrayList<>();
//add a node with no blockers
Game sim = game.copy();
@ -205,7 +206,7 @@ public class SimulatedPlayer extends ComputerPlayer {
List<Permanent> blockers = getAvailableBlockers(game);
addBlocker(game, blockers, engagements);
return new ArrayList<Combat>(engagements.values());
return new ArrayList<>(engagements.values());
}
protected void addBlocker(Game game, List<Permanent> blockers, Map<Integer, Combat> engagements) {

View file

@ -28,13 +28,14 @@
package mage.player.ai;
import mage.abilities.Ability;
import mage.game.Game;
import mage.game.combat.Combat;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import mage.abilities.Ability;
import mage.game.Game;
import mage.game.combat.Combat;
/**
*
@ -48,10 +49,10 @@ public class SimulationNode implements Serializable {
protected int gameValue;
protected List<Ability> abilities;
protected int depth;
protected List<SimulationNode> children = new ArrayList<SimulationNode>();
protected List<SimulationNode> children = new ArrayList<>();
protected SimulationNode parent;
protected List<UUID> targets = new ArrayList<UUID>();
protected List<String> choices = new ArrayList<String>();
protected List<UUID> targets = new ArrayList<>();
protected List<String> choices = new ArrayList<>();
protected UUID playerId;
protected Combat combat;
@ -74,7 +75,7 @@ public class SimulationNode implements Serializable {
public SimulationNode(SimulationNode parent, Game game, Ability ability, UUID playerId) {
this(parent, game, playerId);
this.abilities = new ArrayList<Ability>();
this.abilities = new ArrayList<>();
abilities.add(ability);
}

View file

@ -27,7 +27,6 @@
*/
package mage.cards.a;
import java.util.UUID;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.OnEventTriggeredAbility;
@ -48,6 +47,8 @@ import mage.game.permanent.Permanent;
import mage.players.Player;
import mage.target.common.TargetControlledPermanent;
import java.util.UUID;
/**
*
* @author anonymous
@ -87,7 +88,7 @@ public class ArchdemonOfGreed extends CardImpl {
return new ArchdemonOfGreed(this);
}
class ArchdemonOfGreedEffect extends OneShotEffect {
static class ArchdemonOfGreedEffect extends OneShotEffect {
public ArchdemonOfGreedEffect() {
super(Outcome.Damage);

View file

@ -27,7 +27,6 @@
*/
package mage.cards.a;
import java.util.UUID;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.SimpleActivatedAbility;
@ -46,6 +45,8 @@ import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.players.Player;
import java.util.UUID;
/**
*
* @author LevelX2
@ -79,7 +80,7 @@ public class AshlingThePilgrim extends CardImpl {
class AshlingThePilgrimEffect extends OneShotEffect {
class ActivationInfo {
static class ActivationInfo {
public int zoneChangeCounter;
public int turn;
public int activations;

View file

@ -27,7 +27,6 @@
*/
package mage.cards.a;
import java.util.UUID;
import mage.MageInt;
import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.costs.mana.ManaCostsImpl;
@ -42,6 +41,8 @@ import mage.constants.Duration;
import mage.constants.Zone;
import mage.game.permanent.token.Token;
import java.util.UUID;
/**
*
* @author fireshoes
@ -69,7 +70,7 @@ public class AtarkaMonument extends CardImpl {
return new AtarkaMonument(this);
}
private class AtarkaMonumentToken extends Token {
private static class AtarkaMonumentToken extends Token {
AtarkaMonumentToken() {
super("", "4/4 red and green Dragon artifact creature with flying");
cardType.add(CardType.ARTIFACT);

View file

@ -27,13 +27,11 @@
*/
package mage.cards.a;
import java.util.UUID;
import mage.constants.CardType;
import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.filter.FilterPermanent;
import mage.filter.predicate.mageobject.CardTypePredicate;
@ -42,6 +40,8 @@ import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.players.Player;
import java.util.UUID;
/**
*
* @author LevelX2
@ -66,7 +66,7 @@ public class AuraBarbs extends CardImpl {
return new AuraBarbs(this);
}
private class AuraBarbsEffect extends OneShotEffect {
private static class AuraBarbsEffect extends OneShotEffect {
public AuraBarbsEffect() {
super(Outcome.Detriment);

View file

@ -39,7 +39,10 @@ import mage.abilities.effects.common.counter.AddCountersTargetEffect;
import mage.abilities.keyword.DefenderAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.*;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.Outcome;
import mage.constants.Zone;
import mage.counters.CounterType;
import mage.filter.common.FilterCreaturePermanent;
import mage.filter.predicate.permanent.CounterPredicate;
@ -95,7 +98,7 @@ public class Aurification extends CardImpl {
return new Aurification(this);
}
public class AddGoldCountersAbility extends TriggeredAbilityImpl {
public static class AddGoldCountersAbility extends TriggeredAbilityImpl {
public AddGoldCountersAbility() {
super(Zone.BATTLEFIELD, new AddCountersTargetEffect(CounterType.GOLD.createInstance()));
@ -136,7 +139,7 @@ public class Aurification extends CardImpl {
}
public class RemoveAllGoldCountersEffect extends OneShotEffect {
public static class RemoveAllGoldCountersEffect extends OneShotEffect {
public RemoveAllGoldCountersEffect() {
super(Outcome.Neutral);
this.staticText = "remove all gold counters from all creatures";

View file

@ -27,20 +27,21 @@
*/
package mage.cards.a;
import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
import mage.constants.CardType;
import mage.abilities.Ability;
import mage.abilities.effects.common.DestroyTargetEffect;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.filter.common.FilterCreaturePermanent;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.target.TargetPermanent;
import mage.watchers.common.SourceDidDamageWatcher;
import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
/**
*
* @author jeffwadsworth
@ -92,7 +93,7 @@ class AvengingArrowTarget extends TargetPermanent {
@Override
public Set<UUID> possibleTargets(UUID sourceId, UUID sourceControllerId, Game game) {
Set<UUID> availablePossibleTargets = super.possibleTargets(sourceId, sourceControllerId, game);
Set<UUID> possibleTargets = new HashSet<UUID>();
Set<UUID> possibleTargets = new HashSet<>();
SourceDidDamageWatcher watcher = (SourceDidDamageWatcher) game.getState().getWatchers().get("SourceDidDamageWatcher");
if (watcher != null) {
for (UUID targetId : availablePossibleTargets) {

View file

@ -27,7 +27,6 @@
*/
package mage.cards.a;
import java.util.UUID;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.SimpleStaticAbility;
@ -46,6 +45,8 @@ import mage.game.permanent.token.Token;
import mage.target.TargetPermanent;
import mage.target.common.TargetLandPermanent;
import java.util.UUID;
/**
*
* @author jeffwadsworth
@ -81,7 +82,7 @@ public class AwakenTheAncient extends CardImpl {
return new AwakenTheAncient(this);
}
private class GiantToken extends Token {
private static class GiantToken extends Token {
GiantToken() {
super("Giant", "7/7 red Giant creature with haste");

View file

@ -27,9 +27,6 @@
*/
package mage.cards.a;
import java.util.UUID;
import mage.constants.CardType;
import mage.MageInt;
import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.costs.mana.ManaCostsImpl;
@ -39,10 +36,13 @@ import mage.abilities.mana.BlueManaAbility;
import mage.abilities.mana.WhiteManaAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.Zone;
import mage.game.permanent.token.Token;
import java.util.UUID;
/**
* @author LevelX2
*/
@ -68,7 +68,7 @@ public class AzoriusKeyrune extends CardImpl {
return new AzoriusKeyrune(this);
}
private class AzoriusKeyruneToken extends Token {
private static class AzoriusKeyruneToken extends Token {
AzoriusKeyruneToken() {
super("", "2/2 white and blue Bird artifact creature with flying");
cardType.add(CardType.ARTIFACT);

View file

@ -27,16 +27,10 @@
*/
package mage.cards.b;
import java.util.Set;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.TriggeredAbilityImpl;
import mage.abilities.effects.OneShotEffect;
import mage.cards.Card;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.cards.Cards;
import mage.cards.CardsImpl;
import mage.cards.*;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.Zone;
@ -45,6 +39,9 @@ import mage.game.events.GameEvent;
import mage.game.events.GameEvent.EventType;
import mage.players.Player;
import java.util.Set;
import java.util.UUID;
/**
*
* @author jeffwadsworth
@ -99,7 +96,7 @@ public class BanefulOmen extends CardImpl {
}
}
class BanefulOmenEffect extends OneShotEffect {
static class BanefulOmenEffect extends OneShotEffect {
public BanefulOmenEffect() {
super(Outcome.Benefit);

View file

@ -27,7 +27,6 @@
*/
package mage.cards.b;
import mage.constants.CardType;
import mage.MageInt;
import mage.abilities.Abilities;
import mage.abilities.AbilitiesImpl;
@ -38,6 +37,7 @@ import mage.abilities.keyword.LevelerCardBuilder;
import mage.abilities.keyword.TrampleAbility;
import mage.cards.CardSetInfo;
import mage.cards.LevelerCard;
import mage.constants.CardType;
import java.util.UUID;
@ -59,13 +59,13 @@ public class BeastbreakerOfBalaGed extends LevelerCard {
// Level up {2}{G} ({2}{G}: Put a level counter on this. Level up only as a sorcery.)
this.addAbility(new LevelUpAbility(new ManaCostsImpl("{2}{G}")));
Abilities<Ability> levelAbilities = new AbilitiesImpl<Ability>();
Abilities<Ability> levelAbilities = new AbilitiesImpl<>();
levelAbilities.add(TrampleAbility.getInstance());
this.addAbilities(LevelerCardBuilder.construct(
// LEVEL 1-3
// 4/4
new LevelerCardBuilder.LevelAbility(1, 3, new AbilitiesImpl<Ability>(), 4, 4),
new LevelerCardBuilder.LevelAbility(1, 3, new AbilitiesImpl<>(), 4, 4),
// LEVEL 1-3
// 4/4
// Trample

View file

@ -28,27 +28,27 @@
package mage.cards.b;
import java.util.UUID;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.common.SpellCastControllerTriggeredAbility;
import mage.abilities.costs.Cost;
import mage.abilities.costs.common.RemoveVariableCountersSourceCost;
import mage.abilities.costs.mana.GenericManaCost;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.continuous.BoostSourceEffect;
import mage.abilities.effects.common.counter.AddCountersSourceEffect;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.Outcome;
import mage.constants.Zone;
import mage.counters.CounterType;
import mage.filter.common.FilterSpiritOrArcaneCard;
import mage.game.Game;
import mage.constants.CardType;
import mage.constants.Zone;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.common.SpellCastControllerTriggeredAbility;
import mage.abilities.costs.Cost;
import mage.abilities.costs.common.RemoveVariableCountersSourceCost;
import mage.abilities.costs.mana.GenericManaCost;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.continuous.BoostSourceEffect;
import mage.abilities.effects.common.counter.AddCountersSourceEffect;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.Duration;
import mage.constants.Outcome;
import mage.counters.CounterType;
import mage.filter.common.FilterSpiritOrArcaneCard;
import mage.game.Game;
import java.util.UUID;
/**
* @author LevelX2
@ -82,7 +82,7 @@ public class BlademaneBaku extends CardImpl {
return new BlademaneBaku(this);
}
class BlademaneBakuBoostEffect extends OneShotEffect {
static class BlademaneBakuBoostEffect extends OneShotEffect {
public BlademaneBakuBoostEffect() {
super(Outcome.UnboostCreature);

View file

@ -27,7 +27,6 @@
*/
package mage.cards.b;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect;
import mage.cards.CardImpl;
@ -38,6 +37,8 @@ import mage.filter.common.FilterCreatureCard;
import mage.game.Game;
import mage.players.Player;
import java.util.UUID;
/**
*
* @author Derpthemeus
@ -60,7 +61,7 @@ public class BlossomingWreath extends CardImpl {
return new BlossomingWreath(this);
}
class BlossomingWreathEffect extends OneShotEffect {
static class BlossomingWreathEffect extends OneShotEffect {
public BlossomingWreathEffect() {
super(Outcome.GainLife);

View file

@ -27,7 +27,6 @@
*/
package mage.cards.b;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.condition.common.ManaWasSpentCondition;
import mage.abilities.decorator.ConditionalOneShotEffect;
@ -46,6 +45,8 @@ import mage.game.permanent.Permanent;
import mage.players.Player;
import mage.target.common.TargetCreaturePermanent;
import java.util.UUID;
/**
*
* @author Dilnu
@ -75,7 +76,7 @@ public class BorosFuryShield extends CardImpl {
return new BorosFuryShield(this);
}
class BorosFuryShieldDamageEffect extends OneShotEffect {
static class BorosFuryShieldDamageEffect extends OneShotEffect {
BorosFuryShieldDamageEffect() {
super(Outcome.Damage);
staticText = "{this} deals damage to that creature's controller equal to the creature's power";

View file

@ -27,10 +27,6 @@
*/
package mage.cards.b;
import java.util.UUID;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.Zone;
import mage.MageInt;
import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.costs.mana.ManaCostsImpl;
@ -40,8 +36,13 @@ import mage.abilities.mana.RedManaAbility;
import mage.abilities.mana.WhiteManaAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.Zone;
import mage.game.permanent.token.Token;
import java.util.UUID;
/**
*
* @author LevelX2
@ -68,7 +69,7 @@ public class BorosKeyrune extends CardImpl {
return new BorosKeyrune(this);
}
private class BorosKeyruneToken extends Token {
private static class BorosKeyruneToken extends Token {
BorosKeyruneToken() {
super("Soldier", "1/1 red and white Soldier artifact creature with double strike");
cardType.add(CardType.ARTIFACT);

View file

@ -28,8 +28,6 @@
package mage.cards.b;
import mage.constants.CardType;
import mage.constants.Zone;
import mage.MageInt;
import mage.abilities.Abilities;
import mage.abilities.AbilitiesImpl;
@ -42,6 +40,8 @@ import mage.abilities.keyword.LevelUpAbility;
import mage.abilities.keyword.LevelerCardBuilder;
import mage.cards.CardSetInfo;
import mage.cards.LevelerCard;
import mage.constants.CardType;
import mage.constants.Zone;
import mage.target.common.TargetCreatureOrPlayer;
import java.util.UUID;
@ -61,12 +61,12 @@ public class BrimstoneMage extends LevelerCard {
this.toughness = new MageInt(2);
this.addAbility(new LevelUpAbility(new ManaCostsImpl("{3}{R}")));
Abilities<Ability> abilities1 = new AbilitiesImpl<Ability>();
Abilities<Ability> abilities1 = new AbilitiesImpl<>();
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new DamageTargetEffect(1), new TapSourceCost());
ability.addTarget(new TargetCreatureOrPlayer());
abilities1.add(ability);
Abilities<Ability> abilities2 = new AbilitiesImpl<Ability>();
Abilities<Ability> abilities2 = new AbilitiesImpl<>();
ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new DamageTargetEffect(3), new TapSourceCost());
ability.addTarget(new TargetCreatureOrPlayer());
abilities2.add(ability);

View file

@ -27,10 +27,6 @@
*/
package mage.cards.b;
import java.util.Set;
import java.util.UUID;
import mage.constants.*;
import mage.abilities.Ability;
import mage.abilities.TriggeredAbility;
import mage.abilities.common.BeginningOfUpkeepTriggeredAbility;
@ -41,10 +37,17 @@ import mage.abilities.effects.common.SacrificeSourceEffect;
import mage.cards.Card;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.TargetController;
import mage.constants.Zone;
import mage.game.Game;
import mage.players.Player;
import mage.target.common.TargetOpponent;
import java.util.Set;
import java.util.UUID;
/**
*
* @author Plopman
@ -73,7 +76,7 @@ public class BrinkOfMadness extends CardImpl {
return new BrinkOfMadness(this);
}
class BrinkOfMadnessEffect extends OneShotEffect {
static class BrinkOfMadnessEffect extends OneShotEffect {
public BrinkOfMadnessEffect() {
super(Outcome.Benefit);

View file

@ -27,39 +27,22 @@
*/
package mage.cards.c;
import java.util.UUID;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.MageSingleton;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.effects.ContinuousEffectImpl;
import mage.abilities.keyword.ChangelingAbility;
import mage.abilities.keyword.DeathtouchAbility;
import mage.abilities.keyword.DoubleStrikeAbility;
import mage.abilities.keyword.FearAbility;
import mage.abilities.keyword.FirstStrikeAbility;
import mage.abilities.keyword.FlyingAbility;
import mage.abilities.keyword.HasteAbility;
import mage.abilities.keyword.LandwalkAbility;
import mage.abilities.keyword.LifelinkAbility;
import mage.abilities.keyword.ProtectionAbility;
import mage.abilities.keyword.ReachAbility;
import mage.abilities.keyword.ShroudAbility;
import mage.abilities.keyword.TrampleAbility;
import mage.abilities.keyword.VigilanceAbility;
import mage.abilities.keyword.*;
import mage.cards.Card;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.Layer;
import mage.constants.Outcome;
import mage.constants.SubLayer;
import mage.constants.Zone;
import mage.constants.*;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.players.Player;
import java.util.UUID;
/**
*
* @author psykad
@ -89,7 +72,7 @@ public class CairnWanderer extends CardImpl {
return new CairnWanderer(this);
}
class CairnWandererEffect extends ContinuousEffectImpl {
static class CairnWandererEffect extends ContinuousEffectImpl {
public CairnWandererEffect() {
super(Duration.WhileOnBattlefield, Layer.AbilityAddingRemovingEffects_6, SubLayer.NA, Outcome.AddAbility);

View file

@ -27,17 +27,15 @@
*/
package mage.cards.c;
import java.util.ArrayList;
import java.util.UUID;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.TargetController;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.BeginningOfUpkeepTriggeredAbility;
import mage.abilities.effects.OneShotEffect;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.TargetController;
import mage.filter.common.FilterNonlandPermanent;
import mage.filter.predicate.permanent.ControllerPredicate;
import mage.game.Game;
@ -45,6 +43,9 @@ import mage.game.permanent.Permanent;
import mage.target.TargetPermanent;
import mage.util.RandomUtil;
import java.util.ArrayList;
import java.util.UUID;
/**
*
* @author North
@ -101,7 +102,7 @@ class CapriciousEfreetEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
ArrayList<Permanent> targetPermanents = new ArrayList<Permanent>();
ArrayList<Permanent> targetPermanents = new ArrayList<>();
Permanent permanent = game.getPermanent(source.getTargets().get(0).getFirstTarget());
if (permanent != null) {
targetPermanents.add(permanent);

View file

@ -27,16 +27,16 @@
*/
package mage.cards.c;
import mage.constants.CardType;
import mage.MageInt;
import mage.abilities.AbilitiesImpl;
import mage.abilities.Ability;
import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.keyword.FirstStrikeAbility;
import mage.abilities.keyword.LevelerCardBuilder;
import mage.abilities.keyword.LevelUpAbility;
import mage.abilities.keyword.LevelerCardBuilder;
import mage.cards.CardSetInfo;
import mage.cards.LevelerCard;
import mage.constants.CardType;
import java.util.UUID;
@ -57,9 +57,9 @@ public class CaravanEscort extends LevelerCard {
this.addAbility(new LevelUpAbility(new ManaCostsImpl("{2}")));
AbilitiesImpl<Ability> levelAbilities = new AbilitiesImpl<Ability>(FirstStrikeAbility.getInstance());
AbilitiesImpl<Ability> levelAbilities = new AbilitiesImpl<>(FirstStrikeAbility.getInstance());
this.addAbilities(LevelerCardBuilder.construct(
new LevelerCardBuilder.LevelAbility(1, 4, new AbilitiesImpl<Ability>(), 2, 2),
new LevelerCardBuilder.LevelAbility(1, 4, new AbilitiesImpl<>(), 2, 2),
new LevelerCardBuilder.LevelAbility(5, -1, levelAbilities, 5, 5)
));

View file

@ -135,7 +135,7 @@ class CathedralMembraneEffect extends OneShotEffect {
class CathedralMembraneWatcher extends Watcher {
public List<UUID> blockedCreatures = new ArrayList<UUID>();
public List<UUID> blockedCreatures = new ArrayList<>();
public CathedralMembraneWatcher() {
super("CathedralMembraneWatcher", WatcherScope.CARD);

View file

@ -27,7 +27,6 @@
*/
package mage.cards.c;
import java.util.UUID;
import mage.MageInt;
import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.common.SpellCastOpponentTriggeredAbility;
@ -47,6 +46,8 @@ import mage.filter.predicate.Predicates;
import mage.filter.predicate.mageobject.CardTypePredicate;
import mage.game.permanent.token.Token;
import java.util.UUID;
/**
@ -81,7 +82,7 @@ public class ChimericEgg extends CardImpl {
return new ChimericEgg(this);
}
private class ChimericEggToken extends Token {
private static class ChimericEggToken extends Token {
ChimericEggToken() {
super("", "6/6 Construct artifact creature with trample");
cardType.add(CardType.ARTIFACT);

View file

@ -27,9 +27,6 @@
*/
package mage.cards.c;
import java.util.UUID;
import mage.constants.CardType;
import mage.abilities.Ability;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.common.ZoneChangeTriggeredAbility;
@ -38,6 +35,7 @@ import mage.abilities.effects.common.DamageTargetEffect;
import mage.abilities.effects.common.continuous.GainAbilityAllEffect;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.Zone;
import mage.filter.common.FilterCreaturePermanent;
@ -45,6 +43,8 @@ import mage.filter.predicate.Predicates;
import mage.filter.predicate.mageobject.SubtypePredicate;
import mage.target.common.TargetCreaturePermanent;
import java.util.UUID;
/**
*
* @author LevelX2
@ -83,7 +83,7 @@ public class ClashOfRealities extends CardImpl {
return new ClashOfRealities(this);
}
private class ClashOfRealitiesTriggeredAbility extends ZoneChangeTriggeredAbility {
private static class ClashOfRealitiesTriggeredAbility extends ZoneChangeTriggeredAbility {
public ClashOfRealitiesTriggeredAbility(Effect effect, String rule) {
super(Zone.BATTLEFIELD, effect, rule, true);

View file

@ -68,7 +68,7 @@ public class CoalhaulerSwine extends CardImpl {
return new CoalhaulerSwine(this);
}
class CoalhaulerSwineEffect extends OneShotEffect {
static class CoalhaulerSwineEffect extends OneShotEffect {
public CoalhaulerSwineEffect() {
super(Outcome.Damage);

View file

@ -27,7 +27,6 @@
*/
package mage.cards.c;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.TriggeredAbility;
import mage.abilities.common.BeginningOfUpkeepTriggeredAbility;
@ -42,6 +41,8 @@ import mage.constants.CardType;
import mage.constants.TargetController;
import mage.game.Game;
import java.util.UUID;
/**
*
* @author fireshoes
@ -67,7 +68,7 @@ public class ConvalescentCare extends CardImpl {
return new ConvalescentCare(this);
}
class FiveOrLessLifeCondition implements Condition {
static class FiveOrLessLifeCondition implements Condition {
@Override
public boolean apply(Game game, Ability source) {

View file

@ -27,10 +27,6 @@
*/
package mage.cards.c;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.common.BeginningOfUpkeepTriggeredAbility;
import mage.abilities.common.SimpleStaticAbility;
@ -41,18 +37,16 @@ import mage.abilities.effects.common.SacrificeSourceUnlessPaysEffect;
import mage.abilities.mana.WhiteManaAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.DependencyType;
import mage.constants.Duration;
import mage.constants.Layer;
import mage.constants.Outcome;
import mage.constants.SubLayer;
import mage.constants.TargetController;
import mage.constants.Zone;
import mage.constants.*;
import mage.filter.common.FilterLandPermanent;
import mage.game.Game;
import mage.game.permanent.Permanent;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.UUID;
/**
*
* @author LevelX2
@ -81,7 +75,7 @@ public class Conversion extends CardImpl {
return new Conversion(this);
}
class ConversionEffect extends ContinuousEffectImpl {
static class ConversionEffect extends ContinuousEffectImpl {
ConversionEffect() {
super(Duration.WhileOnBattlefield, Outcome.Detriment);

View file

@ -27,9 +27,6 @@
*/
package mage.cards.c;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.Zone;
import mage.MageInt;
import mage.abilities.Abilities;
import mage.abilities.AbilitiesImpl;
@ -42,6 +39,9 @@ import mage.abilities.keyword.LevelUpAbility;
import mage.abilities.keyword.LevelerCardBuilder;
import mage.cards.CardSetInfo;
import mage.cards.LevelerCard;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.Zone;
import mage.filter.common.FilterCreaturePermanent;
import mage.filter.predicate.mageobject.SubtypePredicate;
@ -70,10 +70,10 @@ public class CoralhelmCommander extends LevelerCard {
this.addAbility(new LevelUpAbility(new ManaCostsImpl("{1}")));
Abilities<Ability> abilities1 = new AbilitiesImpl<Ability>();
Abilities<Ability> abilities1 = new AbilitiesImpl<>();
abilities1.add(FlyingAbility.getInstance());
Abilities<Ability> abilities2 = new AbilitiesImpl<Ability>();
Abilities<Ability> abilities2 = new AbilitiesImpl<>();
abilities2.add(FlyingAbility.getInstance());
abilities2.add(new SimpleStaticAbility(Zone.BATTLEFIELD, new BoostControlledEffect(1, 1, Duration.WhileOnBattlefield, filter, true)));

View file

@ -27,12 +27,6 @@
*/
package mage.cards.c;
import java.util.LinkedList;
import java.util.List;
import java.util.UUID;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.abilities.Ability;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.costs.mana.ManaCostsImpl;
@ -43,6 +37,8 @@ import mage.abilities.effects.common.CounterTargetEffect;
import mage.abilities.keyword.OverloadAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.TargetController;
import mage.constants.Zone;
import mage.filter.FilterSpell;
@ -52,6 +48,10 @@ import mage.game.stack.Spell;
import mage.game.stack.StackObject;
import mage.target.TargetSpell;
import java.util.LinkedList;
import java.util.List;
import java.util.UUID;
/**
*
@ -109,7 +109,7 @@ class CounterfluxEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
List<Spell> spellsToCounter = new LinkedList<Spell>();
List<Spell> spellsToCounter = new LinkedList<>();
for (StackObject stackObject : game.getStack()) {
if (stackObject instanceof Spell && !stackObject.getControllerId().equals(source.getControllerId())) {
spellsToCounter.add((Spell) stackObject);

View file

@ -27,16 +27,13 @@
*/
package mage.cards.c;
import java.util.ArrayList;
import java.util.UUID;
import mage.constants.CardType;
import mage.MageObject;
import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect;
import mage.cards.Card;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.filter.FilterCard;
import mage.filter.predicate.Predicate;
@ -48,6 +45,9 @@ import mage.players.Player;
import mage.target.TargetSpell;
import mage.target.common.TargetCardInHand;
import java.util.ArrayList;
import java.util.UUID;
/**
*
* @author BetaSteward
@ -97,7 +97,7 @@ class CounterlashEffect extends OneShotEffect {
game.getStack().counter(source.getFirstTarget(), source.getSourceId(), game);
if (player.chooseUse(Outcome.PutCardInPlay, "Cast a nonland card in your hand that shares a card type with that spell without paying its mana cost?", source, game)) {
FilterCard filter = new FilterCard();
ArrayList<Predicate<MageObject>> types = new ArrayList<Predicate<MageObject>>();
ArrayList<Predicate<MageObject>> types = new ArrayList<>();
for (CardType type: stackObject.getCardType()) {
if (type != CardType.LAND) {
types.add(new CardTypePredicate(type));

View file

@ -88,7 +88,7 @@ class FilterCoverOfDarkness extends FilterCreaturePermanent {
public boolean match(Permanent permanent, UUID sourceId, UUID playerId, Game game) {
if (super.match(permanent, sourceId, playerId, game)) {
String subtype = (String) game.getState().getValue(sourceId + "_type");
if (subtype != null && !subtype.equals("") && permanent.hasSubtype(subtype, game)) {
if (subtype != null && !subtype.isEmpty() && permanent.hasSubtype(subtype, game)) {
return true;
}
}

View file

@ -27,7 +27,6 @@
*/
package mage.cards.c;
import java.util.UUID;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.DelayedTriggeredAbility;
@ -48,6 +47,8 @@ import mage.game.Game;
import mage.game.events.GameEvent;
import mage.game.events.GameEvent.EventType;
import java.util.UUID;
/**
*
* @author fireshoes
@ -80,7 +81,7 @@ public class CrazedArmodon extends CardImpl {
return new CrazedArmodon(this);
}
class CrazedArmodonDelayedTriggeredAbility extends DelayedTriggeredAbility {
static class CrazedArmodonDelayedTriggeredAbility extends DelayedTriggeredAbility {
public CrazedArmodonDelayedTriggeredAbility() {
super(new DestroySourceEffect());

View file

@ -27,7 +27,6 @@
*/
package mage.cards.c;
import java.util.UUID;
import mage.MageInt;
import mage.abilities.TriggeredAbilityImpl;
import mage.abilities.dynamicvalue.common.StaticValue;
@ -43,6 +42,8 @@ import mage.game.events.GameEvent;
import mage.game.events.GameEvent.EventType;
import mage.target.targetpointer.FixedTarget;
import java.util.UUID;
/**
*
* @author LevelX2
@ -69,7 +70,7 @@ public class CrosstownCourier extends CardImpl {
return new CrosstownCourier(this);
}
class CrosstownCourierTriggeredAbility extends TriggeredAbilityImpl {
static class CrosstownCourierTriggeredAbility extends TriggeredAbilityImpl {
public CrosstownCourierTriggeredAbility() {
super(Zone.BATTLEFIELD, new PutLibraryIntoGraveTargetEffect(0), false);

View file

@ -27,7 +27,6 @@
*/
package mage.cards.d;
import java.util.UUID;
import mage.MageInt;
import mage.abilities.effects.Effect;
import mage.abilities.effects.common.continuous.BecomesCreatureTargetEffect;
@ -39,6 +38,8 @@ import mage.constants.Duration;
import mage.game.permanent.token.Token;
import mage.target.common.TargetControlledCreaturePermanent;
import java.util.UUID;
/**
*
* @author fireshoes
@ -64,7 +65,7 @@ public class DanceOfTheSkywise extends CardImpl {
return new DanceOfTheSkywise(this);
}
private class DragonIllusionToken extends Token {
private static class DragonIllusionToken extends Token {
public DragonIllusionToken() {
super("Dragon", "blue Dragon Illusion with base power and toughness 4/4 and with flying");

View file

@ -75,7 +75,7 @@ public class DeathWatch extends CardImpl {
return new DeathWatch(this);
}
class DeathWatchEffect extends OneShotEffect {
static class DeathWatchEffect extends OneShotEffect {
public DeathWatchEffect() {
super(Outcome.LoseLife);

View file

@ -27,7 +27,6 @@
*/
package mage.cards.d;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.effects.common.RegenerateTargetEffect;
import mage.abilities.effects.common.continuous.GainControlTargetEffect;
@ -39,6 +38,8 @@ import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.target.common.TargetCreaturePermanent;
import java.util.UUID;
/**
*
* @author Dilnu
@ -62,7 +63,7 @@ public class DebtOfLoyalty extends CardImpl {
return new DebtOfLoyalty(this);
}
class DebtOfLoyaltyEffect extends RegenerateTargetEffect {
static class DebtOfLoyaltyEffect extends RegenerateTargetEffect {
public DebtOfLoyaltyEffect ( ) {
super();
this.staticText = "Regenerate target creature. You gain control of that creature if it regenerates this way.";

View file

@ -27,10 +27,6 @@
*/
package mage.cards.d;
import java.util.Set;
import java.util.UUID;
import mage.constants.*;
import mage.abilities.Ability;
import mage.abilities.TriggeredAbility;
import mage.abilities.common.BeginningOfUpkeepTriggeredAbility;
@ -40,11 +36,18 @@ import mage.abilities.effects.common.SacrificeSourceEffect;
import mage.abilities.effects.common.search.SearchLibraryPutInPlayEffect;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.TargetController;
import mage.constants.Zone;
import mage.filter.common.FilterCreatureCard;
import mage.filter.common.FilterCreaturePermanent;
import mage.game.Game;
import mage.target.common.TargetCardInLibrary;
import java.util.Set;
import java.util.UUID;
/**
*
* @author Plopman
@ -72,7 +75,7 @@ public class DefenseOfTheHeart extends CardImpl {
return new DefenseOfTheHeart(this);
}
class DefenseOfTheHeartCondition implements Condition {
static class DefenseOfTheHeartCondition implements Condition {
@Override
public boolean apply(Game game, Ability source) {

View file

@ -27,8 +27,6 @@
*/
package mage.cards.d;
import java.util.HashMap;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect;
import mage.cards.CardImpl;
@ -42,6 +40,9 @@ import mage.players.Player;
import mage.target.Target;
import mage.target.common.TargetCreaturePermanent;
import java.util.HashMap;
import java.util.UUID;
/**
*
* @author jeffwadsworth
@ -87,7 +88,7 @@ class DescentOfTheDragonsEffect extends OneShotEffect {
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
HashMap<UUID, Integer> playersWithTargets = new HashMap<UUID, Integer>();
HashMap<UUID, Integer> playersWithTargets = new HashMap<>();
for (Target target : source.getTargets()) {
for (UUID permanentId : target.getTargets()) {
Permanent permanent = game.getPermanent(permanentId);

View file

@ -27,7 +27,6 @@
*/
package mage.cards.d;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.costs.common.SacrificeXTargetCost;
import mage.abilities.dynamicvalue.common.GetXValue;
@ -40,6 +39,8 @@ import mage.filter.common.FilterControlledLandPermanent;
import mage.game.Game;
import mage.game.permanent.token.Token;
import java.util.UUID;
/**
*
* @author jeffwadsworth
@ -95,7 +96,7 @@ class DevastatingSummonsEffect extends OneShotEffect {
return new DevastatingSummonsEffect(this);
}
class ElementalToken extends Token {
static class ElementalToken extends Token {
public ElementalToken() {
super("Elemental", "X/X red Elemental creature");

View file

@ -27,10 +27,6 @@
*/
package mage.cards.d;
import java.util.UUID;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.Zone;
import mage.MageInt;
import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.costs.mana.ManaCostsImpl;
@ -40,8 +36,13 @@ import mage.abilities.mana.BlackManaAbility;
import mage.abilities.mana.BlueManaAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.Zone;
import mage.game.permanent.token.Token;
import java.util.UUID;
/**
*
* @author LevelX2
@ -68,7 +69,7 @@ public class DimirKeyrune extends CardImpl {
return new DimirKeyrune(this);
}
private class DimirKeyruneToken extends Token {
private static class DimirKeyruneToken extends Token {
DimirKeyruneToken() {
super("Horror", "2/2 blue and black Horror until end of turn and can't be blocked this turn");
cardType.add(CardType.ARTIFACT);

View file

@ -27,9 +27,6 @@
*/
package mage.cards.d;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.SimpleStaticAbility;
@ -38,17 +35,16 @@ import mage.abilities.keyword.FlyingAbility;
import mage.abilities.keyword.ReplicateAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.Layer;
import mage.constants.Outcome;
import mage.constants.SubLayer;
import mage.constants.Zone;
import mage.constants.*;
import mage.filter.common.FilterInstantOrSorcerySpell;
import mage.game.Game;
import mage.game.stack.Spell;
import mage.game.stack.StackObject;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
/**
*
* @author LevelX2
@ -107,11 +103,7 @@ class DjinnIlluminatusGainReplicateEffect extends ContinuousEffectImpl {
if ((stackObject instanceof Spell) && !stackObject.isCopy() && stackObject.getControllerId().equals(source.getControllerId())) {
Spell spell = (Spell) stackObject;
if (filter.match(stackObject, game)) {
ReplicateAbility replicateAbility = replicateAbilities.get(spell.getId());
if (replicateAbility == null) {
replicateAbility = new ReplicateAbility(spell.getCard(), spell.getSpellAbility().getManaCosts().getText());
replicateAbilities.put(spell.getId(), replicateAbility);
}
ReplicateAbility replicateAbility = replicateAbilities.computeIfAbsent(spell.getId(), k -> new ReplicateAbility(spell.getCard(), spell.getSpellAbility().getManaCosts().getText()));
game.getState().addOtherAbility(spell.getCard(), replicateAbility, false); // Do not copy because paid and # of activations state is handled in the baility
}
}

View file

@ -27,16 +27,17 @@
*/
package mage.cards.d;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.Zone;
import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect;
import mage.cards.Card;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.Zone;
import mage.filter.common.FilterCreatureCard;
import mage.filter.common.FilterCreaturePermanent;
import mage.filter.predicate.mageobject.NamePredicate;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.players.Player;
@ -45,7 +46,6 @@ import mage.target.common.TargetCardInLibrary;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import mage.filter.predicate.mageobject.NamePredicate;
/**
*
@ -88,8 +88,8 @@ class DoublingChantEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
List<Card> chosenCards = new ArrayList<Card>();
List<String> namesFiltered = new ArrayList<String>();
List<Card> chosenCards = new ArrayList<>();
List<String> namesFiltered = new ArrayList<>();
Player player = game.getPlayer(source.getControllerId());
if (player == null) {

View file

@ -27,21 +27,22 @@
*/
package mage.cards.e;
import java.util.LinkedList;
import java.util.UUID;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.keyword.FlyingAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.filter.common.FilterCreaturePermanent;
import mage.filter.predicate.mageobject.AbilityPredicate;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.target.common.TargetCreaturePermanent;
import java.util.LinkedList;
import java.util.UUID;
/**
*
* @author North
@ -93,7 +94,7 @@ class EatenBySpidersEffect extends OneShotEffect {
public boolean apply(Game game, Ability source) {
Permanent permanent = game.getPermanent(source.getFirstTarget());
if (permanent != null) {
LinkedList<UUID> attachments = new LinkedList<UUID>();
LinkedList<UUID> attachments = new LinkedList<>();
attachments.addAll(permanent.getAttachments());
for (UUID attachmentId : attachments) {

View file

@ -27,7 +27,6 @@
*/
package mage.cards.e;
import java.util.UUID;
import mage.MageInt;
import mage.abilities.Abilities;
import mage.abilities.AbilitiesImpl;
@ -51,6 +50,8 @@ import mage.game.Game;
import mage.game.stack.Spell;
import mage.target.TargetSpell;
import java.util.UUID;
/**
*
* @author North
@ -79,7 +80,7 @@ public class EchoMage extends LevelerCard {
// LEVEL 2-3
// 2/4
// {U}{U}, {tap}: Copy target instant or sorcery spell. You may choose new targets for the copy.
Abilities<Ability> abilities1 = new AbilitiesImpl<Ability>();
Abilities<Ability> abilities1 = new AbilitiesImpl<>();
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new CopyTargetSpellEffect(), new ManaCostsImpl("{U}{U}"));
ability.addTarget(new TargetSpell(filter));
ability.addCost(new TapSourceCost());
@ -87,7 +88,7 @@ public class EchoMage extends LevelerCard {
// LEVEL 4+
// 2/5
// {U}{U}, {tap}: Copy target instant or sorcery spell twice. You may choose new targets for the copies.
Abilities<Ability> abilities2 = new AbilitiesImpl<Ability>();
Abilities<Ability> abilities2 = new AbilitiesImpl<>();
ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new EchoMageEffect(), new ManaCostsImpl("{U}{U}"));
ability.addTarget(new TargetSpell(filter));
ability.addCost(new TapSourceCost());

View file

@ -27,15 +27,13 @@
*/
package mage.cards.e;
import java.util.ArrayList;
import java.util.UUID;
import mage.constants.CardType;
import mage.MageInt;
import mage.MageObject;
import mage.ObjectColor;
import mage.abilities.keyword.ProtectionAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.filter.Filter;
import mage.filter.FilterCard;
import mage.filter.FilterObject;
@ -45,6 +43,9 @@ import mage.filter.predicate.mageobject.ColorPredicate;
import mage.game.Game;
import mage.game.permanent.Permanent;
import java.util.ArrayList;
import java.util.UUID;
/**
*
* @author LevelX2
@ -113,7 +114,7 @@ class EmptyShrineKannushiProtectionAbility extends ProtectionAbility {
}
}
ArrayList<Predicate<MageObject>> colorPredicates = new ArrayList<Predicate<MageObject>>();
ArrayList<Predicate<MageObject>> colorPredicates = new ArrayList<>();
if (color.isBlack()) {
colorPredicates.add(new ColorPredicate(ObjectColor.BLACK));
}

View file

@ -28,8 +28,6 @@
package mage.cards.e;
import mage.constants.CardType;
import mage.constants.Zone;
import mage.MageInt;
import mage.abilities.Abilities;
import mage.abilities.AbilitiesImpl;
@ -39,10 +37,12 @@ import mage.abilities.costs.common.TapSourceCost;
import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.effects.common.DrawCardSourceControllerEffect;
import mage.abilities.effects.common.DrawDiscardControllerEffect;
import mage.abilities.keyword.LevelerCardBuilder;
import mage.abilities.keyword.LevelUpAbility;
import mage.abilities.keyword.LevelerCardBuilder;
import mage.cards.CardSetInfo;
import mage.cards.LevelerCard;
import mage.constants.CardType;
import mage.constants.Zone;
import java.util.UUID;
@ -63,10 +63,10 @@ public class EnclaveCryptologist extends LevelerCard {
this.addAbility(new LevelUpAbility(new ManaCostsImpl("{1}{U}")));
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new DrawDiscardControllerEffect(), new TapSourceCost());
Abilities<Ability> abilities1 = new AbilitiesImpl<Ability>(ability);
Abilities<Ability> abilities1 = new AbilitiesImpl<>(ability);
ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new DrawCardSourceControllerEffect(1), new TapSourceCost());
Abilities<Ability> abilities2 = new AbilitiesImpl<Ability>(ability);
Abilities<Ability> abilities2 = new AbilitiesImpl<>(ability);
this.addAbilities(LevelerCardBuilder.construct(
new LevelerCardBuilder.LevelAbility(1, 2, abilities1, 0, 1),

View file

@ -27,22 +27,23 @@
*/
package mage.cards.e;
import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.MageObject;
import mage.abilities.Ability;
import mage.abilities.effects.common.continuous.BoostTargetEffect;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.filter.common.FilterCreaturePermanent;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.target.TargetPermanent;
import mage.watchers.common.SourceDidDamageWatcher;
import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
/**
*
* @author LevelX2
@ -119,7 +120,7 @@ class TargetCreaturePermanentThatDealtDamageThisTurn extends TargetPermanent {
@Override
public Set<UUID> possibleTargets(UUID sourceId, UUID sourceControllerId, Game game) {
Set<UUID> availablePossibleTargets = super.possibleTargets(sourceId, sourceControllerId, game);
Set<UUID> possibleTargets = new HashSet<UUID>();
Set<UUID> possibleTargets = new HashSet<>();
SourceDidDamageWatcher watcher = (SourceDidDamageWatcher) game.getState().getWatchers().get("SourceDidDamageWatcher");
if (watcher != null) {
for (UUID targetId : availablePossibleTargets) {

View file

@ -27,9 +27,6 @@
*/
package mage.cards.e;
import java.util.HashMap;
import java.util.Objects;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.TriggeredAbilityImpl;
import mage.abilities.common.EntersBattlefieldTriggeredAbility;
@ -48,6 +45,10 @@ import mage.game.events.GameEvent.EventType;
import mage.game.permanent.Permanent;
import mage.target.targetpointer.FixedTarget;
import java.util.HashMap;
import java.util.Objects;
import java.util.UUID;
/**
*
* @author spjspj
@ -100,7 +101,7 @@ class EyeOfSingularityETBEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
HashMap<String, UUID> cardNames = new HashMap<String, UUID>();
HashMap<String, UUID> cardNames = new HashMap<>();
HashMap<UUID, Integer> toDestroy = new HashMap<>();
for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)) {

Some files were not shown because too many files have changed in this diff Show more