use of mage.target.common.TargetOpponent in project mage by magefree.
the class MausoleumTurnkeyEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
UUID opponentId = null;
if (game.getOpponents(controller.getId()).size() > 1) {
Target target = new TargetOpponent(true);
if (controller.chooseTarget(outcome, target, source, game)) {
opponentId = target.getFirstTarget();
}
} else {
opponentId = game.getOpponents(controller.getId()).iterator().next();
}
if (opponentId != null) {
Player opponent = game.getPlayer(opponentId);
if (opponent != null) {
FilterCreatureCard filter = new FilterCreatureCard("creature card from " + controller.getLogName() + " graveyard");
filter.add(new OwnerIdPredicate(controller.getId()));
Target target = new TargetCardInGraveyard(filter);
opponent.chooseTarget(outcome, target, source, game);
Card card = game.getCard(target.getFirstTarget());
if (card != null) {
controller.moveCards(card, Zone.HAND, source, game);
}
}
}
return true;
}
return false;
}
use of mage.target.common.TargetOpponent in project mage by magefree.
the class RogueSkycaptainEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
Permanent permanent = game.getPermanentOrLKIBattlefield(source.getSourceId());
if (controller != null && permanent != null) {
new AddCountersSourceEffect(CounterType.WAGE.createInstance(), true).apply(game, source);
Cost cost = ManaUtil.createManaCost(2 * permanent.getCounters(game).getCount(CounterType.WAGE), false);
if (!cost.pay(source, game, source, controller.getId(), false)) {
new RemoveAllCountersSourceEffect(CounterType.WAGE).apply(game, source);
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);
target.setNotTarget(true);
target.choose(Outcome.GainControl, source.getControllerId(), source.getSourceId(), game);
opponent = game.getPlayer(target.getFirstTarget());
}
if (opponent != null) {
permanent.changeControllerId(opponent.getId(), game, source);
}
}
return true;
}
return false;
}
use of mage.target.common.TargetOpponent in project mage by magefree.
the class SlithermuseEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
Permanent permanent = (Permanent) game.getLastKnownInformation(source.getSourceId(), Zone.BATTLEFIELD);
if (player != null && permanent != null) {
TargetOpponent target = new TargetOpponent();
target.setNotTarget(true);
if (player.choose(this.outcome, target, source.getSourceId(), game)) {
Player chosenPlayer = game.getPlayer(target.getFirstTarget());
if (chosenPlayer != null) {
game.informPlayers(permanent.getName() + ": " + player.getLogName() + " has chosen " + chosenPlayer.getLogName());
int diff = chosenPlayer.getHand().size() - player.getHand().size();
if (diff > 0) {
player.drawCards(diff, source, game);
}
return true;
}
}
}
return false;
}
use of mage.target.common.TargetOpponent in project mage by magefree.
the class SylvanOfferingEffect2 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.Sacrifice, source.getControllerId(), source.getSourceId(), game);
Player opponent = game.getPlayer(target.getFirstTarget());
if (opponent != null) {
int xValue = source.getManaCostsToPay().getX();
Effect effect = new CreateTokenTargetEffect(new ElfWarriorToken(), xValue);
effect.setTargetPointer(new FixedTarget(controller.getId()));
effect.apply(game, source);
effect.setTargetPointer(new FixedTarget(opponent.getId()));
effect.apply(game, source);
return true;
}
}
return false;
}
use of mage.target.common.TargetOpponent in project mage by magefree.
the class WishclawTalismanEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
effect.apply(game, source);
Player player = game.getPlayer(source.getControllerId());
if (player == null) {
return false;
}
TargetPlayer target = new TargetOpponent();
target.setNotTarget(true);
if (!player.choose(outcome, target, source.getSourceId(), game)) {
return false;
}
ContinuousEffect continuousEffect = new GainControlTargetEffect(Duration.Custom, true, target.getFirstTarget());
continuousEffect.setTargetPointer(new FixedTarget(source.getSourceId(), game));
game.addEffect(continuousEffect, source);
return true;
}
Aggregations