use of mage.abilities.effects.common.continuous.GainAbilityTargetEffect in project mage by magefree.
the class SurgeOfZealEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
Permanent target = game.getPermanent(getTargetPointer().getFirst(game, source));
if (target != null) {
ObjectColor color = target.getColor(game);
for (Permanent permanent : game.getBattlefield().getActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE, source.getControllerId(), source.getSourceId(), game)) {
if (permanent.getColor(game).shares(color)) {
ContinuousEffect effect = new GainAbilityTargetEffect(HasteAbility.getInstance(), Duration.EndOfTurn);
effect.setTargetPointer(new FixedTarget(permanent, game));
game.addEffect(effect, source);
}
}
}
return true;
}
return false;
}
use of mage.abilities.effects.common.continuous.GainAbilityTargetEffect in project mage by magefree.
the class AethermagesTouchEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
MageObject sourceObject = game.getObject(source.getSourceId());
if (controller != null && sourceObject != null) {
Cards cards = new CardsImpl(controller.getLibrary().getTopCards(game, 4));
if (!cards.isEmpty()) {
FilterCreatureCard filter = new FilterCreatureCard("a creature card to put onto the battlefield");
controller.revealCards(sourceObject.getIdName(), cards, game);
TargetCard target = new TargetCard(Zone.LIBRARY, filter);
if (cards.count(filter, game) > 0 && controller.choose(outcome, cards, target, game)) {
Card card = game.getCard(target.getFirstTarget());
if (card != null) {
cards.remove(card);
if (controller.moveCards(card, Zone.BATTLEFIELD, source, game)) {
// It gains \"At the beginning of your end step, return this creature to its owner's hand.\"
Permanent permanent = game.getPermanent(card.getId());
if (permanent != null) {
Ability ability = new BeginningOfEndStepTriggeredAbility(Zone.BATTLEFIELD, new ReturnToHandSourceEffect(true), TargetController.YOU, null, false);
ContinuousEffect effect = new GainAbilityTargetEffect(ability, Duration.Custom);
effect.setTargetPointer(new FixedTarget(permanent, game));
game.addEffect(effect, source);
}
}
}
}
controller.putCardsOnBottomOfLibrary(cards, game, source, true);
}
return true;
}
return false;
}
use of mage.abilities.effects.common.continuous.GainAbilityTargetEffect in project mage by magefree.
the class FlareOfFaithEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Permanent permanent = game.getPermanent(source.getFirstTarget());
if (permanent == null) {
return false;
}
if (permanent.hasSubtype(SubType.HUMAN, game)) {
game.addEffect(new BoostTargetEffect(3, 3), source);
game.addEffect(new GainAbilityTargetEffect(IndestructibleAbility.getInstance(), Duration.EndOfTurn), source);
} else {
game.addEffect(new BoostTargetEffect(2, 2), source);
}
return true;
}
use of mage.abilities.effects.common.continuous.GainAbilityTargetEffect in project mage by magefree.
the class KatsumasaTheAnimatorEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Permanent permanent = game.getPermanent(source.getFirstTarget());
if (permanent == null) {
return false;
}
game.addEffect(new AddCardTypeTargetEffect(Duration.EndOfTurn, CardType.ARTIFACT, CardType.CREATURE), source);
game.addEffect(new GainAbilityTargetEffect(FlyingAbility.getInstance(), Duration.EndOfTurn), source);
if (permanent.hasSubtype(SubType.VEHICLE, game)) {
game.addEffect(new SetPowerToughnessTargetEffect(1, 1, Duration.EndOfTurn), source);
}
return true;
}
use of mage.abilities.effects.common.continuous.GainAbilityTargetEffect in project mage by magefree.
the class LegionWarbossAbility method apply.
@Override
public boolean apply(Game game, Ability source) {
CreateTokenEffect effect = new CreateTokenEffect(new GoblinToken());
effect.apply(game, source);
effect.getLastAddedTokenIds().stream().map((tokenId) -> {
ContinuousEffect continuousEffect = new GainAbilityTargetEffect(HasteAbility.getInstance(), Duration.EndOfTurn);
continuousEffect.setTargetPointer(new FixedTarget(tokenId, game));
return continuousEffect;
}).forEachOrdered((continuousEffect) -> {
game.addEffect(continuousEffect, source);
});
effect.getLastAddedTokenIds().stream().map((tokenId) -> {
ContinuousEffect continuousEffect = new GainAbilityTargetEffect(new LegionWarbossAbility(), Duration.EndOfCombat);
continuousEffect.setTargetPointer(new FixedTarget(tokenId, game));
return continuousEffect;
}).forEachOrdered((continuousEffect) -> {
game.addEffect(continuousEffect, source);
});
return true;
}
Aggregations