use of mage.cards.CardsImpl in project mage by magefree.
the class PrimitiveEtchingsAbility method checkTrigger.
@Override
public boolean checkTrigger(GameEvent event, Game game) {
if (event.getPlayerId().equals(this.getControllerId())) {
if (game.isActivePlayer(this.getControllerId()) && this.lastTriggeredTurn != game.getTurnNum()) {
Card card = game.getCard(event.getTargetId());
Player controller = game.getPlayer(this.getControllerId());
Permanent sourcePermanent = game.getPermanentOrLKIBattlefield(this.getSourceId());
if (card != null && controller != null && sourcePermanent != null) {
lastTriggeredTurn = game.getTurnNum();
controller.revealCards(sourcePermanent.getName(), new CardsImpl(card), game);
this.getEffects().clear();
if (card.isCreature(game)) {
this.addEffect(new DrawCardSourceControllerEffect(1));
}
return true;
}
}
}
return false;
}
use of mage.cards.CardsImpl in project mage by magefree.
the class RaidersKarveEffect 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) {
return false;
}
Card card = controller.getLibrary().getFromTop(game);
if (card == null) {
return true;
}
controller.lookAtCards(sourceObject.getIdName(), new CardsImpl(card), game);
if (!card.isLand(game)) {
return true;
}
String message = "Put " + card.getLogName() + " onto the battlefield tapped?";
if (controller.chooseUse(Outcome.PutLandInPlay, message, source, game)) {
controller.moveCards(card, Zone.BATTLEFIELD, source, game, true, false, false, null);
}
return true;
}
use of mage.cards.CardsImpl in project mage by magefree.
the class RiddleOfLightningEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
Card sourceCard = game.getCard(source.getSourceId());
if (sourceCard != null && controller != null) {
if (controller.getLibrary().hasCards()) {
Card card = controller.getLibrary().getFromTop(game);
controller.revealCards(sourceCard.getName(), new CardsImpl(card), game);
Permanent targetCreature = game.getPermanent(this.getTargetPointer().getFirst(game, source));
if (targetCreature != null) {
targetCreature.damage(card.getManaValue(), source.getSourceId(), source, game, false, true);
return true;
}
Player targetPlayer = game.getPlayer(this.getTargetPointer().getFirst(game, source));
if (targetPlayer != null) {
targetPlayer.damage(card.getManaValue(), source.getSourceId(), source, game);
return true;
}
}
return true;
}
return false;
}
use of mage.cards.CardsImpl in project mage by magefree.
the class ReyEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
Player targetPlayer = game.getPlayer(targetPointer.getFirst(game, source));
if (targetPlayer != null && controller != null) {
if (targetPlayer.getLibrary().hasCards()) {
// reveal the top card of target player's library.
Card topCard = targetPlayer.getLibrary().getFromTop(game);
CardsImpl reveal = new CardsImpl();
reveal.add(topCard);
targetPlayer.revealCards(source, reveal, game);
// You gain life equal to that card's converted mana cost.
if (topCard != null) {
controller.gainLife(topCard.getManaValue(), game, source);
}
}
return true;
}
return false;
}
use of mage.cards.CardsImpl in project mage by magefree.
the class SawtoothLoonEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
controller.drawCards(2, source, game);
TargetCardInHand target = new TargetCardInHand(2, 2, new FilterCard());
controller.chooseTarget(Outcome.Detriment, target, source, game);
Cards cardsToLibrary = new CardsImpl(target.getTargets());
if (!cardsToLibrary.isEmpty()) {
controller.putCardsOnBottomOfLibrary(cardsToLibrary, game, source, false);
}
return true;
}
return false;
}
Aggregations