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;
}
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;
}
Aggregations