use of mage.cards.Cards in project mage by magefree.
the class LensOfClarityLookFaceDownEffect 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) {
return false;
}
Permanent faceDownCreature = game.getPermanent(getTargetPointer().getFirst(game, source));
if (faceDownCreature != null) {
Permanent copyFaceDown = faceDownCreature.copy();
copyFaceDown.setFaceDown(false, game);
Cards cards = new CardsImpl(copyFaceDown);
Player player = game.getPlayer(faceDownCreature.getControllerId());
controller.lookAtCards("face down card - " + mageObject.getName(), cards, game);
if (player != null) {
game.informPlayers(controller.getLogName() + " looks at a face down creature of " + player.getLogName());
}
} else {
return false;
}
return true;
}
use of mage.cards.Cards in project mage by magefree.
the class LevelerExileLibraryEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
int count = controller.getLibrary().size();
Cards cards = new CardsImpl(controller.getLibrary().getTopCards(game, count));
controller.moveCards(cards, Zone.EXILED, source, game);
return true;
}
return false;
}
use of mage.cards.Cards in project mage by magefree.
the class MassPolymorphEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
// Cards creatures = new CardsImpl();
Set<Card> creaturesToExile = new HashSet<>(game.getBattlefield().getAllActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE, source.getControllerId(), game));
int count = creaturesToExile.size();
controller.moveCards(creaturesToExile, Zone.EXILED, source, game);
Cards revealed = new CardsImpl();
Set<Card> creatureCards = new LinkedHashSet<>();
for (Card card : controller.getLibrary().getCards(game)) {
revealed.add(card);
if (card.isCreature(game)) {
creatureCards.add(card);
if (creatureCards.size() == count) {
break;
}
}
}
controller.revealCards(source, revealed, game);
controller.moveCards(creatureCards, Zone.BATTLEFIELD, source, game, false, false, true, null);
controller.shuffleLibrary(source, game);
return true;
}
return false;
}
use of mage.cards.Cards in project mage by magefree.
the class MoonlightBargainEffect 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) {
Set<Card> topFive = controller.getLibrary().getTopCards(game, 5);
Cards lookAtCards = new CardsImpl();
lookAtCards.addAll(topFive);
controller.lookAtCards(sourceObject.getIdName(), lookAtCards, game);
Cards toHand = new CardsImpl();
for (Card card : topFive) {
PayLifeCost cost = new PayLifeCost(2);
if (cost.canPay(source, source, source.getControllerId(), game)) {
if (controller.chooseUse(outcome, "Put " + card.getIdName() + " into your graveyard unless you pay 2 life", sourceObject.getIdName(), "Pay 2 life and put into hand", "Put into your graveyard", source, game)) {
if (cost.pay(source, game, source, source.getControllerId(), false)) {
toHand.add(card);
} else {
controller.moveCards(card, Zone.GRAVEYARD, source, game);
}
} else {
controller.moveCards(card, Zone.GRAVEYARD, source, game);
}
}
}
controller.moveCards(toHand, Zone.HAND, source, game);
return true;
}
return false;
}
use of mage.cards.Cards in project mage by magefree.
the class MonomaniaEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getFirstTarget());
if (player == null || player.getHand().isEmpty()) {
return false;
}
TargetCard target = new TargetDiscard(player.getId());
player.choose(Outcome.Benefit, player.getHand(), target, game);
Cards cards = player.getHand().copy();
cards.removeIf(target.getTargets()::contains);
return !player.discard(cards, false, source, game).isEmpty();
}
Aggregations