use of mage.cards.Card in project mage by magefree.
the class SadisticSacramentEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player targetPlayer = game.getPlayer(source.getFirstTarget());
Player player = game.getPlayer(source.getControllerId());
if (player != null && targetPlayer != null) {
TargetCardInLibrary target = new TargetCardInLibrary(0, amount, new FilterCard("cards to exile"));
if (player.searchLibrary(target, source, game, targetPlayer.getId())) {
List<UUID> targets = target.getTargets();
for (UUID targetId : targets) {
Card card = targetPlayer.getLibrary().remove(targetId, game);
if (card != null) {
card.moveToExile(null, "", source, game);
}
}
}
targetPlayer.shuffleLibrary(source, game);
return true;
}
return false;
}
use of mage.cards.Card in project mage by magefree.
the class RunoStromkirkEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player == null) {
return false;
}
Card card = player.getLibrary().getFromTop(game);
if (card == null) {
return false;
}
player.lookAtCards(null, card, game);
if (!player.chooseUse(outcome, "Reveal " + card.getName() + '?', source, game)) {
return true;
}
player.revealCards(source, new CardsImpl(card), game);
if (!card.isCreature(game) || card.getManaValue() < 6) {
return true;
}
Permanent permanent = source.getSourcePermanentIfItStillExists(game);
if (permanent != null) {
permanent.transform(source, game);
}
return true;
}
use of mage.cards.Card in project mage by magefree.
the class SenTripletsPlayFromOpponentsHandEffect method applies.
@Override
public boolean applies(UUID objectId, Ability source, UUID affectedControllerId, Game game) {
Card card = game.getCard(objectId);
Zone zone;
if (card instanceof Spell) {
zone = ((Spell) card).getFromZone();
} else if (card != null) {
zone = game.getState().getZone(card.getMainCard().getId());
} else {
return false;
}
return card.isOwnedBy(getTargetPointer().getFirst(game, source)) && zone == Zone.HAND && source.isControlledBy(affectedControllerId);
}
use of mage.cards.Card in project mage by magefree.
the class SefrisOfTheHiddenWaysTriggeredAbility method checkTrigger.
@Override
public boolean checkTrigger(GameEvent event, Game game) {
Boolean applies = false;
/*
Sefris of the Hidden Ways must be on the battlefield for its first ability to trigger.
It does not trigger when Sefris goes to the graveyard from the battlefield, even if other
creature cards also went to the graveyard at the same time.
*/
Permanent sourceCard = game.getPermanent(sourceId);
if (((ZoneChangeGroupEvent) event).getToZone() != Zone.GRAVEYARD || sourceCard == null) {
return false;
}
ZoneChangeGroupEvent zEvent = (ZoneChangeGroupEvent) event;
Set<Card> cards = zEvent.getCards();
for (Card card : cards) {
if (card.isCreature(game) && // 603.6c, 603.10a, and 603.10.
(Card) sourceCard != card && !card.isCopy() && card.isOwnedBy(controllerId)) {
applies = true;
}
}
return applies;
}
use of mage.cards.Card in project mage by magefree.
the class SifterWurmEffect 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) {
controller.scry(3, source, game);
Card card = controller.getLibrary().getFromTop(game);
if (card != null) {
Cards cards = new CardsImpl();
cards.add(card);
controller.revealCards(sourceObject.getIdName(), cards, game);
controller.gainLife(card.getManaValue(), game, source);
}
return true;
}
return false;
}
Aggregations