use of mage.target.common.TargetOpponent in project mage by magefree.
the class InfernalOfferingReturnEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
Target target = new TargetOpponent(true);
target.choose(Outcome.PutCreatureInPlay, source.getControllerId(), source.getSourceId(), game);
Player opponent = game.getPlayer(target.getFirstTarget());
target = new TargetCardInYourGraveyard(new FilterCreatureCard("creature card in your graveyard"));
if (target.choose(Outcome.PutCreatureInPlay, controller.getId(), source.getSourceId(), game)) {
Card card = controller.getGraveyard().get(target.getFirstTarget(), game);
if (card != null) {
controller.moveCards(card, Zone.BATTLEFIELD, source, game);
}
}
if (opponent != null) {
target = new TargetCardInYourGraveyard(new FilterCreatureCard("creature card in your graveyard"));
if (target.choose(Outcome.PutCreatureInPlay, opponent.getId(), source.getSourceId(), game)) {
Card card = opponent.getGraveyard().get(target.getFirstTarget(), game);
if (card != null) {
opponent.moveCards(card, Zone.BATTLEFIELD, source, game);
}
}
}
return true;
}
return false;
}
use of mage.target.common.TargetOpponent in project mage by magefree.
the class IngeniousMasteryEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player == null) {
return false;
}
if (!AlternativeCostSourceAbility.getActivatedStatus(game, source, this.alternativeCostOriginalID, false)) {
return player.drawCards(source.getManaCostsToPay().getX(), source, game) > 0;
}
player.drawCards(3, source, game);
TargetOpponent targetOpponent = new TargetOpponent(true);
if (!player.chooseTarget(Outcome.DrawCard, targetOpponent, source, game)) {
return false;
}
Player opponent = game.getPlayer(targetOpponent.getFirstTarget());
if (opponent == null) {
return false;
}
new TreasureToken().putOntoBattlefield(2, game, source, opponent.getId());
opponent.scry(2, source, game);
return true;
}
use of mage.target.common.TargetOpponent in project mage by magefree.
the class ExplosionOfRichesEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
for (UUID playerId : game.getState().getPlayersInRange(source.getControllerId(), game)) {
Player player = game.getPlayer(playerId);
if (player == null) {
continue;
}
if (!playerId.equals(source.getControllerId()) && !player.chooseUse(outcome, "Draw a card?", source, game)) {
continue;
}
if (player.drawCards(1, source, game) >= 1) {
continue;
}
ReflexiveTriggeredAbility ability = new ReflexiveTriggeredAbility(new DamageTargetEffect(5), false, "{this} deals damage to target opponent chosen at random");
Target target = new TargetOpponent();
target.setRandom(true);
ability.addTarget(target);
game.fireReflexiveTriggeredAbility(ability, source);
}
return true;
}
use of mage.target.common.TargetOpponent in project mage by magefree.
the class JaceArchitectOfThoughtEffect3 method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player == null) {
return false;
}
Cards allCards = new CardsImpl(player.getLibrary().getTopCards(game, 3));
player.revealCards(source, allCards, game);
Set<UUID> opponents = game.getOpponents(source.getControllerId());
if (!opponents.isEmpty()) {
Player opponent = null;
if (opponents.size() > 1) {
TargetOpponent targetOpponent = new TargetOpponent();
if (player.chooseTarget(Outcome.Neutral, targetOpponent, source, game)) {
opponent = game.getPlayer(targetOpponent.getFirstTarget());
}
}
if (opponent == null) {
opponent = game.getPlayer(opponents.iterator().next());
}
TargetCard target = new TargetCard(0, allCards.size(), Zone.LIBRARY, new FilterCard("cards to put in the first pile"));
target.setNotTarget(true);
opponent.choose(Outcome.Neutral, allCards, target, game);
Cards pile1 = new CardsImpl(target.getTargets());
Cards pile2 = new CardsImpl(allCards);
pile2.removeAll(pile1);
player.revealCards(source, "Pile 1", pile1, game);
player.revealCards(source, "Pile 2", pile2, game);
postPileToLog("Pile 1", pile1.getCards(game), game);
postPileToLog("Pile 2", pile2.getCards(game), game);
boolean pileChoice = player.choosePile(Outcome.Neutral, "Choose a pile to to put into your hand.", new ArrayList<>(pile1.getCards(game)), new ArrayList<>(pile2.getCards(game)), game);
game.informPlayers(player.getLogName() + " chose pile" + (pileChoice ? "1" : "2"));
player.moveCards(pileChoice ? pile1 : pile2, Zone.HAND, source, game);
player.putCardsOnBottomOfLibrary(pileChoice ? pile2 : pile1, game, source, true);
return true;
}
return false;
}
use of mage.target.common.TargetOpponent in project mage by magefree.
the class KarnMinus1Effect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
MageObject sourceObject = game.getObject(source.getSourceId());
if (sourceObject == null || controller == null) {
return false;
}
Cards cards = new CardsImpl(controller.getLibrary().getTopCards(game, 2));
if (cards.isEmpty()) {
return true;
}
controller.revealCards(staticText, cards, game);
Card cardToHand;
if (cards.size() == 1) {
cardToHand = cards.getRandom(game);
} else {
Player opponent;
Set<UUID> opponents = game.getOpponents(controller.getId());
if (opponents.size() == 1) {
opponent = game.getPlayer(opponents.iterator().next());
} else {
Target target = new TargetOpponent(true);
controller.chooseTarget(Outcome.Detriment, target, source, game);
opponent = game.getPlayer(target.getFirstTarget());
}
TargetCard target = new TargetCard(1, Zone.LIBRARY, new FilterCard());
opponent.chooseTarget(outcome, cards, target, source, game);
cardToHand = game.getCard(target.getFirstTarget());
}
if (cardToHand != null) {
controller.moveCards(cardToHand, Zone.HAND, source, game);
cards.remove(cardToHand);
}
if (!cards.isEmpty()) {
controller.moveCards(cards, Zone.EXILED, source, game);
for (Card c : cards.getCards(game)) {
c.addCounters(CounterType.SILVER.createInstance(1), source.getControllerId(), source, game);
}
}
return true;
}
Aggregations