use of mage.abilities.effects.common.continuous.BecomesFaceDownCreatureEffect in project mage by magefree.
the class ManifestEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
Ability newSource = source.copy();
newSource.setWorksFaceDown(true);
Set<Card> cards = controller.getLibrary().getTopCards(game, amount);
for (Card card : cards) {
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, FaceDownType.MANIFESTED), newSource);
}
controller.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 ThievingAmalgamLifeLossEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
Player active = game.getPlayer(game.getActivePlayerId());
if (controller == null || active == null) {
return false;
}
Ability newSource = source.copy();
newSource.setWorksFaceDown(true);
Set<Card> cards = active.getLibrary().getTopCards(game, 1);
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