use of mage.target.TargetPlayer in project mage by magefree.
the class ExtortionEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player targetPlayer = game.getPlayer(source.getFirstTarget());
Player you = game.getPlayer(source.getControllerId());
if (targetPlayer == null || you == null) {
return false;
}
you.lookAtCards("Discard", targetPlayer.getHand(), game);
TargetCard target = new TargetCardInHand(0, 2, StaticFilters.FILTER_CARD_CARDS);
target.setNotTarget(true);
you.choose(Outcome.Discard, targetPlayer.getHand(), target, game);
targetPlayer.discard(new CardsImpl(target.getTargets()), false, source, game);
return true;
}
use of mage.target.TargetPlayer in project mage by magefree.
the class ExtractEffect 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(1, 1, filter);
if (player.searchLibrary(target, source, game, targetPlayer.getId())) {
Card card = targetPlayer.getLibrary().remove(target.getFirstTarget(), game);
if (card != null) {
player.moveCardToExileWithInfo(card, null, null, source, game, Zone.LIBRARY, true);
}
}
targetPlayer.shuffleLibrary(source, game);
return true;
}
return false;
}
use of mage.target.TargetPlayer in project mage by magefree.
the class LinessaZephyrMageEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
Player targetPlayer = game.getPlayer(source.getFirstTarget());
if (targetPlayer != null) {
// Target player returns a creature they control to its owner's hand,
Target target = new TargetControlledCreaturePermanent();
target.setNotTarget(true);
if (target.choose(Outcome.ReturnToHand, targetPlayer.getId(), source.getSourceId(), game)) {
Permanent permanent = game.getPermanent(target.getFirstTarget());
if (permanent != null) {
targetPlayer.moveCards(permanent, Zone.HAND, source, game);
}
}
// then repeats this process for an artifact,
FilterControlledPermanent filter = new FilterControlledPermanent("artifact you control");
filter.add(CardType.ARTIFACT.getPredicate());
target = new TargetControlledPermanent(filter);
target.setNotTarget(true);
if (target.choose(Outcome.ReturnToHand, targetPlayer.getId(), source.getSourceId(), game)) {
Permanent permanent = game.getPermanent(target.getFirstTarget());
if (permanent != null) {
targetPlayer.moveCards(permanent, Zone.HAND, source, game);
}
}
// an enchantment,
filter = new FilterControlledPermanent("enchantment you control");
filter.add(CardType.ENCHANTMENT.getPredicate());
target = new TargetControlledPermanent(filter);
target.setNotTarget(true);
if (target.choose(Outcome.ReturnToHand, targetPlayer.getId(), source.getSourceId(), game)) {
Permanent permanent = game.getPermanent(target.getFirstTarget());
if (permanent != null) {
targetPlayer.moveCards(permanent, Zone.HAND, source, game);
}
}
// and a land.
filter = new FilterControlledPermanent("land you control");
filter.add(CardType.LAND.getPredicate());
target = new TargetControlledPermanent(filter);
target.setNotTarget(true);
if (target.choose(Outcome.ReturnToHand, targetPlayer.getId(), source.getSourceId(), game)) {
Permanent permanent = game.getPermanent(target.getFirstTarget());
if (permanent != null) {
targetPlayer.moveCards(permanent, Zone.HAND, source, game);
}
}
return true;
}
}
return false;
}
use of mage.target.TargetPlayer in project mage by magefree.
the class MindWarpEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player targetPlayer = game.getPlayer(source.getFirstTarget());
Player you = game.getPlayer(source.getControllerId());
if (targetPlayer == null || you == null) {
return false;
}
int amountToDiscard = source.getManaCostsToPay().getX();
TargetCard target = new TargetCardInHand(amountToDiscard, StaticFilters.FILTER_CARD_CARDS);
you.choose(outcome, targetPlayer.getHand(), target, game);
targetPlayer.discard(new CardsImpl(target.getTargets()), false, source, game);
return true;
}
use of mage.target.TargetPlayer in project mage by magefree.
the class NicolBolasTheArisenEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player targetPlayer = game.getPlayer(source.getFirstTarget());
Player controller = game.getPlayer(source.getControllerId());
if (targetPlayer == null || controller == null) {
return false;
}
return controller.moveCards(targetPlayer.getLibrary().getTopCards(game, targetPlayer.getLibrary().size() - 1), Zone.EXILED, source, game);
}
Aggregations