use of mage.target.TargetPlayer in project mage by magefree.
the class EmberGaleEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player targetPlayer = game.getPlayer(source.getFirstTarget());
if (targetPlayer != null) {
FilterCreaturePermanent filter = new FilterCreaturePermanent();
filter.add(new ControllerIdPredicate(targetPlayer.getId()));
RestrictionEffect effect = new CantBlockAllEffect(filter, Duration.EndOfTurn);
game.addEffect(effect, source);
FilterPermanent filter2 = new FilterPermanent();
filter2.add(new ControllerIdPredicate(targetPlayer.getId()));
filter2.add(Predicates.or(new ColorPredicate(ObjectColor.WHITE), new ColorPredicate(ObjectColor.BLUE)));
filter2.add(CardType.CREATURE.getPredicate());
for (Permanent creature : game.getBattlefield().getAllActivePermanents(filter2, targetPlayer.getId(), game)) {
creature.damage(1, source.getSourceId(), source, game, false, true);
}
return true;
}
return false;
}
use of mage.target.TargetPlayer in project mage by magefree.
the class EquipoiseEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
Player targetPlayer = game.getPlayer(getTargetPointer().getFirst(game, source));
if (controller != null && targetPlayer != null) {
if (!Objects.equals(targetPlayer, controller)) {
phaseOutCardType(controller, targetPlayer, CardType.LAND, source, game);
phaseOutCardType(controller, targetPlayer, CardType.ARTIFACT, source, game);
phaseOutCardType(controller, targetPlayer, CardType.CREATURE, source, game);
}
return true;
}
return false;
}
use of mage.target.TargetPlayer in project mage by magefree.
the class RunEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player targetPlayer = game.getPlayer(source.getTargets().getFirstTarget());
if (targetPlayer != null) {
FilterControlledPermanent filter = new FilterControlledPermanent("artifact or creature");
filter.add(Predicates.or(CardType.ARTIFACT.getPredicate(), CardType.CREATURE.getPredicate()));
TargetControlledPermanent target = new TargetControlledPermanent(1, 1, filter, true);
if (target.canChoose(source.getSourceId(), targetPlayer.getId(), game)) {
targetPlayer.choose(Outcome.Sacrifice, target, source.getSourceId(), game);
Permanent permanent = game.getPermanent(target.getFirstTarget());
if (permanent != null) {
permanent.sacrifice(source, game);
int damage = permanent.getManaValue();
if (damage > 0) {
targetPlayer.damage(damage, source.getSourceId(), source, game);
}
}
}
}
return true;
}
use of mage.target.TargetPlayer in project mage by magefree.
the class LilianasIndignationEffect 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) {
return true;
}
int creatures = controller.millCards(xValue, source, game).getCards(game).stream().filter(Objects::nonNull).filter(card -> game.getState().getZone(card.getId()) == Zone.GRAVEYARD).filter(card1 -> card1.isCreature(game)).mapToInt(x -> 2).sum();
if (creatures > 0) {
Player targetPlayer = game.getPlayer(source.getFirstTarget());
if (targetPlayer != null) {
targetPlayer.loseLife(creatures, game, source, false);
}
}
return true;
}
use of mage.target.TargetPlayer in project mage by magefree.
the class MindshriekerEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player targetPlayer = game.getPlayer(source.getFirstTarget());
if (targetPlayer == null) {
return false;
}
int totalCMC = targetPlayer.millCards(1, source, game).getCards(game).stream().filter(Objects::nonNull).mapToInt(MageObject::getManaValue).sum();
if (totalCMC > 0) {
game.addEffect(new BoostSourceEffect(totalCMC, totalCMC, Duration.EndOfTurn), source);
}
return false;
}
Aggregations