Few lambda's and removed explicit type from creating lists and hashmaps

This commit is contained in:
vraskulin 2017-02-28 13:46:54 +03:00
parent 0a3c95dde5
commit 11dc1e10f1
130 changed files with 725 additions and 1105 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

@ -92,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()) {
@ -236,7 +236,7 @@ public class AbilityPicker extends JXPanel implements MouseWheelListener {
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(
@ -398,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

@ -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

@ -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

@ -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

@ -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);
}
@ -149,7 +141,7 @@ public class ArrowBuilder {
for (Arrow arrow : arrows) {
p.remove(arrow);
}
innerMap.put(type, new ArrayList<Arrow>());
innerMap.put(type, new ArrayList<>());
}
p.revalidate();
p.repaint();

View file

@ -767,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

@ -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

@ -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

@ -617,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;
@ -651,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);

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,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.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,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,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,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

@ -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,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)) {

View file

@ -27,12 +27,15 @@
*/
package mage.cards.f;
import mage.constants.*;
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.WatcherScope;
import mage.constants.Zone;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.game.events.ZoneChangeEvent;
@ -99,7 +102,7 @@ class FaithsRewardEffect extends OneShotEffect {
}
class FaithsRewardWatcher extends Watcher {
ArrayList<UUID> cards = new ArrayList<UUID>();
ArrayList<UUID> cards = new ArrayList<>();
public FaithsRewardWatcher() {
super("FaithsRewardWatcher", WatcherScope.GAME);

View file

@ -27,9 +27,6 @@
*/
package mage.cards.f;
import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
import mage.MageInt;
import mage.MageObject;
import mage.abilities.Ability;
@ -42,11 +39,7 @@ import mage.abilities.effects.common.continuous.BoostTargetEffect;
import mage.cards.Card;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.Outcome;
import mage.constants.WatcherScope;
import mage.constants.Zone;
import mage.constants.*;
import mage.filter.common.FilterControlledCreaturePermanent;
import mage.filter.predicate.permanent.AnotherPredicate;
import mage.game.Game;
@ -57,6 +50,10 @@ import mage.target.common.TargetControlledCreaturePermanent;
import mage.target.common.TargetCreaturePermanent;
import mage.watchers.Watcher;
import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
/**
*
* @author LevelX2
@ -98,7 +95,7 @@ public class FellShepherd extends CardImpl {
class FellShepherdWatcher extends Watcher {
private Set<UUID> creatureIds = new HashSet<UUID>();
private Set<UUID> creatureIds = new HashSet<>();
public FellShepherdWatcher() {
super("YourCreaturesPutToGraveFromBattlefield", WatcherScope.PLAYER);

View file

@ -27,11 +27,6 @@
*/
package mage.cards.f;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.costs.mana.GenericManaCost;
import mage.abilities.effects.OneShotEffect;
@ -44,6 +39,8 @@ import mage.game.permanent.Permanent;
import mage.players.Player;
import mage.target.common.TargetCreatureOrPlayer;
import java.util.*;
/**
*
* @author BetaSteward_at_googlemail.com
@ -158,9 +155,7 @@ class FireballTargetCreatureOrPlayer extends TargetCreatureOrPlayer {
}
possibleTargets.removeAll(getTargets());
Iterator<UUID> it = possibleTargets.iterator();
while (it.hasNext()) {
UUID targetId = it.next();
for (UUID targetId : possibleTargets) {
TargetCreatureOrPlayer target = this.copy();
target.clearChosen();
target.addTarget(targetId, source, game, true);

View file

@ -28,20 +28,21 @@
package mage.cards.f;
import java.util.ArrayList;
import java.util.List;
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.EquipAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.target.common.TargetCreaturePermanent;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
/**
*
* @author maurer.it_at_gmail.com
@ -84,7 +85,7 @@ class FulgentDistractionEffect extends OneShotEffect {
for ( UUID target : targetPointer.getTargets(game, source) ) {
Permanent creature = game.getPermanent(target);
List<UUID> copiedAttachments = new ArrayList<UUID>(creature.getAttachments());
List<UUID> copiedAttachments = new ArrayList<>(creature.getAttachments());
for ( UUID equipmentId : copiedAttachments ) {
Permanent equipment = game.getPermanent(equipmentId);
boolean isEquipment = false;

View file

@ -28,14 +28,6 @@
package mage.cards.g;
import java.util.Iterator;
import java.util.UUID;
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.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.SimpleActivatedAbility;
@ -45,9 +37,12 @@ import mage.abilities.keyword.DefenderAbility;
import mage.abilities.keyword.FlyingAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.*;
import mage.game.Game;
import mage.game.permanent.Permanent;
import java.util.UUID;
/**
*
* @author BetaSteward_at_googlemail.com
@ -98,11 +93,7 @@ class GargoyleSentinelEffect extends ContinuousEffectImpl {
switch (layer) {
case AbilityAddingRemovingEffects_6:
if (sublayer == SubLayer.NA) {
for (Iterator<Ability> i = permanent.getAbilities().iterator(); i.hasNext();) {
Ability entry = i.next();
if (entry.getId().equals(DefenderAbility.getInstance().getId()))
i.remove();
}
permanent.getAbilities().removeIf(entry -> entry.getId().equals(DefenderAbility.getInstance().getId()));
permanent.getAbilities().add(FlyingAbility.getInstance());
}
break;

View file

@ -27,9 +27,6 @@
*/
package mage.cards.g;
import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
import mage.MageInt;
import mage.MageObject;
import mage.abilities.Ability;
@ -47,6 +44,10 @@ import mage.game.permanent.Permanent;
import mage.target.TargetPermanent;
import mage.watchers.common.PlayerDamagedBySourceWatcher;
import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
/**
*
* @author BetaSteward_at_googlemail.com
@ -106,7 +107,7 @@ class GiltspireAvengerTarget 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<>();
PlayerDamagedBySourceWatcher watcher = (PlayerDamagedBySourceWatcher) game.getState().getWatchers().get("PlayerDamagedBySource", sourceControllerId);
for (UUID targetId : availablePossibleTargets) {
Permanent permanent = game.getPermanent(targetId);

View file

@ -27,8 +27,6 @@
*/
package mage.cards.g;
import java.util.Iterator;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.TriggeredAbilityImpl;
import mage.abilities.effects.ContinuousEffectImpl;
@ -36,18 +34,15 @@ import mage.abilities.effects.Effect;
import mage.abilities.keyword.FlyingAbility;
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.events.GameEvent;
import mage.game.events.GameEvent.EventType;
import mage.game.permanent.Permanent;
import mage.target.targetpointer.FixedTarget;
import java.util.UUID;
/**
*
* @author jeffwadsworth
@ -132,12 +127,7 @@ class GravityWellEffect extends ContinuousEffectImpl {
switch (layer) {
case AbilityAddingRemovingEffects_6:
if (sublayer == SubLayer.NA) {
for (Iterator<Ability> i = permanent.getAbilities().iterator(); i.hasNext();) {
Ability entry = i.next();
if (entry.getId().equals(FlyingAbility.getInstance().getId())) {
i.remove();
}
}
permanent.getAbilities().removeIf(entry -> entry.getId().equals(FlyingAbility.getInstance().getId()));
}
break;
}

View file

@ -27,7 +27,6 @@
*/
package mage.cards.h;
import mage.constants.CardType;
import mage.MageInt;
import mage.abilities.Abilities;
import mage.abilities.AbilitiesImpl;
@ -38,6 +37,7 @@ 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;
@ -58,11 +58,11 @@ public class HalimarWavewatch extends LevelerCard {
this.addAbility(new LevelUpAbility(new ManaCostsImpl("{2}")));
Abilities<Ability> levelAbilities = new AbilitiesImpl<Ability>();
Abilities<Ability> levelAbilities = new AbilitiesImpl<>();
levelAbilities.add(new IslandwalkAbility());
this.addAbilities(LevelerCardBuilder.construct(
new LevelerCardBuilder.LevelAbility(1, 4, new AbilitiesImpl<Ability>(), 0, 6),
new LevelerCardBuilder.LevelAbility(1, 4, new AbilitiesImpl<>(), 0, 6),
new LevelerCardBuilder.LevelAbility(5, -1, levelAbilities, 6, 6)
));
setMaxLevelCounters(5);

View file

@ -27,10 +27,6 @@
*/
package mage.cards.h;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect;
import mage.cards.CardImpl;
@ -46,6 +42,11 @@ import mage.game.permanent.Permanent;
import mage.players.Player;
import mage.target.TargetCard;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.UUID;
/**
*
* @author North
@ -93,13 +94,9 @@ class HarmonicConvergenceEffect extends OneShotEffect {
source.getSourceId(),
game);
HashMap<UUID, List<Permanent>> moveList = new HashMap<UUID, List<Permanent>>();
HashMap<UUID, List<Permanent>> moveList = new HashMap<>();
for (Permanent permanent : enchantments) {
List<Permanent> list = moveList.get(permanent.getControllerId());
if (list == null) {
list = new ArrayList<Permanent>();
moveList.put(permanent.getControllerId(), list);
}
List<Permanent> list = moveList.computeIfAbsent(permanent.getControllerId(), k -> new ArrayList<>());
list.add(permanent);
}

View file

@ -28,17 +28,17 @@
package mage.cards.i;
import mage.constants.CardType;
import mage.MageInt;
import mage.abilities.Abilities;
import mage.abilities.AbilitiesImpl;
import mage.abilities.Ability;
import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.keyword.LevelerCardBuilder;
import mage.abilities.keyword.LevelUpAbility;
import mage.abilities.keyword.LevelerCardBuilder;
import mage.abilities.keyword.VigilanceAbility;
import mage.cards.CardSetInfo;
import mage.cards.LevelerCard;
import mage.constants.CardType;
import java.util.UUID;
@ -58,10 +58,10 @@ public class IkiralOutrider extends LevelerCard {
this.addAbility(new LevelUpAbility(new ManaCostsImpl("{4}")));
Abilities<Ability> abilities1 = new AbilitiesImpl<Ability>();
Abilities<Ability> abilities1 = new AbilitiesImpl<>();
abilities1.add(VigilanceAbility.getInstance());
Abilities<Ability> abilities2 = new AbilitiesImpl<Ability>();
Abilities<Ability> abilities2 = new AbilitiesImpl<>();
abilities2.add(VigilanceAbility.getInstance());
this.addAbilities(LevelerCardBuilder.construct(

View file

@ -28,10 +28,6 @@
package mage.cards.j;
import java.util.UUID;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.Zone;
import mage.MageInt;
import mage.Mana;
import mage.abilities.Abilities;
@ -46,9 +42,14 @@ import mage.abilities.keyword.LevelerCardBuilder;
import mage.abilities.mana.SimpleManaAbility;
import mage.cards.CardSetInfo;
import mage.cards.LevelerCard;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.Zone;
import mage.filter.common.FilterControlledCreaturePermanent;
import mage.filter.predicate.mageobject.SubtypePredicate;
import java.util.UUID;
/**
*
@ -77,13 +78,13 @@ public class JoragaTreespeaker extends LevelerCard {
// LEVEL 1-4
// 1/2
// {T}: Add {G}{G} to your mana pool.
Abilities<Ability> abilities1 = new AbilitiesImpl<Ability>();
Abilities<Ability> abilities1 = new AbilitiesImpl<>();
abilities1.add(new SimpleManaAbility(Zone.BATTLEFIELD, Mana.GreenMana(2), new TapSourceCost()));
// LEVEL 5+
// 1/4
// Elves you control have "{T}: Add {G}{G} to your mana pool."
Abilities<Ability> abilities2 = new AbilitiesImpl<Ability>();
Abilities<Ability> abilities2 = new AbilitiesImpl<>();
abilities2.add(new SimpleStaticAbility(Zone.BATTLEFIELD,
new GainAbilityControlledEffect(new SimpleManaAbility(Zone.BATTLEFIELD, Mana.GreenMana(2), new TapSourceCost()),
Duration.WhileOnBattlefield, filter)));

View file

@ -27,9 +27,6 @@
*/
package mage.cards.k;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.Zone;
import mage.MageInt;
import mage.abilities.Abilities;
import mage.abilities.AbilitiesImpl;
@ -41,6 +38,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 java.util.UUID;
@ -62,10 +62,10 @@ public class KabiraVindicator extends LevelerCard {
this.addAbility(new LevelUpAbility(new ManaCostsImpl("{2}{W}")));
Abilities<Ability> abilities1 = new AbilitiesImpl<Ability>();
Abilities<Ability> abilities1 = new AbilitiesImpl<>();
abilities1.add(new SimpleStaticAbility(Zone.BATTLEFIELD, new BoostControlledEffect(1, 1, Duration.WhileOnBattlefield, new FilterCreaturePermanent(), true)));
Abilities<Ability> abilities2 = new AbilitiesImpl<Ability>();
Abilities<Ability> abilities2 = new AbilitiesImpl<>();
abilities2.add(new SimpleStaticAbility(Zone.BATTLEFIELD, new BoostControlledEffect(2, 2, Duration.WhileOnBattlefield, new FilterCreaturePermanent(), true)));
this.addAbilities(LevelerCardBuilder.construct(

View file

@ -28,9 +28,6 @@
package mage.cards.k;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.Zone;
import mage.MageInt;
import mage.abilities.Abilities;
import mage.abilities.AbilitiesImpl;
@ -44,6 +41,9 @@ import mage.abilities.keyword.LevelerCardBuilder;
import mage.abilities.keyword.TrampleAbility;
import mage.cards.CardSetInfo;
import mage.cards.LevelerCard;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.Zone;
import java.util.UUID;
@ -63,10 +63,10 @@ public class KarganDragonlord extends LevelerCard {
this.addAbility(new LevelUpAbility(new ManaCostsImpl("{R}")));
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(TrampleAbility.getInstance());
abilities2.add(new SimpleActivatedAbility(Zone.BATTLEFIELD, new BoostSourceEffect(1, 0, Duration.EndOfTurn), new ManaCostsImpl("{R}")));

View file

@ -27,8 +27,6 @@
*/
package mage.cards.k;
import mage.constants.CardType;
import mage.constants.Zone;
import mage.MageInt;
import mage.abilities.Abilities;
import mage.abilities.AbilitiesImpl;
@ -41,6 +39,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.game.permanent.token.ElephantToken;
import java.util.UUID;
@ -61,12 +61,12 @@ public class KazanduTuskcaller extends LevelerCard {
this.addAbility(new LevelUpAbility(new ManaCostsImpl("{1}{G}")));
Abilities<Ability> abilities1 = new AbilitiesImpl<Ability>();
Abilities<Ability> abilities1 = new AbilitiesImpl<>();
abilities1.add(new SimpleActivatedAbility(Zone.BATTLEFIELD,
new CreateTokenEffect(new ElephantToken()),
new TapSourceCost()));
Abilities<Ability> abilities2 = new AbilitiesImpl<Ability>();
Abilities<Ability> abilities2 = new AbilitiesImpl<>();
abilities2.add(new SimpleActivatedAbility(Zone.BATTLEFIELD,
new CreateTokenEffect(new ElephantToken(), 2),
new TapSourceCost()));

View file

@ -27,13 +27,13 @@
*/
package mage.cards.k;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.abilities.Ability;
import mage.abilities.dynamicvalue.common.ManacostVariableValue;
import mage.abilities.effects.OneShotEffect;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.filter.common.FilterCreaturePermanent;
import mage.game.Game;
import mage.game.permanent.Permanent;
@ -93,8 +93,8 @@ class KillingWaveEffect extends OneShotEffect {
int amount = (new ManacostVariableValue()).calculate(game, source, this);
if (amount > 0) {
LinkedList<Permanent> sacrifices = new LinkedList<Permanent>();
HashMap<UUID, Integer> lifePaidAmounts = new HashMap<UUID, Integer>();
LinkedList<Permanent> sacrifices = new LinkedList<>();
HashMap<UUID, Integer> lifePaidAmounts = new HashMap<>();
FilterCreaturePermanent filter = new FilterCreaturePermanent();
for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {

View file

@ -27,7 +27,6 @@
*/
package mage.cards.k;
import mage.constants.CardType;
import mage.MageInt;
import mage.abilities.Abilities;
import mage.abilities.AbilitiesImpl;
@ -39,6 +38,7 @@ import mage.abilities.keyword.LevelerCardBuilder;
import mage.abilities.keyword.VigilanceAbility;
import mage.cards.CardSetInfo;
import mage.cards.LevelerCard;
import mage.constants.CardType;
import java.util.UUID;
@ -59,10 +59,10 @@ public class KnightOfCliffhaven extends LevelerCard {
this.addAbility(new LevelUpAbility(new ManaCostsImpl("{3}")));
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(VigilanceAbility.getInstance());

View file

@ -27,9 +27,6 @@
*/
package mage.cards.k;
import java.util.HashMap;
import java.util.Objects;
import java.util.UUID;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.BeginningOfEndStepTriggeredAbility;
@ -50,6 +47,10 @@ import mage.players.PlayerList;
import mage.target.Target;
import mage.target.common.TargetCardInHand;
import java.util.HashMap;
import java.util.Objects;
import java.util.UUID;
/**
*
* @author spjspj
@ -110,7 +111,7 @@ class KynaiosAndTirosEffect extends OneShotEffect {
Player currentPlayer = game.getPlayer(playerList.get());
UUID firstInactivePlayer = null;
Target target = new TargetCardInHand(filter);
HashMap<UUID, Boolean> noLandPlayers = new HashMap<UUID, Boolean>();
HashMap<UUID, Boolean> noLandPlayers = new HashMap<>();
while (controller.canRespond()) {
if (currentPlayer != null && currentPlayer.canRespond() && game.getState().getPlayersInRange(controller.getId(), game).contains(currentPlayer.getId())) {

View file

@ -27,11 +27,6 @@
*/
package mage.cards.l;
import java.util.AbstractMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.SpecialAction;
@ -41,16 +36,14 @@ import mage.abilities.effects.ContinuousRuleModifyingEffectImpl;
import mage.abilities.effects.OneShotEffect;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.Outcome;
import mage.constants.TargetController;
import mage.constants.Zone;
import mage.constants.*;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.game.events.GameEvent.EventType;
import mage.game.permanent.Permanent;
import java.util.*;
/**
*
* @author maurer.it_at_gmail.com, dustinconrad
@ -135,7 +128,7 @@ class LeoninArbiterIgnoreEffect extends OneShotEffect {
Map.Entry<Long, Set<UUID>> turnIgnoringPlayersPair = (Map.Entry<Long, Set<UUID>>) game.getState().getValue(key);
if (turnIgnoringPlayersPair == null || !activationState.equals(turnIgnoringPlayersPair.getKey())) {
turnIgnoringPlayersPair = new AbstractMap.SimpleImmutableEntry<Long, Set<UUID>>(activationState, new HashSet<UUID>());
turnIgnoringPlayersPair = new AbstractMap.SimpleImmutableEntry<>(activationState, new HashSet<>());
game.getState().setValue(key, turnIgnoringPlayersPair);
}

View file

@ -27,10 +27,6 @@
*/
package mage.cards.l;
import java.util.List;
import java.util.UUID;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.MageInt;
import mage.abilities.Abilities;
import mage.abilities.AbilitiesImpl;
@ -42,11 +38,16 @@ 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.Outcome;
import mage.filter.common.FilterCreaturePermanent;
import mage.filter.predicate.permanent.ControllerIdPredicate;
import mage.game.Game;
import mage.game.permanent.Permanent;
import java.util.List;
import java.util.UUID;
/**
*
* @author North
@ -66,11 +67,11 @@ public class LordOfShatterskullPass extends LevelerCard {
this.addAbility(new LevelUpAbility(new ManaCostsImpl("{1}{R}")));
// LEVEL 1-5
// 6/6
Abilities<Ability> abilities1 = new AbilitiesImpl<Ability>();
Abilities<Ability> abilities1 = new AbilitiesImpl<>();
// LEVEL 6+
// 6/6
// Whenever Lord of Shatterskull Pass attacks, it deals 6 damage to each creature defending player controls.
Abilities<Ability> abilities2 = new AbilitiesImpl<Ability>();
Abilities<Ability> abilities2 = new AbilitiesImpl<>();
abilities2.add(new AttacksTriggeredAbility(new LordOfShatterskullPassEffect(), false));
this.addAbilities(LevelerCardBuilder.construct(

View file

@ -27,9 +27,6 @@
*/
package mage.cards.m;
import java.util.HashMap;
import java.util.List;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect;
import mage.cards.CardImpl;
@ -41,6 +38,10 @@ import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.game.permanent.token.SpiritWhiteToken;
import java.util.HashMap;
import java.util.List;
import java.util.UUID;
/**
*
* @author LoneFox
@ -85,7 +86,7 @@ class MarchOfSoulsEffect extends OneShotEffect {
public boolean apply(Game game, Ability source) {
List<Permanent> creatures = game.getBattlefield().getActivePermanents(new FilterCreaturePermanent(),
source.getControllerId(), source.getSourceId(), game);
HashMap<UUID, Integer> playersWithCreatures = new HashMap<UUID, Integer>();
HashMap<UUID, Integer> playersWithCreatures = new HashMap<>();
for(Permanent p : creatures) {
UUID controllerId = p.getControllerId();
if(p.destroy(source.getSourceId(), game, true)) {

View file

@ -28,12 +28,6 @@
package mage.cards.m;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.Zone;
import mage.abilities.Ability;
import mage.abilities.common.EntersBattlefieldTappedAbility;
import mage.abilities.common.SimpleActivatedAbility;
@ -45,6 +39,9 @@ import mage.abilities.effects.common.search.SearchLibraryPutInPlayEffect;
import mage.abilities.mana.ColorlessManaAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.Zone;
import mage.filter.FilterCard;
import mage.filter.predicate.mageobject.SubtypePredicate;
import mage.game.Game;
@ -52,6 +49,10 @@ import mage.game.permanent.Permanent;
import mage.players.Player;
import mage.target.common.TargetCardInLibrary;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
/**
*
* @author LevelX2
@ -111,7 +112,7 @@ class MazesEndEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
List<String> names = new ArrayList<String>();
List<String> names = new ArrayList<>();
for (Permanent permanent : game.getBattlefield().getAllActivePermanents(source.getControllerId())) {
if (permanent.hasSubtype("Gate", game)) {
if (!names.contains(permanent.getName())) {

View file

@ -27,9 +27,6 @@
*/
package mage.cards.m;
import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
import mage.MageInt;
import mage.MageObject;
import mage.abilities.Ability;
@ -57,6 +54,10 @@ import mage.target.TargetPlayer;
import mage.target.TargetSpell;
import mage.util.CardUtil;
import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
/**
*
* @author LevelX2
@ -138,7 +139,7 @@ class MindreaverNamePredicate implements Predicate<MageObject> {
@Override
public boolean apply(MageObject input, Game game) {
Set<String> cardNames = new HashSet<String>();
Set<String> cardNames = new HashSet<>();
UUID exileId = CardUtil.getCardExileZoneId(game, sourceId);
ExileZone exileZone = game.getExile().getExileZone(exileId);
if (exileZone != null) {

View file

@ -27,16 +27,9 @@
*/
package mage.cards.m;
import java.util.HashSet;
import java.util.List;
import java.util.UUID;
import mage.abilities.Ability;
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;
@ -47,6 +40,10 @@ import mage.game.permanent.Permanent;
import mage.players.Player;
import mage.target.TargetCard;
import java.util.HashSet;
import java.util.List;
import java.util.UUID;
/**
*
* @author North
@ -89,7 +86,7 @@ class MitoticManipulationEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
List<Permanent> permanents = game.getBattlefield().getActivePermanents(source.getControllerId(), game);
HashSet<String> permanentNames = new HashSet<String>();
HashSet<String> permanentNames = new HashSet<>();
FilterCard filter = new FilterCard("card to put onto the battlefield");
for (Permanent permanent : permanents) {
permanentNames.add(permanent.getName());

View file

@ -27,9 +27,6 @@
*/
package mage.cards.m;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import mage.ObjectColor;
import mage.abilities.Ability;
import mage.abilities.effects.ContinuousEffect;
@ -48,6 +45,10 @@ import mage.game.permanent.Permanent;
import mage.target.common.TargetCreaturePermanent;
import mage.target.targetpointer.FixedTarget;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
/**
*
* @author wetterlicht
@ -94,7 +95,7 @@ class MurderousSpoilsEffect extends OneShotEffect {
public boolean apply(Game game, Ability source) {
Permanent target = game.getPermanent(source.getFirstTarget());
if (target != null) {
List<Permanent> attachments = new ArrayList<Permanent>();
List<Permanent> attachments = new ArrayList<>();
for (UUID uuid : target.getAttachments()) {
Permanent attached = game.getBattlefield().getPermanent(uuid);
if (attached.getSubtype(game).contains("Equipment")) {

View file

@ -27,10 +27,6 @@
*/
package mage.cards.n;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.TriggeredAbilityImpl;
import mage.abilities.effects.Effect;
@ -47,6 +43,11 @@ import mage.game.events.GameEvent;
import mage.game.events.GameEvent.EventType;
import mage.game.permanent.Permanent;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.UUID;
/**
*
* @author LevelX2
@ -74,7 +75,7 @@ public class NaturesWill extends CardImpl {
class NaturesWillTriggeredAbility extends TriggeredAbilityImpl {
private boolean madeDamge = false;
private Set<UUID> damagedPlayers = new HashSet<UUID>();
private Set<UUID> damagedPlayers = new HashSet<>();
public NaturesWillTriggeredAbility() {
super(Zone.BATTLEFIELD, new NaturesWillEffect(), false);
@ -83,7 +84,7 @@ class NaturesWillTriggeredAbility extends TriggeredAbilityImpl {
public NaturesWillTriggeredAbility(final NaturesWillTriggeredAbility ability) {
super(ability);
this.madeDamge = ability.madeDamge;
this.damagedPlayers = new HashSet<UUID>();
this.damagedPlayers = new HashSet<>();
this.damagedPlayers.addAll(ability.damagedPlayers);
}
@ -109,7 +110,7 @@ class NaturesWillTriggeredAbility extends TriggeredAbilityImpl {
}
if (event.getType().equals(EventType.COMBAT_DAMAGE_STEP_POST)) {
if (madeDamge) {
Set<UUID> damagedPlayersCopy = new HashSet<UUID>();
Set<UUID> damagedPlayersCopy = new HashSet<>();
damagedPlayersCopy.addAll(damagedPlayers);
for(Effect effect: this.getEffects()) {
effect.setValue("damagedPlayers", damagedPlayersCopy);

View file

@ -28,7 +28,6 @@
package mage.cards.n;
import mage.constants.CardType;
import mage.MageInt;
import mage.abilities.Abilities;
import mage.abilities.AbilitiesImpl;
@ -40,6 +39,7 @@ 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;
@ -58,10 +58,10 @@ public class NirkanaCutthroat extends LevelerCard {
this.toughness = new MageInt(2);
this.addAbility(new LevelUpAbility(new ManaCostsImpl("{2}{B}")));
Abilities<Ability> abilities1 = new AbilitiesImpl<Ability>();
Abilities<Ability> abilities1 = new AbilitiesImpl<>();
abilities1.add(DeathtouchAbility.getInstance());
Abilities<Ability> abilities2 = new AbilitiesImpl<Ability>();
Abilities<Ability> abilities2 = new AbilitiesImpl<>();
abilities2.add(FirstStrikeAbility.getInstance());
abilities2.add(DeathtouchAbility.getInstance());

View file

@ -28,7 +28,6 @@
package mage.cards.n;
import mage.constants.CardType;
import mage.MageInt;
import mage.abilities.Abilities;
import mage.abilities.AbilitiesImpl;
@ -40,6 +39,7 @@ 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;
@ -59,9 +59,9 @@ public class NullChampion extends LevelerCard {
this.toughness = new MageInt(1);
this.addAbility(new LevelUpAbility(new ManaCostsImpl("{3}")));
Abilities<Ability> abilities1 = new AbilitiesImpl<Ability>();
Abilities<Ability> abilities1 = new AbilitiesImpl<>();
Abilities<Ability> abilities2 = new AbilitiesImpl<Ability>();
Abilities<Ability> abilities2 = new AbilitiesImpl<>();
abilities2.add(new SimpleActivatedAbility(Zone.BATTLEFIELD, new RegenerateSourceEffect(), new ManaCostsImpl("{B}")));
this.addAbilities(LevelerCardBuilder.construct(

View file

@ -27,9 +27,6 @@
*/
package mage.cards.o;
import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.TriggeredAbilityImpl;
import mage.abilities.common.SimpleActivatedAbility;
@ -50,6 +47,10 @@ import mage.game.events.GameEvent.EventType;
import mage.game.permanent.Permanent;
import mage.target.common.TargetCardInYourGraveyard;
import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
/**
*
* @author fireshoes
@ -82,7 +83,7 @@ public class OngoingInvestigation extends CardImpl {
class OngoingInvestigationTriggeredAbility extends TriggeredAbilityImpl {
private boolean madeDamage = false;
private Set<UUID> damagedPlayers = new HashSet<UUID>();
private Set<UUID> damagedPlayers = new HashSet<>();
public OngoingInvestigationTriggeredAbility() {
super(Zone.BATTLEFIELD, new InvestigateEffect(), false);
@ -91,7 +92,7 @@ class OngoingInvestigationTriggeredAbility extends TriggeredAbilityImpl {
public OngoingInvestigationTriggeredAbility(final OngoingInvestigationTriggeredAbility ability) {
super(ability);
this.madeDamage = ability.madeDamage;
this.damagedPlayers = new HashSet<UUID>();
this.damagedPlayers = new HashSet<>();
this.damagedPlayers.addAll(ability.damagedPlayers);
}
@ -117,7 +118,7 @@ class OngoingInvestigationTriggeredAbility extends TriggeredAbilityImpl {
}
if (event.getType().equals(EventType.COMBAT_DAMAGE_STEP_POST)) {
if (madeDamage) {
Set<UUID> damagedPlayersCopy = new HashSet<UUID>();
Set<UUID> damagedPlayersCopy = new HashSet<>();
damagedPlayersCopy.addAll(damagedPlayers);
for(Effect effect: this.getEffects()) {
effect.setValue("damagedPlayers", damagedPlayersCopy);

View file

@ -141,7 +141,7 @@ public class Outwit extends CardImpl {
@Override
public Set<UUID> possibleTargets(UUID sourceControllerId, Game game) {
Set<UUID> possibleTargets = new HashSet<UUID>();
Set<UUID> possibleTargets = new HashSet<>();
for (StackObject stackObject : game.getStack()) {
if (stackObject instanceof Spell && filter.match((Spell) stackObject, game)) {
if (targetsPlayer(stackObject.getId(), game)) {

View file

@ -27,9 +27,6 @@
*/
package mage.cards.p;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
import mage.MageObject;
import mage.abilities.Ability;
import mage.abilities.common.SimpleActivatedAbility;
@ -37,11 +34,7 @@ import mage.abilities.costs.common.SacrificeSourceCost;
import mage.abilities.costs.common.TapSourceCost;
import mage.abilities.costs.mana.GenericManaCost;
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;
@ -50,6 +43,10 @@ import mage.game.Game;
import mage.players.Player;
import mage.util.CardUtil;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
/**
*
* @author LevelX2
@ -117,11 +114,7 @@ class PyxisOfPandemoniumExileEffect extends OneShotEffect {
if (player.getLibrary().size() > 0) {
Card card = player.getLibrary().getFromTop(game);
String exileKey = playerId.toString() + CardUtil.getExileZoneId(game, source.getSourceId(), source.getSourceObjectZoneChangeCounter()).toString();
UUID exileId = exileIds.get(exileKey);
if (exileId == null) {
exileId = UUID.randomUUID();
exileIds.put(exileKey, exileId);
}
UUID exileId = exileIds.computeIfAbsent(exileKey, k -> UUID.randomUUID());
player.moveCardsToExile(card, source, game, false, exileId, sourceObject.getIdName() + " (" + player.getName() + ')');
card.setFaceDown(true, game);
}

View file

@ -27,9 +27,6 @@
*/
package mage.cards.r;
import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
import mage.MageObject;
import mage.abilities.Ability;
import mage.abilities.effects.common.ExileTargetEffect;
@ -42,6 +39,10 @@ import mage.game.permanent.Permanent;
import mage.target.TargetPermanent;
import mage.watchers.common.PlayerDamagedBySourceWatcher;
import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
/**
* @author LevelX2
*/
@ -89,7 +90,7 @@ class ReciprocateTarget 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<>();
PlayerDamagedBySourceWatcher watcher = (PlayerDamagedBySourceWatcher) game.getState().getWatchers().get("PlayerDamagedBySource", sourceControllerId);
for (UUID targetId : availablePossibleTargets) {
Permanent permanent = game.getPermanent(targetId);

View file

@ -27,9 +27,6 @@
*/
package mage.cards.r;
import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect;
import mage.cards.CardImpl;
@ -41,6 +38,10 @@ import mage.constants.Outcome;
import mage.game.Game;
import mage.players.Player;
import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
/**
*
* @author LevelX2
@ -86,7 +87,7 @@ class ReverseTheSandsEffect extends OneShotEffect {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
Choice lifeChoice = new ChoiceImpl(true);
Set<String> choices = new HashSet<String>();
Set<String> choices = new HashSet<>();
for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
Player player = game.getPlayer(playerId);
if (player != null) {

View file

@ -27,20 +27,23 @@
*/
package mage.cards.s;
import java.util.ArrayList;
import java.util.UUID;
import mage.constants.*;
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.WatcherScope;
import mage.constants.Zone;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.game.events.ZoneChangeEvent;
import mage.watchers.Watcher;
import java.util.ArrayList;
import java.util.UUID;
/**
*
* @author LevelX2
@ -101,7 +104,7 @@ class SecondSunriseEffect extends OneShotEffect {
}
class SecondSunriseWatcher extends Watcher {
ArrayList<UUID> cards = new ArrayList<UUID>();
ArrayList<UUID> cards = new ArrayList<>();
public SecondSunriseWatcher() {
super("SecondSunriseWatcher", WatcherScope.GAME);

View file

@ -27,10 +27,6 @@
*/
package mage.cards.s;
import java.util.Iterator;
import java.util.UUID;
import mage.constants.*;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.LandfallAbility;
@ -38,9 +34,12 @@ import mage.abilities.effects.ContinuousEffectImpl;
import mage.abilities.keyword.DefenderAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.*;
import mage.game.Game;
import mage.game.permanent.Permanent;
import java.util.UUID;
/**
*
* @author jeffwadsworth
@ -95,12 +94,7 @@ class ShoalSerpentEffect extends ContinuousEffectImpl {
switch (layer) {
case AbilityAddingRemovingEffects_6:
if (sublayer == SubLayer.NA) {
for (Iterator<Ability> i = permanent.getAbilities().iterator(); i.hasNext();) {
Ability entry = i.next();
if (entry.getId().equals(DefenderAbility.getInstance().getId())) {
i.remove();
}
}
permanent.getAbilities().removeIf(entry -> entry.getId().equals(DefenderAbility.getInstance().getId()));
}
break;
}

View file

@ -27,7 +27,6 @@
*/
package mage.cards.s;
import mage.constants.CardType;
import mage.MageInt;
import mage.abilities.Abilities;
import mage.abilities.AbilitiesImpl;
@ -38,6 +37,7 @@ 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;
@ -58,10 +58,10 @@ public class SkywatcherAdept extends LevelerCard {
this.addAbility(new LevelUpAbility(new ManaCostsImpl("{3}")));
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());
this.addAbilities(LevelerCardBuilder.construct(

View file

@ -27,10 +27,6 @@
*/
package mage.cards.s;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import mage.constants.CardType;
import mage.abilities.costs.mana.GenericManaCost;
import mage.abilities.dynamicvalue.common.MultikickerCount;
import mage.abilities.effects.common.CounterUnlessPaysEffect;
@ -38,8 +34,13 @@ import mage.abilities.effects.common.DrawCardSourceControllerEffect;
import mage.abilities.keyword.MultikickerAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.target.TargetSpell;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
/**
*
* @author jeffwadsworth
@ -71,7 +72,7 @@ public class SpellContortion extends CardImpl {
@Override
public List<String> getRules() {
List<String> rules = new ArrayList<String>();
List<String> rules = new ArrayList<>();
rules.add("Counter target spell unless its controller pays {2}. Draw a card for each time Spell Contortion was kicked.");
return rules;
}

View file

@ -28,7 +28,6 @@
package mage.cards.s;
import mage.constants.CardType;
import mage.MageInt;
import mage.abilities.Abilities;
import mage.abilities.AbilitiesImpl;
@ -40,6 +39,7 @@ 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;
@ -58,10 +58,10 @@ public class StudentOfWarfare extends LevelerCard {
this.toughness = new MageInt(1);
this.addAbility(new LevelUpAbility(new ManaCostsImpl("{W}")));
Abilities<Ability> abilities1 = new AbilitiesImpl<Ability>();
Abilities<Ability> abilities1 = new AbilitiesImpl<>();
abilities1.add(FirstStrikeAbility.getInstance());
Abilities<Ability> abilities2 = new AbilitiesImpl<Ability>();
Abilities<Ability> abilities2 = new AbilitiesImpl<>();
abilities2.add(DoubleStrikeAbility.getInstance());
this.addAbilities(LevelerCardBuilder.construct(

View file

@ -27,9 +27,6 @@
*/
package mage.cards.t;
import java.util.LinkedList;
import java.util.List;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.dynamicvalue.common.ManacostVariableValue;
import mage.abilities.effects.OneShotEffect;
@ -43,6 +40,10 @@ import mage.game.permanent.Permanent;
import mage.players.Player;
import mage.target.common.TargetOpponent;
import java.util.LinkedList;
import java.util.List;
import java.util.UUID;
/**
*
* @author Styxo
@ -93,7 +94,7 @@ class TheBattleOfYavinEffect extends OneShotEffect {
int amount = (new ManacostVariableValue()).calculate(game, source, this);
if (amount > 0) {
LinkedList<Permanent> sacrifices = new LinkedList<Permanent>();
LinkedList<Permanent> sacrifices = new LinkedList<>();
FilterNonlandPermanent filter = new FilterNonlandPermanent();
List<Permanent> permanents = game.getBattlefield().getAllActivePermanents(filter, opponent.getId(), game);

View file

@ -27,12 +27,6 @@
*/
package mage.cards.t;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.ExileSpellEffect;
@ -50,6 +44,8 @@ import mage.players.Player;
import mage.target.TargetCard;
import mage.target.common.TargetCardInHand;
import java.util.*;
/**
*
* @author LevelX2
@ -98,11 +94,7 @@ class TheGreatAuroraEffect extends OneShotEffect {
Map<UUID, List<Permanent>> permanentsOwned = new HashMap<>();
Collection<Permanent> permanents = game.getBattlefield().getActivePermanents(source.getControllerId(), game);
for (Permanent permanent : permanents) {
List<Permanent> list = permanentsOwned.get(permanent.getOwnerId());
if (list == null) {
list = new ArrayList<>();
permanentsOwned.put(permanent.getOwnerId(), list);
}
List<Permanent> list = permanentsOwned.computeIfAbsent(permanent.getOwnerId(), k -> new ArrayList<>());
list.add(permanent);
}

View file

@ -27,9 +27,6 @@
*/
package mage.cards.t;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect;
import mage.cards.CardImpl;
@ -44,6 +41,10 @@ import mage.players.Player;
import mage.target.Target;
import mage.target.common.TargetLandPermanent;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
/**
*
* @author LevelX2
@ -93,7 +94,7 @@ class ThoughtsOfRuinEffect extends OneShotEffect {
if (controller != null) {
int amount = controller.getHand().size();
if (amount > 0) {
List<Permanent> permanentsToSacrifice = new ArrayList<Permanent>();
List<Permanent> permanentsToSacrifice = new ArrayList<>();
// select all lands to sacrifice
for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
Player player = game.getPlayer(playerId);

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