Search in sources :

Example 1 with DomainValue

use of mage.abilities.dynamicvalue.common.DomainValue in project mage by magefree.

the class WorldlyCounselEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller == null) {
        return false;
    }
    Cards cards = new CardsImpl(controller.getLibrary().getTopCards(game, (new DomainValue()).calculate(game, source, this)));
    controller.lookAtCards(source, null, cards, game);
    if (!cards.isEmpty()) {
        if (cards.size() == 1) {
            controller.moveCards(cards, Zone.HAND, source, game);
        } else {
            TargetCard target = new TargetCard(Zone.LIBRARY, new FilterCard("card to put into your hand"));
            if (controller.choose(Outcome.DrawCard, cards, target, game)) {
                Card card = cards.get(target.getFirstTarget(), game);
                if (card != null) {
                    cards.remove(card);
                    controller.moveCards(card, Zone.HAND, source, game);
                }
            }
            controller.putCardsOnBottomOfLibrary(cards, game, source, true);
        }
    }
    return true;
}
Also used : FilterCard(mage.filter.FilterCard) Player(mage.players.Player) DomainValue(mage.abilities.dynamicvalue.common.DomainValue) TargetCard(mage.target.TargetCard) Cards(mage.cards.Cards) CardsImpl(mage.cards.CardsImpl) FilterCard(mage.filter.FilterCard) TargetCard(mage.target.TargetCard) Card(mage.cards.Card)

Example 2 with DomainValue

use of mage.abilities.dynamicvalue.common.DomainValue in project mage by magefree.

the class DracoSacrificeUnlessPaysEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    Permanent permanent = game.getPermanent(source.getSourceId());
    if (player != null && permanent != null) {
        // The cost is reduced by {2} for each basic land type.
        int domainValueReduction = new DomainValue(2).calculate(game, source, this);
        int count = Math.max(0, MAX_DOMAIN_VALUE - domainValueReduction);
        if (player.chooseUse(Outcome.Benefit, "Pay {" + count + "}? Or " + permanent.getName() + " will be sacrificed.", source, game)) {
            Cost cost = ManaUtil.createManaCost(count, false);
            if (cost.pay(source, game, source, source.getControllerId(), false)) {
                return true;
            }
        }
        permanent.sacrifice(source, game);
        return true;
    }
    return false;
}
Also used : Player(mage.players.Player) Permanent(mage.game.permanent.Permanent) DomainValue(mage.abilities.dynamicvalue.common.DomainValue) Cost(mage.abilities.costs.Cost) DomainHint(mage.abilities.hint.common.DomainHint)

Aggregations

DomainValue (mage.abilities.dynamicvalue.common.DomainValue)2 Player (mage.players.Player)2 Cost (mage.abilities.costs.Cost)1 DomainHint (mage.abilities.hint.common.DomainHint)1 Card (mage.cards.Card)1 Cards (mage.cards.Cards)1 CardsImpl (mage.cards.CardsImpl)1 FilterCard (mage.filter.FilterCard)1 Permanent (mage.game.permanent.Permanent)1 TargetCard (mage.target.TargetCard)1