use of mage.abilities.effects.common.continuous.GainAbilityTargetEffect in project mage by magefree.
the class ZirilanOfTheClawEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
FilterPermanentCard filter = new FilterPermanentCard("a Dragon permanent card");
filter.add(SubType.DRAGON.getPredicate());
TargetCardInLibrary target = new TargetCardInLibrary(filter);
if (controller.searchLibrary(target, source, game)) {
Card card = controller.getLibrary().getCard(target.getFirstTarget(), game);
if (card != null) {
controller.moveCards(card, Zone.BATTLEFIELD, source, game);
Permanent permanent = game.getPermanent(card.getId());
if (permanent != null) {
// gains haste
ContinuousEffect effect = new GainAbilityTargetEffect(HasteAbility.getInstance(), Duration.EndOfTurn);
effect.setTargetPointer(new FixedTarget(permanent, game));
game.addEffect(effect, source);
// Exile at begin of next end step
ExileTargetEffect exileEffect = new ExileTargetEffect(null, null, Zone.BATTLEFIELD);
exileEffect.setTargetPointer(new FixedTarget(permanent, game));
DelayedTriggeredAbility delayedAbility = new AtTheBeginOfNextEndStepDelayedTriggeredAbility(exileEffect);
game.addDelayedTriggeredAbility(delayedAbility, source);
}
}
return true;
}
}
return false;
}
use of mage.abilities.effects.common.continuous.GainAbilityTargetEffect 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);
}
use of mage.abilities.effects.common.continuous.GainAbilityTargetEffect in project mage by magefree.
the class InfoEffect method addInfoToPermanent.
/**
* Add temporary information string to permanent (visible in rules list)
*
* @param game
* @param source
* @param permanent
* @param info
* @param duration
*/
public static void addInfoToPermanent(Game game, Ability source, Permanent permanent, String info, Duration duration) {
// add simple static info to permanent's rules
SimpleStaticAbility ability = new SimpleStaticAbility(Zone.BATTLEFIELD, new InfoEffect(info));
GainAbilityTargetEffect gainEffect = new GainAbilityTargetEffect(ability, duration);
gainEffect.setTargetPointer(new FixedTarget(permanent, game));
game.addEffect(gainEffect, source);
}
use of mage.abilities.effects.common.continuous.GainAbilityTargetEffect in project mage by magefree.
the class MonkClassCastEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player == null) {
return false;
}
Card card = player.getLibrary().getFromTop(game);
if (card == null) {
return false;
}
player.moveCards(card, Zone.EXILED, source, game);
game.addEffect(new GainAbilityTargetEffect(new SimpleStaticAbility(Zone.EXILED, new MonkClassCastEffect()), Duration.Custom, null, true).setTargetPointer(new FixedTarget(card, game)), source);
return true;
}
use of mage.abilities.effects.common.continuous.GainAbilityTargetEffect in project mage by magefree.
the class OliviaCrimsonBrideAbility method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller == null) {
return false;
}
Card card = game.getCard(getTargetPointer().getFirst(game, source));
if (card == null) {
return false;
}
controller.moveCards(card, Zone.BATTLEFIELD, source, game, true, false, false, null);
Permanent permanent = game.getPermanent(card.getId());
if (permanent == null) {
return false;
}
game.getCombat().addAttackingCreature(permanent.getId(), game);
game.addEffect(new GainAbilityTargetEffect(new OliviaCrimsonBrideAbility(), Duration.Custom).setTargetPointer(new FixedTarget(permanent, game)), source);
return true;
}
Aggregations