use of mage.abilities.effects.common.continuous.GainAbilityTargetEffect in project mage by magefree.
the class ImpromptuRaidEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
MageObject sourceObject = game.getObject(source.getSourceId());
if (sourceObject != null && controller != null) {
Card card = controller.getLibrary().getFromTop(game);
if (card != null) {
Cards cards = new CardsImpl();
cards.add(card);
controller.revealCards(sourceObject.getName(), cards, game);
if (filterPutInGraveyard.match(card, source.getSourceId(), source.getControllerId(), game)) {
controller.moveCards(card, Zone.GRAVEYARD, source, game);
return true;
}
if (controller.moveCards(card, Zone.BATTLEFIELD, source, game)) {
Permanent permanent = game.getPermanent(card.getId());
if (permanent != null) {
ContinuousEffect effect = new GainAbilityTargetEffect(HasteAbility.getInstance(), Duration.EndOfTurn);
effect.setTargetPointer(new FixedTarget(permanent, game));
game.addEffect(effect, source);
SacrificeTargetEffect sacrificeEffect = new SacrificeTargetEffect("", source.getControllerId());
sacrificeEffect.setTargetPointer(new FixedTarget(permanent, game));
DelayedTriggeredAbility delayedAbility = new AtTheBeginOfNextEndStepDelayedTriggeredAbility(sacrificeEffect);
game.addDelayedTriggeredAbility(delayedAbility, source);
}
return true;
}
}
}
return false;
}
use of mage.abilities.effects.common.continuous.GainAbilityTargetEffect in project mage by magefree.
the class LoyalApprenticeEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Token token = new ThopterColorlessToken();
token.putOntoBattlefield(1, game, source, source.getControllerId());
game.addEffect(new GainAbilityTargetEffect(HasteAbility.getInstance(), Duration.EndOfTurn).setTargetPointer(new FixedTargets(token.getLastAddedTokenIds().stream().map(game::getPermanent).filter(Objects::nonNull).collect(Collectors.toList()), game)), source);
return true;
}
use of mage.abilities.effects.common.continuous.GainAbilityTargetEffect in project mage by magefree.
the class PuppeteerCliqueEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Card card = game.getCard(getTargetPointer().getFirst(game, source));
if (card == null) {
return false;
}
Player controller = game.getPlayer(source.getControllerId());
if (controller == null || !controller.moveCards(card, Zone.BATTLEFIELD, source, game)) {
return false;
}
Permanent permanent = game.getPermanent(card.getId());
if (permanent == null) {
return false;
}
ContinuousEffect hasteEffect = new GainAbilityTargetEffect(HasteAbility.getInstance(), Duration.Custom);
hasteEffect.setTargetPointer(new FixedTarget(permanent, game));
game.addEffect(hasteEffect, source);
ExileTargetEffect exileEffect = new ExileTargetEffect("exile " + permanent.getLogName());
exileEffect.setTargetPointer(new FixedTarget(permanent, game));
DelayedTriggeredAbility delayedAbility = new AtTheBeginOfNextEndStepDelayedTriggeredAbility(exileEffect, TargetController.YOU);
game.addDelayedTriggeredAbility(delayedAbility, source);
return true;
}
use of mage.abilities.effects.common.continuous.GainAbilityTargetEffect in project mage by magefree.
the class SigardasVanguardEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player == null) {
return false;
}
TargetPermanent target = new TargetCreaturesWithDifferentPowers();
player.choose(outcome, target, source.getSourceId(), game);
if (target.getTargets().isEmpty()) {
return false;
}
game.addEffect(new GainAbilityTargetEffect(DoubleStrikeAbility.getInstance(), Duration.EndOfTurn).setTargetPointer(new FixedTargets(new CardsImpl(target.getTargets()), game)), source);
return true;
}
use of mage.abilities.effects.common.continuous.GainAbilityTargetEffect in project mage by magefree.
the class StanggExileTokenEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Permanent sourceObject = game.getPermanentOrLKIBattlefield(source.getSourceId());
if (sourceObject != null) {
CreateTokenEffect effect = new CreateTokenEffect(new StanggTwinToken());
effect.apply(game, source);
game.getState().setValue(source.getSourceId() + "_token", effect.getLastAddedTokenIds());
for (UUID addedTokenId : effect.getLastAddedTokenIds()) {
Effect sacrificeEffect = new SacrificeTargetEffect("sacrifice " + sourceObject.getName());
sacrificeEffect.setTargetPointer(new FixedTarget(sourceObject, game));
LeavesBattlefieldTriggeredAbility triggerAbility = new LeavesBattlefieldTriggeredAbility(sacrificeEffect, false);
ContinuousEffect continuousEffect = new GainAbilityTargetEffect(triggerAbility, Duration.WhileOnBattlefield);
continuousEffect.setTargetPointer(new FixedTarget(addedTokenId, game));
game.addEffect(continuousEffect, source);
}
return true;
}
return false;
}
Aggregations