use of mage.cards.Card in project mage by magefree.
the class LongRoadHomeEntersBattlefieldEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Card card = game.getCard(objectToReturn.getSourceId());
if (card != null && objectToReturn.refersTo(card, game)) {
Player owner = game.getPlayer(card.getOwnerId());
if (owner != null) {
if (card instanceof MeldCard) {
MeldCard meldCard = (MeldCard) card;
game.addEffect(new LongRoadHomeEntersBattlefieldEffect(new MageObjectReference(meldCard.getTopHalfCard(), game)), source);
game.addEffect(new LongRoadHomeEntersBattlefieldEffect(new MageObjectReference(meldCard.getBottomHalfCard(), game)), source);
} else {
game.addEffect(new LongRoadHomeEntersBattlefieldEffect(objectToReturn), source);
}
owner.moveCards(card, Zone.BATTLEFIELD, source, game, false, false, true, null);
}
}
return true;
}
use of mage.cards.Card in project mage by magefree.
the class LongTermPlansEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player != null) {
TargetCardInLibrary target = new TargetCardInLibrary();
if (player.searchLibrary(target, source, game)) {
Card card = player.getLibrary().remove(target.getFirstTarget(), game);
if (card != null) {
player.shuffleLibrary(source, game);
// must hides the card name from other players
player.putCardOnTopXOfLibrary(card, game, source, 3, false);
}
}
return true;
}
return false;
}
use of mage.cards.Card in project mage by magefree.
the class LorcanWarlockCollectorReplacementEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
Card card = game.getCard(getTargetPointer().getFirst(game, source));
if (player == null || card == null) {
return false;
}
Cost cost = new PayLifeCost(card.getManaValue());
if (!cost.canPay(source, source, source.getControllerId(), game) || !cost.pay(source, game, source, source.getControllerId(), true)) {
return false;
}
game.addEffect(new AddCardSubTypeTargetEffect(SubType.WARLOCK, Duration.Custom).setTargetPointer(new FixedTarget(card.getId(), card.getZoneChangeCounter(game) + 1)), source);
player.moveCards(card, Zone.BATTLEFIELD, source, game);
return true;
}
use of mage.cards.Card in project mage by magefree.
the class LostHoursEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player targetPlayer = game.getPlayer(targetPointer.getFirst(game, source));
Player controller = game.getPlayer(source.getControllerId());
if (targetPlayer != null && controller != null) {
targetPlayer.revealCards(source, targetPlayer.getHand(), game);
if (targetPlayer.getHand().size() > 0) {
TargetCard target = new TargetCard(Zone.HAND, new FilterCard(StaticFilters.FILTER_CARD_A_NON_LAND));
if (controller.choose(Outcome.Discard, targetPlayer.getHand(), target, game)) {
Card card = game.getCard(target.getFirstTarget());
if (card != null) {
targetPlayer.putCardOnTopXOfLibrary(card, game, source, 3, true);
}
}
}
return true;
}
return false;
}
use of mage.cards.Card in project mage by magefree.
the class LordOfTheVoidEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(this.getTargetPointer().getFirst(game, source));
Player controller = game.getPlayer(source.getControllerId());
if (player == null || controller == null) {
return false;
}
Cards cards = new CardsImpl(player.getLibrary().getTopCards(game, 7));
controller.moveCards(cards, Zone.EXILED, source, game);
if (!cards.getCards(StaticFilters.FILTER_CARD_CREATURE, game).isEmpty()) {
TargetCard target = new TargetCard(Zone.EXILED, StaticFilters.FILTER_CARD_CREATURE);
if (controller.chooseTarget(outcome, cards, target, source, game)) {
Card card = cards.get(target.getFirstTarget(), game);
if (card != null) {
controller.moveCards(card, Zone.BATTLEFIELD, source, game, false, false, false, null);
}
}
}
return true;
}
Aggregations