use of mage.abilities.condition.Condition 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.condition.Condition in project mage by magefree.
the class PlaneswalkersMischiefCondition method apply.
@Override
public boolean apply(Game game, Ability source) {
Player opponent = game.getPlayer(source.getFirstTarget());
if (opponent != null && opponent.getHand().size() > 0) {
Card revealedCard = opponent.getHand().getRandom(game);
if (revealedCard == null) {
return false;
}
Cards cards = new CardsImpl(revealedCard);
opponent.revealCards(source, cards, game);
if (revealedCard.isInstant(game) || revealedCard.isSorcery(game)) {
opponent.moveCardToExileWithInfo(revealedCard, source.getSourceId(), "Planeswalker's Mischief", source, game, Zone.HAND, true);
AsThoughEffect effect = new PlaneswalkersMischiefCastFromExileEffect();
effect.setTargetPointer(new FixedTarget(revealedCard.getId()));
game.addEffect(effect, source);
OneShotEffect effect2 = new ReturnFromExileEffect(Zone.HAND);
Condition condition = new PlaneswalkersMischiefCondition(source.getSourceId(), revealedCard.getId());
ConditionalOneShotEffect effect3 = new ConditionalOneShotEffect(effect2, condition, "if you haven't cast it, return it to its owner's hand.");
DelayedTriggeredAbility delayedAbility = new AtTheBeginOfNextEndStepDelayedTriggeredAbility(effect3);
delayedAbility.addWatcher(new SpellsCastWatcher());
game.addDelayedTriggeredAbility(delayedAbility, source);
return true;
}
}
return false;
}
use of mage.abilities.condition.Condition in project mage by magefree.
the class LevelerCardBuilder method build.
/**
* Main method constructing ability.
*
* @return
*/
public List<Ability> build() {
List<Ability> constructed = new ArrayList<>();
Condition condition = new SourceHasCounterCondition(CounterType.LEVEL, level1, level2);
for (Ability ability : abilities) {
ContinuousEffect effect = new GainAbilitySourceEffect(ability);
ConditionalContinuousEffect abEffect = new ConditionalContinuousEffect(effect, condition, "");
Ability staticAbility = new SimpleStaticAbility(Zone.BATTLEFIELD, abEffect);
staticAbility.setRuleVisible(false);
constructed.add(staticAbility);
}
ContinuousEffect effect = new SetPowerToughnessSourceEffect(power, toughness, Duration.WhileOnBattlefield, SubLayer.SetPT_7b);
ConditionalContinuousEffect ptEffect = new ConditionalContinuousEffect(effect, condition, rule);
constructed.add(new SimpleStaticAbility(Zone.BATTLEFIELD, ptEffect));
return constructed;
}
use of mage.abilities.condition.Condition in project mage by magefree.
the class BarrinsUnmakingEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Permanent permanent = game.getPermanent(getTargetPointer().getFirst(game, source));
if (permanent != null) {
Condition condition = new MostCommonColorCondition(permanent.getColor(game));
if (condition.apply(game, source)) {
Effect effect = new ReturnToHandTargetEffect();
effect.setTargetPointer(new FixedTarget(permanent, game));
return effect.apply(game, source);
}
}
return false;
}
Aggregations