Search in sources :

Example 16 with NamePredicate

use of mage.filter.predicate.mageobject.NamePredicate in project mage by magefree.

the class CityInABottleCantPlayEffect method getArabianNightsNamePredicates.

public static List<NamePredicate> getArabianNightsNamePredicates() {
    List<NamePredicate> namePredicatesArabianNights = new ArrayList<>();
    namePredicatesArabianNights.add(new NamePredicate("Abu Ja'far"));
    namePredicatesArabianNights.add(new NamePredicate("Aladdin"));
    namePredicatesArabianNights.add(new NamePredicate("Aladdin's Lamp"));
    namePredicatesArabianNights.add(new NamePredicate("Aladdin's Ring"));
    namePredicatesArabianNights.add(new NamePredicate("Ali Baba"));
    namePredicatesArabianNights.add(new NamePredicate("Ali from Cairo"));
    namePredicatesArabianNights.add(new NamePredicate("Army of Allah"));
    namePredicatesArabianNights.add(new NamePredicate("Bazaar of Baghdad"));
    namePredicatesArabianNights.add(new NamePredicate("Bird Maiden"));
    namePredicatesArabianNights.add(new NamePredicate("Bottle of Suleiman"));
    namePredicatesArabianNights.add(new NamePredicate("Brass Man"));
    namePredicatesArabianNights.add(new NamePredicate("Camel"));
    namePredicatesArabianNights.add(new NamePredicate("City of Brass"));
    namePredicatesArabianNights.add(new NamePredicate("Cuombajj Witches"));
    namePredicatesArabianNights.add(new NamePredicate("Cyclone"));
    namePredicatesArabianNights.add(new NamePredicate("Dancing Scimitar"));
    namePredicatesArabianNights.add(new NamePredicate("Dandan"));
    namePredicatesArabianNights.add(new NamePredicate("Desert"));
    namePredicatesArabianNights.add(new NamePredicate("Desert Nomads"));
    namePredicatesArabianNights.add(new NamePredicate("Desert Twister"));
    namePredicatesArabianNights.add(new NamePredicate("Diamond Valley"));
    namePredicatesArabianNights.add(new NamePredicate("Drop of Honey"));
    namePredicatesArabianNights.add(new NamePredicate("Ebony Horse"));
    namePredicatesArabianNights.add(new NamePredicate("El-Hajjaj"));
    namePredicatesArabianNights.add(new NamePredicate("Elephant Graveyard"));
    namePredicatesArabianNights.add(new NamePredicate("Erg Raiders"));
    namePredicatesArabianNights.add(new NamePredicate("Erhnam Djinn"));
    namePredicatesArabianNights.add(new NamePredicate("Eye for an Eye"));
    namePredicatesArabianNights.add(new NamePredicate("Fishliver Oil"));
    namePredicatesArabianNights.add(new NamePredicate("Flying Carpet"));
    namePredicatesArabianNights.add(new NamePredicate("Flying Men"));
    namePredicatesArabianNights.add(new NamePredicate("Ghazban Ogre"));
    namePredicatesArabianNights.add(new NamePredicate("Giant Tortoise"));
    namePredicatesArabianNights.add(new NamePredicate("Guardian Beast"));
    namePredicatesArabianNights.add(new NamePredicate("Hasran Ogress"));
    namePredicatesArabianNights.add(new NamePredicate("Hurr Jackal"));
    namePredicatesArabianNights.add(new NamePredicate("Ifh-Biff Efreet"));
    namePredicatesArabianNights.add(new NamePredicate("Island Fish Jasconius"));
    namePredicatesArabianNights.add(new NamePredicate("Island of Wak-Wak"));
    namePredicatesArabianNights.add(new NamePredicate("Jandor's Ring"));
    namePredicatesArabianNights.add(new NamePredicate("Jandor's Saddlebags"));
    namePredicatesArabianNights.add(new NamePredicate("Jeweled Bird"));
    namePredicatesArabianNights.add(new NamePredicate("Jihad"));
    namePredicatesArabianNights.add(new NamePredicate("Junun Efreet"));
    namePredicatesArabianNights.add(new NamePredicate("Juzam Djinn"));
    namePredicatesArabianNights.add(new NamePredicate("Khabal Ghoul"));
    namePredicatesArabianNights.add(new NamePredicate("King Suleiman"));
    namePredicatesArabianNights.add(new NamePredicate("Kird Ape"));
    namePredicatesArabianNights.add(new NamePredicate("Library of Alexandria"));
    namePredicatesArabianNights.add(new NamePredicate("Magnetic Mountain"));
    namePredicatesArabianNights.add(new NamePredicate("Merchant Ship"));
    namePredicatesArabianNights.add(new NamePredicate("Metamorphosis"));
    namePredicatesArabianNights.add(new NamePredicate("Mijae Djinn"));
    namePredicatesArabianNights.add(new NamePredicate("Moorish Cavalry"));
    namePredicatesArabianNights.add(new NamePredicate("Nafs Asp"));
    namePredicatesArabianNights.add(new NamePredicate("Oasis"));
    namePredicatesArabianNights.add(new NamePredicate("Old Man of the Sea"));
    namePredicatesArabianNights.add(new NamePredicate("Oubliette"));
    namePredicatesArabianNights.add(new NamePredicate("Piety"));
    namePredicatesArabianNights.add(new NamePredicate("Pyramids"));
    namePredicatesArabianNights.add(new NamePredicate("Repentant Blacksmith"));
    namePredicatesArabianNights.add(new NamePredicate("Ring of Ma'ruf"));
    namePredicatesArabianNights.add(new NamePredicate("Rukh Egg"));
    namePredicatesArabianNights.add(new NamePredicate("Sandals of Abdallah"));
    namePredicatesArabianNights.add(new NamePredicate("Sandstorm"));
    namePredicatesArabianNights.add(new NamePredicate("Serendib Djinn"));
    namePredicatesArabianNights.add(new NamePredicate("Serendib Efreet"));
    namePredicatesArabianNights.add(new NamePredicate("Shahrazad"));
    namePredicatesArabianNights.add(new NamePredicate("Sindbad"));
    namePredicatesArabianNights.add(new NamePredicate("Singing Tree"));
    namePredicatesArabianNights.add(new NamePredicate("Sorceress Queen"));
    namePredicatesArabianNights.add(new NamePredicate("Stone-Throwing Devils"));
    namePredicatesArabianNights.add(new NamePredicate("Unstable Mutation"));
    namePredicatesArabianNights.add(new NamePredicate("War Elephant"));
    namePredicatesArabianNights.add(new NamePredicate("Wyluli Wolf"));
    namePredicatesArabianNights.add(new NamePredicate("Ydwen Efreet"));
    return namePredicatesArabianNights;
}
Also used : NamePredicate(mage.filter.predicate.mageobject.NamePredicate) ArrayList(java.util.ArrayList)

Example 17 with NamePredicate

use of mage.filter.predicate.mageobject.NamePredicate in project mage by magefree.

the class DesperateResearchEffect method apply.

@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;
}
Also used : FilterCard(mage.filter.FilterCard) Player(mage.players.Player) NamePredicate(mage.filter.predicate.mageobject.NamePredicate) Cards(mage.cards.Cards) CardsImpl(mage.cards.CardsImpl)

Example 18 with NamePredicate

use of mage.filter.predicate.mageobject.NamePredicate in project mage by magefree.

the class NecromentiaEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    String cardName = (String) game.getState().getValue(source.getSourceId().toString() + ChooseACardNameEffect.INFO_KEY);
    Player controller = game.getPlayer(source.getControllerId());
    if (cardName != null && controller != null) {
        FilterCard filter = new FilterCard("card named " + cardName);
        filter.add(new NamePredicate(cardName));
        Player targetPlayer = game.getPlayer(getTargetPointer().getFirst(game, source));
        // cards in Graveyard
        int cardsCount = (cardName.isEmpty() ? 0 : targetPlayer.getGraveyard().count(filter, game));
        if (cardsCount > 0) {
            filter.setMessage("card named " + cardName + " in the graveyard of " + targetPlayer.getName());
            TargetCard target = new TargetCard(0, cardsCount, Zone.GRAVEYARD, filter);
            if (controller.choose(Outcome.Exile, targetPlayer.getGraveyard(), target, game)) {
                controller.moveCards(new CardsImpl(target.getTargets()), Zone.EXILED, source, game);
            }
        }
        // cards in Hand
        int numberOfCardsExiledFromHand = 0;
        cardsCount = (cardName.isEmpty() ? 0 : targetPlayer.getHand().count(filter, game));
        if (cardsCount > 0) {
            filter.setMessage("card named " + cardName + " in the hand of " + targetPlayer.getName());
            TargetCard target = new TargetCard(0, cardsCount, Zone.HAND, filter);
            if (controller.choose(Outcome.Exile, targetPlayer.getHand(), target, game)) {
                numberOfCardsExiledFromHand = target.getTargets().size();
                controller.moveCards(new CardsImpl(target.getTargets()), Zone.EXILED, source, game);
            }
        } else {
            targetPlayer.revealCards(targetPlayer.getName() + "'s Hand", targetPlayer.getHand(), game);
        }
        // cards in Library
        Cards cardsInLibrary = new CardsImpl();
        cardsInLibrary.addAll(targetPlayer.getLibrary().getCards(game));
        cardsCount = (cardName.isEmpty() ? 0 : cardsInLibrary.count(filter, game));
        if (cardsCount > 0) {
            filter.setMessage("card named " + cardName + " in the library of " + targetPlayer.getLogName());
            TargetCardInLibrary targetLib = new TargetCardInLibrary(0, cardsCount, filter);
            if (controller.choose(Outcome.Exile, cardsInLibrary, targetLib, game)) {
                controller.moveCards(new CardsImpl(targetLib.getTargets()), Zone.EXILED, source, game);
            }
        } else {
            targetPlayer.revealCards(targetPlayer.getName() + "'s Library", new CardsImpl(new HashSet<>(targetPlayer.getLibrary().getCards(game))), game);
        }
        targetPlayer.shuffleLibrary(source, game);
        if (numberOfCardsExiledFromHand > 0) {
            game.getState().applyEffects(game);
            Token zombieToken = new ZombieToken();
            zombieToken.putOntoBattlefield(numberOfCardsExiledFromHand, game, source, targetPlayer.getId());
        }
        return true;
    }
    return false;
}
Also used : FilterCard(mage.filter.FilterCard) Player(mage.players.Player) NamePredicate(mage.filter.predicate.mageobject.NamePredicate) ZombieToken(mage.game.permanent.token.ZombieToken) TargetCard(mage.target.TargetCard) Token(mage.game.permanent.token.Token) ZombieToken(mage.game.permanent.token.ZombieToken) CardsImpl(mage.cards.CardsImpl) Cards(mage.cards.Cards) TargetCardInLibrary(mage.target.common.TargetCardInLibrary) HashSet(java.util.HashSet)

Example 19 with NamePredicate

use of mage.filter.predicate.mageobject.NamePredicate in project mage by magefree.

the class SasayasEssenceManaEffect method getNetMana.

@Override
public List<Mana> getNetMana(Game game, Ability source) {
    List<Mana> netMana = new ArrayList<>();
    Player controller = game.getPlayer(source.getControllerId());
    Mana producedMana = (Mana) this.getValue("mana");
    Permanent permanent = game.getPermanent(getTargetPointer().getFirst(game, source));
    if (controller != null && producedMana != null && permanent != null) {
        FilterPermanent filter = new FilterLandPermanent();
        filter.add(Predicates.not(new PermanentIdPredicate(permanent.getId())));
        filter.add(new NamePredicate(permanent.getName()));
        int count = game.getBattlefield().countAll(filter, controller.getId(), game);
        if (count > 0) {
            if (producedMana.getBlack() > 0) {
                netMana.add(Mana.BlackMana(count));
            }
            if (producedMana.getRed() > 0) {
                netMana.add(Mana.RedMana(count));
            }
            if (producedMana.getBlue() > 0) {
                netMana.add(Mana.BlueMana(count));
            }
            if (producedMana.getGreen() > 0) {
                netMana.add(Mana.GreenMana(count));
            }
            if (producedMana.getWhite() > 0) {
                netMana.add(Mana.WhiteMana(count));
            }
            if (producedMana.getColorless() > 0) {
                netMana.add(Mana.ColorlessMana(count));
            }
        }
    }
    return netMana;
}
Also used : PermanentIdPredicate(mage.filter.predicate.permanent.PermanentIdPredicate) Player(mage.players.Player) NamePredicate(mage.filter.predicate.mageobject.NamePredicate) Mana(mage.Mana) FilterPermanent(mage.filter.FilterPermanent) FilterLandPermanent(mage.filter.common.FilterLandPermanent) FilterPermanent(mage.filter.FilterPermanent) FilterLandPermanent(mage.filter.common.FilterLandPermanent) Permanent(mage.game.permanent.Permanent) FilterControlledLandPermanent(mage.filter.common.FilterControlledLandPermanent) ArrayList(java.util.ArrayList)

Example 20 with NamePredicate

use of mage.filter.predicate.mageobject.NamePredicate in project mage by magefree.

the class SeverTheBloodlineEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    Permanent targetPermanent = game.getPermanent(targetPointer.getFirst(game, source));
    if (controller != null && targetPermanent != null) {
        FilterCreaturePermanent filter = new FilterCreaturePermanent();
        if (CardUtil.haveEmptyName(targetPermanent)) {
            // if no name (face down creature) only the creature itself is selected
            filter.add(new PermanentIdPredicate(targetPermanent.getId()));
        } else {
            filter.add(new NamePredicate(targetPermanent.getName()));
        }
        for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)) {
            controller.moveCardToExileWithInfo(permanent, null, "", source, game, Zone.BATTLEFIELD, true);
        }
        return true;
    }
    return false;
}
Also used : PermanentIdPredicate(mage.filter.predicate.permanent.PermanentIdPredicate) Player(mage.players.Player) NamePredicate(mage.filter.predicate.mageobject.NamePredicate) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) Permanent(mage.game.permanent.Permanent) TargetCreaturePermanent(mage.target.common.TargetCreaturePermanent) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent)

Aggregations

NamePredicate (mage.filter.predicate.mageobject.NamePredicate)78 FilterCard (mage.filter.FilterCard)55 Player (mage.players.Player)55 Permanent (mage.game.permanent.Permanent)31 TargetCardInLibrary (mage.target.common.TargetCardInLibrary)30 Card (mage.cards.Card)24 MageObject (mage.MageObject)22 UUID (java.util.UUID)19 FilterPermanent (mage.filter.FilterPermanent)16 TargetCard (mage.target.TargetCard)14 Spell (mage.game.stack.Spell)12 CardsImpl (mage.cards.CardsImpl)10 FilterCreaturePermanent (mage.filter.common.FilterCreaturePermanent)10 PermanentIdPredicate (mage.filter.predicate.permanent.PermanentIdPredicate)9 TargetCreaturePermanent (mage.target.common.TargetCreaturePermanent)8 ContinuousEffect (mage.abilities.effects.ContinuousEffect)7 Cards (mage.cards.Cards)7 TargetPlayer (mage.target.TargetPlayer)7 ArrayList (java.util.ArrayList)6 HashSet (java.util.HashSet)6