use of mage.target.targetpointer.FixedTargets in project mage by magefree.
the class RiseAndShineEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
List<Permanent> permanents = game.getBattlefield().getActivePermanents(RiseAndShine.filter, source.getControllerId(), source.getSourceId(), game);
if (permanents.isEmpty()) {
return false;
}
game.addEffect(new AddCardTypeTargetEffect(Duration.EndOfGame, CardType.ARTIFACT, CardType.CREATURE).setTargetPointer(new FixedTargets(permanents, game)), source);
game.addEffect(new SetPowerToughnessTargetEffect(0, 0, Duration.EndOfGame).setTargetPointer(new FixedTargets(permanents, game)), source);
for (Permanent permanent : permanents) {
permanent.addCounters(CounterType.P1P1.createInstance(4), source.getControllerId(), source, game);
}
return true;
}
use of mage.target.targetpointer.FixedTargets in project mage by magefree.
the class SuddenDisappearanceEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
MageObject sourceObject = source.getSourceObject(game);
if (controller != null && sourceObject != null) {
Set<Card> permsSet = new HashSet<>(game.getBattlefield().getAllActivePermanents(filter, source.getFirstTarget(), game));
if (!permsSet.isEmpty()) {
controller.moveCardsToExile(permsSet, source, game, true, source.getSourceId(), sourceObject.getIdName());
Cards targets = new CardsImpl();
for (Card card : permsSet) {
targets.add(card.getId());
}
Effect effect = new ReturnToBattlefieldUnderOwnerControlTargetEffect(false, true);
effect.setText("Return the exiled cards to the battlefield under their owner's control at the beginning of the next end step");
effect.setTargetPointer(new FixedTargets(targets, game));
game.addDelayedTriggeredAbility(new AtTheBeginOfNextEndStepDelayedTriggeredAbility(effect), source);
}
return true;
}
return false;
}
use of mage.target.targetpointer.FixedTargets in project mage by magefree.
the class EerieInterludeEffect 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<>();
for (UUID targetId : getTargetPointer().getTargets(game, source)) {
Permanent targetCreature = game.getPermanent(targetId);
if (targetCreature != null) {
toExile.add(targetCreature);
}
}
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 instanceof PermanentMeld) {
MeldCard meldCard = (MeldCard) ((PermanentCard) exiled).getCard();
Card topCard = meldCard.getTopHalfCard();
Card bottomCard = meldCard.getBottomHalfCard();
if (topCard.getZoneChangeCounter(game) == meldCard.getTopLastZoneChangeCounter()) {
cardsToReturn.add(topCard);
}
if (bottomCard.getZoneChangeCounter(game) == meldCard.getBottomLastZoneChangeCounter()) {
cardsToReturn.add(bottomCard);
}
} else 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;
}
use of mage.target.targetpointer.FixedTargets in project mage by magefree.
the class EiganjoUprisingEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
int amount = source.getManaCostsToPay().getX();
if (amount < 1) {
return false;
}
Token token = new SamuraiToken();
token.putOntoBattlefield(amount, game, source);
game.addEffect(new GainAbilityTargetEffect(new MenaceAbility(false)).setTargetPointer(new FixedTargets(token, game)), source);
game.addEffect(new GainAbilityTargetEffect(HasteAbility.getInstance()).setTargetPointer(new FixedTargets(token, game)), source);
if (amount < 2) {
return true;
}
for (UUID opponentId : game.getOpponents(source.getControllerId())) {
token.putOntoBattlefield(amount - 1, game, source, opponentId);
}
return true;
}
use of mage.target.targetpointer.FixedTargets in project mage by magefree.
the class GodPharaohsGiftEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
MageObject sourceObject = source.getSourceObject(game);
if (controller == null || sourceObject == null) {
return false;
}
TargetCardInYourGraveyard target = new TargetCardInYourGraveyard(0, 1, StaticFilters.FILTER_CARD_CREATURE_YOUR_GRAVEYARD, true);
controller.choose(Outcome.PutCreatureInPlay, target, source.getSourceId(), game);
Card cardChosen = game.getCard(target.getFirstTarget());
if (cardChosen == null || !controller.moveCards(cardChosen, Zone.EXILED, source, game)) {
return false;
}
// create token and modify all attributes permanently (without game usage)
EmptyToken token = new EmptyToken();
CardUtil.copyTo(token).from(cardChosen, game);
token.removePTCDA();
token.getPower().modifyBaseValue(4);
token.getToughness().modifyBaseValue(4);
token.getColor().setColor(ObjectColor.BLACK);
token.removeAllCreatureTypes();
token.addSubType(SubType.ZOMBIE);
token.putOntoBattlefield(1, game, source, source.getControllerId());
List<Permanent> permanents = token.getLastAddedTokenIds().stream().map(game::getPermanent).filter(Objects::nonNull).collect(Collectors.toList());
if (!permanents.isEmpty()) {
game.addEffect(new GainAbilityTargetEffect(HasteAbility.getInstance(), Duration.EndOfTurn).setTargetPointer(new FixedTargets(permanents, game)), source);
}
return true;
}
Aggregations