diff --git a/Mage.Client/pom.xml b/Mage.Client/pom.xml index be01880613..13bcbc187c 100644 --- a/Mage.Client/pom.xml +++ b/Mage.Client/pom.xml @@ -35,6 +35,11 @@ log4j 1.2.14 + + net.sf.trove4j + trove4j + 3.0.3 + com.mortennobel java-image-scaling @@ -96,12 +101,12 @@ de.schlichtherle.truezip truezip-file - 7.6.3 + 7.7.5 de.schlichtherle.truezip truezip-driver-zip - 7.6.3 + 7.7.5 diff --git a/Mage.Client/src/main/java/mage/client/components/ext/dlg/DialogContainer.java b/Mage.Client/src/main/java/mage/client/components/ext/dlg/DialogContainer.java index a1de8974d4..cd954f0967 100644 --- a/Mage.Client/src/main/java/mage/client/components/ext/dlg/DialogContainer.java +++ b/Mage.Client/src/main/java/mage/client/components/ext/dlg/DialogContainer.java @@ -14,21 +14,21 @@ import java.awt.image.BufferedImage; */ public class DialogContainer extends JPanel { - private static int X_OFFSET = 30; - private static int Y_OFFSET = 30; - private BufferedImage shadow = null; + private static final int X_OFFSET = 30; + private static final int Y_OFFSET = 30; + private final BufferedImage shadow = null; //private DialogManager.MTGDialogs dialogType; //private DlgParams params; private Color backgroundColor = new Color(0, 255, 255, 60); private int alpha = 50; - private boolean isGradient = false; - private TexturePaint tp = null; - private Image gradient = null; + private final boolean isGradient = false; + private final TexturePaint tp = null; + private final Image gradient = null; private BufferedImage b; private boolean drawContainer = true; - private DialogManager.MTGDialogs dialogType; + private final DialogManager.MTGDialogs dialogType; public DialogContainer(DialogManager.MTGDialogs dialogType, DlgParams params) { setOpaque(false); diff --git a/Mage.Client/src/main/java/mage/client/components/ext/dlg/impl/ChoiceDialog.java b/Mage.Client/src/main/java/mage/client/components/ext/dlg/impl/ChoiceDialog.java index 440c3c8a7e..bdce233a91 100644 --- a/Mage.Client/src/main/java/mage/client/components/ext/dlg/impl/ChoiceDialog.java +++ b/Mage.Client/src/main/java/mage/client/components/ext/dlg/impl/ChoiceDialog.java @@ -36,8 +36,8 @@ public class ChoiceDialog extends IDialogPanel { private JButton jButtonSort = null; - private CardsView cards; - private UUID gameId; + private final CardsView cards; + private final UUID gameId; private int page = 1; private int maxPages; @@ -48,12 +48,14 @@ public class ChoiceDialog extends IDialogPanel { private boolean isChooseAbility = false; private boolean isCancelStopsPlaying = true; - private DlgParams params; + private final DlgParams params; - private String title; + private final String title; /** * This is the default constructor + * @param params + * @param title */ public ChoiceDialog(DlgParams params, String title) { super(params); diff --git a/Mage.Client/src/main/java/mage/client/deckeditor/DeckEditorPanel.java b/Mage.Client/src/main/java/mage/client/deckeditor/DeckEditorPanel.java index 1d8392254f..671962087a 100644 --- a/Mage.Client/src/main/java/mage/client/deckeditor/DeckEditorPanel.java +++ b/Mage.Client/src/main/java/mage/client/deckeditor/DeckEditorPanel.java @@ -125,7 +125,7 @@ public class DeckEditorPanel extends javax.swing.JPanel { /** * Free resources so GC can work */ - public void clear() { + public void cleanUp() { if (updateDeckTask != null) { updateDeckTask.cancel(true); } @@ -319,7 +319,7 @@ public class DeckEditorPanel extends javax.swing.JPanel { public void removeDeckEditor() { hidePopup(); - this.clear(); + this.cleanUp(); Component c = this.getParent(); while (c != null && !(c instanceof DeckEditorPane)) { diff --git a/Mage.Client/src/main/java/mage/client/game/BattlefieldPanel.java b/Mage.Client/src/main/java/mage/client/game/BattlefieldPanel.java index a5998ad06d..0d31bc130c 100644 --- a/Mage.Client/src/main/java/mage/client/game/BattlefieldPanel.java +++ b/Mage.Client/src/main/java/mage/client/game/BattlefieldPanel.java @@ -59,10 +59,10 @@ import java.util.Map.Entry; */ public class BattlefieldPanel extends javax.swing.JLayeredPane { - private Map permanents = new LinkedHashMap(); + private final Map permanents = new LinkedHashMap(); private UUID gameId; private BigCard bigCard; - private Map ui = new HashMap(); + private final Map uiComponentsList = new HashMap(); protected Map battlefield; private Dimension cardDimension; @@ -71,7 +71,7 @@ public class BattlefieldPanel extends javax.swing.JLayeredPane { private JScrollPane jScrollPane; private int width; - private static int i = 0; + //private static int iCounter = 0; private boolean addedPermanent; private boolean addedArtifact; @@ -81,9 +81,9 @@ public class BattlefieldPanel extends javax.swing.JLayeredPane { /** Creates new form BattlefieldPanel */ public BattlefieldPanel() { - ui.put("battlefieldPanel", this); + uiComponentsList.put("battlefieldPanel", this); initComponents(); - ui.put("jPanel", jPanel); + uiComponentsList.put("jPanel", jPanel); addComponentListener(new ComponentAdapter() { @Override @@ -104,7 +104,7 @@ public class BattlefieldPanel extends javax.swing.JLayeredPane { public void cleanUp() { permanents.clear(); - Plugins.getInstance().sortPermanents(ui, permanents.values()); + Plugins.getInstance().sortPermanents(uiComponentsList, permanents.values()); } public void update(Map battlefield) { @@ -145,11 +145,11 @@ public class BattlefieldPanel extends javax.swing.JLayeredPane { removedCreature = false; - for (Iterator> i = permanents.entrySet().iterator(); i.hasNext();) { - Entry entry = i.next(); + for (Iterator> iterator = permanents.entrySet().iterator(); iterator.hasNext();) { + Entry entry = iterator.next(); if (!battlefield.containsKey(entry.getKey())) { removePermanent(entry.getKey(), 1); - i.remove(); + iterator.remove(); changed = true; } } @@ -166,7 +166,7 @@ public class BattlefieldPanel extends javax.swing.JLayeredPane { //TODO: review sorting stuff public void sortLayout() { - int height = Plugins.getInstance().sortPermanents(ui, permanents.values()); + int height = Plugins.getInstance().sortPermanents(uiComponentsList, permanents.values()); BattlefieldPanel.this.jPanel.setPreferredSize(new Dimension(width - 30, height)); this.jScrollPane.repaint(); this.jScrollPane.revalidate(); diff --git a/Mage.Common/pom.xml b/Mage.Common/pom.xml index 8f231e0f3f..081c72f0a4 100644 --- a/Mage.Common/pom.xml +++ b/Mage.Common/pom.xml @@ -50,7 +50,11 @@ trove 1.0.2 - + + net.sf.trove4j + trove4j + 3.0.3 + org.xerial sqlite-jdbc diff --git a/Mage.Common/src/mage/utils/DeckBuilder.java b/Mage.Common/src/mage/utils/DeckBuilder.java index f387f7faa2..fcc9e0c1be 100644 --- a/Mage.Common/src/mage/utils/DeckBuilder.java +++ b/Mage.Common/src/mage/utils/DeckBuilder.java @@ -1,5 +1,6 @@ package mage.utils; +import gnu.trove.set.hash.THashSet; import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; @@ -13,7 +14,6 @@ import mage.cards.decks.Deck; import mage.constants.CardType; import mage.constants.ColoredManaSymbol; import mage.interfaces.rate.RateCallback; -import org.apache.log4j.Logger; /** * Builds deck from provided card pool. @@ -263,7 +263,7 @@ public class DeckBuilder { final Map singleCount = new HashMap(); int maxSingleCount = 0; int multicolor = 0; - Set colors = new HashSet(); + Set colors = new THashSet(); for (String symbol : card.getManaCost().getSymbols()) { int count = 0; symbol = symbol.replace("{", "").replace("}", ""); diff --git a/Mage.Common/src/mage/view/GameView.java b/Mage.Common/src/mage/view/GameView.java index a27b849e3c..49c7ec01aa 100644 --- a/Mage.Common/src/mage/view/GameView.java +++ b/Mage.Common/src/mage/view/GameView.java @@ -59,23 +59,23 @@ import mage.players.Player; public class GameView implements Serializable { private static final long serialVersionUID = 1L; - private int priorityTime; - private List players = new ArrayList(); + private final int priorityTime; + private final List players = new ArrayList(); private SimpleCardsView hand; private Map opponentHands; - private CardsView stack = new CardsView(); - private List exiles = new ArrayList(); - private List revealed = new ArrayList(); + private final CardsView stack = new CardsView(); + private final List exiles = new ArrayList(); + private final List revealed = new ArrayList(); private List lookedAt = new ArrayList(); - private List combat = new ArrayList(); - private TurnPhase phase; - private PhaseStep step; - private UUID activePlayerId; + private final List combat = new ArrayList(); + private final TurnPhase phase; + private final PhaseStep step; + private final UUID activePlayerId; private String activePlayerName = ""; private String priorityPlayerName = ""; - private int turn; + private final int turn; private boolean special = false; - private boolean isPlayer; + private final boolean isPlayer; public GameView(GameState state, Game game, boolean isPlayer) { diff --git a/Mage.Common/src/mage/view/PlayerView.java b/Mage.Common/src/mage/view/PlayerView.java index 44552eb644..2fda2a7f54 100644 --- a/Mage.Common/src/mage/view/PlayerView.java +++ b/Mage.Common/src/mage/view/PlayerView.java @@ -48,24 +48,24 @@ import mage.game.command.Commander; public class PlayerView implements Serializable { private static final long serialVersionUID = 1L; - private UUID playerId; - private String name; - private int life; - private int poison; - private int libraryCount; - private int handCount; - private boolean isActive; - private boolean hasPriority; - private boolean hasLeft; - private ManaPoolView manaPool; - private SimpleCardsView graveyard = new SimpleCardsView(); - private Map battlefield = new LinkedHashMap(); - private CardView topCard; - private UserDataView userDataView; - private List commandList = new ArrayList(); - private List attachments = new ArrayList(); - private int statesSavedSize; - private int priorityTimeLeft; + private final UUID playerId; + private final String name; + private final int life; + private final int poison; + private final int libraryCount; + private final int handCount; + private final boolean isActive; + private final boolean hasPriority; + private final boolean hasLeft; + private final ManaPoolView manaPool; + private final SimpleCardsView graveyard = new SimpleCardsView(); + private final Map battlefield = new LinkedHashMap(); + private final CardView topCard; + private final UserDataView userDataView; + private final List commandList = new ArrayList(); + private final List attachments = new ArrayList(); + private final int statesSavedSize; + private final int priorityTimeLeft; public PlayerView(Player player, GameState state, Game game) { this.playerId = player.getId(); diff --git a/Mage.Sets/src/mage/sets/bornofthegods/KioraTheCrashingWave.java b/Mage.Sets/src/mage/sets/bornofthegods/KioraTheCrashingWave.java index 9b47e26081..ba518087dc 100644 --- a/Mage.Sets/src/mage/sets/bornofthegods/KioraTheCrashingWave.java +++ b/Mage.Sets/src/mage/sets/bornofthegods/KioraTheCrashingWave.java @@ -152,8 +152,9 @@ class KioraPreventionEffect extends PreventionEffectImpl @Override public boolean applies(GameEvent event, Ability source, Game game) { if (super.applies(event, source, game) && event instanceof DamageEvent) { - Permanent targetPermanent = game.getPermanent(getTargetPointer().getFirst(game, source)); - if (event.getSourceId().equals(targetPermanent.getId()) || event.getTargetId().equals(targetPermanent.getId())) { + Permanent targetPermanent = game.getPermanent(this.getTargetPointer().getFirst(game, source)); + if (targetPermanent != null + && (event.getSourceId().equals(targetPermanent.getId()) || event.getTargetId().equals(targetPermanent.getId()))) { return true; } } diff --git a/Mage/pom.xml b/Mage/pom.xml index 9d11b2d682..1e0825d92a 100644 --- a/Mage/pom.xml +++ b/Mage/pom.xml @@ -37,6 +37,11 @@ ormlite-jdbc 4.42 + + net.sf.trove4j + trove4j + 3.0.3 + diff --git a/Mage/src/mage/abilities/costs/mana/ManaCostsImpl.java b/Mage/src/mage/abilities/costs/mana/ManaCostsImpl.java index 393dba8f0e..0caacf25d2 100644 --- a/Mage/src/mage/abilities/costs/mana/ManaCostsImpl.java +++ b/Mage/src/mage/abilities/costs/mana/ManaCostsImpl.java @@ -44,6 +44,7 @@ import mage.target.Targets; /** * @author BetaSteward_at_googlemail.com + * @param */ public class ManaCostsImpl extends ArrayList implements ManaCosts { diff --git a/Mage/src/mage/actions/MageDrawAction.java b/Mage/src/mage/actions/MageDrawAction.java index b193596449..3c2d604455 100644 --- a/Mage/src/mage/actions/MageDrawAction.java +++ b/Mage/src/mage/actions/MageDrawAction.java @@ -12,6 +12,7 @@ import mage.players.Player; import java.util.List; import java.util.UUID; +import mage.util.CardUtil; /** * Action for drawing cards. @@ -22,7 +23,7 @@ public class MageDrawAction extends MageAction { private final Player player; private final int amount; - private ArrayList appliedEffects; + private final ArrayList appliedEffects; private List drawnCards; private static final int NEGATIVE_VALUE = -1000000; @@ -37,6 +38,7 @@ public class MageDrawAction extends MageAction { * Draw and set action score. * * @param game Game context. + * @return */ @Override public int doAction(Game game) { @@ -51,7 +53,7 @@ public class MageDrawAction extends MageAction { score += value; } if (numDrawn > 0) { - game.fireInformEvent(player.getName() + " draws " + Integer.toString(numDrawn) + " card" + (numDrawn > 1 ? "s" : "")); + game.fireInformEvent(player.getName() + " draws " + CardUtil.numberToText(numDrawn, "a") + " card" + (numDrawn > 1 ? "s" : "")); } if (player.isEmptyDraw()) { game.doAction(new MageLoseGameAction(player, MageLoseGameAction.DRAW_REASON)); diff --git a/Mage/src/mage/util/CardUtil.java b/Mage/src/mage/util/CardUtil.java index 86df65bbd7..3101d6c03c 100644 --- a/Mage/src/mage/util/CardUtil.java +++ b/Mage/src/mage/util/CardUtil.java @@ -351,8 +351,25 @@ public class CardUtil { * Converts an integer number to string * Numbers > 20 will be returned as digits * + * @param number + * @return */ public static String numberToText(int number) { + return numberToText(number, "one"); + } + + /** + * Converts an integer number to string like "one", "two", "three", ... + * Numbers > 20 will be returned as digits + * + * @param number number to convert to text + * @param forOne if the number is 1, this string will be returnedinstead of "one". + * @return + */ + public static String numberToText(int number, String forOne) { + if (number == 1 && forOne != null) { + return forOne; + } if (number >= 0 && number < 21) { return numberStrings[number]; } @@ -368,11 +385,7 @@ public class CardUtil { public static String numberToText(String number, String forOne) { if (checkNumeric(number)) { - int intNumber = Integer.parseInt(number); - if (forOne != null && intNumber == 1) { - return forOne; - } - return numberToText(intNumber); + return numberToText(Integer.parseInt(number)); } return number; }