mirror of
https://github.com/correl/mage.git
synced 2024-12-24 11:50:45 +00:00
change some size() comparisons, to isEmpty()
This commit is contained in:
parent
5ba206111a
commit
eb0cfc94f8
23 changed files with 35 additions and 36 deletions
|
@ -352,7 +352,7 @@ public class MageBook extends JComponent {
|
|||
List<Plane> planes = getPlanes(currentPage, currentSet, numTokensEmblems);
|
||||
int numPlanes = 0;
|
||||
|
||||
if (planes != null && planes.size() > 0) {
|
||||
if (!planes.isEmpty()) {
|
||||
int size = planes.size();
|
||||
numPlanes = size;
|
||||
Rectangle rectangle = new Rectangle();
|
||||
|
@ -523,7 +523,7 @@ public class MageBook extends JComponent {
|
|||
// second run for empty numbers
|
||||
int countHave = haveNumbers.size();
|
||||
int countNotHave = 0;
|
||||
if (cards.size() > 0) {
|
||||
if (!cards.isEmpty()) {
|
||||
for (int i = startNumber; i <= endNumber; i++) {
|
||||
if (!haveNumbers.contains(i)) {
|
||||
countNotHave++;
|
||||
|
@ -593,8 +593,8 @@ public class MageBook extends JComponent {
|
|||
}
|
||||
|
||||
private List<Emblem> getEmblems(int page, String set, int numTokensEmblems) {
|
||||
ArrayList<CardDownloadData> allEmblems = getTokenCardUrls();
|
||||
ArrayList<Emblem> emblems = new ArrayList<>();
|
||||
List<CardDownloadData> allEmblems = getTokenCardUrls();
|
||||
List<Emblem> emblems = new ArrayList<>();
|
||||
|
||||
for (CardDownloadData emblem : allEmblems) {
|
||||
if (emblem.getSet().equals(set)) {
|
||||
|
@ -650,8 +650,8 @@ public class MageBook extends JComponent {
|
|||
}
|
||||
|
||||
private List<Plane> getPlanes(int page, String set, int numTokensEmblems) {
|
||||
ArrayList<CardDownloadData> allPlanes = getTokenCardUrls();
|
||||
ArrayList<Plane> planes = new ArrayList<>();
|
||||
List<CardDownloadData> allPlanes = getTokenCardUrls();
|
||||
List<Plane> planes = new ArrayList<>();
|
||||
|
||||
for (CardDownloadData plane : allPlanes) {
|
||||
if (plane.getSet().equals(set)) {
|
||||
|
|
|
@ -198,7 +198,7 @@ public class RandomPacksSelectorDialog extends javax.swing.JDialog {
|
|||
public void doApply() {
|
||||
if (getSelectedPacks().size() < 2 && isRandomDraft) {
|
||||
JOptionPane.showMessageDialog(this, "At least 2 sets must be selected", "Error", JOptionPane.ERROR_MESSAGE);
|
||||
} else if (getSelectedPacks().size() < 1 && isRichManDraft) {
|
||||
} else if (getSelectedPacks().isEmpty() && isRichManDraft) {
|
||||
JOptionPane.showMessageDialog(this, "At least 1 set must be selected", "Error", JOptionPane.ERROR_MESSAGE);
|
||||
} else {
|
||||
this.setVisible(false);
|
||||
|
|
|
@ -1212,7 +1212,7 @@ public final class GamePanel extends javax.swing.JPanel {
|
|||
needPlayable = new HashSet<>();
|
||||
}
|
||||
|
||||
if (needChoosen.size() == 0 && needSelectable.size() == 0 && needPlayable.size() == 0) {
|
||||
if (needChoosen.isEmpty() && needSelectable.isEmpty() && needPlayable.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -365,7 +365,7 @@ public class HelperPanel extends JPanel {
|
|||
this.mainPanel.setOpaque(false);
|
||||
}
|
||||
|
||||
if (buttons.size() == 0) {
|
||||
if (buttons.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -140,7 +140,7 @@ public class PlayerPanelExt extends javax.swing.JPanel {
|
|||
private boolean isCardsPlayable(Collection<CardView> cards, GameView gameView, Set<UUID> possibleTargets) {
|
||||
if (cards != null) {
|
||||
// can play
|
||||
if (gameView != null && gameView.getCanPlayObjects() != null && gameView.getCanPlayObjects().size() > 0) {
|
||||
if (gameView != null && gameView.getCanPlayObjects() != null && !gameView.getCanPlayObjects().isEmpty()) {
|
||||
for (CardView card : cards) {
|
||||
if (gameView.getCanPlayObjects().contains(card.getId())) {
|
||||
return true;
|
||||
|
@ -148,7 +148,7 @@ public class PlayerPanelExt extends javax.swing.JPanel {
|
|||
}
|
||||
}
|
||||
// can select
|
||||
if (possibleTargets != null && possibleTargets.size() > 0) {
|
||||
if (possibleTargets != null && !possibleTargets.isEmpty()) {
|
||||
for (CardView card : cards) {
|
||||
if (possibleTargets.contains(card.getId())) {
|
||||
return true;
|
||||
|
|
|
@ -145,7 +145,7 @@ public enum CopyPasteImageSource implements CardImageSource {
|
|||
final CopyPasteImageSourceDialog dialog = new CopyPasteImageSourceDialog();
|
||||
dialog.pack();
|
||||
int count = 0;
|
||||
if (viewMissingCards && missingCards.size() > 0 && singleLinks.size() == 0) {
|
||||
if (viewMissingCards && !missingCards.isEmpty() && singleLinks.isEmpty()) {
|
||||
viewMissingCards = false;
|
||||
String displayMissingCardsStr = "Up to the first 20 cards are:\n";
|
||||
String missingCardsStr = "";
|
||||
|
@ -228,7 +228,7 @@ public enum CopyPasteImageSource implements CardImageSource {
|
|||
public ArrayList<String> getSupportedSets() {
|
||||
setupLinks();
|
||||
ArrayList<String> supportedSetsCopy = new ArrayList<>();
|
||||
if (supportedSets.size() == 0) {
|
||||
if (supportedSets.isEmpty()) {
|
||||
for (String setCode : Sets.getInstance().keySet()) {
|
||||
supportedSets.add(setCode);
|
||||
}
|
||||
|
|
|
@ -238,16 +238,16 @@ public class GathererSets implements Iterable<DownloadJob> {
|
|||
// 2. missing rarity icon:
|
||||
// WARNING, need too much time (60+ secs), only for debug mode
|
||||
///*
|
||||
if ((set.getCardsByRarity(Rarity.COMMON).size() > 0) && !res.haveCommon) {
|
||||
if (!set.getCardsByRarity(Rarity.COMMON).isEmpty() && !res.haveCommon) {
|
||||
logger.error(String.format("Symbols: set have common cards, but don't download icon: %s (%s)", set.getCode(), set.getName()));
|
||||
}
|
||||
if ((set.getCardsByRarity(Rarity.UNCOMMON).size() > 0) && !res.haveUncommon) {
|
||||
if (!set.getCardsByRarity(Rarity.UNCOMMON).isEmpty() && !res.haveUncommon) {
|
||||
logger.error(String.format("Symbols: set have uncommon cards, but don't download icon: %s (%s)", set.getCode(), set.getName()));
|
||||
}
|
||||
if ((set.getCardsByRarity(Rarity.RARE).size() > 0) && !res.haveRare) {
|
||||
if (!set.getCardsByRarity(Rarity.RARE).isEmpty() && !res.haveRare) {
|
||||
logger.error(String.format("Symbols: set have rare cards, but don't download icon: %s (%s)", set.getCode(), set.getName()));
|
||||
}
|
||||
if ((set.getCardsByRarity(Rarity.MYTHIC).size() > 0) && !res.haveMyth) {
|
||||
if (!set.getCardsByRarity(Rarity.MYTHIC).isEmpty() && !res.haveMyth) {
|
||||
logger.error(String.format("Symbols: set have mythic cards, but don't download icon: %s (%s)", set.getCode(), set.getName()));
|
||||
}
|
||||
//*/
|
||||
|
|
|
@ -115,7 +115,7 @@ public class Commander extends Constructed {
|
|||
}
|
||||
}
|
||||
|
||||
if (deck.getSideboard().size() < 1 || deck.getSideboard().size() > 2) {
|
||||
if (deck.getSideboard().isEmpty() || deck.getSideboard().size() > 2) {
|
||||
if ((deck.getSideboard().size() > 1 && !partnerAllowed)) {
|
||||
invalid.put("Commander", "You may only have one commander");
|
||||
}
|
||||
|
|
|
@ -68,7 +68,7 @@ public class FreeformCommander extends Constructed {
|
|||
}
|
||||
}
|
||||
|
||||
if (deck.getSideboard().size() < 1 || deck.getSideboard().size() > 2) {
|
||||
if (deck.getSideboard().isEmpty() || deck.getSideboard().size() > 2) {
|
||||
invalid.put("Commander", "Sideboard must contain only the commander(s)");
|
||||
valid = false;
|
||||
} else {
|
||||
|
|
|
@ -134,11 +134,11 @@ public class Oathbreaker extends Vintage {
|
|||
}
|
||||
|
||||
// check size (1+1 or 2+2 allows)
|
||||
if (commanderNames.size() == 0 || commanderNames.size() > 2) {
|
||||
if (commanderNames.isEmpty() || commanderNames.size() > 2) {
|
||||
invalid.put("Oathbreaker", "Sideboard must contains 1 or 2 oathbreakers, but found: " + commanderNames.size());
|
||||
valid = false;
|
||||
}
|
||||
if (signatureSpells.size() == 0 || signatureSpells.size() > 2) {
|
||||
if (signatureSpells.isEmpty() || signatureSpells.size() > 2) {
|
||||
invalid.put("Signature Spell", "Sideboard must contains 1 or 2 signature spells, but found: " + signatureSpells.size());
|
||||
valid = false;
|
||||
}
|
||||
|
|
|
@ -79,7 +79,7 @@ public class PennyDreadfulCommander extends Constructed {
|
|||
}
|
||||
}
|
||||
|
||||
if (deck.getSideboard().size() < 1 || deck.getSideboard().size() > 2) {
|
||||
if (deck.getSideboard().isEmpty() || deck.getSideboard().size() > 2) {
|
||||
invalid.put("Commander", "Sideboard must contain only the commander(s)");
|
||||
valid = false;
|
||||
} else {
|
||||
|
|
|
@ -1960,7 +1960,7 @@ public class ComputerPlayer extends PlayerImpl implements Player {
|
|||
final int DECK_SIZE = deckMinSize != 0 ? deckMinSize : 40;
|
||||
|
||||
List<Card> sortedCards = new ArrayList<>(cardPool);
|
||||
if (sortedCards.size() > 0) {
|
||||
if (!sortedCards.isEmpty()) {
|
||||
while (deck.getCards().size() < DECK_SIZE) {
|
||||
deck.getCards().add(sortedCards.get(RandomUtil.nextInt(sortedCards.size())));
|
||||
}
|
||||
|
|
|
@ -68,7 +68,7 @@ class AncestralKnowledgeEffect extends OneShotEffect {
|
|||
Player controller = game.getPlayer(source.getControllerId());
|
||||
if (controller != null) {
|
||||
Cards cards = new CardsImpl(controller.getLibrary().getTopCards(game, 10));
|
||||
if (cards.size() > 0) {
|
||||
if (!cards.isEmpty()) {
|
||||
controller.lookAtCards(source, null, cards, game);
|
||||
TargetCard target = new TargetCard(0, Integer.MAX_VALUE, Zone.LIBRARY, new FilterCard("cards to exile"));
|
||||
controller.choose(Outcome.Exile, cards, target, game);
|
||||
|
|
|
@ -81,7 +81,7 @@ class BandTogetherEffect extends OneShotEffect {
|
|||
return false;
|
||||
}
|
||||
|
||||
Permanent permanentDamage1 = damageTarget.getTargets().size() < 1 ? null : game.getPermanent(damageTarget.getTargets().get(0));
|
||||
Permanent permanentDamage1 = damageTarget.getTargets().isEmpty() ? null : game.getPermanent(damageTarget.getTargets().get(0));
|
||||
Permanent permanentDamage2 = damageTarget.getTargets().size() < 2 ? null : game.getPermanent(damageTarget.getTargets().get(1));
|
||||
Permanent permanentDest = game.getPermanent(destTarget.getTargets().get(0));
|
||||
if (permanentDest == null) {
|
||||
|
|
|
@ -107,7 +107,7 @@ class CephalidSnitchEffect extends LoseAbilityTargetEffect{
|
|||
objectColors.add(o);
|
||||
}
|
||||
//Construct a card filter excluding black
|
||||
if(objectColors.size() > 0) {
|
||||
if(!objectColors.isEmpty()) {
|
||||
FilterCard filter = new FilterCard(filterNameAssembler(objectColors));
|
||||
if (objectColors.size() == 1)
|
||||
filter.add(new ColorPredicate(objectColors.get(0)));
|
||||
|
|
|
@ -125,7 +125,7 @@ class CurseOfThePiercedHeartEffect extends OneShotEffect {
|
|||
if (opponent == null) {
|
||||
return false;
|
||||
}
|
||||
if (game.getBattlefield().getAllActivePermanents(new FilterPlaneswalkerPermanent(), opponentId, game).size() > 0) {
|
||||
if (!game.getBattlefield().getAllActivePermanents(new FilterPlaneswalkerPermanent(), opponentId, game).isEmpty()) {
|
||||
if (controller.chooseUse(Outcome.Damage, "Redirect to a planeswalker controlled by " + opponent.getLogName() + "?", source, game)) {
|
||||
FilterPlaneswalkerPermanent filter = new FilterPlaneswalkerPermanent("a planeswalker controlled by " + opponent.getLogName());
|
||||
filter.add(new ControllerIdPredicate(opponentId));
|
||||
|
|
|
@ -77,7 +77,7 @@ class ElementalAppealEffect extends OneShotEffect {
|
|||
for (UUID tokenId : effect.getLastAddedTokenIds()) {
|
||||
predList.add(new CardIdPredicate(tokenId));
|
||||
}
|
||||
if (predList.size() > 0) {
|
||||
if (!predList.isEmpty()) {
|
||||
FilterCreaturePermanent filter = new FilterCreaturePermanent();
|
||||
filter.add(Predicates.or(predList));
|
||||
game.addEffect(new BoostAllEffect(7, 0, Duration.EndOfTurn, filter, false), source);
|
||||
|
|
|
@ -70,7 +70,7 @@ enum FaceOfDivinityCondition implements Condition {
|
|||
Permanent currentAura = game.getPermanent(source.getSourceId());
|
||||
if (currentAura != null && currentAura.getAttachedTo() != null) {
|
||||
Permanent permanent = game.getPermanent(currentAura.getAttachedTo());
|
||||
if (permanent != null && permanent.getAttachments().size() > 0) {
|
||||
if (permanent != null && !permanent.getAttachments().isEmpty()) {
|
||||
for (UUID id : permanent.getAttachments()) {
|
||||
Permanent otherAura = game.getPermanent(id);
|
||||
if (otherAura != null && !otherAura.getId().equals(currentAura.getId())
|
||||
|
|
|
@ -120,7 +120,7 @@ class FinaleOfPromiseEffect extends OneShotEffect {
|
|||
}
|
||||
|
||||
// ask to cast order
|
||||
if (cardsToCast.size() > 0) {
|
||||
if (!cardsToCast.isEmpty()) {
|
||||
String cardsOrder = cardsToCast.stream()
|
||||
.map(game::getCard)
|
||||
.filter(Objects::nonNull)
|
||||
|
|
|
@ -69,8 +69,8 @@ class FloodOfTearsEffect extends OneShotEffect {
|
|||
StaticFilters.FILTER_PERMANENT_NON_LAND, source.getControllerId(), source.getSourceId(), game
|
||||
);
|
||||
Cards cards = new CardsImpl();
|
||||
if (nonlands.size() > 0) {
|
||||
nonlands.stream().forEach(permanent -> cards.add(permanent));
|
||||
if (!nonlands.isEmpty()) {
|
||||
nonlands.forEach(cards::add);
|
||||
boolean putIntoPlay = nonlands.stream()
|
||||
.filter(permanent -> permanent.isControlledBy(player.getId()))
|
||||
.filter(permanent -> !(permanent instanceof Token))
|
||||
|
|
|
@ -75,7 +75,7 @@ class GeodeGolemEffect extends OneShotEffect {
|
|||
}
|
||||
}
|
||||
|
||||
if (possibleCommanders.size() == 0) {
|
||||
if (possibleCommanders.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -106,7 +106,7 @@ class KarnPlus1Effect extends OneShotEffect {
|
|||
cards.remove(cardToHand);
|
||||
}
|
||||
|
||||
if (cards.size() > 0) {
|
||||
if (!cards.isEmpty()) {
|
||||
controller.moveCards(cards, Zone.EXILED, source, game);
|
||||
for (Card c : cards.getCards(game)) {
|
||||
c.addCounters(CounterType.SILVER.createInstance(1), source, game);
|
||||
|
@ -156,7 +156,6 @@ class KarnMinus1Effect extends OneShotEffect {
|
|||
return true;
|
||||
}
|
||||
|
||||
Set<Card> filtered = new HashSet<Card>();
|
||||
Cards filteredCards = new CardsImpl();
|
||||
|
||||
for (Card exileCard : exile) {
|
||||
|
|
|
@ -75,7 +75,7 @@ class KheruMindEaterExileEffect extends OneShotEffect {
|
|||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player player = game.getPlayer(targetPointer.getFirst(game, source));
|
||||
if (player != null && player.getHand().size() > 0) {
|
||||
if (player != null && !player.getHand().isEmpty()) {
|
||||
Target target = new TargetCardInHand(1, new FilterCard());
|
||||
target.chooseTarget(Outcome.Exile, player.getId(), source, game);
|
||||
Card card = game.getCard(target.getFirstTarget());
|
||||
|
|
Loading…
Reference in a new issue