Tabnine Logo
Cards.removeAll
Code IndexAdd Tabnine to your IDE (free)

How to use
removeAll
method
in
mage.cards.Cards

Best Java code snippets using mage.cards.Cards.removeAll (Showing top 20 results out of 315)

origin: magefree/mage

@Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
  Player player = game.getPlayer(event.getPlayerId());
  if (player != null) {
    Cards revealedCards = new CardsImpl(player.getLibrary().getTopCards(game, 3));
    player.revealCards(source, revealedCards, game);
    Cards creatures = new CardsImpl(revealedCards.getCards(StaticFilters.FILTER_CARD_CREATURE, game));
    player.moveCards(creatures, Zone.HAND, source, game);
    revealedCards.removeAll(creatures);
    player.putCardsOnBottomOfLibrary(revealedCards, game, source, true);
    return true;
  }
  return false;
}
origin: magefree/mage

  @Override
  public boolean apply(Game game, Ability source) {
    String cardName = (String) game.getState().getValue(source.getSourceId().toString() + ChooseACardNameEffect.INFO_KEY);
    Player player = game.getPlayer(source.getControllerId());
    if (player == null || cardName == null) {
      return false;
    }
    Cards cardsToExile = new CardsImpl(player.getLibrary().getTopCards(game, 7));
    player.revealCards(source, cardsToExile, game);
    FilterCard filter = new FilterCard();
    filter.add(new NamePredicate(cardName));
    Cards cardsToKeep = new CardsImpl(cardsToExile.getCards(filter, game));
    cardsToExile.removeAll(cardsToKeep);
    player.moveCards(cardsToKeep, Zone.HAND, source, game);
    player.moveCards(cardsToExile, Zone.EXILED, source, game);
    return true;
  }
}
origin: magefree/mage

  @Override
  public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null) {
      Cards cards = new CardsImpl(controller.getLibrary().getTopCards(game, 7));
      if (!cards.isEmpty()) {
        controller.lookAtCards(source, null, cards, game);
        TargetCard target = new TargetCard(Math.min(2, cards.size()), Zone.LIBRARY, new FilterCard("two cards to put in your hand"));
        if (controller.choose(Outcome.DrawCard, cards, target, game)) {
          Cards toHand = new CardsImpl(target.getTargets());
          controller.moveCards(cards, Zone.HAND, source, game);
          cards.removeAll(toHand);
        }
        controller.moveCards(cards, Zone.GRAVEYARD, source, game);
      }
      return true;
    }
    return false;
  }
}
origin: magefree/mage

@Override
public boolean apply(Game game, Ability source) {
  Player controller = game.getPlayer(source.getControllerId());
  if (controller != null) {
    Cards cards = new CardsImpl(controller.getLibrary().getTopCards(game, 8));
    int creatureCardsFound = cards.count(StaticFilters.FILTER_CARD_CREATURE, game);
    if (!cards.isEmpty()) {
      controller.revealCards(source, cards, game);
      if (creatureCardsFound > 0 && controller.chooseUse(outcome, "Put creature(s) into play?", source, game)) {
        int cardsToChoose = Math.min(numberOfCardsToPutIntoPlay, creatureCardsFound);
        TargetCard target = new TargetCard(cardsToChoose, cardsToChoose, Zone.LIBRARY, StaticFilters.FILTER_CARD_CREATURE);
        if (controller.choose(Outcome.PutCreatureInPlay, cards, target, game)) {
          Cards toBattlefield = new CardsImpl(target.getTargets());
          controller.moveCards(toBattlefield, Zone.BATTLEFIELD, source, game);
          cards.removeAll(toBattlefield);
        }
      }
      controller.moveCards(cards, Zone.GRAVEYARD, source, game);
    }
    return true;
  }
  return false;
}
origin: magefree/mage

  @Override
  public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null) {
      Cards cards = new CardsImpl(controller.getLibrary().getTopCards(game, 10));
      if (cards.size() > 0) {
        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);
        Cards toExile = new CardsImpl(target.getTargets());
        controller.moveCards(toExile, Zone.EXILED, source, game);
        cards.removeAll(toExile);
        controller.putCardsOnTopOfLibrary(cards, game, source, true);
      }
      return true;
    }
    return false;
  }
}
origin: magefree/mage

  @Override
  public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller == null) {
      return false;
    }
    // Look at the top seven cards of your library.
    Cards cards = new CardsImpl(controller.getLibrary().getTopCards(game, 7));
    controller.lookAtCards(source, null, cards, game);
    // Put up to two planeswalker cards from among them onto the battlefield.
    if (cards.count(filter, game) > 0) {
      TargetCard target = new TargetCard(0, 2, Zone.LIBRARY, filter);
      if (controller.choose(Outcome.DrawCard, cards, target, game)) {
        Cards pickedCards = new CardsImpl(target.getTargets());
        cards.removeAll(pickedCards);
        controller.moveCards(pickedCards.getCards(game), Zone.BATTLEFIELD, source, game);
      }
    }
    // Put the rest on the bottom of your library in a random order
    controller.putCardsOnBottomOfLibrary(cards, game, source, false);
    return true;
  }
}
origin: magefree/mage

  @Override
  public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getFirstTarget());
    FilterCard filter = new FilterCard("cards to put on the bottom of your library");
    if (player != null) {
      int number = min(player.getLibrary().size(), 5);
      Set<Card> cards = player.getLibrary().getTopCards(game, number);
      Cards cardsRemaining = new CardsImpl();
      cardsRemaining.addAll(cards);
      TargetCard target = new TargetCard(0, number, Zone.LIBRARY, filter);
      if (player.choose(Outcome.DrawCard, cardsRemaining, target, game)) {
        Cards pickedCards = new CardsImpl(target.getTargets());
        cardsRemaining.removeAll(pickedCards);
        player.putCardsOnBottomOfLibrary(pickedCards, game, source, true);
        player.putCardsOnTopOfLibrary(cardsRemaining, game, source, true);
        return true;
      }
    }
    return false;
  }
}
origin: magefree/mage

  @Override
  public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller == null) {
      return false;
    }
    int countersRemoved = 0;
    for (Cost cost : source.getCosts()) {
      if (cost instanceof JarOfEyeballsCost) {
        countersRemoved = ((JarOfEyeballsCost) cost).getRemovedCounters();
      }
    }
    Cards cards = new CardsImpl(controller.getLibrary().getTopCards(game, countersRemoved));
    controller.lookAtCards(source, null, cards, game);
    TargetCard target = new TargetCard(Zone.LIBRARY, new FilterCard("card to put into your hand"));
    if (controller.choose(Outcome.DrawCard, cards, target, game)) {
      Cards targetCards = new CardsImpl(target.getTargets());
      controller.moveCards(targetCards, Zone.HAND, source, game);
      cards.removeAll(targetCards);
    }
    controller.putCardsOnBottomOfLibrary(cards, game, source, true);
    return true;
  }
}
origin: magefree/mage

@Override
public boolean apply(Game game, Ability source) {
  Player controller = game.getPlayer(source.getControllerId());
  if (controller != null) {
    Cards initialHand = controller.getHand().copy();
    controller.drawCards(cardsToDraw, game);
    Cards drawnCards = new CardsImpl(controller.getHand().copy());
    drawnCards.removeAll(initialHand);
    if (!drawnCards.isEmpty()) {
      TargetCard cardToDiscard = new TargetCard(Zone.HAND, new FilterCard("card to discard"));
      cardToDiscard.setNotTarget(true);
      if (controller.choose(Outcome.Discard, drawnCards, cardToDiscard, game)) {
        Card card = controller.getHand().get(cardToDiscard.getFirstTarget(), game);
        if (card != null) {
          return controller.discard(card, source, game);
        }
      }
    }
    return true;
  }
  return false;
}
origin: magefree/mage

  @Override
  public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller == null) {
      return false;
    }
    int xValue = (Integer) getValue("damage");
    Cards cards = new CardsImpl(controller.getLibrary().getTopCards(game, xValue));
    if (!cards.isEmpty()) {
      controller.revealCards(source, cards, game);
      FilterCreatureCard filter = new FilterCreatureCard("Dinosaur creature cards");
      filter.add(new SubtypePredicate(SubType.DINOSAUR));
      TargetCard target1 = new TargetCard(0, Integer.MAX_VALUE, Zone.LIBRARY, filter);
      target1.setNotTarget(true);
      controller.choose(Outcome.PutCardInPlay, cards, target1, game);
      Cards toBattlefield = new CardsImpl(target1.getTargets());
      cards.removeAll(toBattlefield);
      controller.moveCards(toBattlefield.getCards(game), Zone.BATTLEFIELD, source, game, false, false, false, null);
      controller.putCardsOnBottomOfLibrary(cards, game, source, false);
    }
    return true;
  }
}
origin: magefree/mage

  @Override
  public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    MageObject sourceObject = game.getObject(source.getSourceId());
    if (controller != null && sourceObject != null) {
      Cards cards = new CardsImpl();
      cards.addAll(controller.getLibrary().getTopCards(game, 5));
      controller.lookAtCards(sourceObject.getIdName(), cards, game);
      TargetCard target = new TargetCard(0, 1, Zone.LIBRARY, StaticFilters.FILTER_CARD_BASIC_LAND);
      controller.chooseTarget(outcome, cards, target, source, game);
      Cards cardsRevealed = new CardsImpl(target.getTargets());
      if (!cardsRevealed.isEmpty()) {
        controller.revealCards(sourceObject.getIdName(), cardsRevealed, game);
        cards.removeAll(cardsRevealed);
        controller.putCardsOnTopOfLibrary(cardsRevealed, game, source, true);
      }
      controller.putCardsOnBottomOfLibrary(cards, game, source, true);
      return true;
    }
    return false;
  }
}
origin: magefree/mage

@Override
public boolean apply(Game game, Ability source) {
  Player controller = game.getPlayer(source.getControllerId());
  if (controller == null) {
    return false;
  }
  int xValue = source.getManaCostsToPay().getX();
  Cards cards = new CardsImpl(controller.getLibrary().getTopCards(game, xValue));
  if (!cards.isEmpty()) {
    controller.revealCards(source, cards, game);
    FilterCard filter = new FilterArtifactCard("artifact cards with converted mana cost " + xValue + " or less to put onto the battlefield");
    filter.add(new ConvertedManaCostPredicate(ComparisonType.FEWER_THAN, xValue + 1));
    TargetCard target1 = new TargetCard(0, Integer.MAX_VALUE, Zone.LIBRARY, filter);
    target1.setNotTarget(true);
    controller.choose(Outcome.PutCardInPlay, cards, target1, game);
    Cards toBattlefield = new CardsImpl(target1.getTargets());
    cards.removeAll(toBattlefield);
    controller.moveCards(toBattlefield.getCards(game), Zone.BATTLEFIELD, source, game, false, false, false, null);
    controller.moveCards(cards, Zone.GRAVEYARD, source, game);
  }
  return true;
}
origin: magefree/mage

@Override
public boolean apply(Game game, Ability source) {
  Player controller = game.getPlayer(source.getControllerId());
  if (controller == null) {
    return false;
  }
  int xValue = source.getManaCostsToPay().getX();
  Cards cards = new CardsImpl(controller.getLibrary().getTopCards(game, xValue));
  if (!cards.isEmpty()) {
    controller.revealCards(source, cards, game);
    FilterCard filter = new FilterPermanentCard("cards with converted mana cost " + xValue + " or less to put onto the battlefield");
    filter.add(new ConvertedManaCostPredicate(ComparisonType.FEWER_THAN, xValue + 1));
    TargetCard target1 = new TargetCard(0, Integer.MAX_VALUE, Zone.LIBRARY, filter);
    target1.setNotTarget(true);
    controller.choose(Outcome.PutCardInPlay, cards, target1, game);
    Cards toBattlefield = new CardsImpl(target1.getTargets());
    cards.removeAll(toBattlefield);
    controller.moveCards(toBattlefield.getCards(game), Zone.BATTLEFIELD, source, game, false, false, false, null);
    controller.moveCards(cards, Zone.GRAVEYARD, source, game);
  }
  return true;
}
origin: magefree/mage

@Override
protected void actionWithSelectedCards(Cards cards, Game game, Ability source) {
  Player player = game.getPlayer(source.getControllerId());
  if (player != null && numberToPick.calculate(game, source, this) > 0
      && cards.count(filter, source.getSourceId(), source.getControllerId(), game) > 0) {
    if (!optional || player.chooseUse(Outcome.DrawCard, getMayText(), source, game)) {
      FilterCard pickFilter = filter.copy();
      pickFilter.setMessage(getPickText());
      int number = min(cards.size(), numberToPick.calculate(game, source, this));
      TargetCard target = new TargetCard((upTo ? 0 : number), number, Zone.LIBRARY, pickFilter);
      if (player.choose(Outcome.DrawCard, cards, target, game)) {
        Cards pickedCards = new CardsImpl(target.getTargets());
        cards.removeAll(pickedCards);
        if (targetPickedCards == Zone.LIBRARY && !putOnTopSelected) {
          player.putCardsOnBottomOfLibrary(pickedCards, game, source, anyOrder);
        } else {
          player.moveCards(pickedCards.getCards(game), targetPickedCards, source, game);
        }
        if (revealPickedCards) {
          player.revealCards(source, pickedCards, game);
        }
      }
    }
  }
}
origin: magefree/mage

@Override
public boolean scry(int value, Ability source, Game game) {
  game.informPlayers(getLogName() + " scries " + value);
  Cards cards = new CardsImpl();
  cards.addAll(getLibrary().getTopCards(game, value));
  if (!cards.isEmpty()) {
    String text;
    if (cards.size() == 1) {
      text = "card if you want to put it on the bottom of your library (Scry)";
    } else {
      text = "cards you want to put on the bottom of your library (Scry)";
    }
    TargetCard target = new TargetCard(0, cards.size(), Zone.LIBRARY, new FilterCard(text));
    chooseTarget(Outcome.Benefit, cards, target, source, game);
    putCardsOnBottomOfLibrary(new CardsImpl(target.getTargets()), game, source, true);
    cards.removeAll(target.getTargets());
    putCardsOnTopOfLibrary(cards, game, source, true);
  }
  game.fireEvent(new GameEvent(GameEvent.EventType.SCRY, getId(), source == null ? null : source.getSourceId(), getId(), value, true));
  return true;
}
origin: magefree/mage

  @Override
  public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    MageObject sourceObject = game.getObject(source.getSourceId());
    if (controller != null && sourceObject != null) {
      Cards allCards = new CardsImpl();
      allCards.addAll(controller.getLibrary().getTopCards(game, 4));
      controller.lookAtCards(sourceObject.getIdName(), allCards, game);
      if (!allCards.isEmpty()) {
        Cards cardsToReveal = new CardsImpl();
        TargetCard target = new TargetCard(0, Integer.MAX_VALUE, Zone.LIBRARY, filter);
        controller.chooseTarget(outcome, allCards, target, source, game);
        cardsToReveal.addAll(target.getTargets());
        if (!cardsToReveal.isEmpty()) {
          controller.revealCards(sourceObject.getIdName(), cardsToReveal, game, true);
          allCards.removeAll(cardsToReveal);
        }
        controller.putCardsOnTopOfLibrary(cardsToReveal, game, source, true);
      }
      if (!allCards.isEmpty()) {
        controller.putCardsOnBottomOfLibrary(allCards, game, source, true);
      }
      return true;
    }
    return false;
  }
}
origin: magefree/mage

@Override
public boolean apply(Game game, Ability source) {
  Player controller = game.getPlayer(source.getControllerId());
  if (controller == null) {
    return false;
  }
  int xValue = source.getManaCostsToPay().getX();
  Cards cards = new CardsImpl(controller.getLibrary().getTopCards(game, xValue));
  controller.lookAtCards(source, null, cards, game);
  if (!cards.isEmpty()) {
    FilterCard filter = new FilterPermanentCard("land and/or legendary permanent cards with converted mana cost " + xValue + " or less to put onto the battlefield");
    filter.add(new ConvertedManaCostPredicate(ComparisonType.FEWER_THAN, xValue + 1));
    filter.add(
        Predicates.or(
            new CardTypePredicate(CardType.LAND),
            new SupertypePredicate(SuperType.LEGENDARY)
        ));
    TargetCard target1 = new TargetCard(0, Integer.MAX_VALUE, Zone.LIBRARY, filter);
    target1.setNotTarget(true);
    controller.choose(Outcome.PutCardInPlay, cards, target1, game);
    Cards toBattlefield = new CardsImpl(target1.getTargets());
    cards.removeAll(toBattlefield);
    controller.moveCards(toBattlefield.getCards(game), Zone.BATTLEFIELD, source, game, false, false, false, null);
    controller.moveCards(cards, Zone.GRAVEYARD, source, game);
  }
  return true;
}
origin: magefree/mage

@Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
  Player player = game.getPlayer(event.getPlayerId());
  if (player != null) {
    Cards oldHand = player.getHand().copy();
    if (player.drawCards(1, game, event.getAppliedEffects()) > 0) {
      Cards drawnCards = player.getHand().copy();
      drawnCards.removeAll(oldHand);
      player.revealCards(source, "The card drawn from " + player.getName() + "'s library.", drawnCards, game);
      for (Card cardDrawn : drawnCards.getCards(game)) {
        if (cardDrawn.isCreature()) {
          game.informPlayers("The card drawn by " + player.getName() + " is a creature card.  He/she must pay 3 life or that card gets discarded.");
          PayLifeCost cost = new PayLifeCost(3);
          if (cost.canPay(source, source.getSourceId(), player.getId(), game)
              && player.chooseUse(outcome, "Do you wish to pay 3 life to keep the card " + cardDrawn.getIdName() + "?  If not, you discard it.", source, game)) {
            cost.pay(source, game, source.getSourceId(), player.getId(), true, cost);
          } else {
            game.informPlayers("The cost of 3 life was not paid by " + player.getName() + ", so " + cardDrawn.getIdName() + " will be discarded.");
            player.discard(cardDrawn, source, game);
          }
        }
      }
    }
    return true;
  }
  return false;
}
origin: magefree/mage

  @Override
  public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    Player targetOpponent = game.getPlayer(getTargetPointer().getFirst(game, source));
    MageObject sourceObject = source.getSourceObject(game);
    if (controller != null && targetOpponent != null && sourceObject != null) {
      Cards cards = new CardsImpl();
      cards.addAll(controller.getLibrary().getTopCards(game, 4));

      TargetCard target = new TargetCard(0, Integer.MAX_VALUE, Zone.LIBRARY, new FilterCard("cards for the face-down pile"));
      targetOpponent.choose(outcome, cards, target, game);
      Cards faceDownPile = new CardsImpl();
      faceDownPile.addAll(target.getTargets());
      cards.removeAll(target.getTargets());
      controller.revealCards(sourceObject.getIdName() + " - cards in face-up pile", cards, game);
      game.informPlayers(targetOpponent.getLogName() + " puts " + faceDownPile.size() + " card(s) into the face-down pile");
      if (controller.chooseUse(outcome, "Choose a pile to put in your hand.", null, "Face-down", "Face-up", source, game)) {
        controller.moveCards(faceDownPile, Zone.HAND, source, game);
        controller.moveCards(cards, Zone.GRAVEYARD, source, game);
      } else {
        controller.moveCards(faceDownPile, Zone.GRAVEYARD, source, game);
        controller.moveCards(cards, Zone.HAND, source, game);
      }
      return true;
    }
    return false;
  }
}
origin: magefree/mage

@Override
public boolean surveil(int value, Ability source, Game game) {
  GameEvent event = new GameEvent(GameEvent.EventType.SURVEIL, getId(), source == null ? null : source.getSourceId(), getId(), value, true);
  if (game.replaceEvent(event)) {
    return false;
  }
  game.informPlayers(getLogName() + " surveils " + event.getAmount());
  Cards cards = new CardsImpl();
  cards.addAll(getLibrary().getTopCards(game, event.getAmount()));
  if (!cards.isEmpty()) {
    String text;
    if (cards.size() == 1) {
      text = "card if you want to put it into your graveyard (Surveil)";
    } else {
      text = "cards you want to put into your graveyard (Surveil)";
    }
    TargetCard target = new TargetCard(0, cards.size(), Zone.LIBRARY, new FilterCard(text));
    chooseTarget(Outcome.Benefit, cards, target, source, game);
    moveCards(new CardsImpl(target.getTargets()), Zone.GRAVEYARD, source, game);
    cards.removeAll(target.getTargets());
    putCardsOnTopOfLibrary(cards, game, source, true);
  }
  game.fireEvent(new GameEvent(GameEvent.EventType.SURVEILED, getId(), source == null ? null : source.getSourceId(), getId(), event.getAmount(), true));
  return true;
}
mage.cardsCardsremoveAll

Popular methods of Cards

  • getCards
  • size
  • add
  • isEmpty
  • clear
  • count
  • getRandom
  • addAll
  • contains
  • copy
  • get
  • iterator
  • get,
  • iterator,
  • remove,
  • toArray,
  • <init>,
  • getUniqueCards,
  • getValue,
  • stream

Popular in Java

  • Making http post requests using okhttp
  • startActivity (Activity)
  • getOriginalFilename (MultipartFile)
    Return the original filename in the client's filesystem.This may contain path information depending
  • setContentView (Activity)
  • Color (java.awt)
    The Color class is used to encapsulate colors in the default sRGB color space or colors in arbitrary
  • Component (java.awt)
    A component is an object having a graphical representation that can be displayed on the screen and t
  • FileOutputStream (java.io)
    An output stream that writes bytes to a file. If the output file exists, it can be replaced or appen
  • JFrame (javax.swing)
  • JList (javax.swing)
  • JPanel (javax.swing)
  • Top plugins for Android Studio
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now