use of mage.target.targetpointer.FixedTargets in project mage by magefree.
the class KillSwitchUntapEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
List<Permanent> permanents = game.getBattlefield().getActivePermanents(StaticFilters.FILTER_PERMANENT_ARTIFACT, source.getControllerId(), source.getSourceId(), game);
Permanent sourcePermanent = source.getSourcePermanentIfItStillExists(game);
if (sourcePermanent != null) {
permanents.remove(sourcePermanent);
game.addEffect(new KillSwitchUntapEffect().setTargetPointer(new FixedTargets(permanents, game)), source);
}
for (Permanent permanent : permanents) {
permanent.tap(source, game);
}
return true;
}
use of mage.target.targetpointer.FixedTargets in project mage by magefree.
the class WakeThePastEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player == null) {
return false;
}
Cards cards = new CardsImpl(player.getGraveyard().getCards(StaticFilters.FILTER_CARD_ARTIFACT, game));
if (cards.isEmpty()) {
return false;
}
player.moveCards(cards, Zone.BATTLEFIELD, source, game);
cards.removeIf(uuid -> game.getState().getZone(uuid) != Zone.BATTLEFIELD);
if (cards.isEmpty()) {
return true;
}
game.addEffect(new GainAbilityTargetEffect(HasteAbility.getInstance(), Duration.EndOfTurn).setTargetPointer(new FixedTargets(cards, game)), source);
return true;
}
use of mage.target.targetpointer.FixedTargets in project mage by magefree.
the class ExileTopXMayPlayUntilEndOfTurnEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller == null) {
return false;
}
Set<Card> cards = controller.getLibrary().getTopCards(game, amount);
if (cards.isEmpty()) {
return true;
}
controller.moveCardsToExile(cards, source, game, true, CardUtil.getExileZoneId(game, source), CardUtil.getSourceName(game, source));
// remove cards that could not be moved to exile
cards.removeIf(card -> !Zone.EXILED.equals(game.getState().getZone(card.getId())));
if (!cards.isEmpty()) {
game.addEffect(new PlayFromNotOwnHandZoneTargetEffect(Zone.EXILED, duration).setTargetPointer(new FixedTargets(cards, game)), source);
}
return true;
}
use of mage.target.targetpointer.FixedTargets in project mage by magefree.
the class FogPatchEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Effect effect = new BecomeBlockedTargetEffect();
effect.setTargetPointer(new FixedTargets(game.getBattlefield().getActivePermanents(StaticFilters.FILTER_ATTACKING_CREATURES, source.getSourceId(), game), game));
return effect.apply(game, source);
}
use of mage.target.targetpointer.FixedTargets in project mage by magefree.
the class GhostwayEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
MageObject sourceObject = source.getSourceObject(game);
if (sourceObject != null && controller != null) {
Set<Card> toExile = new HashSet<>();
toExile.addAll(game.getBattlefield().getActivePermanents(filter, source.getControllerId(), game));
UUID exileId = CardUtil.getExileZoneId(game, source.getSourceId(), source.getSourceObjectZoneChangeCounter());
controller.moveCardsToExile(toExile, source, game, true, exileId, sourceObject.getIdName());
Cards cardsToReturn = new CardsImpl();
for (Card exiled : toExile) {
if (exiled.getZoneChangeCounter(game) == game.getState().getZoneChangeCounter(exiled.getId()) - 1) {
cardsToReturn.add(exiled);
}
}
Effect effect = new ReturnToBattlefieldUnderOwnerControlTargetEffect(false, false);
effect.setTargetPointer(new FixedTargets(cardsToReturn, game));
AtTheBeginOfNextEndStepDelayedTriggeredAbility delayedAbility = new AtTheBeginOfNextEndStepDelayedTriggeredAbility(effect);
game.addDelayedTriggeredAbility(delayedAbility, source);
return true;
}
return false;
}
Aggregations