use of mage.abilities.common.SimpleStaticAbility in project mage by magefree.
the class GlyphOfDelusionEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
if (source.getTargets().get(1) != null) {
Permanent targetPermanent = game.getPermanent(source.getTargets().get(1).getFirstTarget());
if (targetPermanent != null) {
targetPermanent.addCounters(CounterType.GLYPH.createInstance(targetPermanent.getPower().getValue()), source.getControllerId(), source, game);
SimpleStaticAbility ability = new SimpleStaticAbility(Zone.BATTLEFIELD, new ConditionalContinuousRuleModifyingEffect(new DontUntapInControllersUntapStepSourceEffect(), new SourceHasCounterCondition(CounterType.GLYPH)).setText("This creature doesn't untap during your untap step if it has a glyph counter on it"));
GainAbilityTargetEffect effect = new GainAbilityTargetEffect(ability, Duration.Custom);
effect.setTargetPointer(new FixedTarget(targetPermanent.getId(), game));
game.addEffect(effect, source);
BeginningOfUpkeepTriggeredAbility ability2 = new BeginningOfUpkeepTriggeredAbility(new RemoveCounterSourceEffect(CounterType.GLYPH.createInstance()), TargetController.YOU, false);
GainAbilityTargetEffect effect2 = new GainAbilityTargetEffect(ability2, Duration.Custom);
effect2.setTargetPointer(new FixedTarget(targetPermanent.getId(), game));
game.addEffect(effect2, source);
}
}
return false;
}
use of mage.abilities.common.SimpleStaticAbility in project mage by magefree.
the class WallOfStolenIdentityCopyEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
Permanent permanent = game.getPermanent(source.getSourceId());
if (permanent == null) {
permanent = game.getPermanentEntering(source.getSourceId());
}
final Permanent sourcePermanent = permanent;
if (controller == null || sourcePermanent == null) {
return false;
}
Target target = new TargetPermanent(new FilterCreaturePermanent("target creature (you copy from)"));
target.setRequired(true);
if (source instanceof SimpleStaticAbility) {
target = new TargetPermanent(new FilterCreaturePermanent("creature (you copy from)"));
target.setRequired(false);
target.setNotTarget(true);
}
if (!target.canChoose(source.getSourceId(), source.getControllerId(), game)) {
return false;
}
controller.choose(Outcome.Copy, target, source.getSourceId(), game);
Permanent copyFromPermanent = game.getPermanent(target.getFirstTarget());
if (copyFromPermanent == null) {
return false;
}
game.copyPermanent(copyFromPermanent, sourcePermanent.getId(), source, new CopyApplier() {
@Override
public boolean apply(Game game, MageObject blueprint, Ability source, UUID copyToObjectId) {
blueprint.addSubType(SubType.WALL);
blueprint.getAbilities().add(DefenderAbility.getInstance());
return true;
}
});
ReflexiveTriggeredAbility ability = new ReflexiveTriggeredAbility(new TapTargetEffect(), false, "tap the copied creature " + "and it doesn't untap during its controller's untap step for as long as you control {this}");
ability.addEffect(new DontUntapInControllersUntapStepTargetEffect(Duration.WhileControlled));
ability.getEffects().setTargetPointer(new FixedTarget(copyFromPermanent, game));
game.fireReflexiveTriggeredAbility(ability, source);
return true;
}
use of mage.abilities.common.SimpleStaticAbility in project mage by magefree.
the class ConditionalCostModificationTest method test_ModificationNormal.
@Test
public void test_ModificationNormal() {
addCustomCardWithAbility("mod", playerA, new SimpleStaticAbility(new AbilitiesCostReductionControllerEffect(EquipAbility.class, "equip")));
addCard(Zone.BATTLEFIELD, playerA, "Balduvian Bears", 1);
addCard(Zone.BATTLEFIELD, playerA, "Dagger of the Worthy", 1);
addCard(Zone.BATTLEFIELD, playerA, "Mountain", 2);
activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Equip", "Balduvian Bears");
setStrictChooseMode(true);
setStopAt(1, PhaseStep.END_TURN);
execute();
assertAllCommandsUsed();
assertTappedCount("Mountain", true, 1);
assertTappedCount("Mountain", false, 1);
}
use of mage.abilities.common.SimpleStaticAbility in project mage by magefree.
the class ConditionalCostModificationTest method test_ModificationConditionalActive.
@Test
public void test_ModificationConditionalActive() {
addCustomCardWithAbility("mod", playerA, new SimpleStaticAbility(new ConditionalCostModificationEffect(new AbilitiesCostReductionControllerEffect(EquipAbility.class, "equip"), MyTurnCondition.instance, "")));
addCard(Zone.BATTLEFIELD, playerA, "Balduvian Bears", 1);
addCard(Zone.BATTLEFIELD, playerA, "Dagger of the Worthy", 1);
addCard(Zone.BATTLEFIELD, playerA, "Mountain", 2);
activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Equip", "Balduvian Bears");
setStrictChooseMode(true);
setStopAt(1, PhaseStep.END_TURN);
execute();
assertAllCommandsUsed();
assertTappedCount("Mountain", true, 1);
assertTappedCount("Mountain", false, 1);
}
use of mage.abilities.common.SimpleStaticAbility in project mage by magefree.
the class FeatherTheRedeemedTest method test_ExileSpellAndRecastWithoutReturn.
@Test
public void test_ExileSpellAndRecastWithoutReturn() {
// cast bolt, put to exile, cast from exile with different target, put to graveyard, not return
addCustomCardWithAbility("cast from exile", playerA, new SimpleStaticAbility(new PlayFromNotOwnHandZoneAllEffect(StaticFilters.FILTER_CARD, Zone.EXILED, false, TargetController.ANY, Duration.WhileOnBattlefield)));
addCard(Zone.BATTLEFIELD, playerA, "Feather, the Redeemed");
addCard(Zone.BATTLEFIELD, playerA, "Mountain", 3);
addCard(Zone.HAND, playerA, "Lightning Bolt", 1);
addCard(Zone.BATTLEFIELD, playerA, "Grizzly Bears", 3);
// cast and put to exile
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Lightning Bolt", "Grizzly Bears");
waitStackResolved(1, PhaseStep.PRECOMBAT_MAIN);
checkPermanentCount("turn 1", 1, PhaseStep.PRECOMBAT_MAIN, playerA, "Grizzly Bears", 3 - 1);
checkExileCount("turn 1", 1, PhaseStep.PRECOMBAT_MAIN, playerA, "Lightning Bolt", 1);
checkHandCardCount("turn 1", 1, PhaseStep.PRECOMBAT_MAIN, playerA, "Lightning Bolt", 0);
// cast from exile to target player (without trigger) and put to graveyard
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Lightning Bolt", playerB);
waitStackResolved(1, PhaseStep.PRECOMBAT_MAIN);
// no changes
checkPermanentCount("turn 1 recast", 1, PhaseStep.PRECOMBAT_MAIN, playerA, "Grizzly Bears", 3 - 1);
checkLife("turn 1 recast", 1, PhaseStep.PRECOMBAT_MAIN, playerB, 20 - 3);
checkExileCount("turn 1 recast", 1, PhaseStep.PRECOMBAT_MAIN, playerA, "Lightning Bolt", 0);
checkHandCardCount("turn 1 recast", 1, PhaseStep.PRECOMBAT_MAIN, playerA, "Lightning Bolt", 0);
// not return to hand at the next end step
checkExileCount("turn 1 after", 2, PhaseStep.PRECOMBAT_MAIN, playerA, "Lightning Bolt", 0);
checkHandCardCount("turn 1 after", 2, PhaseStep.PRECOMBAT_MAIN, playerA, "Lightning Bolt", 0);
setStrictChooseMode(true);
setStopAt(2, PhaseStep.POSTCOMBAT_MAIN);
execute();
assertAllCommandsUsed();
}
Aggregations