use of mage.cards.Cards in project mage by magefree.
the class ThrillingEncoreEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
CardsPutIntoGraveyardWatcher watcher = game.getState().getWatcher(CardsPutIntoGraveyardWatcher.class);
if (controller == null || watcher == null) {
return false;
}
Cards cards = new CardsImpl(watcher.getCardsPutIntoGraveyardFromBattlefield(game));
cards.removeIf(uuid -> !game.getCard(uuid).isCreature(game));
return controller.moveCards(cards, Zone.BATTLEFIELD, source, game);
}
use of mage.cards.Cards in project mage by magefree.
the class ThoughtDistortionEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getFirstTarget());
if (player == null) {
return false;
}
player.revealCards(source, player.getHand(), game);
Cards cards = new CardsImpl(player.getHand().getCards(filter, game));
cards.addAll(player.getGraveyard().getCards(filter, game));
return player.moveCards(cards, Zone.EXILED, source, game);
}
use of mage.cards.Cards in project mage by magefree.
the class VesselOfNascencyEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
MageObject sourceObject = game.getObject(source.getSourceId());
if (controller != null && sourceObject != null) {
Cards cards = new CardsImpl(controller.getLibrary().getTopCards(game, 4));
boolean properCardFound = cards.count(filterPutInHand, source.getControllerId(), source.getSourceId(), game) > 0;
if (!cards.isEmpty()) {
controller.revealCards(sourceObject.getName(), cards, game);
TargetCard target = new TargetCard(Zone.LIBRARY, filterPutInHand);
if (properCardFound && controller.chooseUse(outcome, "Put an artifact, creature, enchantment, land, or planeswalker card into your hand?", source, game) && controller.choose(Outcome.DrawCard, cards, target, game)) {
Card card = game.getCard(target.getFirstTarget());
if (card != null) {
cards.remove(card);
controller.moveCards(card, Zone.HAND, source, game);
}
}
controller.moveCards(cards, Zone.GRAVEYARD, source, game);
}
return true;
}
return false;
}
use of mage.cards.Cards in project mage by magefree.
the class WizardMentorEffect 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(source.getSourcePermanentIfItStillExists(game));
cards.add(source.getFirstTarget());
return player.moveCards(cards, Zone.HAND, source, game);
}
use of mage.cards.Cards in project mage by magefree.
the class AmplifyEffect method replaceEvent.
@Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
Permanent sourceCreature = ((EntersTheBattlefieldEvent) event).getTarget();
Player controller = game.getPlayer(source.getControllerId());
if (controller == null || sourceCreature == null) {
return false;
}
FilterCreatureCard filter = new FilterCreatureCard("creatures cards to reveal");
filter.add(new AmplifyPredicate(sourceCreature));
// You can’t reveal this card or any other cards that are entering the battlefield at the same time as this card.
filter.add(Predicates.not(new CardIdPredicate(source.getSourceId())));
for (Permanent enteringPermanent : game.getPermanentsEntering().values()) {
filter.add(Predicates.not(new CardIdPredicate(enteringPermanent.getId())));
}
if (controller.getHand().count(filter, source.getSourceId(), source.getControllerId(), game) <= 0) {
return false;
}
if (!controller.chooseUse(outcome, "Reveal cards to Amplify?", source, game)) {
return false;
}
TargetCardInHand target = new TargetCardInHand(0, Integer.MAX_VALUE, filter);
if (controller.chooseTarget(outcome, target, source, game) && !target.getTargets().isEmpty()) {
Cards cards = new CardsImpl();
cards.addAll(target.getTargets());
int amountCounters = cards.size() * amplifyFactor.getFactor();
sourceCreature.addCounters(CounterType.P1P1.createInstance(amountCounters), source.getControllerId(), source, game);
controller.revealCards(sourceCreature.getIdName(), cards, game);
}
return false;
}
Aggregations