change getLibrary().size() > 0 to hasCards()

This commit is contained in:
ingmargoudt 2017-03-07 17:28:26 +01:00
parent d6e4ef793e
commit 1caf3a6be4
131 changed files with 186 additions and 220 deletions

View file

@ -121,7 +121,7 @@ class KinshipBaseEffect extends OneShotEffect {
Player controller = game.getPlayer(source.getControllerId());
Permanent sourcePermanent = game.getPermanentOrLKIBattlefield(source.getSourceId());
if (controller != null && sourcePermanent != null) {
if (controller.getLibrary().size() > 0) {
if (controller.getLibrary().hasCards()) {
Card card = controller.getLibrary().getFromTop(game);
if (card != null) {
Cards cards = new CardsImpl(card);

View file

@ -48,7 +48,7 @@ public class TopLibraryCardTypeCondition implements Condition {
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null && controller.getLibrary().size() > 0) {
if (controller != null && controller.getLibrary().hasCards()) {
Card card = controller.getLibrary().getFromTop(game);
if (card != null) {
switch (this.type) {

View file

@ -128,7 +128,7 @@ public class ClashEffect extends OneShotEffect implements MageSingleton {
// Reveal top cards of involved players
StringBuilder message = new StringBuilder("Clash: ");
message.append(controller.getLogName());
if (controller.getLibrary().size() > 0) {
if (controller.getLibrary().hasCards()) {
Cards cards = new CardsImpl();
cardController = controller.getLibrary().getFromTop(game);
cards.add(cardController);
@ -139,7 +139,7 @@ public class ClashEffect extends OneShotEffect implements MageSingleton {
message.append(" no card");
}
message.append(" vs. ").append(opponent.getLogName());
if (opponent.getLibrary().size() > 0) {
if (opponent.getLibrary().hasCards()) {
Cards cards = new CardsImpl();
cardOpponent = opponent.getLibrary().getFromTop(game);
cards.add(cardOpponent);

View file

@ -89,7 +89,7 @@ public class RevealCardsFromLibraryUntilEffect extends OneShotEffect {
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
MageObject sourceObject = game.getObject(source.getSourceId());
if (controller != null && controller.getLibrary().size() > 0) {
if (controller != null && controller.getLibrary().hasCards()) {
Cards cards = new CardsImpl();
Library library = controller.getLibrary();
Card card = null;
@ -98,7 +98,7 @@ public class RevealCardsFromLibraryUntilEffect extends OneShotEffect {
if (card != null) {
cards.add(card);
}
} while (library.size() > 0 && card != null && !filter.match(card, game));
} while (library.hasCards() && card != null && !filter.match(card, game));
// reveal cards
if (!cards.isEmpty()) {
controller.revealCards(sourceObject.getIdName(), cards, game);

View file

@ -34,7 +34,7 @@ public class RevealTopLandToBattlefieldElseHandEffect extends OneShotEffect {
if (sourceObject == null || controller == null) {
return false;
}
if (controller.getLibrary().size() > 0) {
if (controller.getLibrary().hasCards()) {
CardsImpl cards = new CardsImpl();
Card card = controller.getLibrary().getFromTop(game);
if (card == null) {

View file

@ -40,6 +40,7 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
import mage.cards.Card;
import mage.constants.Zone;
import mage.filter.FilterCard;
@ -47,7 +48,6 @@ import mage.game.Game;
import mage.util.RandomUtil;
/**
*
* @author BetaSteward_at_googlemail.com
*/
public class Library implements Serializable {
@ -255,6 +255,11 @@ public class Library implements Serializable {
return null;
}
public boolean hasCards() {
return size() > 0;
}
public void reset() {
this.emptyDraw = false;
}

View file

@ -2685,7 +2685,7 @@ public abstract class PlayerImpl implements Player, Serializable {
for (UUID playerInRangeId : game.getState().getPlayersInRange(getId(), game)) {
Player player = game.getPlayer(playerInRangeId);
if (player != null) {
if (player.isTopCardRevealed() && player.getLibrary().size() > 0) {
if (player.isTopCardRevealed() && player.getLibrary().hasCards()) {
Card card = player.getLibrary().getFromTop(game);
if (game.getContinuousEffects().asThough(card.getId(), AsThoughEffectType.PLAY_FROM_NOT_OWN_HAND_ZONE, getId(), game)) {
for (ActivatedAbility ability : card.getAbilities().getActivatedAbilities(Zone.HAND)) {