use of mage.abilities.common.SimpleStaticAbility in project mage by magefree.
the class MakeshiftMannequinGainAbilityEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
UUID cardId = this.getTargetPointer().getFirst(game, source);
Card card = controller.getGraveyard().get(cardId, game);
if (card != null) {
Counters counters = new Counters();
counters.addCounter(CounterType.MANNEQUIN.createInstance());
game.setEnterWithCounters(cardId, counters);
if (controller.moveCards(card, Zone.BATTLEFIELD, source, game)) {
Permanent permanent = game.getPermanent(cardId);
if (permanent != null) {
ContinuousEffect gainedEffect = new MakeshiftMannequinGainAbilityEffect();
// Bug #6885 Fixed when owner/controller leaves the game the effect still applies
SimpleStaticAbility gainAbility = new SimpleStaticAbility(Zone.BATTLEFIELD, gainedEffect);
gainAbility.setSourceId(cardId);
gainAbility.getTargets().add(source.getTargets().get(0));
game.addEffect(gainedEffect, gainAbility);
return true;
}
}
}
}
return false;
}
use of mage.abilities.common.SimpleStaticAbility in project mage by magefree.
the class FeatherTheRedeemedTest method test_ExileSpellAndRecastWithReturnAtTheEnd.
@Test
public void test_ExileSpellAndRecastWithReturnAtTheEnd() {
// cast bolt, put to exile, cast from exile, put to exile, return to hand
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 and put to exile again
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Lightning Bolt", "Grizzly Bears");
waitStackResolved(1, PhaseStep.PRECOMBAT_MAIN);
checkPermanentCount("turn 1 recast", 1, PhaseStep.PRECOMBAT_MAIN, playerA, "Grizzly Bears", 3 - 2);
checkExileCount("turn 1 recast", 1, PhaseStep.PRECOMBAT_MAIN, playerA, "Lightning Bolt", 1);
checkHandCardCount("turn 1 recast", 1, PhaseStep.PRECOMBAT_MAIN, playerA, "Lightning Bolt", 0);
// return to hand at the next end step
// two triggeres from two cast (card's code adds two same effects on each trigger)
setChoice(playerA, "At the beginning of 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", 1);
setStrictChooseMode(true);
setStopAt(2, PhaseStep.POSTCOMBAT_MAIN);
execute();
assertAllCommandsUsed();
}
use of mage.abilities.common.SimpleStaticAbility in project mage by magefree.
the class ExileCardsFromHandAdjuster method addAdjusterAndMessage.
public static final void addAdjusterAndMessage(Card card, FilterCard filter) {
card.addAbility(new SimpleStaticAbility(Zone.ALL, new InfoEffect("as an additional cost to cast this spell, you may exile any number of " + filter.getMessage() + ". This spell costs {2} less to cast for each card exiled this way")).setRuleAtTheTop(true));
card.getSpellAbility().setCostAdjuster(new ExileCardsFromHandAdjuster(filter));
}
use of mage.abilities.common.SimpleStaticAbility in project mage by magefree.
the class DreadWightCounterCondition method apply.
@Override
public boolean apply(Game game, Ability source) {
Permanent permanent = game.getPermanent(targetPointer.getFirst(game, source));
if (permanent != null) {
// add paralyzation counter
Effect effect = new AddCountersTargetEffect(CounterType.PARALYZATION.createInstance());
effect.setTargetPointer(new FixedTarget(permanent, game));
effect.apply(game, source);
// tap permanent
permanent.tap(source, game);
// does not untap while paralyzation counter is on it
ContinuousRuleModifyingEffect effect2 = new DreadWightDoNotUntapEffect(Duration.WhileOnBattlefield, permanent.getId());
effect2.setText("This creature doesn't untap during its controller's untap step for as long as it has a paralyzation counter on it");
Condition condition = new DreadWightCounterCondition(permanent.getId());
ConditionalContinuousRuleModifyingEffect conditionalEffect = new ConditionalContinuousRuleModifyingEffect(effect2, condition);
Ability ability = new SimpleStaticAbility(Zone.BATTLEFIELD, conditionalEffect);
ContinuousEffect effect3 = new GainAbilityTargetEffect(ability, Duration.WhileOnBattlefield);
ability.setRuleVisible(true);
effect3.setTargetPointer(new FixedTarget(permanent, game));
game.addEffect(effect3, source);
// each gains 4: remove paralyzation counter
Ability activatedAbility = new SimpleActivatedAbility(Zone.BATTLEFIELD, new RemoveCounterSourceEffect(CounterType.PARALYZATION.createInstance()), new ManaCostsImpl("{4}"));
ContinuousEffect effect4 = new GainAbilityTargetEffect(activatedAbility, Duration.WhileOnBattlefield);
effect4.setTargetPointer(new FixedTarget(permanent, game));
game.addEffect(effect4, source);
return true;
}
return false;
}
use of mage.abilities.common.SimpleStaticAbility in project mage by magefree.
the class ConditionalPreventionTest method test_PreventDamageConditionalNotActiveWithOtherEffect.
@Test
public void test_PreventDamageConditionalNotActiveWithOtherEffect() {
addCustomCardWithAbility("prevent", playerA, new SimpleStaticAbility(new ConditionalPreventionEffect(new PreventAllDamageToAllEffect(Duration.WhileOnBattlefield, StaticFilters.FILTER_PERMANENT), new PreventAllDamageToPlayersEffect(Duration.WhileOnBattlefield, false), NotMyTurnCondition.instance, "")));
addCard(Zone.BATTLEFIELD, playerA, "Balduvian Bears", 1);
addCard(Zone.BATTLEFIELD, playerA, "Mountain", 2);
addCard(Zone.HAND, playerA, "Lightning Bolt", 2);
// will prevent
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Lightning Bolt", "Balduvian Bears");
// will not prevent
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Lightning Bolt", playerA);
setStrictChooseMode(true);
setStopAt(1, PhaseStep.END_TURN);
execute();
assertAllCommandsUsed();
// not prevented, dies
assertPermanentCount(playerA, "Balduvian Bears", 0);
// prevented, no damage
assertLife(playerA, 20);
assertHandCount(playerA, "Lightning Bolt", 0);
}
Aggregations