program towards Interface rather than implementations

This commit is contained in:
Ingmar Goudt 2020-02-10 10:39:56 +01:00
parent b04c436801
commit ae7919cd07
100 changed files with 218 additions and 209 deletions

View file

@ -1241,7 +1241,7 @@ public class DragCardGrid extends JPanel implements DragCardSource, DragCardTarg
if (button.isSelected()) { if (button.isSelected()) {
// Special case - "Multiples" (CONSPIRACY type) // Special case - "Multiples" (CONSPIRACY type)
if (cardType == CardType.CONSPIRACY) { if (cardType == CardType.CONSPIRACY) {
HashMap<String, CardView> cardNames = new HashMap<>(); Map<String, CardView> cardNames = new HashMap<>();
for (List<List<CardView>> gridRow : cardGrid) { for (List<List<CardView>> gridRow : cardGrid) {
for (List<CardView> stack : gridRow) { for (List<CardView> stack : gridRow) {
@ -1334,11 +1334,11 @@ public class DragCardGrid extends JPanel implements DragCardSource, DragCardTarg
private static final Pattern pattern = Pattern.compile(".*Add(.*)(\\{[WUBRGXC]\\})"); private static final Pattern pattern = Pattern.compile(".*Add(.*)(\\{[WUBRGXC]\\})");
public void analyseDeck() { public void analyseDeck() {
HashMap<String, Integer> qtys = new HashMap<>(); Map<String, Integer> qtys = new HashMap<>();
HashMap<String, Integer> pips = new HashMap<>(); Map<String, Integer> pips = new HashMap<>();
HashMap<String, Integer> pips_at_cmcs = new HashMap<>(); Map<String, Integer> pips_at_cmcs = new HashMap<>();
HashMap<String, Integer> sourcePips = new HashMap<>(); Map<String, Integer> sourcePips = new HashMap<>();
HashMap<String, Integer> manaCounts = new HashMap<>(); Map<String, Integer> manaCounts = new HashMap<>();
pips.put("#w}", 0); pips.put("#w}", 0);
pips.put("#u}", 0); pips.put("#u}", 0);
pips.put("#b}", 0); pips.put("#b}", 0);
@ -1651,7 +1651,7 @@ public class DragCardGrid extends JPanel implements DragCardSource, DragCardTarg
int thisMaxStackSize = 0; int thisMaxStackSize = 0;
cardGrid.add(gridRow); cardGrid.add(gridRow);
for (List<DeckCardInfo> stack : row) { for (List<DeckCardInfo> stack : row) {
ArrayList<CardView> gridStack = new ArrayList<>(); List<CardView> gridStack = new ArrayList<>();
gridRow.add(gridStack); gridRow.add(gridStack);
for (DeckCardInfo info : stack) { for (DeckCardInfo info : stack) {
if (trackedCards.containsKey(info.getSetCode()) && trackedCards.get(info.getSetCode()).containsKey(info.getCardNum())) { if (trackedCards.containsKey(info.getSetCode()) && trackedCards.get(info.getSetCode()).containsKey(info.getCardNum())) {

View file

@ -43,7 +43,7 @@ public class ManaBarChart extends JComponent {
void drawBar(Graphics2D g, Rectangle area) { void drawBar(Graphics2D g, Rectangle area) {
Pattern regex = Pattern.compile("^([0-9]+)##(.)}"); Pattern regex = Pattern.compile("^([0-9]+)##(.)}");
HashMap<Integer, Integer> totals_at_cmcs = new HashMap<Integer, Integer>(); Map<Integer, Integer> totals_at_cmcs = new HashMap<Integer, Integer>();
int max_num_pips = 0; int max_num_pips = 0;
int max_cmc = 0; int max_cmc = 0;
@ -112,7 +112,7 @@ public class ManaBarChart extends JComponent {
} }
HashMap<Integer, Integer> running_totals_at_cmcs = new HashMap<Integer, Integer>(); Map<Integer, Integer> running_totals_at_cmcs = new HashMap<Integer, Integer>();
for (String key : pips_at_cmcs.keySet()) { for (String key : pips_at_cmcs.keySet()) {
Matcher regexMatcher = regex.matcher(key); Matcher regexMatcher = regex.matcher(key);
int num_pips = pips_at_cmcs.get(key); int num_pips = pips_at_cmcs.get(key);

View file

@ -38,6 +38,7 @@ import javax.swing.table.DefaultTableCellRenderer;
import java.awt.*; import java.awt.*;
import java.awt.event.*; import java.awt.event.*;
import java.util.*; import java.util.*;
import java.util.List;
import java.util.Map.Entry; import java.util.Map.Entry;
import static mage.client.dialog.PreferencesDialog.*; import static mage.client.dialog.PreferencesDialog.*;
@ -228,7 +229,7 @@ public class CardSelector extends javax.swing.JPanel implements ComponentListene
filter.add(new CardTextPredicate(name, chkNames.isSelected(), chkTypes.isSelected(), chkRules.isSelected(), chkUnique.isSelected())); filter.add(new CardTextPredicate(name, chkNames.isSelected(), chkTypes.isSelected(), chkRules.isSelected(), chkUnique.isSelected()));
if (limited) { if (limited) {
ArrayList<Predicate<MageObject>> predicates = new ArrayList<>(); List<Predicate<MageObject>> predicates = new ArrayList<>();
if (this.tbGreen.isSelected()) { if (this.tbGreen.isSelected()) {
predicates.add(new ColorPredicate(ObjectColor.GREEN)); predicates.add(new ColorPredicate(ObjectColor.GREEN));
@ -277,7 +278,7 @@ public class CardSelector extends javax.swing.JPanel implements ComponentListene
if (this.cbExpansionSet.isVisible()) { if (this.cbExpansionSet.isVisible()) {
String expansionSelection = this.cbExpansionSet.getSelectedItem().toString(); String expansionSelection = this.cbExpansionSet.getSelectedItem().toString();
if (!expansionSelection.equals("- All Sets")) { if (!expansionSelection.equals("- All Sets")) {
ArrayList<Predicate<Card>> expansionPredicates = new ArrayList<>(); List<Predicate<Card>> expansionPredicates = new ArrayList<>();
for (String setCode : ConstructedFormats.getSetsByFormat(expansionSelection)) { for (String setCode : ConstructedFormats.getSetsByFormat(expansionSelection)) {
expansionPredicates.add(new ExpansionSetPredicate(setCode)); expansionPredicates.add(new ExpansionSetPredicate(setCode));
} }

View file

@ -541,8 +541,8 @@ public class MageBook extends JComponent {
} }
private List<Token> getTokens(int page, String set) { private List<Token> getTokens(int page, String set) {
ArrayList<CardDownloadData> allTokens = getTokenCardUrls(); List<CardDownloadData> allTokens = getTokenCardUrls();
ArrayList<Token> tokens = new ArrayList<>(); List<Token> tokens = new ArrayList<>();
for (CardDownloadData token : allTokens) { for (CardDownloadData token : allTokens) {
if (token.getSet().equals(set)) { if (token.getSet().equals(set)) {
@ -715,7 +715,7 @@ public class MageBook extends JComponent {
} }
private int getTotalNumTokens(String set) { private int getTotalNumTokens(String set) {
ArrayList<CardDownloadData> allTokens = getTokenCardUrls(); List<CardDownloadData> allTokens = getTokenCardUrls();
int numTokens = 0; int numTokens = 0;
for (CardDownloadData token : allTokens) { for (CardDownloadData token : allTokens) {
@ -732,7 +732,7 @@ public class MageBook extends JComponent {
} }
private int getTotalNumEmblems(String set) { private int getTotalNumEmblems(String set) {
ArrayList<CardDownloadData> allEmblems = getTokenCardUrls(); List<CardDownloadData> allEmblems = getTokenCardUrls();
int numEmblems = 0; int numEmblems = 0;
for (CardDownloadData emblem : allEmblems) { for (CardDownloadData emblem : allEmblems) {
@ -749,7 +749,7 @@ public class MageBook extends JComponent {
} }
private int getTotalNumPlanes(String set) { private int getTotalNumPlanes(String set) {
ArrayList<CardDownloadData> allPlanes = getTokenCardUrls(); List<CardDownloadData> allPlanes = getTokenCardUrls();
int numPlanes = 0; int numPlanes = 0;
for (CardDownloadData plane : allPlanes) { for (CardDownloadData plane : allPlanes) {

View file

@ -3,6 +3,7 @@ package mage.client.dialog;
import java.awt.*; import java.awt.*;
import java.io.File; import java.io.File;
import java.util.*; import java.util.*;
import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import javax.swing.*; import javax.swing.*;
import mage.cards.decks.Deck; import mage.cards.decks.Deck;
@ -951,7 +952,7 @@ public class NewTournamentDialog extends MageDialog {
private void loadRandomPacks(int version) { private void loadRandomPacks(int version) {
String versionStr = prepareVersionStr(version, false); String versionStr = prepareVersionStr(version, false);
ArrayList<String> packList; List<String> packList;
String packNames; String packNames;
String randomPrefs = PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TOURNAMENT_PACKS_RANDOM_DRAFT + versionStr, ""); String randomPrefs = PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TOURNAMENT_PACKS_RANDOM_DRAFT + versionStr, "");
if (!randomPrefs.isEmpty()) { if (!randomPrefs.isEmpty()) {
@ -1219,7 +1220,7 @@ public class NewTournamentDialog extends MageDialog {
this.isRandom = tournamentType.isRandom(); this.isRandom = tournamentType.isRandom();
this.isRichMan = tournamentType.isRichMan(); this.isRichMan = tournamentType.isRichMan();
tOptions.getLimitedOptions().getSetCodes().clear(); tOptions.getLimitedOptions().getSetCodes().clear();
ArrayList<String> selected = randomPackSelector.getSelectedPacks(); List<String> selected = randomPackSelector.getSelectedPacks();
Collections.shuffle(selected); Collections.shuffle(selected);
int maxPacks = 3 * (players.size() + 1); int maxPacks = 3 * (players.size() + 1);
if (tournamentType.isRichMan()) { if (tournamentType.isRichMan()) {

View file

@ -10,6 +10,7 @@ import javax.swing.event.DocumentListener;
import java.awt.*; import java.awt.*;
import java.awt.event.*; import java.awt.event.*;
import java.util.*; import java.util.*;
import java.util.List;
/** /**
* @author JayDi85 * @author JayDi85
@ -19,7 +20,7 @@ import java.util.*;
public class PickCheckBoxDialog extends MageDialog { public class PickCheckBoxDialog extends MageDialog {
Choice choice; Choice choice;
ArrayList<KeyValueItem> allItems = new ArrayList<>(); List<KeyValueItem> allItems = new ArrayList<>();
DefaultListModel<KeyValueItem> dataModel = new DefaultListModel(); DefaultListModel<KeyValueItem> dataModel = new DefaultListModel();
CheckBoxList.CheckBoxListModel m_dataModel; CheckBoxList.CheckBoxListModel m_dataModel;

View file

@ -10,6 +10,7 @@ import javax.swing.event.DocumentListener;
import java.awt.*; import java.awt.*;
import java.awt.event.*; import java.awt.event.*;
import java.util.*; import java.util.*;
import java.util.List;
/** /**
* @author JayDi85 * @author JayDi85
@ -18,8 +19,8 @@ import java.util.*;
public class PickChoiceDialog extends MageDialog { public class PickChoiceDialog extends MageDialog {
Choice choice; Choice choice;
ArrayList<KeyValueItem> allItems = new ArrayList<>(); List<KeyValueItem> allItems = new ArrayList<>();
DefaultListModel<KeyValueItem> dataModel = new DefaultListModel(); DefaultListModel<KeyValueItem> dataModel = new DefaultListModel<>();
final private static String HTML_TEMPLATE = "<html><div style='text-align: center;'>%s</div></html>"; final private static String HTML_TEMPLATE = "<html><div style='text-align: center;'>%s</div></html>";

View file

@ -7,6 +7,7 @@ package mage.client.dialog;
import java.awt.Component; import java.awt.Component;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List;
import javax.swing.JCheckBox; import javax.swing.JCheckBox;
import javax.swing.JOptionPane; import javax.swing.JOptionPane;
import mage.cards.repository.ExpansionInfo; import mage.cards.repository.ExpansionInfo;
@ -58,7 +59,7 @@ public class RandomPacksSelectorDialog extends javax.swing.JDialog {
this.setModal(true); this.setModal(true);
} }
public void setSelectedPacks(ArrayList<String> packs) { public void setSelectedPacks(List<String> packs) {
if (!boxesCreated) { if (!boxesCreated) {
createCheckboxes(); createCheckboxes();
} }
@ -72,8 +73,8 @@ public class RandomPacksSelectorDialog extends javax.swing.JDialog {
} }
} }
public ArrayList<String> getSelectedPacks() { public List<String> getSelectedPacks() {
ArrayList<String> returnVal = new ArrayList<>(); List<String> returnVal = new ArrayList<>();
for (Component pack : pnlPacks.getComponents()) { for (Component pack : pnlPacks.getComponents()) {
JCheckBox thePack = (JCheckBox) pack; JCheckBox thePack = (JCheckBox) pack;
if (thePack.isSelected()) { if (thePack.isSelected()) {

View file

@ -202,7 +202,7 @@ public class TestCardRenderDialog extends MageDialog {
Player playerOpponent = new StubPlayer("player2", RangeOfInfluence.ALL); Player playerOpponent = new StubPlayer("player2", RangeOfInfluence.ALL);
game.addPlayer(playerOpponent, deck); game.addPlayer(playerOpponent, deck);
ArrayList<CardView> cardViews = new ArrayList<>(); java.util.List<CardView> cardViews = new ArrayList<>();
///* ///*
cardViews.add(createPermanentCard(game, playerYou.getId(), "RNA", "263", 0, 0, 0, false)); // mountain cardViews.add(createPermanentCard(game, playerYou.getId(), "RNA", "263", 0, 0, 0, false)); // mountain
cardViews.add(createPermanentCard(game, playerYou.getId(), "RNA", "185", 0, 0, 0, true)); // Judith, the Scourge Diva cardViews.add(createPermanentCard(game, playerYou.getId(), "RNA", "185", 0, 0, 0, true)); // Judith, the Scourge Diva

View file

@ -308,7 +308,7 @@ public class HelperPanel extends JPanel {
this.buttonGrid.setLayout(new FlowLayout(FlowLayout.CENTER, BUTTONS_H_GAP, 0)); this.buttonGrid.setLayout(new FlowLayout(FlowLayout.CENTER, BUTTONS_H_GAP, 0));
this.buttonGrid.setPreferredSize(null); this.buttonGrid.setPreferredSize(null);
ArrayList<JButton> buttons = new ArrayList<>(); java.util.List<JButton> buttons = new ArrayList<>();
if (this.btnSpecial.isVisible()) { if (this.btnSpecial.isVisible()) {
buttons.add(this.btnSpecial); buttons.add(this.btnSpecial);
} }

View file

@ -1,6 +1,7 @@
package mage.client.util; package mage.client.util;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List;
/** /**
* @author JayDi85 * @author JayDi85
@ -41,7 +42,7 @@ public enum CardLanguage {
} }
public static String[] toList() { public static String[] toList() {
ArrayList<String> res = new ArrayList<>(); List<String> res = new ArrayList<>();
for (CardLanguage l : values()) { for (CardLanguage l : values()) {
res.add(l.toString()); res.add(l.toString());
} }

View file

@ -190,7 +190,7 @@ public final class GuiDisplayUtil {
// counters // counters
if (card.getMageObjectType().canHaveCounters()) { if (card.getMageObjectType().canHaveCounters()) {
ArrayList<CounterView> counters = new ArrayList<>(); java.util.List<CounterView> counters = new ArrayList<>();
if (card instanceof PermanentView) { if (card instanceof PermanentView) {
if (card.getCounters() != null) { if (card.getCounters() != null) {
counters = new ArrayList<>(card.getCounters()); counters = new ArrayList<>(card.getCounters());

View file

@ -132,7 +132,7 @@ public abstract class CardRenderer {
} }
} }
protected void parseRules(List<String> stringRules, ArrayList<TextboxRule> keywords, ArrayList<TextboxRule> rules) { protected void parseRules(List<String> stringRules, List<TextboxRule> keywords, List<TextboxRule> rules) {
// Translate the textbox text and remove card hints // Translate the textbox text and remove card hints
for (String rule : stringRules) { for (String rule : stringRules) {
// remove all card hints // remove all card hints

View file

@ -1170,7 +1170,7 @@ public class ModernCardRenderer extends CardRenderer {
return layout; return layout;
} }
protected void drawRulesText(Graphics2D g, ArrayList<TextboxRule> keywords, ArrayList<TextboxRule> rules, int x, int y, int w, int h, boolean forceRules) { protected void drawRulesText(Graphics2D g, List<TextboxRule> keywords, List<TextboxRule> rules, int x, int y, int w, int h, boolean forceRules) {
// Gather all rules to render // Gather all rules to render
List<TextboxRule> allRules = new ArrayList<>(rules); List<TextboxRule> allRules = new ArrayList<>(rules);
@ -1271,7 +1271,7 @@ public class ModernCardRenderer extends CardRenderer {
} }
// Get the first line of the textbox, the keyword string // Get the first line of the textbox, the keyword string
private static String getKeywordRulesString(ArrayList<TextboxRule> keywords) { private static String getKeywordRulesString(List<TextboxRule> keywords) {
StringBuilder builder = new StringBuilder(); StringBuilder builder = new StringBuilder();
for (int i = 0; i < keywords.size(); ++i) { for (int i = 0; i < keywords.size(); ++i) {
builder.append(keywords.get(i).text); builder.append(keywords.get(i).text);

View file

@ -25,8 +25,8 @@ public class ModernSplitCardRenderer extends ModernCardRenderer {
String typeLineString; String typeLineString;
String manaCostString; String manaCostString;
ObjectColor color; ObjectColor color;
ArrayList<TextboxRule> rules = new ArrayList<>(); List<TextboxRule> rules = new ArrayList<>();
ArrayList<TextboxRule> keywords = new ArrayList<>(); List<TextboxRule> keywords = new ArrayList<>();
} }
private static ArrayList<CardType> ONLY_LAND_TYPE = new ArrayList<CardType>() { private static ArrayList<CardType> ONLY_LAND_TYPE = new ArrayList<CardType>() {

View file

@ -1,6 +1,7 @@
package org.mage.card.arcane; package org.mage.card.arcane;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List;
/** /**
* Created by stravant@gmail.com on 2016-09-14. * Created by stravant@gmail.com on 2016-09-14.
@ -8,7 +9,7 @@ import java.util.ArrayList;
public class TextboxBasicManaRule extends TextboxRule { public class TextboxBasicManaRule extends TextboxRule {
private final String basicManaSymbol; private final String basicManaSymbol;
public TextboxBasicManaRule(String rule, ArrayList<AttributeRegion> regions, String basicManaSymbol) { public TextboxBasicManaRule(String rule, List<AttributeRegion> regions, String basicManaSymbol) {
super(rule, regions, TextboxRuleType.BASIC_MANA); super(rule, regions, TextboxRuleType.BASIC_MANA);
this.basicManaSymbol = basicManaSymbol; this.basicManaSymbol = basicManaSymbol;

View file

@ -30,7 +30,7 @@ public final class TextboxRuleParser {
// the textbox of a card. // the textbox of a card.
public static TextboxRule parse(CardView source, String rule) { public static TextboxRule parse(CardView source, String rule) {
// List of regions to apply // List of regions to apply
ArrayList<TextboxRule.AttributeRegion> regions = new ArrayList<>(); java.util.List<TextboxRule.AttributeRegion> regions = new ArrayList<>();
// Leveler / loyalty / basic // Leveler / loyalty / basic
boolean isLeveler = false; boolean isLeveler = false;

View file

@ -7,6 +7,7 @@ import org.mage.plugins.card.images.CardDownloadData;
import java.io.IOException; import java.io.IOException;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map;
/** /**
* @author spjspj * @author spjspj
@ -69,9 +70,9 @@ public enum AltMtgOnlTokensImageSource implements CardImageSource {
return null; return null;
} }
HashMap<String, String> copyUrlToImage = null; Map<String, String> copyUrlToImage = null;
HashMap<String, String> copyImageToUrl = null; Map<String, String> copyImageToUrl = null;
HashMap<String, Integer> copyUrlToImageDone = null; Map<String, Integer> copyUrlToImageDone = null;
private void setupLinks() { private void setupLinks() {
if (copyUrlToImage != null) { if (copyUrlToImage != null) {

View file

@ -4,6 +4,8 @@ package org.mage.plugins.card.dl.sources;
import java.io.File; import java.io.File;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Iterator; import java.util.Iterator;
import java.util.List;
import org.mage.plugins.card.dl.DownloadJob; import org.mage.plugins.card.dl.DownloadJob;
import static org.mage.plugins.card.dl.DownloadJob.fromURL; import static org.mage.plugins.card.dl.DownloadJob.fromURL;
import static org.mage.plugins.card.dl.DownloadJob.toFile; import static org.mage.plugins.card.dl.DownloadJob.toFile;
@ -40,7 +42,7 @@ public class CardFrames implements Iterable<DownloadJob> {
@Override @Override
public Iterator<DownloadJob> iterator() { public Iterator<DownloadJob> iterator() {
ArrayList<DownloadJob> jobs = new ArrayList<>(); List<DownloadJob> jobs = new ArrayList<>();
for (String texture : TEXTURES) { for (String texture : TEXTURES) {
jobs.add(generateDownloadJob(TEXTURES_FOLDER, texture)); jobs.add(generateDownloadJob(TEXTURES_FOLDER, texture));
} }

View file

@ -49,7 +49,7 @@ public interface CardImageSource {
void doPause(String httpImageUrl); void doPause(String httpImageUrl);
default ArrayList<String> getSupportedSets() { default List<String> getSupportedSets() {
return new ArrayList<>(); return new ArrayList<>();
} }

View file

@ -23,10 +23,10 @@ public enum CopyPasteImageSource implements CardImageSource {
private Set<String> supportedSets = new LinkedHashSet<String>(); private Set<String> supportedSets = new LinkedHashSet<String>();
private Set<String> missingCards = new LinkedHashSet<String>(); private Set<String> missingCards = new LinkedHashSet<String>();
HashMap<String, String> singleLinks = null; Map<String, String> singleLinks = null;
boolean loadedFromDialog = false; boolean loadedFromDialog = false;
boolean viewMissingCards = true; boolean viewMissingCards = true;
HashMap<String, Integer> singleLinksDone = null; Map<String, Integer> singleLinksDone = null;
private static int maxTimes = 2; private static int maxTimes = 2;
@Override @Override
@ -225,13 +225,11 @@ public enum CopyPasteImageSource implements CardImageSource {
} }
@Override @Override
public ArrayList<String> getSupportedSets() { public List<String> getSupportedSets() {
setupLinks(); setupLinks();
ArrayList<String> supportedSetsCopy = new ArrayList<>(); List<String> supportedSetsCopy = new ArrayList<>();
if (supportedSets.isEmpty()) { if (supportedSets.isEmpty()) {
for (String setCode : Sets.getInstance().keySet()) { supportedSets.addAll(Sets.getInstance().keySet());
supportedSets.add(setCode);
}
} }
supportedSetsCopy.addAll(supportedSets); supportedSetsCopy.addAll(supportedSets);

View file

@ -10,10 +10,7 @@ import mage.client.constants.Constants;
import org.mage.plugins.card.dl.DownloadJob; import org.mage.plugins.card.dl.DownloadJob;
import java.io.File; import java.io.File;
import java.util.ArrayList; import java.util.*;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.Map;
import static org.mage.plugins.card.dl.DownloadJob.fromURL; import static org.mage.plugins.card.dl.DownloadJob.fromURL;
import static org.mage.plugins.card.dl.DownloadJob.toFile; import static org.mage.plugins.card.dl.DownloadJob.toFile;
@ -48,7 +45,7 @@ public class DirectLinksForDownload implements Iterable<DownloadJob> {
@Override @Override
public Iterator<DownloadJob> iterator() { public Iterator<DownloadJob> iterator() {
ArrayList<DownloadJob> jobs = new ArrayList<>(); List<DownloadJob> jobs = new ArrayList<>();
for (Map.Entry<String, String> url : directLinks.entrySet()) { for (Map.Entry<String, String> url : directLinks.entrySet()) {
File dst = new File(outDir, url.getKey()); File dst = new File(outDir, url.getKey());

View file

@ -1,11 +1,7 @@
package org.mage.plugins.card.dl.sources; package org.mage.plugins.card.dl.sources;
import java.io.File; import java.io.File;
import java.util.ArrayList; import java.util.*;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import mage.cards.ExpansionSet; import mage.cards.ExpansionSet;
import mage.cards.Sets; import mage.cards.Sets;
@ -286,7 +282,7 @@ public class GathererSets implements Iterable<DownloadJob> {
c.setTime(new Date()); c.setTime(new Date());
c.add(Calendar.DATE, DAYS_BEFORE_RELEASE_TO_DOWNLOAD); c.add(Calendar.DATE, DAYS_BEFORE_RELEASE_TO_DOWNLOAD);
Date compareDate = c.getTime(); Date compareDate = c.getTime();
ArrayList<DownloadJob> jobs = new ArrayList<>(); List<DownloadJob> jobs = new ArrayList<>();
boolean canDownload; boolean canDownload;
setsToDownload.clear(); setsToDownload.clear();

View file

@ -69,7 +69,7 @@ public enum GrabbagImageSource implements CardImageSource {
return null; return null;
} }
HashMap<String, String> singleLinks = null; Map<String, String> singleLinks = null;
private void setupLinks() { private void setupLinks() {
if (singleLinks != null) { if (singleLinks != null) {
@ -485,10 +485,8 @@ public enum GrabbagImageSource implements CardImageSource {
} }
@Override @Override
public ArrayList<String> getSupportedSets() { public List<String> getSupportedSets() {
ArrayList<String> supportedSetsCopy = new ArrayList<>(); return new ArrayList<>(supportedSets);
supportedSetsCopy.addAll(supportedSets);
return supportedSetsCopy;
} }
@Override @Override

View file

@ -289,9 +289,7 @@ public enum MagidexImageSource implements CardImageSource {
} }
@Override @Override
public ArrayList<String> getSupportedSets() { public List<String> getSupportedSets() {
ArrayList<String> supportedSetsCopy = new ArrayList<>(); return new ArrayList<>(supportedSets);
supportedSetsCopy.addAll(supportedSets);
return supportedSetsCopy;
} }
} }

View file

@ -7,6 +7,7 @@ import org.mage.plugins.card.images.CardDownloadData;
import java.io.IOException; import java.io.IOException;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map;
/** /**
* @author spjspj * @author spjspj
@ -69,9 +70,9 @@ public enum MtgOnlTokensImageSource implements CardImageSource {
return null; return null;
} }
HashMap<String, String> copyUrlToImage = null; Map<String, String> copyUrlToImage = null;
HashMap<String, String> copyImageToUrl = null; Map<String, String> copyImageToUrl = null;
HashMap<String, Integer> copyUrlToImageDone = null; Map<String, Integer> copyUrlToImageDone = null;
private void setupLinks() { private void setupLinks() {
if (copyUrlToImage != null) { if (copyUrlToImage != null) {

View file

@ -259,7 +259,7 @@ public enum MythicspoilerComSource implements CardImageSource {
cardNameAliases.put("RIX-tetzimocdeathprimordial", "tetzimocprimaldeath"); cardNameAliases.put("RIX-tetzimocdeathprimordial", "tetzimocprimaldeath");
// <card name, card link> // <card name, card link>
manualLinks = new HashMap<>(); manualLinks = new HashMap<>();
HashMap<String, String> links = new HashMap<>(); Map<String, String> links = new HashMap<>();
links.put("templeofaclazotz", "templeofaclazotz"); links.put("templeofaclazotz", "templeofaclazotz");
links.put("conquerorsfoothold", "conquerorsfoothold"); links.put("conquerorsfoothold", "conquerorsfoothold");
links.put("primalwellspring", "primalwellspring"); links.put("primalwellspring", "primalwellspring");
@ -272,7 +272,7 @@ public enum MythicspoilerComSource implements CardImageSource {
links.put("spitfirebastion", "spitfirebastion"); links.put("spitfirebastion", "spitfirebastion");
manualLinks.put("XLN", links); manualLinks.put("XLN", links);
HashMap<String, String> linksRix = new HashMap<>(); Map<String, String> linksRix = new HashMap<>();
linksRix.put("vaultofcatlacan", "vaultofcatlacan"); linksRix.put("vaultofcatlacan", "vaultofcatlacan");
linksRix.put("atzalcaveofeternity", "atzalcaveofeternity"); linksRix.put("atzalcaveofeternity", "atzalcaveofeternity");
linksRix.put("wingedtempleoforazca", "wingedtempleoforazca"); linksRix.put("wingedtempleoforazca", "wingedtempleoforazca");
@ -283,7 +283,7 @@ public enum MythicspoilerComSource implements CardImageSource {
manualLinks.put("RIX", linksRix); manualLinks.put("RIX", linksRix);
cardNameAliasesStart = new HashMap<>(); cardNameAliasesStart = new HashMap<>();
HashSet<String> names = new HashSet<>(); Set<String> names = new HashSet<>();
names.add("eldrazidevastator.jpg"); names.add("eldrazidevastator.jpg");
cardNameAliasesStart.put("BFZ", names); cardNameAliasesStart.put("BFZ", names);
} }
@ -450,10 +450,8 @@ public enum MythicspoilerComSource implements CardImageSource {
} }
@Override @Override
public ArrayList<String> getSupportedSets() { public List<String> getSupportedSets() {
ArrayList<String> supportedSetsCopy = new ArrayList<>(); return new ArrayList<>(supportedSets);
supportedSetsCopy.addAll(supportedSets);
return supportedSetsCopy;
} }
} }

View file

@ -309,11 +309,10 @@ public enum ScryfallImageSource implements CardImageSource {
} }
@Override @Override
public ArrayList<String> getSupportedSets() { public List<String> getSupportedSets() {
ArrayList<String> supportedSetsCopy = new ArrayList<>();
// cards // cards
supportedSetsCopy.addAll(ScryfallImageSupportCards.getSupportedSets()); List<String> supportedSetsCopy = new ArrayList<>(ScryfallImageSupportCards.getSupportedSets());
// tokens // tokens
for (String code : ScryfallImageSupportTokens.getSupportedSets().keySet()) { for (String code : ScryfallImageSupportTokens.getSupportedSets().keySet()) {

View file

@ -52,7 +52,7 @@ public class ScryfallSymbolsSource implements Iterable<DownloadJob> {
@Override @Override
public Iterator<DownloadJob> iterator() { public Iterator<DownloadJob> iterator() {
ArrayList<DownloadJob> jobs = new ArrayList<>(); List<DownloadJob> jobs = new ArrayList<>();
// all symbols on one page // all symbols on one page
jobs.add(generateDownloadJob()); jobs.add(generateDownloadJob());

View file

@ -151,10 +151,8 @@ public enum TokensMtgImageSource implements CardImageSource {
} }
@Override @Override
public ArrayList<String> getSupportedSets() { public List<String> getSupportedSets() {
ArrayList<String> supportedSetsCopy = new ArrayList<>(); return new ArrayList<>(supportedSets);
supportedSetsCopy.addAll(supportedSets);
return supportedSetsCopy;
} }
@Override @Override

View file

@ -625,7 +625,7 @@ public enum WizardCardsImageSource implements CardImageSource {
} }
String languageName = languageAliases.get(preferredLanguage); String languageName = languageAliases.get(preferredLanguage);
HashMap<String, Integer> localizedLanguageIds = getlocalizedMultiverseIds(multiverseId); Map<String, Integer> localizedLanguageIds = getlocalizedMultiverseIds(multiverseId);
if (localizedLanguageIds.containsKey(languageName)) { if (localizedLanguageIds.containsKey(languageName)) {
return localizedLanguageIds.get(languageName); return localizedLanguageIds.get(languageName);
} else { } else {
@ -633,11 +633,11 @@ public enum WizardCardsImageSource implements CardImageSource {
} }
} }
private HashMap<String, Integer> getlocalizedMultiverseIds(Integer englishMultiverseId) throws IOException { private Map<String, Integer> getlocalizedMultiverseIds(Integer englishMultiverseId) throws IOException {
String cardLanguagesUrl = "https://gatherer.wizards.com/Pages/Card/Languages.aspx?multiverseid=" + englishMultiverseId; String cardLanguagesUrl = "https://gatherer.wizards.com/Pages/Card/Languages.aspx?multiverseid=" + englishMultiverseId;
Document cardLanguagesDoc = CardImageUtils.downloadHtmlDocument(cardLanguagesUrl); Document cardLanguagesDoc = CardImageUtils.downloadHtmlDocument(cardLanguagesUrl);
Elements languageTableRows = cardLanguagesDoc.select("tr.cardItem"); Elements languageTableRows = cardLanguagesDoc.select("tr.cardItem");
HashMap<String, Integer> localizedIds = new HashMap<>(); Map<String, Integer> localizedIds = new HashMap<>();
if (!languageTableRows.isEmpty()) { if (!languageTableRows.isEmpty()) {
for (Element languageTableRow : languageTableRows) { for (Element languageTableRow : languageTableRows) {
Elements languageTableColumns = languageTableRow.select("td"); Elements languageTableColumns = languageTableRow.select("td");
@ -714,10 +714,8 @@ public enum WizardCardsImageSource implements CardImageSource {
} }
@Override @Override
public ArrayList<String> getSupportedSets() { public List<String> getSupportedSets() {
ArrayList<String> supportedSetsCopy = new ArrayList<>(); return new ArrayList<>(supportedSets);
supportedSetsCopy.addAll(supportedSets);
return supportedSetsCopy;
} }
} }

View file

@ -277,7 +277,7 @@ public class DownloadPicturesService extends DefaultBoundedRangeModel implements
private Object[] getSetsForCurrentImageSource() { private Object[] getSetsForCurrentImageSource() {
// Set the available sets to the combo box // Set the available sets to the combo box
ArrayList<String> supportedSets = selectedSource.getSupportedSets(); List<String> supportedSets = selectedSource.getSupportedSets();
List<String> setNames = new ArrayList<>(); List<String> setNames = new ArrayList<>();
// multiple sets selection // multiple sets selection
@ -490,8 +490,8 @@ public class DownloadPicturesService extends DefaultBoundedRangeModel implements
return Collections.synchronizedList(new ArrayList<>(cardsToDownload)); return Collections.synchronizedList(new ArrayList<>(cardsToDownload));
} }
public static ArrayList<CardDownloadData> getTokenCardUrls() throws RuntimeException { public static List<CardDownloadData> getTokenCardUrls() throws RuntimeException {
ArrayList<CardDownloadData> list = new ArrayList<>(); List<CardDownloadData> list = new ArrayList<>();
InputStream in = DownloadPicturesService.class.getClassLoader().getResourceAsStream("card-pictures-tok.txt"); InputStream in = DownloadPicturesService.class.getClassLoader().getResourceAsStream("card-pictures-tok.txt");
if (in == null) { if (in == null) {

View file

@ -56,7 +56,7 @@ public class Log {
} }
public List<String> getArguments() { public List<String> getArguments() {
ArrayList<String> arguments = new ArrayList<>(); List<String> arguments = new ArrayList<>();
if (arg0 != null) { if (arg0 != null) {
arguments.add(arg0); arguments.add(arg0);
} }

View file

@ -66,7 +66,7 @@ public class SimulatedPlayer2 extends ComputerPlayer {
forced = false; forced = false;
simulateOptions(sim); simulateOptions(sim);
ArrayList<Ability> list = new ArrayList<>(allActions); List<Ability> list = new ArrayList<>(allActions);
Collections.reverse(list); Collections.reverse(list);
if (!forced) { if (!forced) {

View file

@ -517,7 +517,7 @@ public class ComputerPlayer extends PlayerImpl implements Player {
if (outcome.isGood()) { if (outcome.isGood()) {
// good // good
Cards cards = new CardsImpl(target.possibleTargets(sourceId, getId(), game)); Cards cards = new CardsImpl(target.possibleTargets(sourceId, getId(), game));
ArrayList<Card> cardsInHand = new ArrayList<>(cards.getCards(game)); List<Card> cardsInHand = new ArrayList<>(cards.getCards(game));
while (!target.isChosen() while (!target.isChosen()
&& !target.possibleTargets(sourceId, getId(), game).isEmpty() && !target.possibleTargets(sourceId, getId(), game).isEmpty()
&& target.getMaxNumberOfTargets() > target.getTargets().size()) { && target.getMaxNumberOfTargets() > target.getTargets().size()) {
@ -1793,7 +1793,7 @@ public class ComputerPlayer extends PlayerImpl implements Player {
abilityControllerId = target.getAbilityController(); abilityControllerId = target.getAbilityController();
} }
ArrayList<Card> cardChoices = new ArrayList<>(cards.getCards(target.getFilter(), game)); List<Card> cardChoices = new ArrayList<>(cards.getCards(target.getFilter(), game));
while (!target.doneChosing()) { while (!target.doneChosing()) {
Card card = pickTarget(abilityControllerId, cardChoices, outcome, target, source, game); Card card = pickTarget(abilityControllerId, cardChoices, outcome, target, source, game);
if (card != null) { if (card != null) {
@ -1824,7 +1824,7 @@ public class ComputerPlayer extends PlayerImpl implements Player {
abilityControllerId = target.getAbilityController(); abilityControllerId = target.getAbilityController();
} }
ArrayList<Card> cardChoices = new ArrayList<>(cards.getCards(target.getFilter(), game)); List<Card> cardChoices = new ArrayList<>(cards.getCards(target.getFilter(), game));
while (!target.doneChosing()) { while (!target.doneChosing()) {
Card card = pickTarget(abilityControllerId, cardChoices, outcome, target, null, game); Card card = pickTarget(abilityControllerId, cardChoices, outcome, target, null, game);
if (card != null) { if (card != null) {

View file

@ -53,7 +53,7 @@ public class SimulatedPlayer extends ComputerPlayer {
simulateOptions(sim, pass); simulateOptions(sim, pass);
ArrayList<Ability> list = new ArrayList<>(allActions); List<Ability> list = new ArrayList<>(allActions);
//Collections.shuffle(list); //Collections.shuffle(list);
Collections.reverse(list); Collections.reverse(list);
return list; return list;

View file

@ -187,7 +187,7 @@ public enum UserManager {
calendarRemove.add(Calendar.SECOND, -1 * SERVER_TIMEOUTS_USER_REMOVE_FROM_SERVER_AFTER_SECS); calendarRemove.add(Calendar.SECOND, -1 * SERVER_TIMEOUTS_USER_REMOVE_FROM_SERVER_AFTER_SECS);
List<User> toRemove = new ArrayList<>(); List<User> toRemove = new ArrayList<>();
logger.debug("Start Check Expired"); logger.debug("Start Check Expired");
ArrayList<User> userList = new ArrayList<>(); List<User> userList = new ArrayList<>();
final Lock r = lock.readLock(); final Lock r = lock.readLock();
r.lock(); r.lock();
try { try {

View file

@ -85,7 +85,7 @@ public final class SystemUtil {
String name; String name;
boolean isSpecialCommand; boolean isSpecialCommand;
ArrayList<String> commands = new ArrayList<>(); List<String> commands = new ArrayList<>();
public CommandGroup(String name) { public CommandGroup(String name) {
this(name, false); this(name, false);
@ -114,14 +114,14 @@ public final class SystemUtil {
} }
} }
private static String getCardsListForSpecialInform(Game game, Set<UUID> cardsList, ArrayList<String> commandParams) { private static String getCardsListForSpecialInform(Game game, Set<UUID> cardsList, List<String> commandParams) {
return getCardsListForSpecialInform(game, cardsList.stream().collect(Collectors.toList()), commandParams); return getCardsListForSpecialInform(game, cardsList.stream().collect(Collectors.toList()), commandParams);
} }
private static String getCardsListForSpecialInform(Game game, List<UUID> cardsList, ArrayList<String> commandParams) { private static String getCardsListForSpecialInform(Game game, List<UUID> cardsList, List<String> commandParams) {
// cards list with ext info // cards list with ext info
ArrayList<String> res = new ArrayList<>(); List<String> res = new ArrayList<>();
for (UUID cardID : cardsList) { for (UUID cardID : cardsList) {
Card card = game.getCard(cardID); Card card = game.getCard(cardID);
@ -276,7 +276,7 @@ public final class SystemUtil {
// 3. process system commands // 3. process system commands
// 4. run commands from selected group // 4. run commands from selected group
// 1. parse // 1. parse
ArrayList<CommandGroup> groups = new ArrayList<>(); List<CommandGroup> groups = new ArrayList<>();
try (Scanner scanner = new Scanner(f)) { try (Scanner scanner = new Scanner(f)) {

View file

@ -2,6 +2,7 @@
package mage.cards.a; package mage.cards.a;
import java.util.HashSet; import java.util.HashSet;
import java.util.Set;
import java.util.UUID; import java.util.UUID;
import mage.MageInt; import mage.MageInt;
import mage.abilities.Ability; import mage.abilities.Ability;
@ -56,7 +57,7 @@ class AwakenedAmalgamLandNamesCount implements DynamicValue {
@Override @Override
public int calculate(Game game, Ability sourceAbility, Effect effect) { public int calculate(Game game, Ability sourceAbility, Effect effect) {
HashSet<String> landNames = new HashSet<>(); Set<String> landNames = new HashSet<>();
for (Permanent permanent : game.getBattlefield().getAllActivePermanents(sourceAbility.getControllerId())) { for (Permanent permanent : game.getBattlefield().getAllActivePermanents(sourceAbility.getControllerId())) {
if (permanent.isLand()) { if (permanent.isLand()) {
landNames.add(permanent.getName()); landNames.add(permanent.getName());

View file

@ -1,6 +1,7 @@
package mage.cards.b; package mage.cards.b;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List;
import java.util.UUID; import java.util.UUID;
import mage.MageInt; import mage.MageInt;
import mage.MageObject; import mage.MageObject;
@ -151,7 +152,7 @@ class BronzehideLionContinuousEffect extends ContinuousEffectImpl {
lion.getSubtype(game).add(SubType.AURA); lion.getSubtype(game).add(SubType.AURA);
break; break;
case AbilityAddingRemovingEffects_6: case AbilityAddingRemovingEffects_6:
ArrayList<Ability> toRemove = new ArrayList<>(); List<Ability> toRemove = new ArrayList<>();
for (Ability ability : lion.getAbilities(game)) { for (Ability ability : lion.getAbilities(game)) {
if (!lion.getSpellAbility().equals(ability)) { if (!lion.getSpellAbility().equals(ability)) {
toRemove.add(ability); toRemove.add(ability);

View file

@ -3,6 +3,7 @@ package mage.cards.e;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.List;
import java.util.UUID; import java.util.UUID;
import mage.Mana; import mage.Mana;
import mage.abilities.Ability; import mage.abilities.Ability;
@ -85,7 +86,7 @@ class ElementalResonanceEffect extends OneShotEffect {
if (controller == null) { if (controller == null) {
return false; return false;
} }
ArrayList<String> manaOptions = new ArrayList<>(); List<String> manaOptions = new ArrayList<>();
// TODO: Phyrexian mana gives multiple choices when there should only be one (e.g. Slash Panther is {4} or {4}{R}). // TODO: Phyrexian mana gives multiple choices when there should only be one (e.g. Slash Panther is {4} or {4}{R}).
for (Mana mana : permanent.getManaCost().getOptions()) { for (Mana mana : permanent.getManaCost().getOptions()) {
String manaString = mana.toString(); String manaString = mana.toString();

View file

@ -2,6 +2,7 @@
package mage.cards.h; package mage.cards.h;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List;
import java.util.UUID; import java.util.UUID;
import mage.MageInt; import mage.MageInt;
import mage.abilities.Ability; import mage.abilities.Ability;
@ -70,7 +71,7 @@ class HammerJammerEntersEffect extends EntersBattlefieldWithXCountersEffect {
Permanent permanent = game.getPermanentEntering(source.getSourceId()); Permanent permanent = game.getPermanentEntering(source.getSourceId());
if (controller != null && permanent != null) { if (controller != null && permanent != null) {
int amount = controller.rollDice(game, 6); int amount = controller.rollDice(game, 6);
ArrayList<UUID> appliedEffects = (ArrayList<UUID>) this.getValue("appliedEffects"); // the basic event is the EntersBattlefieldEvent, so use already applied replacement effects from that event List<UUID> appliedEffects = (ArrayList<UUID>) this.getValue("appliedEffects"); // the basic event is the EntersBattlefieldEvent, so use already applied replacement effects from that event
permanent.addCounters(CounterType.P1P1.createInstance(amount), source, game, appliedEffects); permanent.addCounters(CounterType.P1P1.createInstance(amount), source, game, appliedEffects);
return super.apply(game, source); return super.apply(game, source);
} }

View file

@ -2,6 +2,7 @@
package mage.cards.j; package mage.cards.j;
import java.util.HashSet; import java.util.HashSet;
import java.util.Set;
import java.util.UUID; import java.util.UUID;
import mage.MageInt; import mage.MageInt;
import mage.MageObjectReference; import mage.MageObjectReference;
@ -82,7 +83,7 @@ class JeskaiInfiltratorEffect extends OneShotEffect {
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId()); Player controller = game.getPlayer(source.getControllerId());
if (controller != null) { if (controller != null) {
HashSet<Card> cardsToManifest = new HashSet<>(); Set<Card> cardsToManifest = new HashSet<>();
cardsToManifest.add(source.getSourcePermanentIfItStillExists(game)); cardsToManifest.add(source.getSourcePermanentIfItStillExists(game));
cardsToManifest.add(controller.getLibrary().getFromTop(game)); cardsToManifest.add(controller.getLibrary().getFromTop(game));
UUID exileId = UUID.randomUUID(); UUID exileId = UUID.randomUUID();

View file

@ -2,6 +2,7 @@
package mage.cards.j; package mage.cards.j;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List;
import java.util.UUID; import java.util.UUID;
import mage.MageInt; import mage.MageInt;
import mage.abilities.Ability; import mage.abilities.Ability;
@ -78,7 +79,7 @@ class JumboImpEffect extends EntersBattlefieldWithXCountersEffect {
Permanent permanent = game.getPermanentEntering(source.getSourceId()); Permanent permanent = game.getPermanentEntering(source.getSourceId());
if (controller != null && permanent != null) { if (controller != null && permanent != null) {
int amount = controller.rollDice(game, 6); int amount = controller.rollDice(game, 6);
ArrayList<UUID> appliedEffects = (ArrayList<UUID>) this.getValue("appliedEffects"); // the basic event is the EntersBattlefieldEvent, so use already applied replacement effects from that event List<UUID> appliedEffects = (ArrayList<UUID>) this.getValue("appliedEffects"); // the basic event is the EntersBattlefieldEvent, so use already applied replacement effects from that event
permanent.addCounters(CounterType.P1P1.createInstance(amount), source, game, appliedEffects); permanent.addCounters(CounterType.P1P1.createInstance(amount), source, game, appliedEffects);
return super.apply(game, source); return super.apply(game, source);
} }

View file

@ -15,6 +15,7 @@ import mage.target.TargetCard;
import mage.target.common.TargetCardInLibrary; import mage.target.common.TargetCardInLibrary;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map;
import java.util.UUID; import java.util.UUID;
/** /**
@ -79,7 +80,7 @@ class NissasEncouragementEffect extends OneShotEffect {
searchGY = true; searchGY = true;
} }
HashMap<String, Integer> foundCards = new HashMap<>(); Map<String, Integer> foundCards = new HashMap<>();
foundCards.put("Forest", 0); foundCards.put("Forest", 0);
foundCards.put("Brambleweft Behemoth", 0); foundCards.put("Brambleweft Behemoth", 0);
foundCards.put("Nissa, Genesis Mage", 0); foundCards.put("Nissa, Genesis Mage", 0);

View file

@ -71,7 +71,7 @@ class NykthosShrineToNyxManaAbility extends ActivatedManaAbilityImpl {
@Override @Override
public List<Mana> getNetMana(Game game) { public List<Mana> getNetMana(Game game) {
ArrayList<Mana> netManaCopy = new ArrayList<>(); List<Mana> netManaCopy = new ArrayList<>();
if (game == null) { if (game == null) {
return netManaCopy; return netManaCopy;
} }

View file

@ -70,7 +70,7 @@ class NyxLotusManaAbility extends ActivatedManaAbilityImpl {
@Override @Override
public List<Mana> getNetMana(Game game) { public List<Mana> getNetMana(Game game) {
ArrayList<Mana> netManaCopy = new ArrayList<>(); List<Mana> netManaCopy = new ArrayList<>();
if (game == null) { if (game == null) {
return netManaCopy; return netManaCopy;
} }

View file

@ -2,6 +2,7 @@
package mage.cards.p; package mage.cards.p;
import java.util.HashSet; import java.util.HashSet;
import java.util.Set;
import java.util.UUID; import java.util.UUID;
import mage.MageInt; import mage.MageInt;
import mage.MageObject; import mage.MageObject;
@ -69,7 +70,7 @@ class PlanarGuideExileEffect extends OneShotEffect {
MageObject sourceObject = game.getObject(source.getSourceId()); MageObject sourceObject = game.getObject(source.getSourceId());
Player controller = game.getPlayer(source.getControllerId()); Player controller = game.getPlayer(source.getControllerId());
if (sourceObject != null && controller != null) { if (sourceObject != null && controller != null) {
HashSet<Card> toExile = new HashSet<>(); Set<Card> toExile = new HashSet<>();
toExile.addAll(game.getBattlefield().getActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE, source.getControllerId(), source.getSourceId(), game)); toExile.addAll(game.getBattlefield().getActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE, source.getControllerId(), source.getSourceId(), game));
controller.moveCardsToExile(toExile, source, game, true, source.getSourceId(), sourceObject.getIdName()); controller.moveCardsToExile(toExile, source, game, true, source.getSourceId(), sourceObject.getIdName());
ExileZone exile = game.getExile().getExileZone(source.getSourceId()); ExileZone exile = game.getExile().getExileZone(source.getSourceId());

View file

@ -2,6 +2,7 @@
package mage.cards.s; package mage.cards.s;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List;
import java.util.UUID; import java.util.UUID;
import mage.MageInt; import mage.MageInt;
import mage.abilities.Ability; import mage.abilities.Ability;
@ -112,7 +113,7 @@ class StanggExileTokenEffect extends OneShotEffect {
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId()); Player controller = game.getPlayer(source.getControllerId());
if (controller != null) { if (controller != null) {
ArrayList<UUID> tokenIds = (ArrayList<UUID>) game.getState().getValue(source.getSourceId() + "_token"); List<UUID> tokenIds = (ArrayList<UUID>) game.getState().getValue(source.getSourceId() + "_token");
if (tokenIds != null) { if (tokenIds != null) {
Cards cards = new CardsImpl(); Cards cards = new CardsImpl();
for (UUID tokenId : tokenIds) { for (UUID tokenId : tokenIds) {

View file

@ -2,6 +2,7 @@
package mage.cards.s; package mage.cards.s;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map;
import java.util.UUID; import java.util.UUID;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.OneShotEffect;
@ -61,7 +62,7 @@ class StrongarmTacticsEffect extends OneShotEffect {
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId()); Player controller = game.getPlayer(source.getControllerId());
// Store for each player the cards to discard, that's important because all discard shall happen at the same time // Store for each player the cards to discard, that's important because all discard shall happen at the same time
HashMap<UUID, Cards> cardsToDiscard = new HashMap<>(); Map<UUID, Cards> cardsToDiscard = new HashMap<>();
if (controller != null) { if (controller != null) {
// choose cards to discard // choose cards to discard
for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) { for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {

View file

@ -2973,7 +2973,7 @@ public class TestPlayer implements Player {
} }
@Override @Override
public boolean flipCoin(Ability source, Game game, boolean winnable, ArrayList<UUID> appliedEffects) { public boolean flipCoin(Ability source, Game game, boolean winnable, List<UUID> appliedEffects) {
return computerPlayer.flipCoin(source, game, true, appliedEffects); return computerPlayer.flipCoin(source, game, true, appliedEffects);
} }
@ -2983,7 +2983,7 @@ public class TestPlayer implements Player {
} }
@Override @Override
public int rollDice(Game game, ArrayList<UUID> appliedEffects, int numSides) { public int rollDice(Game game, List<UUID> appliedEffects, int numSides) {
return computerPlayer.rollDice(game, appliedEffects, numSides); return computerPlayer.rollDice(game, appliedEffects, numSides);
} }
@ -3604,12 +3604,12 @@ public class TestPlayer implements Player {
} }
@Override @Override
public PlanarDieRoll rollPlanarDie(Game game, ArrayList<UUID> appliedEffects) { public PlanarDieRoll rollPlanarDie(Game game, List<UUID> appliedEffects) {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
} }
@Override @Override
public PlanarDieRoll rollPlanarDie(Game game, ArrayList<UUID> appliedEffects, int numberChaosSides, int numberPlanarSides) { public PlanarDieRoll rollPlanarDie(Game game, List<UUID> appliedEffects, int numberChaosSides, int numberPlanarSides) {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
} }

View file

@ -642,7 +642,7 @@ public class PlayerStub implements Player {
} }
@Override @Override
public boolean flipCoin(Ability source, Game game, boolean winnable, ArrayList<UUID> appliedEffects) { public boolean flipCoin(Ability source, Game game, boolean winnable, List<UUID> appliedEffects) {
return false; return false;
} }
@ -652,7 +652,7 @@ public class PlayerStub implements Player {
} }
@Override @Override
public int rollDice(Game game, ArrayList<UUID> appliedEffects, int numSides) { public int rollDice(Game game, List<UUID> appliedEffects, int numSides) {
return 1; return 1;
} }
@ -1322,12 +1322,12 @@ public class PlayerStub implements Player {
} }
@Override @Override
public PlanarDieRoll rollPlanarDie(Game game, ArrayList<UUID> appliedEffects) { public PlanarDieRoll rollPlanarDie(Game game, List<UUID> appliedEffects) {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
} }
@Override @Override
public PlanarDieRoll rollPlanarDie(Game game, ArrayList<UUID> appliedEffects, int numberChaosSides, int numberPlanarSides) { public PlanarDieRoll rollPlanarDie(Game game, List<UUID> appliedEffects, int numberChaosSides, int numberPlanarSides) {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
} }

View file

@ -2,6 +2,7 @@ package org.mage.test.utils;
import java.util.HashMap; import java.util.HashMap;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.Map;
import java.util.UUID; import java.util.UUID;
import mage.Mana; import mage.Mana;
import mage.abilities.Ability; import mage.abilities.Ability;
@ -188,7 +189,7 @@ public class ManaUtilTest extends CardTestPlayerBase {
Card card = CardRepository.instance.findCard(landName).getCard(); Card card = CardRepository.instance.findCard(landName).getCard();
Assert.assertNotNull(card); Assert.assertNotNull(card);
HashMap<UUID, ActivatedManaAbilityImpl> useableAbilities = getManaAbilities(card); Map<UUID, ActivatedManaAbilityImpl> useableAbilities = getManaAbilities(card);
Assert.assertEquals(expected1, useableAbilities.size()); Assert.assertEquals(expected1, useableAbilities.size());
useableAbilities = ManaUtil.tryToAutoPay(unpaid, (LinkedHashMap<UUID, ActivatedManaAbilityImpl>) useableAbilities); useableAbilities = ManaUtil.tryToAutoPay(unpaid, (LinkedHashMap<UUID, ActivatedManaAbilityImpl>) useableAbilities);
@ -216,7 +217,7 @@ public class ManaUtilTest extends CardTestPlayerBase {
Card card = CardRepository.instance.findCard(landName).getCard(); Card card = CardRepository.instance.findCard(landName).getCard();
Assert.assertNotNull(card); Assert.assertNotNull(card);
HashMap<UUID, ActivatedManaAbilityImpl> useableAbilities = getManaAbilities(card); Map<UUID, ActivatedManaAbilityImpl> useableAbilities = getManaAbilities(card);
Assert.assertEquals(expected1, useableAbilities.size()); Assert.assertEquals(expected1, useableAbilities.size());
useableAbilities = ManaUtil.tryToAutoPay(unpaid, (LinkedHashMap<UUID, ActivatedManaAbilityImpl>) useableAbilities); useableAbilities = ManaUtil.tryToAutoPay(unpaid, (LinkedHashMap<UUID, ActivatedManaAbilityImpl>) useableAbilities);
@ -251,8 +252,8 @@ public class ManaUtilTest extends CardTestPlayerBase {
* @param card Card to extract mana abilities from. * @param card Card to extract mana abilities from.
* @return * @return
*/ */
private HashMap<UUID, ActivatedManaAbilityImpl> getManaAbilities(Card card) { private Map<UUID, ActivatedManaAbilityImpl> getManaAbilities(Card card) {
HashMap<UUID, ActivatedManaAbilityImpl> useableAbilities = new LinkedHashMap<>(); Map<UUID, ActivatedManaAbilityImpl> useableAbilities = new LinkedHashMap<>();
for (Ability ability : card.getAbilities()) { for (Ability ability : card.getAbilities()) {
if (ability instanceof ActivatedManaAbilityImpl) { if (ability instanceof ActivatedManaAbilityImpl) {
ability.newId(); // we need to assign id manually as we are not in game ability.newId(); // we need to assign id manually as we are not in game

View file

@ -628,7 +628,7 @@ public class VerifyCardDataTest {
} }
// tok file's data // tok file's data
ArrayList<CardDownloadData> tokFileTokens = DownloadPicturesService.getTokenCardUrls(); List<CardDownloadData> tokFileTokens = DownloadPicturesService.getTokenCardUrls();
LinkedHashMap<String, String> tokDataClassesIndex = new LinkedHashMap<>(); LinkedHashMap<String, String> tokDataClassesIndex = new LinkedHashMap<>();
LinkedHashMap<String, String> tokDataNamesIndex = new LinkedHashMap<>(); LinkedHashMap<String, String> tokDataNamesIndex = new LinkedHashMap<>();
for (CardDownloadData tokData : tokFileTokens) { for (CardDownloadData tokData : tokFileTokens) {

View file

@ -2,6 +2,7 @@
package mage.abilities.common; package mage.abilities.common;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List;
import java.util.UUID; import java.util.UUID;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.ActivatedAbilityImpl; import mage.abilities.ActivatedAbilityImpl;
@ -120,7 +121,7 @@ class LicidContinuousEffect extends ContinuousEffectImpl {
licid.getSubtype(game).add(SubType.AURA); licid.getSubtype(game).add(SubType.AURA);
break; break;
case AbilityAddingRemovingEffects_6: case AbilityAddingRemovingEffects_6:
ArrayList<Ability> toRemove = new ArrayList<>(); List<Ability> toRemove = new ArrayList<>();
for (Ability ability : licid.getAbilities(game)) { for (Ability ability : licid.getAbilities(game)) {
for (Effect effect : ability.getEffects()) { for (Effect effect : ability.getEffects()) {
if (effect instanceof LicidEffect) { if (effect instanceof LicidEffect) {

View file

@ -705,7 +705,7 @@ public class ContinuousEffects implements Serializable {
Cards cardsToReveal = new CardsImpl(); Cards cardsToReveal = new CardsImpl();
do { do {
FilterCard filter = new FilterCard("a card to splice"); FilterCard filter = new FilterCard("a card to splice");
ArrayList<Predicate<MageObject>> idPredicates = new ArrayList<>(); List<Predicate<MageObject>> idPredicates = new ArrayList<>();
for (Ability ability : spliceAbilities) { for (Ability ability : spliceAbilities) {
idPredicates.add(new CardIdPredicate((ability.getSourceId()))); idPredicates.add(new CardIdPredicate((ability.getSourceId())));
} }

View file

@ -29,7 +29,7 @@ public class CreateTokenEffect extends OneShotEffect {
private boolean tapped; private boolean tapped;
private boolean attacking; private boolean attacking;
private UUID lastAddedTokenId; private UUID lastAddedTokenId;
private ArrayList<UUID> lastAddedTokenIds = new ArrayList<>(); private List<UUID> lastAddedTokenIds = new ArrayList<>();
public CreateTokenEffect(Token token) { public CreateTokenEffect(Token token) {
this(token, StaticValue.get(1)); this(token, StaticValue.get(1));

View file

@ -3,6 +3,7 @@
package mage.abilities.effects.common; package mage.abilities.effects.common;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List;
import java.util.UUID; import java.util.UUID;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.OneShotEffect;
@ -32,7 +33,7 @@ public class ExileGraveyardAllTargetPlayerEffect extends OneShotEffect {
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
Player targetPlayer = game.getPlayer(this.getTargetPointer().getFirst(game, source)); Player targetPlayer = game.getPlayer(this.getTargetPointer().getFirst(game, source));
if (targetPlayer != null) { if (targetPlayer != null) {
ArrayList<UUID> graveyard = new ArrayList<>(targetPlayer.getGraveyard()); List<UUID> graveyard = new ArrayList<>(targetPlayer.getGraveyard());
for (UUID cardId : graveyard) { for (UUID cardId : graveyard) {
game.getCard(cardId).moveToZone(Zone.EXILED, cardId, game, false); game.getCard(cardId).moveToZone(Zone.EXILED, cardId, game, false);
} }

View file

@ -12,10 +12,7 @@ import mage.filter.FilterPermanent;
import mage.game.Game; import mage.game.Game;
import mage.game.permanent.Permanent; import mage.game.permanent.Permanent;
import java.util.HashMap; import java.util.*;
import java.util.Iterator;
import java.util.Locale;
import java.util.UUID;
/** /**
* @author Loki * @author Loki
@ -101,7 +98,7 @@ public class GainAbilityAllEffect extends ContinuousEffectImpl {
} }
} }
// still as long as the prev. permanent is known to the LKI (e.g. Mikaeus, the Unhallowed) so gained dies triggered ability will trigger // still as long as the prev. permanent is known to the LKI (e.g. Mikaeus, the Unhallowed) so gained dies triggered ability will trigger
HashMap<UUID, MageObject> LKIBattlefield = game.getLKI().get(Zone.BATTLEFIELD); Map<UUID, MageObject> LKIBattlefield = game.getLKI().get(Zone.BATTLEFIELD);
if (LKIBattlefield != null) { if (LKIBattlefield != null) {
for (MageObject mageObject : LKIBattlefield.values()) { for (MageObject mageObject : LKIBattlefield.values()) {
Permanent perm = (Permanent) mageObject; Permanent perm = (Permanent) mageObject;

View file

@ -13,6 +13,7 @@ import mage.game.permanent.Permanent;
import java.util.HashMap; import java.util.HashMap;
import java.util.Iterator; import java.util.Iterator;
import java.util.Map;
import java.util.UUID; import java.util.UUID;
/** /**
@ -104,7 +105,7 @@ public class GainAbilityControlledEffect extends ContinuousEffectImpl {
} }
} }
// still as long as the prev. permanent is known to the LKI (e.g. Mikaeus, the Unhallowed) so gained dies triggered ability will trigger // still as long as the prev. permanent is known to the LKI (e.g. Mikaeus, the Unhallowed) so gained dies triggered ability will trigger
HashMap<UUID, MageObject> LKIBattlefield = game.getLKI().get(Zone.BATTLEFIELD); Map<UUID, MageObject> LKIBattlefield = game.getLKI().get(Zone.BATTLEFIELD);
if (LKIBattlefield != null) { if (LKIBattlefield != null) {
for (MageObject mageObject : LKIBattlefield.values()) { for (MageObject mageObject : LKIBattlefield.values()) {
Permanent perm = (Permanent) mageObject; Permanent perm = (Permanent) mageObject;

View file

@ -2,6 +2,7 @@ package mage.abilities.effects.common.continuous;
import java.util.HashMap; import java.util.HashMap;
import java.util.Iterator; import java.util.Iterator;
import java.util.Map;
import java.util.UUID; import java.util.UUID;
import mage.MageObject; import mage.MageObject;
import mage.MageObjectReference; import mage.MageObjectReference;
@ -104,7 +105,7 @@ public class LoseAbilityAllEffect extends ContinuousEffectImpl {
} }
} }
// still as long as the prev. permanent is known to the LKI (e.g. Mikaeus, the Unhallowed) so gained dies triggered ability will trigger // still as long as the prev. permanent is known to the LKI (e.g. Mikaeus, the Unhallowed) so gained dies triggered ability will trigger
HashMap<UUID, MageObject> LKIBattlefield = game.getLKI().get(Zone.BATTLEFIELD); Map<UUID, MageObject> LKIBattlefield = game.getLKI().get(Zone.BATTLEFIELD);
if (LKIBattlefield != null) { if (LKIBattlefield != null) {
for (MageObject mageObject : LKIBattlefield.values()) { for (MageObject mageObject : LKIBattlefield.values()) {
Permanent perm = (Permanent) mageObject; Permanent perm = (Permanent) mageObject;

View file

@ -2,6 +2,7 @@
package mage.abilities.effects.common.continuous; package mage.abilities.effects.common.continuous;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List;
import java.util.UUID; import java.util.UUID;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.Mode; import mage.abilities.Mode;
@ -45,7 +46,7 @@ public class PlayWithHandRevealedEffect extends ContinuousEffectImpl {
affectedPlayers = game.getOpponents(source.getControllerId()); affectedPlayers = game.getOpponents(source.getControllerId());
break; break;
case YOU: case YOU:
ArrayList<UUID> tmp = new ArrayList<>(); List<UUID> tmp = new ArrayList<>();
tmp.add(source.getControllerId()); tmp.add(source.getControllerId());
affectedPlayers = tmp; affectedPlayers = tmp;
break; break;

View file

@ -1,6 +1,7 @@
package mage.abilities.effects.common.counter; package mage.abilities.effects.common.counter;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List;
import java.util.Locale; import java.util.Locale;
import java.util.UUID; import java.util.UUID;
import mage.abilities.Ability; import mage.abilities.Ability;
@ -79,7 +80,7 @@ public class AddCountersSourceEffect extends OneShotEffect {
countersToAdd--; countersToAdd--;
} }
newCounter.add(countersToAdd); newCounter.add(countersToAdd);
ArrayList<UUID> appliedEffects = (ArrayList<UUID>) this.getValue("appliedEffects"); List<UUID> appliedEffects = (ArrayList<UUID>) this.getValue("appliedEffects");
card.addCounters(newCounter, source, game, appliedEffects); card.addCounters(newCounter, source, game, appliedEffects);
if (informPlayers && !game.isSimulation()) { if (informPlayers && !game.isSimulation()) {
Player player = game.getPlayer(source.getControllerId()); Player player = game.getPlayer(source.getControllerId());
@ -107,7 +108,7 @@ public class AddCountersSourceEffect extends OneShotEffect {
} }
newCounter.add(countersToAdd); newCounter.add(countersToAdd);
int before = permanent.getCounters(game).getCount(newCounter.getName()); int before = permanent.getCounters(game).getCount(newCounter.getName());
ArrayList<UUID> appliedEffects = (ArrayList<UUID>) this.getValue("appliedEffects"); List<UUID> appliedEffects = (ArrayList<UUID>) this.getValue("appliedEffects");
permanent.addCounters(newCounter, source, game, appliedEffects); // if used from a replacement effect, the basic event determines if an effect was already applied to an event permanent.addCounters(newCounter, source, game, appliedEffects); // if used from a replacement effect, the basic event determines if an effect was already applied to an event
if (informPlayers && !game.isSimulation()) { if (informPlayers && !game.isSimulation()) {
int amountAdded = permanent.getCounters(game).getCount(newCounter.getName()) - before; int amountAdded = permanent.getCounters(game).getCount(newCounter.getName()) - before;

View file

@ -18,6 +18,7 @@ import mage.target.common.TargetDiscard;
import mage.util.CardUtil; import mage.util.CardUtil;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map;
import java.util.UUID; import java.util.UUID;
public class DiscardEachPlayerEffect extends OneShotEffect { public class DiscardEachPlayerEffect extends OneShotEffect {
@ -60,7 +61,7 @@ public class DiscardEachPlayerEffect extends OneShotEffect {
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId()); Player controller = game.getPlayer(source.getControllerId());
// Store for each player the cards to discard, that's important because all discard shall happen at the same time // Store for each player the cards to discard, that's important because all discard shall happen at the same time
HashMap<UUID, Cards> cardsToDiscard = new HashMap<>(); Map<UUID, Cards> cardsToDiscard = new HashMap<>();
if (controller != null) { if (controller != null) {
// choose cards to discard // choose cards to discard
for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) { for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {

View file

@ -37,7 +37,7 @@ public class AddConditionalManaOfTwoDifferentColorsEffect extends ManaEffect {
@Override @Override
public List<Mana> getNetMana(Game game, Ability source) { public List<Mana> getNetMana(Game game, Ability source) {
ArrayList<Mana> netMana = new ArrayList<>(); List<Mana> netMana = new ArrayList<>();
netMana.add(Mana.AnyMana(2)); netMana.add(Mana.AnyMana(2));
return netMana; return netMana;
} }

View file

@ -44,7 +44,7 @@ public class AddManaAnyColorAttachedControllerEffect extends ManaEffect {
@Override @Override
public List<Mana> getNetMana(Game game, Ability source) { public List<Mana> getNetMana(Game game, Ability source) {
ArrayList<Mana> netMana = new ArrayList<>(); List<Mana> netMana = new ArrayList<>();
netMana.add(Mana.AnyMana(1)); netMana.add(Mana.AnyMana(1));
return netMana; return netMana;
} }

View file

@ -65,7 +65,7 @@ public class AddManaInAnyCombinationEffect extends ManaEffect {
@Override @Override
public List<Mana> getNetMana(Game game, Ability source) { public List<Mana> getNetMana(Game game, Ability source) {
ArrayList<Mana> netMana = new ArrayList<>(); List<Mana> netMana = new ArrayList<>();
int amountOfManaLeft = amount.calculate(game, source, this); int amountOfManaLeft = amount.calculate(game, source, this);
if (amountOfManaLeft > 0) { if (amountOfManaLeft > 0) {
netMana.add(Mana.AnyMana(amountOfManaLeft)); netMana.add(Mana.AnyMana(amountOfManaLeft));

View file

@ -37,7 +37,7 @@ public class AddManaOfAnyTypeProducedEffect extends ManaEffect {
@Override @Override
public List<Mana> getNetMana(Game game, Ability source) { public List<Mana> getNetMana(Game game, Ability source) {
ArrayList<Mana> netMana = new ArrayList<>(); List<Mana> netMana = new ArrayList<>();
Mana types = (Mana) this.getValue("mana"); // TODO: will not work until TriggeredManaAbility fix (see TriggeredManaAbilityMustGivesExtraManaOptions test) Mana types = (Mana) this.getValue("mana"); // TODO: will not work until TriggeredManaAbility fix (see TriggeredManaAbilityMustGivesExtraManaOptions test)
if (types != null) { if (types != null) {
netMana.add(types.copy()); netMana.add(types.copy());

View file

@ -24,7 +24,7 @@ public class AddManaOfTwoDifferentColorsEffect extends ManaEffect {
@Override @Override
public List<Mana> getNetMana(Game game, Ability source) { public List<Mana> getNetMana(Game game, Ability source) {
ArrayList<Mana> netMana = new ArrayList<>(); List<Mana> netMana = new ArrayList<>();
netMana.add(Mana.AnyMana(2)); netMana.add(Mana.AnyMana(2));
return netMana; return netMana;
} }

View file

@ -60,7 +60,7 @@ public class AddManaToManaPoolTargetControllerEffect extends ManaEffect {
@Override @Override
public List<Mana> getNetMana(Game game, Ability source) { public List<Mana> getNetMana(Game game, Ability source) {
ArrayList<Mana> netMana = new ArrayList<>(); List<Mana> netMana = new ArrayList<>();
netMana.add(mana.copy()); netMana.add(mana.copy());
return netMana; return netMana;
} }

View file

@ -3,6 +3,7 @@ package mage.abilities.hint;
import java.awt.*; import java.awt.*;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Set;
/** /**
* @author JayDi85 * @author JayDi85
@ -46,7 +47,7 @@ public class HintUtils {
public static void appendHints(List<String> destList, List<String> newHints) { public static void appendHints(List<String> destList, List<String> newHints) {
// append only unique hints // append only unique hints
HashSet<String> used = new HashSet<>(); Set<String> used = new HashSet<>();
for (String s : newHints) { for (String s : newHints) {
if (!used.contains(s)) { if (!used.contains(s)) {
destList.add(s); destList.add(s);

View file

@ -1,6 +1,7 @@
package mage.abilities.keyword; package mage.abilities.keyword;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List;
import java.util.UUID; import java.util.UUID;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.common.EntersBattlefieldAbility; import mage.abilities.common.EntersBattlefieldAbility;
@ -73,7 +74,7 @@ class BloodthirstEffect extends OneShotEffect {
if (watcher != null && watcher.conditionMet()) { if (watcher != null && watcher.conditionMet()) {
Permanent permanent = game.getPermanentEntering(source.getSourceId()); Permanent permanent = game.getPermanentEntering(source.getSourceId());
if (permanent != null) { if (permanent != null) {
ArrayList<UUID> appliedEffects = (ArrayList<UUID>) this.getValue("appliedEffects"); // the basic event is the EntersBattlefieldEvent, so use already applied replacement effects from that event List<UUID> appliedEffects = (ArrayList<UUID>) this.getValue("appliedEffects"); // the basic event is the EntersBattlefieldEvent, so use already applied replacement effects from that event
permanent.addCounters(CounterType.P1P1.createInstance(amount), source, game, appliedEffects); permanent.addCounters(CounterType.P1P1.createInstance(amount), source, game, appliedEffects);
} }
return true; return true;

View file

@ -3,6 +3,7 @@ package mage.abilities.keyword;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.EnumSet; import java.util.EnumSet;
import java.util.List;
import java.util.UUID; import java.util.UUID;
import mage.MageObject; import mage.MageObject;
import mage.abilities.Ability; import mage.abilities.Ability;
@ -74,7 +75,7 @@ public class ChampionAbility extends StaticAbility {
this.subtypes = subtypes; this.subtypes = subtypes;
StringBuilder sb = new StringBuilder("another "); StringBuilder sb = new StringBuilder("another ");
ArrayList<Predicate<MageObject>> subtypesPredicates = new ArrayList<>(); List<Predicate<MageObject>> subtypesPredicates = new ArrayList<>();
if (!subtypes.isEmpty()) { if (!subtypes.isEmpty()) {
int i = 0; int i = 0;
for (SubType subtype : this.subtypes) { for (SubType subtype : this.subtypes) {

View file

@ -1,6 +1,7 @@
package mage.abilities.keyword; package mage.abilities.keyword;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List;
import java.util.UUID; import java.util.UUID;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.StaticAbility; import mage.abilities.StaticAbility;
@ -160,7 +161,7 @@ class ModularDistributeCounterEffect extends OneShotEffect {
if (sourcePermanent != null && targetArtifact != null && player != null) { if (sourcePermanent != null && targetArtifact != null && player != null) {
int numberOfCounters = sourcePermanent.getCounters(game).getCount(CounterType.P1P1); int numberOfCounters = sourcePermanent.getCounters(game).getCount(CounterType.P1P1);
if (numberOfCounters > 0) { if (numberOfCounters > 0) {
ArrayList<UUID> appliedEffects = (ArrayList<UUID>) this.getValue("appliedEffects"); // the basic event is the EntersBattlefieldEvent, so use already applied replacement effects from that event List<UUID> appliedEffects = (ArrayList<UUID>) this.getValue("appliedEffects"); // the basic event is the EntersBattlefieldEvent, so use already applied replacement effects from that event
targetArtifact.addCounters(CounterType.P1P1.createInstance(numberOfCounters), source, game, appliedEffects); targetArtifact.addCounters(CounterType.P1P1.createInstance(numberOfCounters), source, game, appliedEffects);
} }
return true; return true;

View file

@ -10,6 +10,7 @@ import mage.constants.Zone;
import mage.game.Game; import mage.game.Game;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List;
import java.util.UUID; import java.util.UUID;
/** /**
@ -56,7 +57,7 @@ public class SpectacleAbility extends SpellAbility {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public boolean activate(Game game, boolean noMana) { public boolean activate(Game game, boolean noMana) {
if (super.activate(game, noMana)) { if (super.activate(game, noMana)) {
ArrayList<Integer> spectacleActivations = (ArrayList) game.getState().getValue(SPECTACLE_ACTIVATION_VALUE_KEY + getSourceId()); List<Integer> spectacleActivations = (ArrayList) game.getState().getValue(SPECTACLE_ACTIVATION_VALUE_KEY + getSourceId());
if (spectacleActivations == null) { if (spectacleActivations == null) {
spectacleActivations = new ArrayList<>(); // zoneChangeCounter spectacleActivations = new ArrayList<>(); // zoneChangeCounter
game.getState().setValue(SPECTACLE_ACTIVATION_VALUE_KEY + getSourceId(), spectacleActivations); game.getState().setValue(SPECTACLE_ACTIVATION_VALUE_KEY + getSourceId(), spectacleActivations);

View file

@ -2,6 +2,7 @@
package mage.abilities.keyword; package mage.abilities.keyword;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List;
import java.util.UUID; import java.util.UUID;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.common.EntersBattlefieldAbility; import mage.abilities.common.EntersBattlefieldAbility;
@ -71,14 +72,12 @@ class SunburstEffect extends OneShotEffect {
} else { } else {
counter = CounterType.CHARGE.createInstance(amount.calculate(game, source, this)); counter = CounterType.CHARGE.createInstance(amount.calculate(game, source, this));
} }
if (counter != null) { List<UUID> appliedEffects = (ArrayList<UUID>) this.getValue("appliedEffects"); // the basic event is the EntersBattlefieldEvent, so use already applied replacement effects from that event
ArrayList<UUID> appliedEffects = (ArrayList<UUID>) this.getValue("appliedEffects"); // the basic event is the EntersBattlefieldEvent, so use already applied replacement effects from that event permanent.addCounters(counter, source, game, appliedEffects);
permanent.addCounters(counter, source, game, appliedEffects); if (!game.isSimulation()) {
if (!game.isSimulation()) { Player player = game.getPlayer(source.getControllerId());
Player player = game.getPlayer(source.getControllerId()); if (player != null) {
if (player != null) { game.informPlayers(player.getLogName() + " puts " + counter.getCount() + ' ' + counter.getName() + " counter on " + permanent.getName());
game.informPlayers(player.getLogName() + " puts " + counter.getCount() + ' ' + counter.getName() + " counter on " + permanent.getName());
}
} }
} }
} }

View file

@ -10,6 +10,7 @@ import mage.players.Player;
import mage.watchers.common.CastSpellLastTurnWatcher; import mage.watchers.common.CastSpellLastTurnWatcher;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List;
import java.util.UUID; import java.util.UUID;
/** /**
@ -66,7 +67,7 @@ public class SurgeAbility extends SpellAbility {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public boolean activate(Game game, boolean noMana) { public boolean activate(Game game, boolean noMana) {
if (super.activate(game, noMana)) { if (super.activate(game, noMana)) {
ArrayList<Integer> surgeActivations = (ArrayList) game.getState().getValue(SURGE_ACTIVATION_VALUE_KEY + getSourceId()); List<Integer> surgeActivations = (ArrayList) game.getState().getValue(SURGE_ACTIVATION_VALUE_KEY + getSourceId());
if (surgeActivations == null) { if (surgeActivations == null) {
surgeActivations = new ArrayList<>(); // zoneChangeCounter surgeActivations = new ArrayList<>(); // zoneChangeCounter
game.getState().setValue(SURGE_ACTIVATION_VALUE_KEY + getSourceId(), surgeActivations); game.getState().setValue(SURGE_ACTIVATION_VALUE_KEY + getSourceId(), surgeActivations);

View file

@ -70,7 +70,7 @@ public abstract class ActivatedManaAbilityImpl extends ActivatedAbilityImpl impl
@Override @Override
public List<Mana> getNetMana(Game game) { public List<Mana> getNetMana(Game game) {
if (netMana.isEmpty()) { if (netMana.isEmpty()) {
ArrayList<Mana> dynamicNetMana = new ArrayList<>(); List<Mana> dynamicNetMana = new ArrayList<>();
for (Effect effect : getEffects()) { for (Effect effect : getEffects()) {
if (effect instanceof ManaEffect) { if (effect instanceof ManaEffect) {
List<Mana> effectNetMana = ((ManaEffect) effect).getNetMana(game, this); List<Mana> effectNetMana = ((ManaEffect) effect).getNetMana(game, this);
@ -81,7 +81,7 @@ public abstract class ActivatedManaAbilityImpl extends ActivatedAbilityImpl impl
} }
return dynamicNetMana; return dynamicNetMana;
} }
ArrayList<Mana> netManaCopy = new ArrayList<>(); List<Mana> netManaCopy = new ArrayList<>();
for (Mana mana : netMana) { for (Mana mana : netMana) {
netManaCopy.add(mana.copy()); netManaCopy.add(mana.copy());
} }

View file

@ -45,7 +45,7 @@ public abstract class TriggeredManaAbility extends TriggeredAbilityImpl implemen
@Override @Override
public List<Mana> getNetMana(Game game) { public List<Mana> getNetMana(Game game) {
if (game != null) { if (game != null) {
ArrayList<Mana> newNetMana = new ArrayList<>(); List<Mana> newNetMana = new ArrayList<>();
for (Effect effect : getEffects()) { for (Effect effect : getEffects()) {
if (effect instanceof ManaEffect) { if (effect instanceof ManaEffect) {
newNetMana.addAll(((ManaEffect) effect).getNetMana(game, this)); newNetMana.addAll(((ManaEffect) effect).getNetMana(game, this));

View file

@ -30,7 +30,7 @@ public class Sets extends HashMap<String, ExpansionSet> {
private Set<String> customSets = new HashSet<>(); private Set<String> customSets = new HashSet<>();
private Sets() { private Sets() {
ArrayList<String> packages = new ArrayList<>(); List<String> packages = new ArrayList<>();
packages.add("mage.sets"); packages.add("mage.sets");
for (Class c : ClassScanner.findClasses(null, packages, ExpansionSet.class)) { for (Class c : ClassScanner.findClasses(null, packages, ExpansionSet.class)) {
try { try {

View file

@ -25,7 +25,7 @@ public abstract class XmlDeckImporter extends DeckImporter {
protected List<Node> getNodes(Document doc, String xpathExpression) throws XPathExpressionException { protected List<Node> getNodes(Document doc, String xpathExpression) throws XPathExpressionException {
NodeList nodes = (NodeList) xpathFactory.newXPath().evaluate(xpathExpression, doc, NODESET); NodeList nodes = (NodeList) xpathFactory.newXPath().evaluate(xpathExpression, doc, NODESET);
ArrayList<Node> list = new ArrayList<>(); List<Node> list = new ArrayList<>();
for (int i = 0; i < nodes.getLength(); i++) { for (int i = 0; i < nodes.getLength(); i++) {
list.add(nodes.item(i)); list.add(nodes.item(i));
} }

View file

@ -183,7 +183,7 @@ public class CardInfo {
} }
if (length > MAX_RULE_LENGTH) { if (length > MAX_RULE_LENGTH) {
length = 0; length = 0;
ArrayList<String> shortRules = new ArrayList<>(); List<String> shortRules = new ArrayList<>();
for (String rule : rulesList) { for (String rule : rulesList) {
if (length + rule.length() + 3 <= MAX_RULE_LENGTH) { if (length + rule.length() + 3 <= MAX_RULE_LENGTH) {
shortRules.add(rule); shortRules.add(rule);

View file

@ -15,7 +15,7 @@ public class ChoiceColor extends ChoiceImpl {
private static final List<String> colorChoices = getBaseColors(); private static final List<String> colorChoices = getBaseColors();
public static List<String> getBaseColors() { public static List<String> getBaseColors() {
ArrayList<String> arr = new ArrayList<>(); List<String> arr = new ArrayList<>();
arr.add("Green"); arr.add("Green");
arr.add("Blue"); arr.add("Blue");
arr.add("Black"); arr.add("Black");

View file

@ -2,6 +2,7 @@
package mage.filter.common; package mage.filter.common;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List;
import java.util.Set; import java.util.Set;
import java.util.UUID; import java.util.UUID;
import mage.filter.FilterImpl; import mage.filter.FilterImpl;
@ -26,14 +27,14 @@ public class FilterPlaneswalkerOrPlayer extends FilterImpl<Object> {
public FilterPlaneswalkerOrPlayer(Set<UUID> defenders) { public FilterPlaneswalkerOrPlayer(Set<UUID> defenders) {
super("planeswalker or player"); super("planeswalker or player");
ArrayList<Predicate<Permanent>> permanentPredicates = new ArrayList<>(); List<Predicate<Permanent>> permanentPredicates = new ArrayList<>();
for (UUID defenderId : defenders) { for (UUID defenderId : defenders) {
permanentPredicates.add(new ControllerIdPredicate(defenderId)); permanentPredicates.add(new ControllerIdPredicate(defenderId));
} }
planeswalkerFilter = new FilterPlaneswalkerPermanent(); planeswalkerFilter = new FilterPlaneswalkerPermanent();
planeswalkerFilter.add(Predicates.or(permanentPredicates)); planeswalkerFilter.add(Predicates.or(permanentPredicates));
ArrayList<Predicate<Player>> playerPredicates = new ArrayList<>(); List<Predicate<Player>> playerPredicates = new ArrayList<>();
for (UUID defenderId : defenders) { for (UUID defenderId : defenders) {
playerPredicates.add(new PlayerIdPredicate(defenderId)); playerPredicates.add(new PlayerIdPredicate(defenderId));
} }

View file

@ -195,7 +195,7 @@ public final class Predicates {
} }
static <T> List<T> defensiveCopy(Iterable<T> iterable) { static <T> List<T> defensiveCopy(Iterable<T> iterable) {
ArrayList<T> list = new ArrayList<>(); List<T> list = new ArrayList<>();
for (T element : iterable) { for (T element : iterable) {
list.add(checkNotNull(element)); list.add(checkNotNull(element));
} }

View file

@ -95,7 +95,7 @@ public interface Game extends MageItem, Serializable {
Map<UUID, Permanent> getPermanentsEntering(); Map<UUID, Permanent> getPermanentsEntering();
Map<Zone, HashMap<UUID, MageObject>> getLKI(); Map<Zone, Map<UUID, MageObject>> getLKI();
// Result must be checked for null. Possible errors search pattern: (\S*) = game.getCard.+\n(?!.+\1 != null) // Result must be checked for null. Possible errors search pattern: (\S*) = game.getCard.+\n(?!.+\1 != null)
Card getCard(UUID cardId); Card getCard(UUID cardId);

View file

@ -89,8 +89,8 @@ public abstract class GameImpl implements Game, Serializable {
protected Map<UUID, Card> gameCards = new HashMap<>(); protected Map<UUID, Card> gameCards = new HashMap<>();
protected Map<UUID, MeldCard> meldCards = new HashMap<>(0); protected Map<UUID, MeldCard> meldCards = new HashMap<>(0);
protected Map<Zone, HashMap<UUID, MageObject>> lki = new EnumMap<>(Zone.class); protected Map<Zone, Map<UUID, MageObject>> lki = new EnumMap<>(Zone.class);
protected Map<Zone, HashMap<UUID, CardState>> lkiCardState = new EnumMap<>(Zone.class); protected Map<Zone, Map<UUID, CardState>> lkiCardState = new EnumMap<>(Zone.class);
protected Map<UUID, Map<Integer, MageObject>> lkiExtended = new HashMap<>(); protected Map<UUID, Map<Integer, MageObject>> lkiExtended = new HashMap<>();
// Used to check if an object was moved by the current effect in resolution (so Wrath like effect can be handled correctly) // Used to check if an object was moved by the current effect in resolution (so Wrath like effect can be handled correctly)
protected Map<Zone, Set<UUID>> shortLivingLKI = new EnumMap<>(Zone.class); protected Map<Zone, Set<UUID>> shortLivingLKI = new EnumMap<>(Zone.class);
@ -2819,7 +2819,7 @@ public abstract class GameImpl implements Game, Serializable {
if (lkiMap != null) { if (lkiMap != null) {
lkiMap.put(objectId, copy); lkiMap.put(objectId, copy);
} else { } else {
HashMap<UUID, MageObject> newMap = new HashMap<>(); Map<UUID, MageObject> newMap = new HashMap<>();
newMap.put(objectId, copy); newMap.put(objectId, copy);
lki.put(zone, newMap); lki.put(zone, newMap);
} }
@ -2844,7 +2844,7 @@ public abstract class GameImpl implements Game, Serializable {
if (lkiMap != null) { if (lkiMap != null) {
lkiMap.put(objectId, getState().getCardState(objectId)); lkiMap.put(objectId, getState().getCardState(objectId));
} else { } else {
HashMap<UUID, CardState> newMap = new HashMap<>(); Map<UUID, CardState> newMap = new HashMap<>();
newMap.put(objectId, getState().getCardState(objectId).copy()); newMap.put(objectId, getState().getCardState(objectId).copy());
lkiCardState.put(zone, newMap); lkiCardState.put(zone, newMap);
} }
@ -2908,7 +2908,7 @@ public abstract class GameImpl implements Game, Serializable {
} }
@Override @Override
public Map<Zone, HashMap<UUID, MageObject>> getLKI() { public Map<Zone, Map<UUID, MageObject>> getLKI() {
return lki; return lki;
} }

View file

@ -448,8 +448,7 @@ public class Combat implements Serializable, Copyable<Combat> {
} }
if (mustAttack) { if (mustAttack) {
// check which defenders the forced to attack creature can attack without paying a cost // check which defenders the forced to attack creature can attack without paying a cost
HashSet<UUID> defendersCostlessAttackable = new HashSet<>(); Set<UUID> defendersCostlessAttackable = new HashSet<>(defenders);
defendersCostlessAttackable.addAll(defenders);
for (UUID defenderId : defenders) { for (UUID defenderId : defenders) {
if (game.getContinuousEffects().checkIfThereArePayCostToAttackBlockEffects( if (game.getContinuousEffects().checkIfThereArePayCostToAttackBlockEffects(
GameEvent.getEvent(GameEvent.EventType.DECLARE_ATTACKER, GameEvent.getEvent(GameEvent.EventType.DECLARE_ATTACKER,

View file

@ -6,6 +6,7 @@ import mage.abilities.Ability;
import mage.cards.Card; import mage.cards.Card;
import mage.game.Game; import mage.game.Game;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List;
import java.util.UUID; import java.util.UUID;
/** /**
@ -23,7 +24,7 @@ public interface Token extends MageObject {
UUID getLastAddedToken(); UUID getLastAddedToken();
ArrayList<UUID> getLastAddedTokenIds(); List<UUID> getLastAddedTokenIds();
void addAbility(Ability ability); void addAbility(Ability ability);

View file

@ -111,10 +111,8 @@ public abstract class TokenImpl extends MageObjectImpl implements Token {
} }
@Override @Override
public ArrayList<UUID> getLastAddedTokenIds() { public List<UUID> getLastAddedTokenIds() {
ArrayList<UUID> ids = new ArrayList<>(); return new ArrayList<>(lastAddedTokenIds);
ids.addAll(lastAddedTokenIds);
return ids;
} }
@Override @Override

View file

@ -405,7 +405,7 @@ public abstract class TournamentImpl implements Tournament {
} }
public void resetBufferedCards() { public void resetBufferedCards() {
HashSet<ExpansionSet> setsDone = new HashSet<>(); Set<ExpansionSet> setsDone = new HashSet<>();
for (ExpansionSet set : sets) { for (ExpansionSet set : sets) {
if (!setsDone.contains(set)) { if (!setsDone.contains(set)) {
set.removeSavedCards(); set.removeSavedCards();

View file

@ -396,17 +396,17 @@ public interface Player extends MageItem, Copyable<Player> {
boolean flipCoin(Ability source, Game game, boolean winnable); boolean flipCoin(Ability source, Game game, boolean winnable);
boolean flipCoin(Ability source, Game game, boolean winnable, ArrayList<UUID> appliedEffects); boolean flipCoin(Ability source, Game game, boolean winnable, List<UUID> appliedEffects);
int rollDice(Game game, int numSides); int rollDice(Game game, int numSides);
int rollDice(Game game, ArrayList<UUID> appliedEffects, int numSides); int rollDice(Game game, List<UUID> appliedEffects, int numSides);
PlanarDieRoll rollPlanarDie(Game game); PlanarDieRoll rollPlanarDie(Game game);
PlanarDieRoll rollPlanarDie(Game game, ArrayList<UUID> appliedEffects); PlanarDieRoll rollPlanarDie(Game game, List<UUID> appliedEffects);
PlanarDieRoll rollPlanarDie(Game game, ArrayList<UUID> appliedEffects, int numberChaosSides, int numberPlanarSides); PlanarDieRoll rollPlanarDie(Game game, List<UUID> appliedEffects, int numberChaosSides, int numberPlanarSides);
Card discardOne(boolean random, Ability source, Game game); Card discardOne(boolean random, Ability source, Game game);

View file

@ -1784,7 +1784,7 @@ public abstract class PlayerImpl implements Player, Serializable {
@Override @Override
public void untap(Game game) { public void untap(Game game) {
// create list of all "notMoreThan" effects to track which one are consumed // create list of all "notMoreThan" effects to track which one are consumed
HashMap<Entry<RestrictionUntapNotMoreThanEffect, Set<Ability>>, Integer> notMoreThanEffectsUsage = new HashMap<>(); Map<Entry<RestrictionUntapNotMoreThanEffect, Set<Ability>>, Integer> notMoreThanEffectsUsage = new HashMap<>();
for (Entry<RestrictionUntapNotMoreThanEffect, Set<Ability>> restrictionEffect for (Entry<RestrictionUntapNotMoreThanEffect, Set<Ability>> restrictionEffect
: game.getContinuousEffects().getApplicableRestrictionUntapNotMoreThanEffects(this, game).entrySet()) { : game.getContinuousEffects().getApplicableRestrictionUntapNotMoreThanEffects(this, game).entrySet()) {
notMoreThanEffectsUsage.put(restrictionEffect, restrictionEffect.getKey().getNumber()); notMoreThanEffectsUsage.put(restrictionEffect, restrictionEffect.getKey().getNumber());
@ -1908,6 +1908,7 @@ public abstract class PlayerImpl implements Player, Serializable {
} else { } else {
//20091005 - 502.2 //20091005 - 502.2
for (Permanent permanent : game.getBattlefield().getAllActivePermanents(playerId)) { for (Permanent permanent : game.getBattlefield().getAllActivePermanents(playerId)) {
boolean untap = true; boolean untap = true;
for (RestrictionEffect effect : game.getContinuousEffects().getApplicableRestrictionEffects(permanent, game).keySet()) { for (RestrictionEffect effect : game.getContinuousEffects().getApplicableRestrictionEffects(permanent, game).keySet()) {
@ -2788,7 +2789,7 @@ public abstract class PlayerImpl implements Player, Serializable {
* for heads and false for tails * for heads and false for tails
*/ */
@Override @Override
public boolean flipCoin(Ability source, Game game, boolean winnable, ArrayList<UUID> appliedEffects) { public boolean flipCoin(Ability source, Game game, boolean winnable, List<UUID> appliedEffects) {
boolean chosen = false; boolean chosen = false;
if (winnable) { if (winnable) {
chosen = this.chooseUse(Outcome.Benefit, "Heads or tails?", "", "Heads", "Tails", source, game); chosen = this.chooseUse(Outcome.Benefit, "Heads or tails?", "", "Heads", "Tails", source, game);
@ -2843,7 +2844,7 @@ public abstract class PlayerImpl implements Player, Serializable {
* @return the number that the player rolled * @return the number that the player rolled
*/ */
@Override @Override
public int rollDice(Game game, ArrayList<UUID> appliedEffects, int numSides) { public int rollDice(Game game, List<UUID> appliedEffects, int numSides) {
int result = RandomUtil.nextInt(numSides) + 1; int result = RandomUtil.nextInt(numSides) + 1;
if (!game.isSimulation()) { if (!game.isSimulation()) {
game.informPlayers("[Roll a die] " + getLogName() + " rolled a " game.informPlayers("[Roll a die] " + getLogName() + " rolled a "
@ -2869,7 +2870,7 @@ public abstract class PlayerImpl implements Player, Serializable {
} }
@Override @Override
public PlanarDieRoll rollPlanarDie(Game game, ArrayList<UUID> appliedEffects) { public PlanarDieRoll rollPlanarDie(Game game, List<UUID> appliedEffects) {
return rollPlanarDie(game, appliedEffects, 2, 2); return rollPlanarDie(game, appliedEffects, 2, 2);
} }
@ -2884,7 +2885,7 @@ public abstract class PlayerImpl implements Player, Serializable {
* or NilRoll * or NilRoll
*/ */
@Override @Override
public PlanarDieRoll rollPlanarDie(Game game, ArrayList<UUID> appliedEffects, int numberChaosSides, public PlanarDieRoll rollPlanarDie(Game game, List<UUID> appliedEffects, int numberChaosSides,
int numberPlanarSides) { int numberPlanarSides) {
int result = RandomUtil.nextInt(9) + 1; int result = RandomUtil.nextInt(9) + 1;
PlanarDieRoll roll = PlanarDieRoll.NIL_ROLL; PlanarDieRoll roll = PlanarDieRoll.NIL_ROLL;

View file

@ -451,9 +451,7 @@ public abstract class TargetImpl implements Target {
@Override @Override
public List<UUID> getTargets() { public List<UUID> getTargets() {
ArrayList<UUID> newList = new ArrayList<>(); return new ArrayList<>(targets.keySet());
newList.addAll(targets.keySet());
return newList;
} }
@Override @Override

View file

@ -42,7 +42,7 @@ public class FirstTargetPointer implements TargetPointer {
@Override @Override
public List<UUID> getTargets(Game game, Ability source) { public List<UUID> getTargets(Game game, Ability source) {
ArrayList<UUID> target = new ArrayList<>(); List<UUID> target = new ArrayList<>();
if (!source.getTargets().isEmpty()) { if (!source.getTargets().isEmpty()) {
for (UUID targetId : source.getTargets().get(0).getTargets()) { for (UUID targetId : source.getTargets().get(0).getTargets()) {
Card card = game.getCard(targetId); Card card = game.getCard(targetId);

View file

@ -90,7 +90,7 @@ public class FixedTarget implements TargetPointer {
} }
} }
ArrayList<UUID> list = new ArrayList<>(1); List<UUID> list = new ArrayList<>(1);
list.add(targetId); list.add(targetId);
return list; return list;
} }

View file

@ -75,7 +75,7 @@ public class FixedTargets implements TargetPointer {
@Override @Override
public List<UUID> getTargets(Game game, Ability source) { public List<UUID> getTargets(Game game, Ability source) {
// check target not changed zone // check target not changed zone
ArrayList<UUID> list = new ArrayList<>(1); List<UUID> list = new ArrayList<>(1);
for (MageObjectReference mor : targets) { for (MageObjectReference mor : targets) {
if (game.getState().getZoneChangeCounter(mor.getSourceId()) == mor.getZoneChangeCounter()) { if (game.getState().getZoneChangeCounter(mor.getSourceId()) == mor.getZoneChangeCounter()) {
list.add(mor.getSourceId()); list.add(mor.getSourceId());

View file

@ -37,7 +37,7 @@ public class SecondTargetPointer implements TargetPointer {
@Override @Override
public List<UUID> getTargets(Game game, Ability source) { public List<UUID> getTargets(Game game, Ability source) {
ArrayList<UUID> target = new ArrayList<>(); List<UUID> target = new ArrayList<>();
if (source.getTargets().size() > 1) { if (source.getTargets().size() > 1) {
for (UUID targetId : source.getTargets().get(1).getTargets()) { for (UUID targetId : source.getTargets().get(1).getTargets()) {
Card card = game.getCard(targetId); Card card = game.getCard(targetId);

View file

@ -50,7 +50,7 @@ public class ThirdTargetPointer implements TargetPointer {
@Override @Override
public List<UUID> getTargets(Game game, Ability source) { public List<UUID> getTargets(Game game, Ability source) {
ArrayList<UUID> target = new ArrayList<>(); List<UUID> target = new ArrayList<>();
if (source.getTargets().size() > 2) { if (source.getTargets().size() > 2) {
for (UUID targetId : source.getTargets().get(2).getTargets()) { for (UUID targetId : source.getTargets().get(2).getTargets()) {
Card card = game.getCard(targetId); Card card = game.getCard(targetId);

View file

@ -17,7 +17,7 @@ import java.util.*;
public class CastFromGraveyardWatcher extends Watcher { public class CastFromGraveyardWatcher extends Watcher {
// holds which spell with witch zone change counter was cast from graveyard // holds which spell with witch zone change counter was cast from graveyard
private final Map<UUID, HashSet<Integer>> spellsCastFromGraveyard = new HashMap<>(); private final Map<UUID, Set<Integer>> spellsCastFromGraveyard = new HashMap<>();
public CastFromGraveyardWatcher() { public CastFromGraveyardWatcher() {
super(WatcherScope.GAME); super(WatcherScope.GAME);