use of mage.abilities.effects.common.DrawCardSourceControllerEffect in project mage by magefree.
the class UrzasTomeEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
new DrawCardSourceControllerEffect(1).apply(game, source);
if (controller != null && controller.chooseUse(Outcome.Exile, "Exile a historic card from your graveyard?", source, game)) {
Cost cost = new ExileFromGraveCost(new TargetCardInYourGraveyard(new FilterHistoricCard()));
if (cost.canPay(source, source, controller.getId(), game)) {
if (cost.pay(source, game, source, controller.getId(), false, null)) {
return true;
}
}
}
if (controller != null) {
controller.discard(1, false, false, source, game);
return true;
}
return false;
}
use of mage.abilities.effects.common.DrawCardSourceControllerEffect in project mage by magefree.
the class GainAbilitiesTest method test_AttachmentUnique.
@Test
public void test_AttachmentUnique() {
// {R}
// Enchanted creature has "{R}, {T}, Discard a card: Draw a card."
addCard(Zone.HAND, playerA, "Epiphany Storm@attach", 2);
addCard(Zone.BATTLEFIELD, playerA, "Mountain", 2);
//
// 2/2
addCard(Zone.BATTLEFIELD, playerA, "Balduvian Bears@bear", 1);
// attach all
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "@attach.1", "@bear");
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "@attach.2", "@bear");
waitStackResolved(1, PhaseStep.PRECOMBAT_MAIN);
// checkAbility("after", 1, PhaseStep.PRECOMBAT_MAIN, playerA, "@bear", VigilanceAbility.class, true);
setStrictChooseMode(true);
setStopAt(1, PhaseStep.BEGIN_COMBAT);
execute();
assertAllCommandsUsed();
Permanent permanent = getPermanent("Balduvian Bears");
Assert.assertEquals("must have 2 dynamic ability instances from two attachments", 2, permanent.getAbilities(currentGame).stream().filter(a -> a.getEffects().stream().anyMatch(e -> e instanceof DrawCardSourceControllerEffect)).count());
}
use of mage.abilities.effects.common.DrawCardSourceControllerEffect in project mage by magefree.
the class PrimitiveEtchingsAbility method checkTrigger.
@Override
public boolean checkTrigger(GameEvent event, Game game) {
if (event.getPlayerId().equals(this.getControllerId())) {
if (game.isActivePlayer(this.getControllerId()) && this.lastTriggeredTurn != game.getTurnNum()) {
Card card = game.getCard(event.getTargetId());
Player controller = game.getPlayer(this.getControllerId());
Permanent sourcePermanent = game.getPermanentOrLKIBattlefield(this.getSourceId());
if (card != null && controller != null && sourcePermanent != null) {
lastTriggeredTurn = game.getTurnNum();
controller.revealCards(sourcePermanent.getName(), new CardsImpl(card), game);
this.getEffects().clear();
if (card.isCreature(game)) {
this.addEffect(new DrawCardSourceControllerEffect(1));
}
return true;
}
}
}
return false;
}
use of mage.abilities.effects.common.DrawCardSourceControllerEffect in project mage by magefree.
the class VilisBrokerOfBloodTriggeredAbility method checkTrigger.
@Override
public boolean checkTrigger(GameEvent event, Game game) {
if (event.getPlayerId().equals(this.getControllerId())) {
this.getEffects().clear();
this.addEffect(new DrawCardSourceControllerEffect(event.getAmount()));
return true;
}
return false;
}
use of mage.abilities.effects.common.DrawCardSourceControllerEffect in project mage by magefree.
the class HuntersInsightTriggeredAbility method checkTrigger.
@Override
public boolean checkTrigger(GameEvent event, Game game) {
if (!mor.refersTo(event.getSourceId(), game) || !((DamagedEvent) event).isCombatDamage()) {
return false;
}
Permanent permanent = game.getPermanent(event.getTargetId());
if (permanent != null && !permanent.isPlaneswalker(game)) {
return false;
}
this.getEffects().clear();
this.addEffect(new DrawCardSourceControllerEffect(event.getAmount()));
return true;
}
Aggregations