use of mage.cards.Cards in project mage by magefree.
the class SpinningDarknessCost method pay.
@Override
public boolean pay(Ability ability, Game game, Ability source, UUID controllerId, boolean noMana, Cost costToPay) {
Player controller = game.getPlayer(controllerId);
if (controller != null) {
Set<Card> blackCardsInGraveyard = controller.getGraveyard().getCards(filter, game);
int size = blackCardsInGraveyard.size();
if (size >= 3) {
Iterator<Card> it = blackCardsInGraveyard.iterator();
Cards cardsToExile = new CardsImpl();
int i = 1;
while (cardsToExile.size() < 3) {
Card card = it.next();
if (i > size - 3) {
cardsToExile.add(card);
}
i++;
}
paid = controller.moveCards(cardsToExile, Zone.EXILED, ability, game);
}
}
return paid;
}
use of mage.cards.Cards in project mage by magefree.
the class StormOfSoulsChangeCreatureEffect 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(player.getGraveyard().getCards(StaticFilters.FILTER_CARD_CREATURE, game));
if (cards.isEmpty()) {
return false;
}
player.moveCards(cards, Zone.BATTLEFIELD, source, game);
// Figure out which cards were successfuly moved so that they can be turned into 1/1 Spirits
cards.retainZone(Zone.BATTLEFIELD, game);
// Change the creatures
game.addEffect(new StormOfSoulsChangeCreatureEffect().setTargetPointer(new FixedTargets(cards, game)), source);
return true;
}
use of mage.cards.Cards in project mage by magefree.
the class VoidMawCost method pay.
@Override
public boolean pay(Ability ability, Game game, Ability source, UUID controllerId, boolean noMana, Cost costToPay) {
Player controller = game.getPlayer(controllerId);
if (controller != null) {
TargetCardInExile target = new TargetCardInExile(new FilterCard(), CardUtil.getCardExileZoneId(game, ability));
target.setNotTarget(true);
Cards cards = game.getExile().getExileZone(CardUtil.getCardExileZoneId(game, ability));
if (cards != null && !cards.isEmpty() && controller.choose(Outcome.Benefit, cards, target, game)) {
Card card = game.getCard(target.getFirstTarget());
if (card != null) {
if (controller.moveCardToGraveyardWithInfo(card, source, game, Zone.EXILED)) {
paid = true;
}
}
}
}
return paid;
}
use of mage.cards.Cards in project mage by magefree.
the class ExploreSourceEffect method explorePermanent.
public static boolean explorePermanent(Game game, UUID permanentId, Ability source) {
Boolean cardWasRevealed = false;
Permanent permanent = game.getPermanentOrLKIBattlefield(permanentId);
if (permanent == null) {
return false;
}
Player permanentController = game.getPlayer(source.getControllerId());
if (permanentController == null) {
return false;
}
game.fireEvent(GameEvent.getEvent(GameEvent.EventType.EXPLORED, permanentId, source, permanent.getControllerId()));
if (permanentController.getLibrary().hasCards()) {
Card card = permanentController.getLibrary().getFromTop(game);
Cards cards = new CardsImpl();
cards.add(card);
permanentController.revealCards("Explored card", cards, game);
cardWasRevealed = true;
if (card != null) {
if (card.isLand(game)) {
permanentController.moveCards(card, Zone.HAND, source, game);
} else {
if (game.getState().getZone(permanentId) == Zone.BATTLEFIELD) {
// needed in case LKI object is used
permanent.addCounters(CounterType.P1P1.createInstance(), source.getControllerId(), source, game);
}
if (permanentController.chooseUse(Outcome.Neutral, "Put " + card.getLogName() + " in your graveyard?", source, game)) {
permanentController.moveCards(card, Zone.GRAVEYARD, source, game);
} else {
game.informPlayers(permanentController.getLogName() + " leaves " + card.getLogName() + " on top of their library.");
}
}
}
}
if (!cardWasRevealed && game.getState().getZone(permanentId) == Zone.BATTLEFIELD) {
// If no card is revealed, most likely because that player's library is empty,
// the exploring creature receives a +1/+1 counter.
permanent.addCounters(CounterType.P1P1.createInstance(), source.getControllerId(), source, game);
}
return true;
}
use of mage.cards.Cards in project mage by magefree.
the class FatesealEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
Target target = new TargetOpponent(true);
if (controller.choose(outcome, target, source.getSourceId(), game)) {
Player opponent = game.getPlayer(target.getFirstTarget());
if (opponent == null) {
return false;
}
// by looking at the cards with fateseal you have not to reveal the next card
boolean revealed = opponent.isTopCardRevealed();
opponent.setTopCardRevealed(false);
Cards cards = new CardsImpl();
int count = Math.min(fatesealNumber, opponent.getLibrary().size());
if (count == 0) {
return true;
}
for (int i = 0; i < count; i++) {
Card card = opponent.getLibrary().removeFromTop(game);
cards.add(card);
}
TargetCard target1 = new TargetCard(Zone.LIBRARY, filter1);
target1.setRequired(false);
// move cards to the bottom of the library
while (!cards.isEmpty() && controller.choose(Outcome.Detriment, cards, target1, game)) {
if (!controller.canRespond() || !opponent.canRespond()) {
return false;
}
Card card = cards.get(target1.getFirstTarget(), game);
if (card != null) {
cards.remove(card);
controller.moveCardToLibraryWithInfo(card, source, game, Zone.LIBRARY, false, false);
}
target1.clearChosen();
}
// move cards to the top of the library
controller.putCardsOnTopOfLibrary(cards, game, source, true);
game.fireEvent(new GameEvent(GameEvent.EventType.FATESEALED, opponent.getId(), source, source.getControllerId()));
controller.setTopCardRevealed(revealed);
return true;
}
}
return false;
}
Aggregations