use of mage.target.TargetPlayer in project mage by magefree.
the class LammastideWeaveEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
Player targetPlayer = game.getPlayer(source.getFirstTarget());
String cardName = (String) game.getState().getValue(source.getSourceId().toString() + ChooseACardNameEffect.INFO_KEY);
if (controller == null || targetPlayer == null || cardName == null || cardName.isEmpty()) {
return false;
}
for (Card card : targetPlayer.millCards(1, source, game).getCards(game)) {
if (CardUtil.haveSameNames(card, cardName, game)) {
controller.gainLife(card.getManaValue(), game, source);
}
}
return true;
}
use of mage.target.TargetPlayer in project mage by magefree.
the class MultipleChoiceEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller == null) {
return false;
}
int xValue = source.getManaCostsToPay().getX();
if (xValue == 1 || xValue >= 4) {
controller.scry(1, source, game);
controller.drawCards(1, source, game);
}
if (xValue == 3 || xValue >= 4) {
new Elemental44Token().putOntoBattlefield(1, game, source, source.getControllerId());
}
if (xValue != 2 && xValue < 4) {
return true;
}
TargetPlayer targetPlayer = new TargetPlayer(0, 1, true);
controller.choose(Outcome.Detriment, targetPlayer, source.getSourceId(), game);
Player player = game.getPlayer(targetPlayer.getFirstTarget());
if (player == null || game.getBattlefield().count(StaticFilters.FILTER_CONTROLLED_CREATURE, source.getSourceId(), player.getId(), game) <= 0) {
return true;
}
TargetPermanent targetPermanent = new TargetControlledCreaturePermanent();
targetPermanent.setNotTarget(true);
player.choose(Outcome.ReturnToHand, targetPermanent, source.getSourceId(), game);
Permanent permanent = game.getPermanent(targetPermanent.getFirstTarget());
return permanent == null || player.moveCards(permanent, Zone.HAND, source, game);
}
use of mage.target.TargetPlayer in project mage by magefree.
the class OathOfGhoulsEffect method apply.
@Override
public boolean apply(ObjectSourcePlayer<Player> input, Game game) {
Player targetPlayer = input.getObject();
Player firstPlayer = game.getPlayer(game.getActivePlayerId());
if (targetPlayer == null || firstPlayer == null || !firstPlayer.hasOpponent(targetPlayer.getId(), game)) {
return false;
}
int countGraveyardTargetPlayer = targetPlayer.getGraveyard().getCards(StaticFilters.FILTER_CARD_CREATURE, game).size();
int countGraveyardFirstPlayer = firstPlayer.getGraveyard().getCards(StaticFilters.FILTER_CARD_CREATURE, game).size();
return countGraveyardTargetPlayer < countGraveyardFirstPlayer;
}
use of mage.target.TargetPlayer in project mage by magefree.
the class PredictEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
Player targetPlayer = game.getPlayer(source.getFirstTarget());
String cardName = (String) game.getState().getValue(source.getSourceId().toString() + ChooseACardNameEffect.INFO_KEY);
if (controller == null || targetPlayer == null || cardName == null || cardName.isEmpty()) {
return false;
}
int toDraw = 1;
for (Card card : targetPlayer.millCards(1, source, game).getCards(game)) {
if (CardUtil.haveSameNames(card, cardName, game)) {
toDraw = 2;
break;
}
}
controller.drawCards(toDraw, source, game);
return true;
}
use of mage.target.TargetPlayer 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;
}
Aggregations