use of mage.abilities.effects.common.continuous.BecomesFaceDownCreatureEffect in project mage by magefree.
the class ManifestTargetPlayerEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player targetPlayer = game.getPlayer(getTargetPointer().getFirst(game, source));
if (targetPlayer != null) {
Ability newSource = source.copy();
newSource.setWorksFaceDown(true);
Set<Card> cards = targetPlayer.getLibrary().getTopCards(game, amount);
for (Card card : cards) {
ManaCosts manaCosts = null;
if (card.isCreature(game)) {
manaCosts = card.getSpellAbility().getManaCosts();
if (manaCosts == null) {
manaCosts = new ManaCostsImpl("{0}");
}
}
MageObjectReference objectReference = new MageObjectReference(card.getId(), card.getZoneChangeCounter(game) + 1, game);
game.addEffect(new BecomesFaceDownCreatureEffect(manaCosts, objectReference, Duration.Custom, FaceDownType.MANIFESTED), newSource);
}
targetPlayer.moveCards(cards, Zone.BATTLEFIELD, source, game, false, true, false, null);
for (Card card : cards) {
Permanent permanent = game.getPermanent(card.getId());
if (permanent != null) {
permanent.setManifested(true);
}
}
return true;
}
return false;
}
use of mage.abilities.effects.common.continuous.BecomesFaceDownCreatureEffect in project mage by magefree.
the class GhastlyConscriptionEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
Player targetPlayer = game.getPlayer(getTargetPointer().getFirst(game, source));
if (controller != null && targetPlayer != null) {
List<Card> cardsToManifest = new ArrayList<>();
for (Card card : targetPlayer.getGraveyard().getCards(StaticFilters.FILTER_CARD_CREATURE, game)) {
cardsToManifest.add(card);
controller.moveCardToExileWithInfo(card, null, "", source, game, Zone.GRAVEYARD, true);
}
if (cardsToManifest.isEmpty()) {
return true;
}
Collections.shuffle(cardsToManifest);
game.informPlayers(controller.getLogName() + " shuffles the face-down pile");
Ability newSource = source.copy();
newSource.setWorksFaceDown(true);
for (Card card : cardsToManifest) {
ManaCosts manaCosts = null;
if (card.isCreature(game)) {
manaCosts = card.getSpellAbility().getManaCosts();
if (manaCosts == null) {
manaCosts = new ManaCostsImpl("{0}");
}
}
MageObjectReference objectReference = new MageObjectReference(card.getId(), card.getZoneChangeCounter(game) + 1, game);
game.addEffect(new BecomesFaceDownCreatureEffect(manaCosts, objectReference, Duration.Custom, FaceDownType.MANIFESTED), newSource);
}
Set<Card> toBattlefield = new LinkedHashSet();
toBattlefield.addAll(cardsToManifest);
controller.moveCards(toBattlefield, Zone.BATTLEFIELD, source, game, false, true, false, null);
return true;
}
return false;
}
use of mage.abilities.effects.common.continuous.BecomesFaceDownCreatureEffect in project mage by magefree.
the class TurnOverEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Permanent creature = game.getPermanent(source.getFirstTarget());
if (creature != null) {
if (creature.isFaceDown(game)) {
creature.turnFaceUp(source, game, source.getControllerId());
} else {
creature.turnFaceDown(source, game, source.getControllerId());
MageObjectReference objectReference = new MageObjectReference(creature.getId(), creature.getZoneChangeCounter(game), game);
game.addEffect(new BecomesFaceDownCreatureEffect(null, objectReference, Duration.Custom, FaceDownType.MANUAL), source);
}
return true;
}
return false;
}
use of mage.abilities.effects.common.continuous.BecomesFaceDownCreatureEffect in project mage by magefree.
the class JeskaiInfiltratorEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
Set<Card> cardsToManifest = new HashSet<>();
cardsToManifest.add(source.getSourcePermanentIfItStillExists(game));
cardsToManifest.add(controller.getLibrary().getFromTop(game));
UUID exileId = UUID.randomUUID();
controller.moveCardsToExile(cardsToManifest, source, game, false, exileId, "");
ExileZone exileZone = game.getExile().getExileZone(exileId);
for (Card card : exileZone.getCards(game)) {
card.setFaceDown(true, game);
}
// removes Jeskai Infiltrator from Battlefield, so Jeskai Infiltrator returns as a fresh permanent to the battlefield with new position
game.fireUpdatePlayersEvent();
Ability newSource = source.copy();
newSource.setWorksFaceDown(true);
// the Set will mimic the Shuffling
exileZone.getCards(game).forEach(card -> {
ManaCosts manaCosts = null;
if (card.isCreature(game)) {
manaCosts = card.getSpellAbility().getManaCosts();
if (manaCosts == null) {
manaCosts = new ManaCostsImpl("{0}");
}
}
MageObjectReference objectReference = new MageObjectReference(card.getId(), card.getZoneChangeCounter(game) + 1, game);
game.addEffect(new BecomesFaceDownCreatureEffect(manaCosts, objectReference, Duration.Custom, FaceDownType.MANIFESTED), newSource);
});
controller.moveCards(exileZone.getCards(game), Zone.BATTLEFIELD, source, game, false, true, false, null);
return true;
}
return false;
}
use of mage.abilities.effects.common.continuous.BecomesFaceDownCreatureEffect in project mage by magefree.
the class ScrollOfFateEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller == null || controller.getHand().isEmpty()) {
return false;
}
TargetCardInHand targetCard = new TargetCardInHand();
if (!controller.chooseTarget(Outcome.PutCardInPlay, controller.getHand(), targetCard, source, game)) {
return false;
}
Ability newSource = source.copy();
newSource.setWorksFaceDown(true);
Set<Card> cards = targetCard.getTargets().stream().map(game::getCard).filter(Objects::nonNull).collect(Collectors.toSet());
cards.stream().forEach(card -> {
ManaCosts manaCosts = null;
if (card.isCreature(game)) {
manaCosts = card.getSpellAbility() != null ? card.getSpellAbility().getManaCosts() : null;
if (manaCosts == null) {
manaCosts = new ManaCostsImpl("{0}");
}
}
MageObjectReference objectReference = new MageObjectReference(card.getId(), card.getZoneChangeCounter(game) + 1, game);
game.addEffect(new BecomesFaceDownCreatureEffect(manaCosts, objectReference, Duration.Custom, BecomesFaceDownCreatureEffect.FaceDownType.MANIFESTED), newSource);
});
controller.moveCards(cards, Zone.BATTLEFIELD, source, game, false, true, false, null);
cards.stream().map(Card::getId).map(game::getPermanent).filter(permanent -> permanent != null).forEach(permanent -> permanent.setManifested(true));
return true;
}
Aggregations