use of mage.target.TargetPlayer 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.target.TargetPlayer in project mage by magefree.
the class LoreholdCommandEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player targetPlayer = game.getPlayer(source.getFirstTarget());
if (targetPlayer != null) {
targetPlayer.damage(3, source.getSourceId(), source, game);
}
Permanent targetPermanent = game.getPermanent(source.getFirstTarget());
if (targetPermanent != null) {
targetPermanent.damage(3, source.getSourceId(), source, game);
}
Player player = game.getPlayer(source.getTargets().get(1).getFirstTarget());
if (player != null) {
player.gainLife(3, game, source);
}
return true;
}
use of mage.target.TargetPlayer 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.target.TargetPlayer in project mage by magefree.
the class SufferThePastEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
FilterCard filter = new FilterCard("card in target player's graveyard");
int numberExiled = 0;
Player you = game.getPlayer(source.getControllerId());
Player targetPlayer = game.getPlayer(targetPointer.getFirst(game, source));
if (targetPlayer != null) {
int numberToTarget = Math.min(targetPlayer.getGraveyard().size(), source.getManaCostsToPay().getX());
TargetCardInOpponentsGraveyard target = new TargetCardInOpponentsGraveyard(numberToTarget, numberToTarget, filter);
if (you != null) {
if (target.canChoose(source.getSourceId(), source.getControllerId(), game) && target.choose(Outcome.Neutral, source.getControllerId(), source.getSourceId(), game)) {
if (!target.getTargets().isEmpty()) {
List<UUID> targets = target.getTargets();
for (UUID targetId : targets) {
Card card = game.getCard(targetId);
if (card != null) {
card.moveToExile(id, "Suffer the Past", source, game);
numberExiled++;
}
}
you.gainLife(numberExiled, game, source);
targetPlayer.loseLife(numberExiled, game, source, false);
}
}
return true;
}
}
return false;
}
use of mage.target.TargetPlayer in project mage by magefree.
the class VassalsDutyPreventDamageTargetEffect method applies.
@Override
public boolean applies(GameEvent event, Ability source, Game game) {
if (event.getTargetId().equals(getTargetPointer().getFirst(game, source))) {
TargetPlayer target = new TargetPlayer();
target.add(source.getControllerId(), game);
redirectTarget = target;
return true;
}
return false;
}
Aggregations