Search in sources :

Example 1 with ChooseExpansionSetEffect

use of mage.abilities.effects.common.ChooseExpansionSetEffect in project mage by magefree.

the class BoosterTutorEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    ChooseExpansionSetEffect effect = new ChooseExpansionSetEffect(Outcome.UnboostCreature);
    effect.apply(game, source);
    Player controller = game.getPlayer(source.getControllerId());
    String setChosen = null;
    if (effect.getValue("setchosen") != null) {
        setChosen = (String) effect.getValue("setchosen");
    } else if (game.getState().getValue(this.getId() + "_set") != null) {
        setChosen = (String) game.getState().getValue(this.getId() + "_set");
    }
    if (setChosen != null && controller != null) {
        // ExpansionInfo set = ExpansionRepository.instance.getSetByName(setChosen);
        ExpansionSet expansionSet = Sets.findSet(setChosen);
        if (expansionSet != null) {
            List<Card> boosterPack = expansionSet.create15CardBooster();
            if (boosterPack != null) {
                StringBuilder message = new StringBuilder(controller.getLogName()).append(" opened: ");
                for (Card card : boosterPack) {
                    message.append(card.getName()).append(" ");
                }
                game.informPlayers(message.toString());
                TargetCard targetCard = new TargetCard(Zone.ALL, new FilterCard());
                Set<Card> cardsToLoad = new HashSet<Card>(boosterPack);
                game.loadCards(cardsToLoad, controller.getId());
                CardsImpl cards = new CardsImpl();
                cards.addAll(boosterPack);
                if (controller.choose(Outcome.Benefit, cards, targetCard, game)) {
                    Card card = game.getCard(targetCard.getFirstTarget());
                    if (card != null) {
                        controller.moveCards(card, Zone.HAND, source, game);
                    }
                }
            }
        }
        return true;
    }
    return false;
}
Also used : FilterCard(mage.filter.FilterCard) Player(mage.players.Player) ChooseExpansionSetEffect(mage.abilities.effects.common.ChooseExpansionSetEffect) TargetCard(mage.target.TargetCard) ExpansionSet(mage.cards.ExpansionSet) CardsImpl(mage.cards.CardsImpl) FilterCard(mage.filter.FilterCard) TargetCard(mage.target.TargetCard) Card(mage.cards.Card) HashSet(java.util.HashSet)

Example 2 with ChooseExpansionSetEffect

use of mage.abilities.effects.common.ChooseExpansionSetEffect in project mage by magefree.

the class WorldBottlingKitEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null) {
        ChooseExpansionSetEffect effect = new ChooseExpansionSetEffect(Outcome.Exile);
        effect.apply(game, source);
        String setChosen = null;
        if (effect.getValue("setchosen") != null) {
            setChosen = (String) effect.getValue("setchosen");
        } else if (game.getState().getValue(this.getId() + "_set") != null) {
            setChosen = (String) game.getState().getValue(this.getId() + "_set");
        }
        if (setChosen != null) {
            game.informPlayers(controller.getLogName() + " has chosen set " + setChosen);
            FilterPermanent filter = new FilterPermanent();
            filter.add(Predicates.not(Predicates.and(CardType.LAND.getPredicate(), SuperType.BASIC.getPredicate())));
            List<Permanent> permanents = game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game);
            for (Permanent permanent : permanents) {
                if (permanent.getExpansionSetCode().equals(setChosen)) {
                    controller.moveCardToExileWithInfo(permanent, null, "", source, game, Zone.BATTLEFIELD, true);
                }
            }
        }
        return true;
    }
    return false;
}
Also used : Player(mage.players.Player) FilterPermanent(mage.filter.FilterPermanent) FilterPermanent(mage.filter.FilterPermanent) Permanent(mage.game.permanent.Permanent) ChooseExpansionSetEffect(mage.abilities.effects.common.ChooseExpansionSetEffect)

Example 3 with ChooseExpansionSetEffect

use of mage.abilities.effects.common.ChooseExpansionSetEffect in project mage by magefree.

the class SummonThePackEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    ChooseExpansionSetEffect effect = new ChooseExpansionSetEffect(Outcome.UnboostCreature);
    effect.apply(game, source);
    Player controller = game.getPlayer(source.getControllerId());
    String setChosen = null;
    if (effect.getValue("setchosen") != null) {
        setChosen = (String) effect.getValue("setchosen");
    } else if (game.getState().getValue(this.getId() + "_set") != null) {
        setChosen = (String) game.getState().getValue(this.getId() + "_set");
    }
    if (setChosen != null && controller != null) {
        // ExpansionInfo set = ExpansionRepository.instance.getSetByName(setChosen);
        ExpansionSet expansionSet = Sets.findSet(setChosen);
        if (expansionSet != null) {
            List<Card> boosterPack = expansionSet.create15CardBooster();
            List<Card> creatureCards = new ArrayList<>();
            if (boosterPack != null) {
                StringBuilder message = new StringBuilder(controller.getLogName()).append(" opened: ");
                for (Card c : boosterPack) {
                    if (c != null && c.isCreature(game)) {
                        message.append(c.getName()).append(" ");
                        message.append(" (creature card) ");
                        ContinuousEffect effect2 = new BecomesBlackZombieAdditionEffect(false);
                        effect2.setTargetPointer(new FixedTarget(c.getId()));
                        game.addEffect(effect2, source);
                        creatureCards.add(c);
                        c.setZone(Zone.OUTSIDE, game);
                    }
                }
                if (creatureCards.size() > 0) {
                    Set<Card> ccs = new HashSet<>(creatureCards);
                    game.loadCards(ccs, controller.getId());
                    controller.moveCards(ccs, Zone.BATTLEFIELD, source, game);
                }
                game.informPlayers(message.toString());
            }
        }
    }
    return false;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Player(mage.players.Player) ArrayList(java.util.ArrayList) BecomesBlackZombieAdditionEffect(mage.abilities.effects.common.continuous.BecomesBlackZombieAdditionEffect) ExpansionSet(mage.cards.ExpansionSet) Card(mage.cards.Card) ChooseExpansionSetEffect(mage.abilities.effects.common.ChooseExpansionSetEffect) ContinuousEffect(mage.abilities.effects.ContinuousEffect) HashSet(java.util.HashSet)

Aggregations

ChooseExpansionSetEffect (mage.abilities.effects.common.ChooseExpansionSetEffect)3 Player (mage.players.Player)3 HashSet (java.util.HashSet)2 Card (mage.cards.Card)2 ExpansionSet (mage.cards.ExpansionSet)2 ArrayList (java.util.ArrayList)1 ContinuousEffect (mage.abilities.effects.ContinuousEffect)1 BecomesBlackZombieAdditionEffect (mage.abilities.effects.common.continuous.BecomesBlackZombieAdditionEffect)1 CardsImpl (mage.cards.CardsImpl)1 FilterCard (mage.filter.FilterCard)1 FilterPermanent (mage.filter.FilterPermanent)1 Permanent (mage.game.permanent.Permanent)1 TargetCard (mage.target.TargetCard)1 FixedTarget (mage.target.targetpointer.FixedTarget)1