use of mage.abilities.common.SimpleActivatedAbility in project mage by magefree.
the class ConditionalAsThoughTest method test_PlayFromNotOwnHandZoneTargetEffect.
@Test
public void test_PlayFromNotOwnHandZoneTargetEffect() {
Ability ability = new SimpleActivatedAbility(Zone.ALL, new ConditionalAsThoughEffect(new PlayFromNotOwnHandZoneTargetEffect(Zone.GRAVEYARD, TargetController.ANY, Duration.EndOfTurn), new PermanentsOnTheBattlefieldCondition(StaticFilters.FILTER_PERMANENT_CREATURE, ComparisonType.MORE_THAN, 0)).setText("allow target cast"), new ManaCostsImpl("{R}"));
ability.addTarget(new TargetCardInOpponentsGraveyard(StaticFilters.FILTER_CARD));
addCustomCardWithAbility("play any opponent hand", playerA, ability);
addCard(Zone.HAND, playerA, "Grizzly Bears");
addCard(Zone.GRAVEYARD, playerA, "Silvercoat Lion");
addCard(Zone.GRAVEYARD, playerB, "Lightning Bolt");
addCard(Zone.BATTLEFIELD, playerA, "Plains", 5);
addCard(Zone.BATTLEFIELD, playerA, "Forest", 5);
addCard(Zone.BATTLEFIELD, playerA, "Mountain", 5);
// can't play grave before
checkPlayableAbility("before", 1, PhaseStep.PRECOMBAT_MAIN, playerA, "Cast Grizzly Bears", true);
checkPlayableAbility("before", 1, PhaseStep.PRECOMBAT_MAIN, playerA, "Cast Silvercoat Lion", false);
checkPlayableAbility("before", 1, PhaseStep.PRECOMBAT_MAIN, playerA, "Cast Lightning Bolt", false);
// activate target effect
activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{R}: Allow");
addTarget(playerA, "Lightning Bolt");
waitStackResolved(1, PhaseStep.PRECOMBAT_MAIN);
// can't play grave after but without good condition
checkPlayableAbility("after bad", 1, PhaseStep.PRECOMBAT_MAIN, playerA, "Cast Grizzly Bears", true);
checkPlayableAbility("after bad", 1, PhaseStep.PRECOMBAT_MAIN, playerA, "Cast Silvercoat Lion", false);
checkPlayableAbility("after bad", 1, PhaseStep.PRECOMBAT_MAIN, playerA, "Cast Lightning Bolt", false);
// make good condition - now we can play opponent's grave
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Grizzly Bears");
waitStackResolved(1, PhaseStep.PRECOMBAT_MAIN);
checkPlayableAbility("after good", 1, PhaseStep.PRECOMBAT_MAIN, playerA, "Cast Grizzly Bears", false);
checkPlayableAbility("after good", 1, PhaseStep.PRECOMBAT_MAIN, playerA, "Cast Silvercoat Lion", false);
checkPlayableAbility("after good", 1, PhaseStep.PRECOMBAT_MAIN, playerA, "Cast Lightning Bolt", true);
setStrictChooseMode(true);
setStopAt(1, PhaseStep.POSTCOMBAT_MAIN);
execute();
assertAllCommandsUsed();
}
use of mage.abilities.common.SimpleActivatedAbility in project mage by magefree.
the class ConditionalAsThoughTest method test_TargetCardInLibrary_CantUseAsAbilityTarget.
@Test(expected = IllegalArgumentException.class)
public void test_TargetCardInLibrary_CantUseAsAbilityTarget() {
Ability ability = new SimpleActivatedAbility(Zone.ALL, new InfoEffect("test"), new ManaCostsImpl("{R}"));
ability.addTarget(new TargetCardInLibrary());
}
use of mage.abilities.common.SimpleActivatedAbility in project mage by magefree.
the class GigantoplasmCopyApplier method apply.
@Override
public boolean apply(Game game, MageObject blueprint, Ability source, UUID copyToObjectId) {
DynamicValue variableMana = ManacostVariableValue.REGULAR;
Effect effect = new SetPowerToughnessSourceEffect(variableMana, Duration.WhileOnBattlefield, SubLayer.SetPT_7b);
effect.setText("This creature has base power and toughness X/X");
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, effect, new ManaCostsImpl("{X}"));
blueprint.getAbilities().add(ability);
return true;
}
use of mage.abilities.common.SimpleActivatedAbility in project mage by magefree.
the class HeliodsPunishmentEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Permanent sourceEnchantment = game.getPermanentOrLKIBattlefield(source.getSourceId());
if (sourceEnchantment != null && sourceEnchantment.getAttachedTo() != null) {
Permanent attachedTo = game.getPermanent(sourceEnchantment.getAttachedTo());
if (attachedTo != null) {
attachedTo.removeAllAbilities(source.getSourceId(), game);
HeliodsPunishmentEffect effect = new HeliodsPunishmentEffect(sourceEnchantment.getName());
Ability ability = new SimpleActivatedAbility(effect, new TapSourceCost());
effect.setSourceEnchantment(sourceEnchantment.getId());
attachedTo.addAbility(ability, source.getSourceId(), game);
}
}
return true;
}
use of mage.abilities.common.SimpleActivatedAbility in project mage by magefree.
the class EvilTwinPredicate method apply.
@Override
public boolean apply(Game game, MageObject blueprint, Ability source, UUID copyToObjectId) {
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new DestroyTargetEffect(), new ManaCostsImpl("{U}{B}"));
ability.addCost(new TapSourceCost());
ability.addTarget(new TargetCreaturePermanent(filter));
blueprint.getAbilities().add(ability);
return true;
}
Aggregations