use of mage.target.TargetPlayer in project mage by magefree.
the class WandOfDenialEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
Player targetPlayer = game.getPlayer(source.getFirstTarget());
if (controller != null && targetPlayer != null) {
Card card = targetPlayer.getLibrary().getFromTop(game);
if (card != null) {
MageObject sourceObject = game.getObject(source.getSourceId());
controller.lookAtCards(sourceObject != null ? sourceObject.getName() : "", new CardsImpl(card), game);
if (!card.isLand(game) && controller.canPayLifeCost(source) && controller.getLife() >= 2 && controller.chooseUse(Outcome.Neutral, "Pay 2 life to put " + card.getLogName() + " into graveyard?", source, game)) {
controller.loseLife(2, game, source, false);
controller.moveCards(card, Zone.GRAVEYARD, source, game);
}
return true;
}
}
return false;
}
use of mage.target.TargetPlayer in project mage by magefree.
the class GainLifeOpponentCost 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) {
TargetPlayer target = new TargetPlayer(1, 1, true, filter);
if (controller.chooseTarget(Outcome.Detriment, target, ability, game)) {
Player opponent = game.getPlayer(target.getFirstTarget());
if (opponent != null) {
opponent.gainLife(amount, game, source);
paid = true;
}
}
}
return paid;
}
use of mage.target.TargetPlayer in project mage by magefree.
the class ArchitectsOfWillEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
Player targetPlayer = game.getPlayer(source.getFirstTarget());
if (targetPlayer == null || controller == null) {
return false;
}
Cards cards = new CardsImpl(targetPlayer.getLibrary().getTopCards(game, 3));
controller.lookAtCards(source, null, cards, game);
controller.putCardsOnTopOfLibrary(cards, game, source, true);
return true;
}
use of mage.target.TargetPlayer in project mage by magefree.
the class CompulsiveResearchDiscardEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player targetPlayer = game.getPlayer(this.getTargetPointer().getFirst(game, source));
if (targetPlayer == null || targetPlayer.getHand().isEmpty()) {
return false;
}
if (targetPlayer.getHand().count(StaticFilters.FILTER_CARD_LAND, game) < 1 || !targetPlayer.chooseUse(outcome, "Discard a land card?", source, game)) {
return !targetPlayer.discard(2, false, false, source, game).isEmpty();
}
TargetDiscard target = new TargetDiscard(StaticFilters.FILTER_CARD_LAND_A, targetPlayer.getId());
targetPlayer.choose(Outcome.Discard, target, source.getSourceId(), game);
Card card = targetPlayer.getHand().get(target.getFirstTarget(), game);
if (card != null && targetPlayer.discard(card, false, source, game)) {
return true;
}
return !targetPlayer.discard(2, false, false, source, game).isEmpty();
}
use of mage.target.TargetPlayer in project mage by magefree.
the class CollectiveDefianceEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player targetPlayer = game.getPlayer(targetPointer.getFirst(game, source));
if (targetPlayer == null) {
return false;
}
int count = targetPlayer.discard(targetPlayer.getHand(), false, source, game).size();
targetPlayer.drawCards(count, source, game);
return true;
}
Aggregations