use of mage.cards.Cards in project mage by magefree.
the class DesperateResearchEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
String cardName = (String) game.getState().getValue(source.getSourceId().toString() + ChooseACardNameEffect.INFO_KEY);
Player player = game.getPlayer(source.getControllerId());
if (player == null || cardName == null) {
return false;
}
Cards cardsToExile = new CardsImpl(player.getLibrary().getTopCards(game, 7));
player.revealCards(source, cardsToExile, game);
FilterCard filter = new FilterCard();
filter.add(new NamePredicate(cardName));
Cards cardsToKeep = new CardsImpl(cardsToExile.getCards(filter, game));
cardsToExile.removeAll(cardsToKeep);
player.moveCards(cardsToKeep, Zone.HAND, source, game);
player.moveCards(cardsToExile, Zone.EXILED, source, game);
return true;
}
use of mage.cards.Cards in project mage by magefree.
the class DreamPillagerEffect 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) {
int amount = (Integer) getValue("damage");
if (amount > 0) {
Set<Card> cards = controller.getLibrary().getTopCards(game, amount);
if (!cards.isEmpty()) {
controller.moveCards(cards, Zone.EXILED, source, game);
Cards canBeCast = new CardsImpl();
for (Card card : cards) {
if (!card.isLand(game)) {
canBeCast.add(card);
}
}
ContinuousEffect effect = new PlayFromNotOwnHandZoneTargetEffect(Zone.EXILED, Duration.EndOfTurn);
effect.setTargetPointer(new FixedTargets(canBeCast, game));
game.addEffect(effect, source);
}
return true;
}
return true;
}
return false;
}
use of mage.cards.Cards in project mage by magefree.
the class HonorTheFallenEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller == null) {
return false;
}
Cards cards = new CardsImpl();
for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
Player player = game.getPlayer(playerId);
if (player == null) {
continue;
}
cards.addAll(player.getGraveyard().getCards(StaticFilters.FILTER_CARD_CREATURE, game));
}
controller.moveCards(cards, Zone.EXILED, source, game);
int count = cards.stream().map(game.getState()::getZone).map(Zone.EXILED::equals).mapToInt(x -> x ? 1 : 0).sum();
controller.gainLife(count, game, source);
return true;
}
use of mage.cards.Cards in project mage by magefree.
the class JaceTheMindSculptorEffect2 method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
Player player = game.getPlayer(source.getFirstTarget());
if (controller != null && player != null) {
Card card = player.getLibrary().getFromTop(game);
if (card != null) {
Cards cards = new CardsImpl(card);
controller.lookAtCards("Jace, the Mind Sculptor", cards, game);
if (controller.chooseUse(outcome, "Put that card on the bottom of its owner's library?", source, game)) {
controller.moveCardToLibraryWithInfo(card, source, game, Zone.LIBRARY, false, false);
} else {
game.informPlayers(controller.getLogName() + " puts the card back on top of the library.");
}
return true;
}
}
return false;
}
use of mage.cards.Cards in project mage by magefree.
the class LichsMirrorEffect method replaceEvent.
@Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
Player player = game.getPlayer(event.getPlayerId());
if (player != null) {
Cards toLib = new CardsImpl();
FilterControlledPermanent filter = new FilterControlledPermanent();
filter.add(new OwnerIdPredicate(player.getId()));
toLib.addAll(player.getHand());
toLib.addAll(player.getGraveyard());
for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)) {
toLib.add(permanent);
}
player.shuffleCardsToLibrary(toLib, game, source);
game.getState().processAction(game);
// original event is not a draw event, so skip it in params
player.drawCards(7, source, game);
player.setLife(20, game, source);
}
// replace the loses event
return true;
}
Aggregations