use of mage.abilities.decorator.ConditionalContinuousEffect in project mage by magefree.
the class PreacherEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Permanent sourcePermanent = game.getPermanent(source.getSourceId());
Permanent targetPermanent = game.getPermanent(source.getFirstTarget());
Player controller = game.getPlayer(source.getControllerId());
if (controller != null && sourcePermanent != null && targetPermanent != null) {
SourceTappedCondition sourceTappedCondition = SourceTappedCondition.TAPPED;
ConditionalContinuousEffect effect = new ConditionalContinuousEffect(new GainControlTargetEffect(Duration.Custom), sourceTappedCondition, "Gain control of target creature of an opponent's choice that they control for as long as {this} remains tapped");
effect.setTargetPointer(new FixedTarget(targetPermanent.getId(), game));
game.addEffect(effect, source);
return true;
}
return false;
}
use of mage.abilities.decorator.ConditionalContinuousEffect 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;
}
Aggregations