use of mage.abilities.effects.common.DrawCardSourceControllerEffect in project mage by magefree.
the class DistantMelodyEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
Choice typeChoice = new ChoiceCreatureType(game.getObject(source.getSourceId()));
if (controller != null && controller.choose(Outcome.BoostCreature, typeChoice, game)) {
FilterControlledCreaturePermanent filter = new FilterControlledCreaturePermanent();
filter.add(SubType.byDescription(typeChoice.getChoice()).getPredicate());
return new DrawCardSourceControllerEffect(new PermanentsOnBattlefieldCount(filter)).apply(game, source);
}
return false;
}
use of mage.abilities.effects.common.DrawCardSourceControllerEffect in project mage by magefree.
the class FblthpTheLostTargetedTriggeredAbility method checkTrigger.
@Override
public boolean checkTrigger(GameEvent event, Game game) {
if (!super.checkTrigger(event, game)) {
return false;
}
EntersTheBattlefieldEvent entersEvent = (EntersTheBattlefieldEvent) event;
if (entersEvent.getFromZone() == Zone.LIBRARY) {
this.getEffects().clear();
this.addEffect(new DrawCardSourceControllerEffect(2));
return true;
}
FblthpTheLostWatcher watcher = game.getState().getWatcher(FblthpTheLostWatcher.class);
int zcc = entersEvent.getTarget().getZoneChangeCounter(game) - 1;
MageObjectReference mor = new MageObjectReference(entersEvent.getTargetId(), zcc, game);
if (watcher != null && watcher.spellWasCastFromLibrary(mor)) {
this.getEffects().clear();
this.addEffect(new DrawCardSourceControllerEffect(2));
return true;
}
this.getEffects().clear();
this.addEffect(new DrawCardSourceControllerEffect(1));
return true;
}
use of mage.abilities.effects.common.DrawCardSourceControllerEffect in project mage by magefree.
the class IgnorantBlissEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller == null) {
return false;
}
Cards hand = new CardsImpl(controller.getHand());
controller.moveCardsToExile(hand.getCards(game), source, game, false, CardUtil.getExileZoneId(game, source), CardUtil.getSourceName(game, source));
hand.getCards(game).stream().filter(Objects::nonNull).filter(card -> game.getState().getZone(card.getId()) == Zone.EXILED).forEach(card -> card.setFaceDown(true, game));
DelayedTriggeredAbility ability = new AtTheBeginOfNextEndStepDelayedTriggeredAbility(new ReturnFromExileEffect(Zone.HAND));
ability.addEffect(new DrawCardSourceControllerEffect(1));
game.addDelayedTriggeredAbility(ability, source);
return true;
}
use of mage.abilities.effects.common.DrawCardSourceControllerEffect in project mage by magefree.
the class ToppleTheStatueEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Permanent permanent = game.getPermanent(source.getFirstTarget());
if (permanent == null) {
return false;
}
permanent.tap(source, game);
if (permanent.isArtifact(game)) {
permanent.destroy(source, game, false);
}
return new DrawCardSourceControllerEffect(1).apply(game, source);
}
use of mage.abilities.effects.common.DrawCardSourceControllerEffect in project mage by magefree.
the class TradeSecretsEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
String message = "Do you want to draw two cards and allow the spellcaster to draw up to four cards again?";
String message2 = "How many cards do you want to draw?";
Player controller = game.getPlayer(source.getControllerId());
Player targetOpponent = game.getPlayer(source.getFirstTarget());
if (controller != null && targetOpponent != null) {
// The drawcard method would not work immediately
new DrawCardTargetEffect(2).apply(game, source);
int amountOfCardsToDraw = controller.getAmount(0, 4, message2, game);
new DrawCardSourceControllerEffect(amountOfCardsToDraw).apply(game, source);
while (targetOpponent.chooseUse(Outcome.AIDontUseIt, message, source, game)) {
new DrawCardTargetEffect(2).apply(game, source);
amountOfCardsToDraw = controller.getAmount(0, 4, message2, game);
new DrawCardSourceControllerEffect(amountOfCardsToDraw).apply(game, source);
}
return true;
}
return false;
}
Aggregations