use of mage.players.Player in project mage by magefree.
the class DeliverUntoEvilEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player == null) {
return false;
}
Cards cards = new CardsImpl(source.getTargets().get(0).getTargets());
if (cards.isEmpty()) {
return false;
}
if (!game.getBattlefield().getActivePermanents(filter, source.getControllerId(), game).isEmpty()) {
return player.moveCards(cards, Zone.HAND, source, game);
}
TargetOpponent targetOpponent = new TargetOpponent();
targetOpponent.setNotTarget(true);
if (!player.choose(outcome, targetOpponent, source.getSourceId(), game)) {
return false;
}
Player opponent = game.getPlayer(targetOpponent.getFirstTarget());
if (opponent == null) {
return false;
}
TargetCard targetCard = new TargetCardInGraveyard(Math.min(2, cards.size()), filter2);
if (!opponent.choose(outcome, cards, targetCard, game)) {
return false;
}
cards.removeAll(targetCard.getTargets());
return player.moveCards(cards, Zone.HAND, source, game);
}
use of mage.players.Player in project mage by magefree.
the class DiluvianPrimordialReplacementEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
for (Target target : source.getTargets()) {
if (target instanceof TargetCardInOpponentsGraveyard) {
Card targetCard = game.getCard(target.getFirstTarget());
if (targetCard != null) {
if (controller.chooseUse(Outcome.PlayForFree, "Cast " + targetCard.getLogName() + '?', source, game)) {
game.getState().setValue("PlayFromNotOwnHandZone" + targetCard.getId(), Boolean.TRUE);
Boolean cardWasCast = controller.cast(controller.chooseAbilityForCast(targetCard, game, true), game, true, new ApprovingObject(source, game));
game.getState().setValue("PlayFromNotOwnHandZone" + targetCard.getId(), null);
if (cardWasCast) {
ContinuousEffect effect = new DiluvianPrimordialReplacementEffect();
effect.setTargetPointer(new FixedTarget(targetCard.getId(), game.getState().getZoneChangeCounter(targetCard.getId())));
game.addEffect(effect, source);
}
}
}
}
}
return true;
}
return false;
}
use of mage.players.Player in project mage by magefree.
the class DiminishingReturnsEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
controller.moveCards(controller.getLibrary().getTopCards(game, 10), Zone.EXILED, source, game);
game.getState().processAction(game);
for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
Player player = game.getPlayer(playerId);
if (player != null) {
int amount = player.getAmount(0, 7, "How many cards to draw (up to 7)?", game);
player.drawCards(amount, source, game);
}
}
}
return true;
}
use of mage.players.Player in project mage by magefree.
the class DinOfTheFireherdEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
boolean applied;
Token token = new DinOfTheFireherdToken();
applied = token.putOntoBattlefield(1, game, source, source.getControllerId());
int blackCreaturesControllerControls = game.getBattlefield().countAll(blackCreatureFilter, source.getControllerId(), game);
int redCreaturesControllerControls = game.getBattlefield().countAll(redCreatureFilter, source.getControllerId(), game);
Player targetOpponent = game.getPlayer(targetPointer.getFirst(game, source));
if (targetOpponent != null) {
Effect effect = new SacrificeEffect(new FilterControlledCreaturePermanent(), blackCreaturesControllerControls, "Target Opponent");
effect.setTargetPointer(new FixedTarget(targetOpponent.getId()));
effect.apply(game, source);
Effect effect2 = new SacrificeEffect(new FilterControlledLandPermanent(), redCreaturesControllerControls, "Target Opponent");
effect2.setTargetPointer(new FixedTarget(targetOpponent.getId()));
effect2.apply(game, source);
applied = true;
}
return applied;
}
use of mage.players.Player in project mage by magefree.
the class DinrovaHorrorEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Permanent target = game.getPermanent(source.getFirstTarget());
if (target != null) {
Player controller = game.getPlayer(target.getControllerId());
if (controller != null) {
controller.moveCards(target, Zone.HAND, source, game);
controller.discard(1, false, false, source, game);
return true;
}
}
return false;
}
Aggregations