use of mage.abilities.decorator.ConditionalContinuousEffect in project mage by magefree.
the class SowerOfTemptationGainControlEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
ConditionalContinuousEffect effect = new ConditionalContinuousEffect(new GainControlTargetEffect(Duration.Custom), new SourceRemainsInZoneCondition(Zone.BATTLEFIELD), "gain control of target creature for as long as {this} remains on the battlefield");
game.addEffect(effect, source);
return false;
}
use of mage.abilities.decorator.ConditionalContinuousEffect in project mage by magefree.
the class InfernalDenizenEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Permanent creature = game.getPermanent(source.getSourceId());
Player player = game.getPlayer(source.getControllerId());
if (player != null) {
DynamicValue swamps = new PermanentsOnBattlefieldCount(filter);
boolean canSac = swamps.calculate(game, source, this) > 1;
Effect effect = new SacrificeControllerEffect(filter, 2, "Sacrifice two Swamps");
effect.apply(game, source);
if (!canSac) {
if (creature != null) {
creature.tap(source, game);
}
TargetOpponent targetOpp = new TargetOpponent(true);
if (targetOpp.canChoose(source.getSourceId(), player.getId(), game) && targetOpp.choose(Outcome.Detriment, player.getId(), source.getSourceId(), game)) {
Player opponent = game.getPlayer(targetOpp.getFirstTarget());
if (opponent != null) {
FilterCreaturePermanent filter2 = new FilterCreaturePermanent("creature controlled by " + player.getLogName());
filter2.add(new ControllerIdPredicate(player.getId()));
TargetCreaturePermanent targetCreature = new TargetCreaturePermanent(1, 1, filter2, true);
targetCreature.setTargetController(opponent.getId());
if (targetCreature.canChoose(source.getSourceId(), id, game) && opponent.chooseUse(Outcome.GainControl, "Gain control of a creature?", source, game) && opponent.chooseTarget(Outcome.GainControl, targetCreature, source, game)) {
ConditionalContinuousEffect giveEffect = new ConditionalContinuousEffect(new GainControlTargetEffect(Duration.Custom, true, opponent.getId()), SourceOnBattlefieldCondition.instance, "");
giveEffect.setTargetPointer(new FixedTarget(targetCreature.getFirstTarget(), game));
game.addEffect(giveEffect, source);
return true;
}
}
}
}
}
return false;
}
use of mage.abilities.decorator.ConditionalContinuousEffect in project mage by magefree.
the class HomurasEssence2 method apply.
@Override
public boolean apply(Game game, Ability source) {
Card sourceCard = game.getCard(source.getSourceId());
Player controller = game.getPlayer(source.getControllerId());
if (sourceCard != null && controller != null && game.getState().getZone(source.getSourceId()) == Zone.GRAVEYARD) {
ContinuousEffect effect = new ConditionalContinuousEffect(new CopyTokenEffect(flipToken), FlippedCondition.instance, "");
game.addEffect(effect, source);
controller.moveCards(sourceCard, Zone.BATTLEFIELD, source, game);
Permanent permanent = game.getPermanent(source.getSourceId());
if (permanent != null) {
// not complete correct because it should enter the battlefield flipped
permanent.flip(game);
}
return true;
}
return false;
}
use of mage.abilities.decorator.ConditionalContinuousEffect in project mage by magefree.
the class FlipSourceEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Permanent permanent = source.getSourcePermanentIfItStillExists(game);
Player controller = game.getPlayer(source.getControllerId());
if (permanent != null && controller != null) {
if (permanent.flip(game)) {
ContinuousEffect effect = new ConditionalContinuousEffect(new CopyTokenEffect(flipToken), FlippedCondition.instance, "");
game.addEffect(effect, source);
if (!game.isSimulation()) {
game.informPlayers(new StringBuilder(controller.getLogName()).append(" flips ").append(permanent.getName()).toString());
}
return true;
}
}
return false;
}
use of mage.abilities.decorator.ConditionalContinuousEffect in project mage by magefree.
the class InfoEffect method addCardHintToPermanentConditional.
/**
* Add temporary card hint to permanent (visible in rules list)
* Will be visible on conditional only
*
* @param game
* @param source
* @param permanent
* @param cardHint
* @param duration
* @param condition
*/
public static void addCardHintToPermanentConditional(Game game, Ability source, Permanent permanent, Hint cardHint, Duration duration, Condition condition) {
SimpleStaticAbility ability = new SimpleStaticAbility(Zone.BATTLEFIELD, new InfoEffect("hint"));
ability.setRuleVisible(false);
ability.addHint(cardHint);
GainAbilityTargetEffect gainEffect = new GainAbilityTargetEffect(ability, duration);
gainEffect.setTargetPointer(new FixedTarget(permanent, game));
ConditionalContinuousEffect conditionalEffect = new ConditionalContinuousEffect(gainEffect, condition, "test");
conditionalEffect.setTargetPointer(new FixedTarget(permanent, game));
game.addEffect(conditionalEffect, source);
}
Aggregations