mirror of
https://github.com/magefree/mage.git
synced 2025-12-25 04:52:07 -08:00
Merge pull request #2268 from ingmargoudt/master
replace [list].size() == 0 and [string].length() == 0 to use .isEmpty…
This commit is contained in:
commit
eae53c0cfc
48 changed files with 90 additions and 109 deletions
|
|
@ -45,7 +45,7 @@ public class BeginningOfCombatTriggeredAbility extends TriggeredAbilityImpl {
|
|||
case YOU:
|
||||
boolean yours = event.getPlayerId().equals(this.controllerId);
|
||||
if (yours && setTargetPointer) {
|
||||
if (getTargets().size() == 0) {
|
||||
if (getTargets().isEmpty()) {
|
||||
for (Effect effect : this.getEffects()) {
|
||||
effect.setTargetPointer(new FixedTarget(event.getPlayerId()));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -77,7 +77,7 @@ public class BeginningOfDrawTriggeredAbility extends TriggeredAbilityImpl {
|
|||
case YOU:
|
||||
boolean yours = event.getPlayerId().equals(this.controllerId);
|
||||
if (yours) {
|
||||
if (getTargets().size() == 0) {
|
||||
if (getTargets().isEmpty()) {
|
||||
for (Effect effect : this.getEffects()) {
|
||||
effect.setTargetPointer(new FixedTarget(event.getPlayerId()));
|
||||
}
|
||||
|
|
@ -86,7 +86,7 @@ public class BeginningOfDrawTriggeredAbility extends TriggeredAbilityImpl {
|
|||
return yours;
|
||||
case OPPONENT:
|
||||
if (game.getPlayer(this.controllerId).hasOpponent(event.getPlayerId(), game)) {
|
||||
if (getTargets().size() == 0) {
|
||||
if (getTargets().isEmpty()) {
|
||||
for (Effect effect : this.getEffects()) {
|
||||
effect.setTargetPointer(new FixedTarget(event.getPlayerId()));
|
||||
}
|
||||
|
|
@ -96,7 +96,7 @@ public class BeginningOfDrawTriggeredAbility extends TriggeredAbilityImpl {
|
|||
break;
|
||||
case NOT_YOU:
|
||||
if (!this.controllerId.equals(event.getPlayerId())) {
|
||||
if (getTargets().size() == 0) {
|
||||
if (getTargets().isEmpty()) {
|
||||
for (Effect effect : this.getEffects()) {
|
||||
effect.setTargetPointer(new FixedTarget(event.getPlayerId()));
|
||||
}
|
||||
|
|
@ -109,7 +109,7 @@ public class BeginningOfDrawTriggeredAbility extends TriggeredAbilityImpl {
|
|||
if (attachment != null && attachment.getAttachedTo() != null) {
|
||||
Permanent attachedTo = game.getPermanent(attachment.getAttachedTo());
|
||||
if (attachedTo != null && attachedTo.getControllerId().equals(event.getPlayerId())) {
|
||||
if (getTargets().size() == 0) {
|
||||
if (getTargets().isEmpty()) {
|
||||
for (Effect effect : this.getEffects()) {
|
||||
effect.setTargetPointer(new FixedTarget(event.getPlayerId()));
|
||||
}
|
||||
|
|
@ -119,7 +119,7 @@ public class BeginningOfDrawTriggeredAbility extends TriggeredAbilityImpl {
|
|||
}
|
||||
break;
|
||||
case ANY:
|
||||
if (getTargets().size() == 0) {
|
||||
if (getTargets().isEmpty()) {
|
||||
for (Effect effect : this.getEffects()) {
|
||||
effect.setTargetPointer(new FixedTarget(event.getPlayerId()));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@ public class BeginningOfPreCombatMainTriggeredAbility extends TriggeredAbilityIm
|
|||
case YOU:
|
||||
boolean yours = event.getPlayerId().equals(this.controllerId);
|
||||
if (yours && setTargetPointer) {
|
||||
if (getTargets().size() == 0) {
|
||||
if (getTargets().isEmpty()) {
|
||||
for (Effect effect : this.getEffects()) {
|
||||
effect.setTargetPointer(new FixedTarget(event.getPlayerId()));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -71,7 +71,7 @@ public class BeginningOfUntapTriggeredAbility extends TriggeredAbilityImpl {
|
|||
break;
|
||||
case OPPONENT:
|
||||
if (game.getPlayer(this.controllerId).hasOpponent(event.getPlayerId(), game)) {
|
||||
if (getTargets().size() == 0) {
|
||||
if (getTargets().isEmpty()) {
|
||||
for (Effect effect : this.getEffects()) {
|
||||
effect.setTargetPointer(new FixedTarget(event.getPlayerId()));
|
||||
}
|
||||
|
|
@ -82,7 +82,7 @@ public class BeginningOfUntapTriggeredAbility extends TriggeredAbilityImpl {
|
|||
case ANY:
|
||||
controller = game.getPlayer(this.getControllerId());
|
||||
if (controller != null && controller.getInRange().contains(event.getPlayerId())) {
|
||||
if (getTargets().size() == 0) {
|
||||
if (getTargets().isEmpty()) {
|
||||
for (Effect effect : this.getEffects()) {
|
||||
effect.setTargetPointer(new FixedTarget(event.getPlayerId()));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ public class HellbentCondition implements Condition {
|
|||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
return game.getPlayer(source.getControllerId()).getHand().size() == 0;
|
||||
return game.getPlayer(source.getControllerId()).getHand().isEmpty();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -70,7 +70,7 @@ public class CostsImpl<T extends Cost> extends ArrayList<T> implements Costs<T>
|
|||
if (text != null) {
|
||||
return text;
|
||||
}
|
||||
if (this.size() == 0) {
|
||||
if (this.isEmpty()) {
|
||||
return "";
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
for (ManaCost cost : this) {
|
||||
if (!cost.isPaid() && cost instanceof MonoHybridManaCost) {
|
||||
if (((((MonoHybridManaCost) cost).containsColor(ColoredManaSymbol.W)) && pool.getWhite() > 0)
|
||||
|| ((((MonoHybridManaCost) cost).containsColor(ColoredManaSymbol.B)) && pool.getBlack() > 0)
|
||||
|| ((((MonoHybridManaCost) cost).containsColor(ColoredManaSymbol.R)) && pool.getRed() > 0)
|
||||
|| ((((MonoHybridManaCost) cost).containsColor(ColoredManaSymbol.G)) && pool.getGreen() > 0)
|
||||
|| ((((MonoHybridManaCost) cost).containsColor(ColoredManaSymbol.U)) && pool.getBlue() > 0)) {
|
||||
if (((cost.containsColor(ColoredManaSymbol.W)) && pool.getWhite() > 0)
|
||||
|| ((cost.containsColor(ColoredManaSymbol.B)) && pool.getBlack() > 0)
|
||||
|| ((cost.containsColor(ColoredManaSymbol.R)) && pool.getRed() > 0)
|
||||
|| ((cost.containsColor(ColoredManaSymbol.G)) && pool.getGreen() > 0)
|
||||
|| ((cost.containsColor(ColoredManaSymbol.U)) && pool.getBlue() > 0)) {
|
||||
cost.assignPayment(game, ability, pool, costToPay);
|
||||
if (pool.count() == 0) {
|
||||
return;
|
||||
|
|
@ -315,12 +315,12 @@ public class ManaCostsImpl<T extends ManaCost> extends ArrayList<T> implements M
|
|||
public final void load(String mana) {
|
||||
this.clear();
|
||||
if (costs.containsKey(mana)) {
|
||||
ManaCosts<T> savedCosts = costs.get(mana);
|
||||
ManaCosts<ManaCost> savedCosts = costs.get(mana);
|
||||
for (ManaCost cost : savedCosts) {
|
||||
this.add((T) cost.copy());
|
||||
this.add(cost.copy());
|
||||
}
|
||||
} else {
|
||||
if (mana == null || mana.length() == 0) {
|
||||
if (mana == null || mana.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
String[] symbols = mana.split("^\\{|\\}\\{|\\}$");
|
||||
|
|
@ -347,11 +347,11 @@ public class ManaCostsImpl<T extends ManaCost> extends ArrayList<T> implements M
|
|||
this.add(new VariableManaCost(modifierForX));
|
||||
} //TODO: handle multiple {X} and/or {Y} symbols
|
||||
} 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")) {
|
||||
this.add((T) new PhyrexianManaCost(ColoredManaSymbol.lookup(symbol.charAt(0))));
|
||||
this.add(new PhyrexianManaCost(ColoredManaSymbol.lookup(symbol.charAt(0))));
|
||||
} 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) {
|
||||
return text;
|
||||
}
|
||||
if (this.size() == 0) {
|
||||
if (this.isEmpty()) {
|
||||
return "";
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -110,7 +110,7 @@ public class CounterUnlessPaysEffect extends OneShotEffect {
|
|||
}
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
if (mode.getTargets().size() == 0) {
|
||||
if (mode.getTargets().isEmpty()) {
|
||||
sb.append("counter it");
|
||||
} else {
|
||||
sb.append("Counter target ").append(mode.getTargets().get(0).getTargetName());
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ public class DckDeckImporter extends DeckImporter {
|
|||
@Override
|
||||
protected void readLine(String line, DeckCardLists deckList) {
|
||||
|
||||
if (line.length() == 0 || line.startsWith("#")) {
|
||||
if (line.isEmpty() || line.startsWith("#")) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ public class DecDeckImporter extends DeckImporter {
|
|||
|
||||
@Override
|
||||
protected void readLine(String line, DeckCardLists deckList) {
|
||||
if (line.length() == 0 || line.startsWith("//")) {
|
||||
if (line.isEmpty() || line.startsWith("//")) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ public class DekDeckImporter extends DeckImporter {
|
|||
@Override
|
||||
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;
|
||||
}
|
||||
try {
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ public class MWSDeckImporter extends DeckImporter {
|
|||
|
||||
@Override
|
||||
protected void readLine(String line, DeckCardLists deckList) {
|
||||
if (line.length() == 0 || line.startsWith("//")) {
|
||||
if (line.isEmpty() || line.startsWith("//")) {
|
||||
return;
|
||||
}
|
||||
boolean sideboard = false;
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ public class TxtDeckImporter extends DeckImporter {
|
|||
|
||||
// Start the sideboard on empty line that follows
|
||||
// at least 1 non-empty line
|
||||
if (line.length() == 0 && nonEmptyLinesTotal > 0) {
|
||||
if (line.isEmpty() && nonEmptyLinesTotal > 0) {
|
||||
sideboard = true;
|
||||
return;
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -55,11 +55,11 @@ public class FilterPermanentOrPlayerWithCounter extends FilterPermanentOrPlayer
|
|||
@Override
|
||||
public boolean match(MageItem o, Game game) {
|
||||
if (o instanceof Player) {
|
||||
if (((Player)o).getCounters().size() == 0) {
|
||||
if (((Player)o).getCounters().isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
} else if (o instanceof Permanent) {
|
||||
if (((Permanent)o).getCounters(game).size() == 0) {
|
||||
if (((Permanent)o).getCounters(game).isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@
|
|||
package mage.game.tournament;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.UUID;
|
||||
|
||||
import mage.constants.TournamentPlayerState;
|
||||
|
|
@ -49,7 +49,7 @@ public abstract class TournamentSwiss extends TournamentImpl {
|
|||
|
||||
@Override
|
||||
protected void runTournament() {
|
||||
for (Map.Entry<UUID, TournamentPlayer> entry : players.entrySet()) {
|
||||
for (Entry<UUID, TournamentPlayer> entry : players.entrySet()) {
|
||||
if (entry.getValue().getPlayer().autoLoseGame()) {
|
||||
entry.getValue().setEliminated();
|
||||
entry.getValue().setResults("Auto Eliminated");
|
||||
|
|
|
|||
|
|
@ -474,4 +474,8 @@ public class ManaPool implements Serializable {
|
|||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isEmpty(){
|
||||
return count() == 0;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2536,7 +2536,7 @@ public abstract class PlayerImpl implements Player, Serializable {
|
|||
}
|
||||
}
|
||||
|
||||
if (manaCosts.size() == 0) {
|
||||
if (manaCosts.isEmpty()) {
|
||||
return true;
|
||||
} else {
|
||||
if (available == null) {
|
||||
|
|
@ -2567,7 +2567,7 @@ public abstract class PlayerImpl implements Player, Serializable {
|
|||
}
|
||||
}
|
||||
|
||||
if (manaCosts.size() == 0) {
|
||||
if (manaCosts.isEmpty()) {
|
||||
return true;
|
||||
} else {
|
||||
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;
|
||||
} else {
|
||||
for (Mana mana : manaCosts.getOptions()) {
|
||||
|
|
|
|||
|
|
@ -80,13 +80,13 @@ public class TargetPermanentOrPlayerWithCounter extends TargetPermanentOrPlayer
|
|||
public boolean canTarget(UUID id, Game game) {
|
||||
Permanent permanent = game.getPermanent(id);
|
||||
if (permanent != null) {
|
||||
if (permanent.getCounters(game).size() == 0) {
|
||||
if (permanent.getCounters(game).isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
Player player = game.getPlayer(id);
|
||||
if (player != null) {
|
||||
if (player.getCounters().size() == 0) {
|
||||
if (player.getCounters().isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
@ -97,13 +97,13 @@ public class TargetPermanentOrPlayerWithCounter extends TargetPermanentOrPlayer
|
|||
public boolean canTarget(UUID id, Ability source, Game game) {
|
||||
Permanent permanent = game.getPermanent(id);
|
||||
if (permanent != null) {
|
||||
if (permanent.getCounters(game).size() == 0) {
|
||||
if (permanent.getCounters(game).isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
Player player = game.getPlayer(id);
|
||||
if (player != null) {
|
||||
if (player.getCounters().size() == 0) {
|
||||
if (player.getCounters().isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue