use of mage.cards.CardsImpl in project mage by magefree.
the class DeliverUntoEvilEffect 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.getTargets().get(0).getTargets());
if (cards.isEmpty()) {
return false;
}
if (!game.getBattlefield().getActivePermanents(filter, source.getControllerId(), game).isEmpty()) {
return player.moveCards(cards, Zone.HAND, source, game);
}
TargetOpponent targetOpponent = new TargetOpponent();
targetOpponent.setNotTarget(true);
if (!player.choose(outcome, targetOpponent, source.getSourceId(), game)) {
return false;
}
Player opponent = game.getPlayer(targetOpponent.getFirstTarget());
if (opponent == null) {
return false;
}
TargetCard targetCard = new TargetCardInGraveyard(Math.min(2, cards.size()), filter2);
if (!opponent.choose(outcome, cards, targetCard, game)) {
return false;
}
cards.removeAll(targetCard.getTargets());
return player.moveCards(cards, Zone.HAND, source, game);
}
use of mage.cards.CardsImpl in project mage by magefree.
the class DimensionalBreachReturnEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(game.getActivePlayerId());
if (player == null) {
return false;
}
Cards cards = new CardsImpl(morSet.stream().map(mor -> mor.getCard(game)).filter(Objects::nonNull).filter(c -> c.isOwnedBy(game.getActivePlayerId())).collect(Collectors.toSet()));
if (cards.isEmpty()) {
return false;
}
if (cards.size() > 1) {
TargetCard target = new TargetCardInExile(StaticFilters.FILTER_CARD);
target.setNotTarget(true);
player.choose(outcome, cards, target, game);
cards.clear();
cards.add(target.getFirstTarget());
}
return player.moveCards(cards, Zone.BATTLEFIELD, source, game);
}
use of mage.cards.CardsImpl in project mage by magefree.
the class DiscordantDirgeEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Permanent discordantDirge = game.getPermanentOrLKIBattlefield(source.getSourceId());
if (discordantDirge == null) {
return false;
}
int verseCounters = discordantDirge.getCounters(game).getCount(CounterType.VERSE);
Player targetOpponent = game.getPlayer(source.getFirstTarget());
Player controller = game.getPlayer(source.getControllerId());
if (targetOpponent == null || controller == null) {
return false;
}
controller.lookAtCards(targetOpponent.getName() + " hand", targetOpponent.getHand(), game);
TargetCard target = new TargetCard(0, verseCounters, Zone.HAND, new FilterCard());
target.setNotTarget(true);
if (!controller.choose(Outcome.Benefit, targetOpponent.getHand(), target, game)) {
return false;
}
targetOpponent.discard(new CardsImpl(target.getTargets()), false, source, game);
return true;
}
use of mage.cards.CardsImpl in project mage by magefree.
the class ElvishSoultillerEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
MageObject mageObject = game.getObject(source.getSourceId());
if (controller != null && mageObject != null) {
Choice typeChoice = new ChoiceCreatureType(mageObject);
if (controller.choose(outcome, typeChoice, game)) {
if (!game.isSimulation()) {
game.informPlayers(mageObject.getName() + ": " + controller.getLogName() + " has chosen " + typeChoice.getChoice());
}
Cards cardsToLibrary = new CardsImpl();
FilterCreatureCard filter = new FilterCreatureCard();
filter.add(SubType.byDescription(typeChoice.getChoice()).getPredicate());
cardsToLibrary.addAll(controller.getGraveyard().getCards(filter, source.getSourceId(), source.getControllerId(), game));
controller.putCardsOnTopOfLibrary(cardsToLibrary, game, source, false);
controller.shuffleLibrary(source, game);
return true;
}
}
return false;
}
use of mage.cards.CardsImpl in project mage by magefree.
the class FieldOfRuinEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
Player player = game.getPlayer(playerId);
if (player != null) {
TargetCardInLibrary target = new TargetCardInLibrary(0, 1, StaticFilters.FILTER_CARD_BASIC_LAND);
if (player.searchLibrary(target, source, game)) {
player.moveCards(new CardsImpl(target.getTargets()).getCards(game), Zone.BATTLEFIELD, source, game);
player.shuffleLibrary(source, game);
}
}
}
return true;
}
return false;
}
Aggregations