replace [list].size() == 0 and [string].length() == 0 to use .isEmpty() instead

This commit is contained in:
ingmargoudt 2016-09-14 15:27:03 +02:00
parent 3612332607
commit 3128bd2b4b
48 changed files with 90 additions and 109 deletions

View file

@ -85,7 +85,7 @@ public class DraftGrid extends javax.swing.JPanel implements MouseListener {
} }
public void loadBooster(CardsView booster, BigCard bigCard) { public void loadBooster(CardsView booster, BigCard bigCard) {
if (booster instanceof CardsView && booster.size() == 0) { if (booster instanceof CardsView && booster.isEmpty()) {
emptyGrid = true; emptyGrid = true;
} else { } else {
if (!emptyGrid) { if (!emptyGrid) {

View file

@ -126,7 +126,7 @@ public class ChoiceDialog extends IDialogPanel {
} }
private void displayCards(CardsView cards, UUID gameId, BigCard bigCard) { private void displayCards(CardsView cards, UUID gameId, BigCard bigCard) {
if (cards.size() == 0) { if (cards.isEmpty()) {
return; return;
} }

View file

@ -103,7 +103,7 @@ public class StackDialog extends IDialogPanel {
private void displayStack(CardsView cards, UUID gameId, BigCard bigCard) { private void displayStack(CardsView cards, UUID gameId, BigCard bigCard) {
if (cards == null || cards.size() == 0) { if (cards == null || cards.isEmpty()) {
return; return;
} }

View file

@ -259,7 +259,7 @@ public class ResetPasswordDialog extends MageDialog {
}// </editor-fold>//GEN-END:initComponents }// </editor-fold>//GEN-END:initComponents
private void btnGetAuthTokenActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnGetAuthTokenActionPerformed private void btnGetAuthTokenActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnGetAuthTokenActionPerformed
if (this.txtEmail.getText().length() == 0) { if (this.txtEmail.getText().isEmpty()) {
MageFrame.getInstance().showError("Please enter an email address."); MageFrame.getInstance().showError("Please enter an email address.");
return; return;
} }
@ -275,15 +275,15 @@ public class ResetPasswordDialog extends MageDialog {
}//GEN-LAST:event_btnGetAuthTokenActionPerformed }//GEN-LAST:event_btnGetAuthTokenActionPerformed
private void btnSubmitNewPasswordActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSubmitNewPasswordActionPerformed private void btnSubmitNewPasswordActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSubmitNewPasswordActionPerformed
if (this.txtEmail.getText().length() == 0) { if (this.txtEmail.getText().isEmpty()) {
MageFrame.getInstance().showError("Please enter an email address."); MageFrame.getInstance().showError("Please enter an email address.");
return; return;
} }
if (this.txtAuthToken.getText().length() == 0) { if (this.txtAuthToken.getText().isEmpty()) {
MageFrame.getInstance().showError("Please enter an auth token."); MageFrame.getInstance().showError("Please enter an auth token.");
return; return;
} }
if (this.txtPassword.getText().length() == 0) { if (this.txtPassword.getText().isEmpty()) {
MageFrame.getInstance().showError("Please enter a new password."); MageFrame.getInstance().showError("Please enter a new password.");
return; return;
} }

View file

@ -166,7 +166,7 @@ public class TournamentPlayerPanel extends javax.swing.JPanel {
private void cbPlayerTypeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cbPlayerTypeActionPerformed private void cbPlayerTypeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cbPlayerTypeActionPerformed
if (!this.cbPlayerType.getSelectedItem().equals("Human")) { if (!this.cbPlayerType.getSelectedItem().equals("Human")) {
this.pnlPlayerName.setVisible(true); this.pnlPlayerName.setVisible(true);
if (this.txtPlayerName.getText().length() == 0) { if (this.txtPlayerName.getText().isEmpty()) {
this.txtPlayerName.setText("Computer " + this.lblPlayerNum.getText()); this.txtPlayerName.setText("Computer " + this.lblPlayerNum.getText());
} }
} }

View file

@ -153,7 +153,7 @@ public class GlowText extends JLabel {
@Override @Override
public void paint(Graphics g) { public void paint(Graphics g) {
if (getText().length() == 0) { if (getText().isEmpty()) {
return; return;
} }

View file

@ -217,7 +217,7 @@ public class ManaSymbols {
loadSymbolsImages(symbolWidth); loadSymbolsImages(symbolWidth);
} }
Map<String, BufferedImage> sizedSymbols = manaImages.get(symbolWidth); Map<String, BufferedImage> sizedSymbols = manaImages.get(symbolWidth);
if (manaCost.length() == 0) { if (manaCost.isEmpty()) {
return; return;
} }
manaCost = manaCost.replace("\\", ""); manaCost = manaCost.replace("\\", "");

View file

@ -98,7 +98,7 @@ public class DownloadPictures extends DefaultBoundedRangeModel implements Runnab
ArrayList<CardDownloadData> cards = getNeededCards(allCards); ArrayList<CardDownloadData> cards = getNeededCards(allCards);
/* /*
* if (cards == null || cards.size() == 0) { * if (cards == null || cards.isEmpty()) {
* JOptionPane.showMessageDialog(null, * JOptionPane.showMessageDialog(null,
* "All card pictures have been downloaded."); return; } * "All card pictures have been downloaded."); return; }
*/ */

View file

@ -27,22 +27,6 @@
*/ */
package mage.remote; package mage.remote;
import java.io.IOException;
import java.lang.reflect.UndeclaredThrowableException;
import java.net.Authenticator;
import java.net.ConnectException;
import java.net.MalformedURLException;
import java.net.PasswordAuthentication;
import java.net.SocketException;
import java.net.SocketTimeoutException;
import java.util.Collection;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
import java.util.concurrent.TimeUnit;
import mage.MageException; import mage.MageException;
import mage.cards.decks.DeckCardLists; import mage.cards.decks.DeckCardLists;
import mage.cards.decks.InvalidDeckException; import mage.cards.decks.InvalidDeckException;
@ -62,22 +46,9 @@ import mage.interfaces.ServerState;
import mage.interfaces.callback.ClientCallback; import mage.interfaces.callback.ClientCallback;
import mage.players.net.UserData; import mage.players.net.UserData;
import mage.utils.CompressUtil; import mage.utils.CompressUtil;
import mage.view.DraftPickView; import mage.view.*;
import mage.view.GameTypeView;
import mage.view.MatchView;
import mage.view.RoomUsersView;
import mage.view.TableView;
import mage.view.TournamentTypeView;
import mage.view.TournamentView;
import mage.view.UserView;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import org.jboss.remoting.CannotConnectException; import org.jboss.remoting.*;
import org.jboss.remoting.Client;
import org.jboss.remoting.ConnectionListener;
import org.jboss.remoting.ConnectionValidator;
import org.jboss.remoting.InvocationFailureException;
import org.jboss.remoting.InvokerLocator;
import org.jboss.remoting.Remoting;
import org.jboss.remoting.callback.Callback; import org.jboss.remoting.callback.Callback;
import org.jboss.remoting.callback.HandleCallbackException; import org.jboss.remoting.callback.HandleCallbackException;
import org.jboss.remoting.callback.InvokerCallbackHandler; import org.jboss.remoting.callback.InvokerCallbackHandler;
@ -85,6 +56,12 @@ import org.jboss.remoting.transport.bisocket.Bisocket;
import org.jboss.remoting.transport.socket.SocketWrapper; import org.jboss.remoting.transport.socket.SocketWrapper;
import org.jboss.remoting.transporter.TransporterClient; import org.jboss.remoting.transporter.TransporterClient;
import java.io.IOException;
import java.lang.reflect.UndeclaredThrowableException;
import java.net.*;
import java.util.*;
import java.util.concurrent.TimeUnit;
/** /**
* *
* @author BetaSteward_at_googlemail.com * @author BetaSteward_at_googlemail.com

View file

@ -185,7 +185,7 @@ public class ComputerPlayer6 extends ComputerPlayer /*implements Player*/ {
if (logger.isInfoEnabled()) { if (logger.isInfoEnabled()) {
printOutState(game); printOutState(game);
} }
if (actions.size() == 0) { if (actions.isEmpty()) {
calculateActions(game); calculateActions(game);
} }
act(game); act(game);
@ -351,7 +351,7 @@ public class ComputerPlayer6 extends ComputerPlayer /*implements Player*/ {
/* /*
* // Try to fix horizon effect if (root.combat == null || * // Try to fix horizon effect if (root.combat == null ||
* root.combat.getAttackers().size() == 0) { * root.combat.getAttackers().isEmpty()) {
* FilterCreatureForAttack attackFilter = new * FilterCreatureForAttack attackFilter = new
* FilterCreatureForAttack(); * FilterCreatureForAttack();
* attackFilter.getControllerId().add(playerId); List<Permanent> * attackFilter.getControllerId().add(playerId); List<Permanent>

View file

@ -105,7 +105,7 @@ public class ComputerPlayer7 extends ComputerPlayer6 {
case PRECOMBAT_MAIN: case PRECOMBAT_MAIN:
if (game.getActivePlayerId().equals(playerId)) { if (game.getActivePlayerId().equals(playerId)) {
printOutState(game); printOutState(game);
if (actions.size() == 0) { if (actions.isEmpty()) {
logger.info("Sim Calculate pre combat actions ----------------------------------------------------- "); logger.info("Sim Calculate pre combat actions ----------------------------------------------------- ");
calculatePreCombatActions(game); calculatePreCombatActions(game);
} }
@ -122,7 +122,7 @@ public class ComputerPlayer7 extends ComputerPlayer6 {
case DECLARE_ATTACKERS: case DECLARE_ATTACKERS:
if (!game.getActivePlayerId().equals(playerId)) { if (!game.getActivePlayerId().equals(playerId)) {
printOutState(game); printOutState(game);
if (actions.size() == 0) { if (actions.isEmpty()) {
logger.info("Sim Calculate declare attackers actions ----------------------------------------------------- "); logger.info("Sim Calculate declare attackers actions ----------------------------------------------------- ");
calculatePreCombatActions(game); calculatePreCombatActions(game);
} }
@ -142,7 +142,7 @@ public class ComputerPlayer7 extends ComputerPlayer6 {
case POSTCOMBAT_MAIN: case POSTCOMBAT_MAIN:
// if (game.getActivePlayerId().equals(playerId)) { // if (game.getActivePlayerId().equals(playerId)) {
printOutState(game); printOutState(game);
if (actions.size() == 0) { if (actions.isEmpty()) {
calculatePostCombatActions(game); calculatePostCombatActions(game);
} }
act(game); act(game);

View file

@ -117,7 +117,7 @@ public class ComputerPlayer2 extends ComputerPlayer implements Player {
case COMBAT_DAMAGE: case COMBAT_DAMAGE:
case END_COMBAT: case END_COMBAT:
case POSTCOMBAT_MAIN: case POSTCOMBAT_MAIN:
if (actions.size() == 0) { if (actions.isEmpty()) {
calculateActions(game); calculateActions(game);
} }
act(game); act(game);
@ -131,7 +131,7 @@ public class ComputerPlayer2 extends ComputerPlayer implements Player {
} }
protected void act(Game game) { protected void act(Game game) {
if (actions == null || actions.size() == 0) if (actions == null || actions.isEmpty())
pass(game); pass(game);
else { else {
boolean usedStack = false; boolean usedStack = false;

View file

@ -78,7 +78,7 @@ public class ComputerPlayer3 extends ComputerPlayer2 implements Player {
return false; return false;
case PRECOMBAT_MAIN: case PRECOMBAT_MAIN:
if (game.getActivePlayerId().equals(playerId)) { if (game.getActivePlayerId().equals(playerId)) {
if (actions.size() == 0) { if (actions.isEmpty()) {
calculatePreCombatActions(game); calculatePreCombatActions(game);
} }
act(game); act(game);
@ -92,7 +92,7 @@ public class ComputerPlayer3 extends ComputerPlayer2 implements Player {
return false; return false;
case DECLARE_ATTACKERS: case DECLARE_ATTACKERS:
if (!game.getActivePlayerId().equals(playerId)) { if (!game.getActivePlayerId().equals(playerId)) {
if (actions.size() == 0) { if (actions.isEmpty()) {
calculatePreCombatActions(game); calculatePreCombatActions(game);
} }
act(game); act(game);
@ -109,7 +109,7 @@ public class ComputerPlayer3 extends ComputerPlayer2 implements Player {
return false; return false;
case POSTCOMBAT_MAIN: case POSTCOMBAT_MAIN:
if (game.getActivePlayerId().equals(playerId)) { if (game.getActivePlayerId().equals(playerId)) {
if (actions.size() == 0) { if (actions.isEmpty()) {
calculatePostCombatActions(game); calculatePostCombatActions(game);
} }
act(game); act(game);

View file

@ -63,7 +63,7 @@ public class GmailClient {
} }
public static boolean sendMessage(String email, String subject, String text) { public static boolean sendMessage(String email, String subject, String text) {
if (email.length() == 0) { if (email.isEmpty()) {
logger.info("Email is not sent because the address is empty"); logger.info("Email is not sent because the address is empty");
return false; return false;
} }

View file

@ -15,7 +15,7 @@ public class MailClient {
private static final Logger logger = Logger.getLogger(Main.class); private static final Logger logger = Logger.getLogger(Main.class);
public static boolean sendMessage(String email, String subject, String text) { public static boolean sendMessage(String email, String subject, String text) {
if (email.length() == 0) { if (email.isEmpty()) {
logger.info("Email is not sent because the address is empty"); logger.info("Email is not sent because the address is empty");
return false; return false;
} }

View file

@ -14,7 +14,7 @@ public class MailgunClient {
private static final Logger logger = Logger.getLogger(Main.class); private static final Logger logger = Logger.getLogger(Main.class);
public static boolean sendMessage(String email, String subject, String text) { public static boolean sendMessage(String email, String subject, String text) {
if (email.length() == 0) { if (email.isEmpty()) {
logger.info("Email is not sent because the address is empty"); logger.info("Email is not sent because the address is empty");
return false; return false;
} }

View file

@ -55,7 +55,7 @@ public class SystemUtil {
try { try {
while (scanner.hasNextLine()) { while (scanner.hasNextLine()) {
String line = scanner.nextLine().trim(); String line = scanner.nextLine().trim();
if (line.trim().length() == 0 || line.startsWith("#")) { if (line.trim().isEmpty() || line.startsWith("#")) {
continue; continue;
} }

View file

@ -95,7 +95,7 @@ class CreaturesYouControlBecomesTargetTriggeredAbility extends TriggeredAbilityI
if (object != null && object instanceof Spell) { if (object != null && object instanceof Spell) {
Card c = (Spell) object; Card c = (Spell) object;
if (c.getCardType().contains(CardType.INSTANT) || c.getCardType().contains(CardType.SORCERY)) { if (c.getCardType().contains(CardType.INSTANT) || c.getCardType().contains(CardType.SORCERY)) {
if (getTargets().size() == 0) { if (getTargets().isEmpty()) {
for (Effect effect : getEffects()) { for (Effect effect : getEffects()) {
effect.setTargetPointer(new FixedTarget(event.getTargetId())); effect.setTargetPointer(new FixedTarget(event.getTargetId()));
} }

View file

@ -102,7 +102,7 @@ class NezumiGraverobberFlipEffect extends OneShotEffect {
if (card != null) { if (card != null) {
Player player = game.getPlayer(card.getOwnerId()); Player player = game.getPlayer(card.getOwnerId());
if (player != null) { if (player != null) {
if (player.getGraveyard().size() == 0) { if (player.getGraveyard().isEmpty()) {
return new FlipSourceEffect(new NighteyesTheDesecratorToken()).apply(game, source); return new FlipSourceEffect(new NighteyesTheDesecratorToken()).apply(game, source);
} }
} }

View file

@ -112,7 +112,7 @@ class DesecratorHagEffect extends OneShotEffect {
} }
} }
} }
if (cards.size() == 0) { if (cards.isEmpty()) {
return true; return true;
} }
if (cards.size() > 1 if (cards.size() > 1

View file

@ -85,7 +85,7 @@ class OpponentHasNoCardsInHandCondition implements Condition {
if (player != null) { if (player != null) {
for (UUID playerId : game.getOpponents(source.getControllerId())) { for (UUID playerId : game.getOpponents(source.getControllerId())) {
Player opponent = game.getPlayer(playerId); Player opponent = game.getPlayer(playerId);
if (opponent != null && opponent.getHand().size() == 0) { if (opponent != null && opponent.getHand().isEmpty()) {
return true; return true;
} }
} }

View file

@ -86,7 +86,7 @@ class DingusEggTriggeredAbility extends TriggeredAbilityImpl {
if (zEvent.getFromZone() == Zone.BATTLEFIELD if (zEvent.getFromZone() == Zone.BATTLEFIELD
&& zEvent.getToZone() == Zone.GRAVEYARD && zEvent.getToZone() == Zone.GRAVEYARD
&& zEvent.getTarget().getCardType().contains(CardType.LAND)) { && zEvent.getTarget().getCardType().contains(CardType.LAND)) {
if (getTargets().size() == 0) { if (getTargets().isEmpty()) {
UUID targetId = zEvent.getTarget().getControllerId(); UUID targetId = zEvent.getTarget().getControllerId();
for (Effect effect : this.getEffects()) { for (Effect effect : this.getEffects()) {
effect.setTargetPointer(new FixedTarget(targetId)); effect.setTargetPointer(new FixedTarget(targetId));

View file

@ -84,7 +84,7 @@ class GorillaTitanCondition implements Condition {
Player p = game.getPlayer(source.getControllerId()); Player p = game.getPlayer(source.getControllerId());
if (p != null) if (p != null)
{ {
return p.getGraveyard().size() == 0; return p.getGraveyard().isEmpty();
} }
return false; return false;
} }

View file

@ -102,7 +102,7 @@ class CloneShellEffect extends OneShotEffect {
cards.add(card); cards.add(card);
} }
if (cards.size() == 0) { if (cards.isEmpty()) {
return false; return false;
} }

View file

@ -89,7 +89,7 @@ class AEtherFlashTriggeredAbility extends TriggeredAbilityImpl {
UUID targetId = event.getTargetId(); UUID targetId = event.getTargetId();
Permanent permanent = game.getPermanent(targetId); Permanent permanent = game.getPermanent(targetId);
if (filter.match(permanent, getSourceId(), getControllerId(), game)) { if (filter.match(permanent, getSourceId(), getControllerId(), game)) {
if (getTargets().size() == 0) { if (getTargets().isEmpty()) {
for (Effect effect : this.getEffects()) { for (Effect effect : this.getEffects()) {
effect.setTargetPointer(new FixedTarget(targetId)); effect.setTargetPointer(new FixedTarget(targetId));
} }

View file

@ -134,7 +134,7 @@ class HollowbornBarghestTriggeredAbility extends TriggeredAbilityImpl {
public boolean checkTrigger(GameEvent event, Game game) { public boolean checkTrigger(GameEvent event, Game game) {
if (game.getOpponents(controllerId).contains(event.getPlayerId())) { if (game.getOpponents(controllerId).contains(event.getPlayerId())) {
Player opponent = game.getPlayer(event.getPlayerId()); Player opponent = game.getPlayer(event.getPlayerId());
if (opponent != null && opponent.getHand().size() == 0) { if (opponent != null && opponent.getHand().isEmpty()) {
opponent.loseLife(2, game); opponent.loseLife(2, game);
return true; return true;
} }

View file

@ -100,7 +100,7 @@ class ImmortalCoilAbility extends StateTriggeredAbility {
@Override @Override
public boolean checkTrigger(GameEvent event, Game game) { public boolean checkTrigger(GameEvent event, Game game) {
Player player = game.getPlayer(this.getControllerId()); Player player = game.getPlayer(this.getControllerId());
return player != null && player.getGraveyard().size() == 0; return player != null && player.getGraveyard().isEmpty();
} }
@Override @Override

View file

@ -94,7 +94,7 @@ class RivalryTriggeredAbility extends TriggeredAbilityImpl {
@Override @Override
public boolean checkTrigger(GameEvent event, Game game) { public boolean checkTrigger(GameEvent event, Game game) {
if (getTargets().size() == 0) { if (getTargets().isEmpty()) {
for (Effect effect : this.getEffects()) { for (Effect effect : this.getEffects()) {
effect.setTargetPointer(new FixedTarget(event.getPlayerId())); effect.setTargetPointer(new FixedTarget(event.getPlayerId()));
} }

View file

@ -133,7 +133,7 @@ class QuestForTheNihilStoneTriggeredAbility2 extends TriggeredAbilityImpl {
if (game.getOpponents(controllerId).contains(event.getPlayerId())) { if (game.getOpponents(controllerId).contains(event.getPlayerId())) {
Player opponent = game.getPlayer(event.getPlayerId()); Player opponent = game.getPlayer(event.getPlayerId());
if (opponent != null if (opponent != null
&& opponent.getHand().size() == 0 && opponent.getHand().isEmpty()
&& quest.getCounters(game).getCount(CounterType.QUEST) >= 2) { && quest.getCounters(game).getCount(CounterType.QUEST) >= 2) {
for (Effect effect : this.getEffects()) { for (Effect effect : this.getEffects()) {
effect.setTargetPointer(new FixedTarget(opponent.getId())); effect.setTargetPointer(new FixedTarget(opponent.getId()));

View file

@ -90,7 +90,7 @@ class GuulDrazSpecterCondition implements Condition {
Set<UUID> opponents = game.getOpponents(source.getControllerId()); Set<UUID> opponents = game.getOpponents(source.getControllerId());
for (UUID opponentId : opponents) { for (UUID opponentId : opponents) {
result |= game.getPlayer(opponentId).getHand().size() == 0; result |= game.getPlayer(opponentId).getHand().isEmpty();
} }
return result; return result;

View file

@ -45,7 +45,7 @@ public class BeginningOfCombatTriggeredAbility extends TriggeredAbilityImpl {
case YOU: case YOU:
boolean yours = event.getPlayerId().equals(this.controllerId); boolean yours = event.getPlayerId().equals(this.controllerId);
if (yours && setTargetPointer) { if (yours && setTargetPointer) {
if (getTargets().size() == 0) { if (getTargets().isEmpty()) {
for (Effect effect : this.getEffects()) { for (Effect effect : this.getEffects()) {
effect.setTargetPointer(new FixedTarget(event.getPlayerId())); effect.setTargetPointer(new FixedTarget(event.getPlayerId()));
} }

View file

@ -77,7 +77,7 @@ public class BeginningOfDrawTriggeredAbility extends TriggeredAbilityImpl {
case YOU: case YOU:
boolean yours = event.getPlayerId().equals(this.controllerId); boolean yours = event.getPlayerId().equals(this.controllerId);
if (yours) { if (yours) {
if (getTargets().size() == 0) { if (getTargets().isEmpty()) {
for (Effect effect : this.getEffects()) { for (Effect effect : this.getEffects()) {
effect.setTargetPointer(new FixedTarget(event.getPlayerId())); effect.setTargetPointer(new FixedTarget(event.getPlayerId()));
} }
@ -86,7 +86,7 @@ public class BeginningOfDrawTriggeredAbility extends TriggeredAbilityImpl {
return yours; return yours;
case OPPONENT: case OPPONENT:
if (game.getPlayer(this.controllerId).hasOpponent(event.getPlayerId(), game)) { if (game.getPlayer(this.controllerId).hasOpponent(event.getPlayerId(), game)) {
if (getTargets().size() == 0) { if (getTargets().isEmpty()) {
for (Effect effect : this.getEffects()) { for (Effect effect : this.getEffects()) {
effect.setTargetPointer(new FixedTarget(event.getPlayerId())); effect.setTargetPointer(new FixedTarget(event.getPlayerId()));
} }
@ -96,7 +96,7 @@ public class BeginningOfDrawTriggeredAbility extends TriggeredAbilityImpl {
break; break;
case NOT_YOU: case NOT_YOU:
if (!this.controllerId.equals(event.getPlayerId())) { if (!this.controllerId.equals(event.getPlayerId())) {
if (getTargets().size() == 0) { if (getTargets().isEmpty()) {
for (Effect effect : this.getEffects()) { for (Effect effect : this.getEffects()) {
effect.setTargetPointer(new FixedTarget(event.getPlayerId())); effect.setTargetPointer(new FixedTarget(event.getPlayerId()));
} }
@ -109,7 +109,7 @@ public class BeginningOfDrawTriggeredAbility extends TriggeredAbilityImpl {
if (attachment != null && attachment.getAttachedTo() != null) { if (attachment != null && attachment.getAttachedTo() != null) {
Permanent attachedTo = game.getPermanent(attachment.getAttachedTo()); Permanent attachedTo = game.getPermanent(attachment.getAttachedTo());
if (attachedTo != null && attachedTo.getControllerId().equals(event.getPlayerId())) { if (attachedTo != null && attachedTo.getControllerId().equals(event.getPlayerId())) {
if (getTargets().size() == 0) { if (getTargets().isEmpty()) {
for (Effect effect : this.getEffects()) { for (Effect effect : this.getEffects()) {
effect.setTargetPointer(new FixedTarget(event.getPlayerId())); effect.setTargetPointer(new FixedTarget(event.getPlayerId()));
} }
@ -119,7 +119,7 @@ public class BeginningOfDrawTriggeredAbility extends TriggeredAbilityImpl {
} }
break; break;
case ANY: case ANY:
if (getTargets().size() == 0) { if (getTargets().isEmpty()) {
for (Effect effect : this.getEffects()) { for (Effect effect : this.getEffects()) {
effect.setTargetPointer(new FixedTarget(event.getPlayerId())); effect.setTargetPointer(new FixedTarget(event.getPlayerId()));
} }

View file

@ -54,7 +54,7 @@ public class BeginningOfPreCombatMainTriggeredAbility extends TriggeredAbilityIm
case YOU: case YOU:
boolean yours = event.getPlayerId().equals(this.controllerId); boolean yours = event.getPlayerId().equals(this.controllerId);
if (yours && setTargetPointer) { if (yours && setTargetPointer) {
if (getTargets().size() == 0) { if (getTargets().isEmpty()) {
for (Effect effect : this.getEffects()) { for (Effect effect : this.getEffects()) {
effect.setTargetPointer(new FixedTarget(event.getPlayerId())); effect.setTargetPointer(new FixedTarget(event.getPlayerId()));
} }

View file

@ -71,7 +71,7 @@ public class BeginningOfUntapTriggeredAbility extends TriggeredAbilityImpl {
break; break;
case OPPONENT: case OPPONENT:
if (game.getPlayer(this.controllerId).hasOpponent(event.getPlayerId(), game)) { if (game.getPlayer(this.controllerId).hasOpponent(event.getPlayerId(), game)) {
if (getTargets().size() == 0) { if (getTargets().isEmpty()) {
for (Effect effect : this.getEffects()) { for (Effect effect : this.getEffects()) {
effect.setTargetPointer(new FixedTarget(event.getPlayerId())); effect.setTargetPointer(new FixedTarget(event.getPlayerId()));
} }
@ -82,7 +82,7 @@ public class BeginningOfUntapTriggeredAbility extends TriggeredAbilityImpl {
case ANY: case ANY:
controller = game.getPlayer(this.getControllerId()); controller = game.getPlayer(this.getControllerId());
if (controller != null && controller.getInRange().contains(event.getPlayerId())) { if (controller != null && controller.getInRange().contains(event.getPlayerId())) {
if (getTargets().size() == 0) { if (getTargets().isEmpty()) {
for (Effect effect : this.getEffects()) { for (Effect effect : this.getEffects()) {
effect.setTargetPointer(new FixedTarget(event.getPlayerId())); effect.setTargetPointer(new FixedTarget(event.getPlayerId()));
} }

View file

@ -41,7 +41,7 @@ public class HellbentCondition implements Condition {
@Override @Override
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
return game.getPlayer(source.getControllerId()).getHand().size() == 0; return game.getPlayer(source.getControllerId()).getHand().isEmpty();
} }
@Override @Override

View file

@ -70,7 +70,7 @@ public class CostsImpl<T extends Cost> extends ArrayList<T> implements Costs<T>
if (text != null) { if (text != null) {
return text; return text;
} }
if (this.size() == 0) { if (this.isEmpty()) {
return ""; return "";
} }

View file

@ -262,11 +262,11 @@ public class ManaCostsImpl<T extends ManaCost> extends ArrayList<T> implements M
// First try only to pay colored mana with the pool // First try only to pay colored mana with the pool
for (ManaCost cost : this) { for (ManaCost cost : this) {
if (!cost.isPaid() && cost instanceof MonoHybridManaCost) { if (!cost.isPaid() && cost instanceof MonoHybridManaCost) {
if (((((MonoHybridManaCost) cost).containsColor(ColoredManaSymbol.W)) && pool.getWhite() > 0) if (((cost.containsColor(ColoredManaSymbol.W)) && pool.getWhite() > 0)
|| ((((MonoHybridManaCost) cost).containsColor(ColoredManaSymbol.B)) && pool.getBlack() > 0) || ((cost.containsColor(ColoredManaSymbol.B)) && pool.getBlack() > 0)
|| ((((MonoHybridManaCost) cost).containsColor(ColoredManaSymbol.R)) && pool.getRed() > 0) || ((cost.containsColor(ColoredManaSymbol.R)) && pool.getRed() > 0)
|| ((((MonoHybridManaCost) cost).containsColor(ColoredManaSymbol.G)) && pool.getGreen() > 0) || ((cost.containsColor(ColoredManaSymbol.G)) && pool.getGreen() > 0)
|| ((((MonoHybridManaCost) cost).containsColor(ColoredManaSymbol.U)) && pool.getBlue() > 0)) { || ((cost.containsColor(ColoredManaSymbol.U)) && pool.getBlue() > 0)) {
cost.assignPayment(game, ability, pool, costToPay); cost.assignPayment(game, ability, pool, costToPay);
if (pool.count() == 0) { if (pool.count() == 0) {
return; return;
@ -315,12 +315,12 @@ public class ManaCostsImpl<T extends ManaCost> extends ArrayList<T> implements M
public final void load(String mana) { public final void load(String mana) {
this.clear(); this.clear();
if (costs.containsKey(mana)) { if (costs.containsKey(mana)) {
ManaCosts<T> savedCosts = costs.get(mana); ManaCosts<ManaCost> savedCosts = costs.get(mana);
for (ManaCost cost : savedCosts) { for (ManaCost cost : savedCosts) {
this.add((T) cost.copy()); this.add(cost.copy());
} }
} else { } else {
if (mana == null || mana.length() == 0) { if (mana == null || mana.isEmpty()) {
return; return;
} }
String[] symbols = mana.split("^\\{|\\}\\{|\\}$"); String[] symbols = mana.split("^\\{|\\}\\{|\\}$");
@ -347,11 +347,11 @@ public class ManaCostsImpl<T extends ManaCost> extends ArrayList<T> implements M
this.add(new VariableManaCost(modifierForX)); this.add(new VariableManaCost(modifierForX));
} //TODO: handle multiple {X} and/or {Y} symbols } //TODO: handle multiple {X} and/or {Y} symbols
} else if (Character.isDigit(symbol.charAt(0))) { } else if (Character.isDigit(symbol.charAt(0))) {
this.add((T) new MonoHybridManaCost(ColoredManaSymbol.lookup(symbol.charAt(2)))); this.add(new MonoHybridManaCost(ColoredManaSymbol.lookup(symbol.charAt(2))));
} else if (symbol.contains("P")) { } else if (symbol.contains("P")) {
this.add((T) new PhyrexianManaCost(ColoredManaSymbol.lookup(symbol.charAt(0)))); this.add(new PhyrexianManaCost(ColoredManaSymbol.lookup(symbol.charAt(0))));
} else { } else {
this.add((T) new HybridManaCost(ColoredManaSymbol.lookup(symbol.charAt(0)), ColoredManaSymbol.lookup(symbol.charAt(2)))); this.add(new HybridManaCost(ColoredManaSymbol.lookup(symbol.charAt(0)), ColoredManaSymbol.lookup(symbol.charAt(2))));
} }
} }
} }
@ -392,7 +392,7 @@ public class ManaCostsImpl<T extends ManaCost> extends ArrayList<T> implements M
if (text != null) { if (text != null) {
return text; return text;
} }
if (this.size() == 0) { if (this.isEmpty()) {
return ""; return "";
} }

View file

@ -110,7 +110,7 @@ public class CounterUnlessPaysEffect extends OneShotEffect {
} }
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
if (mode.getTargets().size() == 0) { if (mode.getTargets().isEmpty()) {
sb.append("counter it"); sb.append("counter it");
} else { } else {
sb.append("Counter target ").append(mode.getTargets().get(0).getTargetName()); sb.append("Counter target ").append(mode.getTargets().get(0).getTargetName());

View file

@ -45,7 +45,7 @@ public class DckDeckImporter extends DeckImporter {
@Override @Override
protected void readLine(String line, DeckCardLists deckList) { protected void readLine(String line, DeckCardLists deckList) {
if (line.length() == 0 || line.startsWith("#")) { if (line.isEmpty() || line.startsWith("#")) {
return; return;
} }

View file

@ -40,7 +40,7 @@ public class DecDeckImporter extends DeckImporter {
@Override @Override
protected void readLine(String line, DeckCardLists deckList) { protected void readLine(String line, DeckCardLists deckList) {
if (line.length() == 0 || line.startsWith("//")) { if (line.isEmpty() || line.startsWith("//")) {
return; return;
} }

View file

@ -13,7 +13,7 @@ public class DekDeckImporter extends DeckImporter {
@Override @Override
protected void readLine(String line, DeckCardLists deckList) { protected void readLine(String line, DeckCardLists deckList) {
if (line.length() == 0 || line.startsWith("#") || !line.contains("<Cards CatID")) { if (line.isEmpty() || line.startsWith("#") || !line.contains("<Cards CatID")) {
return; return;
} }
try { try {

View file

@ -44,7 +44,7 @@ public class MWSDeckImporter extends DeckImporter {
@Override @Override
protected void readLine(String line, DeckCardLists deckList) { protected void readLine(String line, DeckCardLists deckList) {
if (line.length() == 0 || line.startsWith("//")) { if (line.isEmpty() || line.startsWith("//")) {
return; return;
} }
boolean sideboard = false; boolean sideboard = false;

View file

@ -61,7 +61,7 @@ public class TxtDeckImporter extends DeckImporter {
// Start the sideboard on empty line that follows // Start the sideboard on empty line that follows
// at least 1 non-empty line // at least 1 non-empty line
if (line.length() == 0 && nonEmptyLinesTotal > 0) { if (line.isEmpty() && nonEmptyLinesTotal > 0) {
sideboard = true; sideboard = true;
return; return;
} else { } else {

View file

@ -55,11 +55,11 @@ public class FilterPermanentOrPlayerWithCounter extends FilterPermanentOrPlayer
@Override @Override
public boolean match(MageItem o, Game game) { public boolean match(MageItem o, Game game) {
if (o instanceof Player) { if (o instanceof Player) {
if (((Player)o).getCounters().size() == 0) { if (((Player)o).getCounters().isEmpty()) {
return false; return false;
} }
} else if (o instanceof Permanent) { } else if (o instanceof Permanent) {
if (((Permanent)o).getCounters(game).size() == 0) { if (((Permanent)o).getCounters(game).isEmpty()) {
return false; return false;
} }
} }

View file

@ -28,7 +28,7 @@
package mage.game.tournament; package mage.game.tournament;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map.Entry;
import java.util.UUID; import java.util.UUID;
import mage.constants.TournamentPlayerState; import mage.constants.TournamentPlayerState;
@ -49,7 +49,7 @@ public abstract class TournamentSwiss extends TournamentImpl {
@Override @Override
protected void runTournament() { protected void runTournament() {
for (Map.Entry<UUID, TournamentPlayer> entry : players.entrySet()) { for (Entry<UUID, TournamentPlayer> entry : players.entrySet()) {
if (entry.getValue().getPlayer().autoLoseGame()) { if (entry.getValue().getPlayer().autoLoseGame()) {
entry.getValue().setEliminated(); entry.getValue().setEliminated();
entry.getValue().setResults("Auto Eliminated"); entry.getValue().setResults("Auto Eliminated");

View file

@ -474,4 +474,8 @@ public class ManaPool implements Serializable {
} }
return false; return false;
} }
public boolean isEmpty(){
return count() == 0;
}
} }

View file

@ -2536,7 +2536,7 @@ public abstract class PlayerImpl implements Player, Serializable {
} }
} }
if (manaCosts.size() == 0) { if (manaCosts.isEmpty()) {
return true; return true;
} else { } else {
if (available == null) { if (available == null) {
@ -2567,7 +2567,7 @@ public abstract class PlayerImpl implements Player, Serializable {
} }
} }
if (manaCosts.size() == 0) { if (manaCosts.isEmpty()) {
return true; return true;
} else { } else {
for (Mana mana : manaCosts.getOptions()) { for (Mana mana : manaCosts.getOptions()) {
@ -2604,7 +2604,7 @@ public abstract class PlayerImpl implements Player, Serializable {
} }
} }
if (manaCosts.size() == 0) { if (manaCosts.isEmpty()) {
return true; return true;
} else { } else {
for (Mana mana : manaCosts.getOptions()) { for (Mana mana : manaCosts.getOptions()) {

View file

@ -80,13 +80,13 @@ public class TargetPermanentOrPlayerWithCounter extends TargetPermanentOrPlayer
public boolean canTarget(UUID id, Game game) { public boolean canTarget(UUID id, Game game) {
Permanent permanent = game.getPermanent(id); Permanent permanent = game.getPermanent(id);
if (permanent != null) { if (permanent != null) {
if (permanent.getCounters(game).size() == 0) { if (permanent.getCounters(game).isEmpty()) {
return false; return false;
} }
} }
Player player = game.getPlayer(id); Player player = game.getPlayer(id);
if (player != null) { if (player != null) {
if (player.getCounters().size() == 0) { if (player.getCounters().isEmpty()) {
return false; return false;
} }
} }
@ -97,13 +97,13 @@ public class TargetPermanentOrPlayerWithCounter extends TargetPermanentOrPlayer
public boolean canTarget(UUID id, Ability source, Game game) { public boolean canTarget(UUID id, Ability source, Game game) {
Permanent permanent = game.getPermanent(id); Permanent permanent = game.getPermanent(id);
if (permanent != null) { if (permanent != null) {
if (permanent.getCounters(game).size() == 0) { if (permanent.getCounters(game).isEmpty()) {
return false; return false;
} }
} }
Player player = game.getPlayer(id); Player player = game.getPlayer(id);
if (player != null) { if (player != null) {
if (player.getCounters().size() == 0) { if (player.getCounters().isEmpty()) {
return false; return false;
} }
} }