use of mage.filter.common.FilterArtifactCard in project mage by magefree.
the class MuzzioVisionaryArchitectEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller == null) {
return false;
}
int highCMC = 0;
List<Permanent> controlledArtifacts = game.getBattlefield().getAllActivePermanents(new FilterArtifactPermanent(), controller.getId(), game);
for (Permanent permanent : controlledArtifacts) {
if (permanent.getSpellAbility() != null) {
int cmc = permanent.getSpellAbility().getManaCosts().manaValue();
if (cmc > highCMC) {
highCMC = cmc;
}
}
}
Cards cards = new CardsImpl(controller.getLibrary().getTopCards(game, highCMC));
controller.lookAtCards(source, null, cards, game);
if (!cards.isEmpty()) {
TargetCard target = new TargetCard(Zone.LIBRARY, new FilterArtifactCard("artifact card to put onto the battlefield"));
if (target.canChoose(source.getSourceId(), controller.getId(), game) && controller.choose(Outcome.Benefit, cards, target, game)) {
Card card = cards.get(target.getFirstTarget(), game);
if (card != null) {
controller.revealCards(source, new CardsImpl(card), game);
cards.remove(card);
controller.moveCards(card, Zone.BATTLEFIELD, source, game);
}
}
}
controller.putCardsOnBottomOfLibrary(cards, game, source, true);
return true;
}
use of mage.filter.common.FilterArtifactCard in project mage by magefree.
the class TezzeretTheSeekerEffect3 method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller == null) {
return false;
}
int cmc = 0;
for (Cost cost : source.getCosts()) {
if (cost instanceof PayVariableLoyaltyCost) {
cmc = ((PayVariableLoyaltyCost) cost).getAmount();
}
}
FilterArtifactCard filter = new FilterArtifactCard("artifact card with mana value " + cmc + " or less");
filter.add(new ManaValuePredicate(ComparisonType.FEWER_THAN, cmc + 1));
TargetCardInLibrary target = new TargetCardInLibrary(filter);
if (controller.searchLibrary(target, source, game)) {
Card card = controller.getLibrary().getCard(target.getFirstTarget(), game);
if (card != null) {
controller.moveCards(card, Zone.BATTLEFIELD, source, game);
}
controller.shuffleLibrary(source, game);
return true;
}
controller.shuffleLibrary(source, game);
return false;
}
use of mage.filter.common.FilterArtifactCard in project mage by magefree.
the class SaheelisDirectiveEffect method apply.
@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 mana value " + xValue + " or less to put onto the battlefield");
filter.add(new ManaValuePredicate(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;
}
use of mage.filter.common.FilterArtifactCard in project mage by magefree.
the class SequesteredStashEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller == null) {
return false;
}
TargetCardInYourGraveyard target = new TargetCardInYourGraveyard(new FilterArtifactCard("artifact card from your graveyard"));
target.setNotTarget(true);
if (target.canChoose(source.getSourceId(), source.getControllerId(), game) && controller.chooseUse(outcome, "Put an artifact card from your graveyard to library?", source, game) && controller.choose(outcome, target, source.getSourceId(), game)) {
Card card = game.getCard(target.getFirstTarget());
if (card != null) {
controller.moveCards(card, Zone.LIBRARY, source, game);
}
}
return true;
}
use of mage.filter.common.FilterArtifactCard in project mage by magefree.
the class ArsenalThresherEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller == null) {
return false;
}
Permanent arsenalThresher = game.getPermanentEntering(source.getSourceId());
FilterArtifactCard filter = new FilterArtifactCard();
filter.add(new AnotherCardPredicate());
if (controller.chooseUse(Outcome.Benefit, "Reveal other artifacts in your hand?", source, game)) {
Cards cards = new CardsImpl();
if (controller.getHand().count(filter, source.getSourceId(), source.getControllerId(), game) > 0) {
TargetCardInHand target = new TargetCardInHand(0, Integer.MAX_VALUE, filter);
if (controller.choose(Outcome.Benefit, target, source.getSourceId(), game)) {
for (UUID uuid : target.getTargets()) {
cards.add(controller.getHand().get(uuid, game));
}
if (arsenalThresher != null) {
controller.revealCards(arsenalThresher.getIdName(), cards, game);
// the basic event is the EntersBattlefieldEvent, so use already applied replacement effects from that event
List<UUID> appliedEffects = (ArrayList<UUID>) this.getValue("appliedEffects");
arsenalThresher.addCounters(CounterType.P1P1.createInstance(cards.size()), source.getControllerId(), source, game, appliedEffects);
}
}
}
return true;
}
return false;
}
Aggregations