use of mage.target.TargetPlayer in project mage by magefree.
the class CryptIncursionEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
Player targetPlayer = game.getPlayer(source.getFirstTarget());
Cards cards = new CardsImpl(targetPlayer.getGraveyard().getCards(StaticFilters.FILTER_CARD_CREATURE, game));
player.moveCards(cards, Zone.EXILED, source, game);
int count = cards.stream().map(game.getState()::getZone).map(Zone.EXILED::equals).mapToInt(x -> x ? 1 : 0).sum();
player.gainLife(3 * count, game, source);
return true;
}
use of mage.target.TargetPlayer in project mage by magefree.
the class HopeOfGhirapurCombatDamageWatcher method apply.
@Override
public boolean apply(ObjectSourcePlayer<Player> input, Game game) {
Player targetPlayer = input.getObject();
if (targetPlayer == null) {
return false;
}
HopeOfGhirapurCombatDamageWatcher watcher = game.getState().getWatcher(HopeOfGhirapurCombatDamageWatcher.class);
if (watcher != null) {
return watcher.playerGotCombatDamage(input.getSourceId(), input.getObject().getId(), game);
}
return false;
}
use of mage.target.TargetPlayer in project mage by magefree.
the class NaturalSelectionEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
Player targetPlayer = game.getPlayer(source.getFirstTarget());
if (targetPlayer == null || controller == null) {
return false;
}
Cards cards = new CardsImpl(targetPlayer.getLibrary().getTopCards(game, 3));
controller.lookAtCards(source, null, cards, game);
controller.putCardsOnTopOfLibrary(cards, game, source, true);
if (controller.chooseUse(Outcome.Neutral, "You may have that player shuffle", source, game)) {
targetPlayer.shuffleLibrary(source, game);
}
return true;
}
use of mage.target.TargetPlayer in project mage by magefree.
the class TorgaarFamineIncarnateEffectCostReductionEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player targetPlayer = game.getPlayer(getTargetPointer().getFirst(game, source));
if (targetPlayer != null) {
int startingLifeTotal = game.getStartingLife();
targetPlayer.setLife(startingLifeTotal / 2, game, source);
}
return true;
}
use of mage.target.TargetPlayer in project mage by magefree.
the class VoidEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller == null) {
return false;
}
int number = controller.announceXMana(0, Integer.MAX_VALUE, this.staticText, game, source);
game.informPlayers(controller.getLogName() + " chooses " + number + '.');
for (Permanent permanent : game.getBattlefield().getActivePermanents(source.getControllerId(), game)) {
if ((permanent.isArtifact(game) || permanent.isCreature(game)) && permanent.getManaValue() == number) {
permanent.destroy(source, game, false);
}
}
FilterCard filterCard = new FilterCard();
filterCard.add(new ManaValuePredicate(ComparisonType.EQUAL_TO, number));
filterCard.add(Predicates.not(CardType.LAND.getPredicate()));
Player targetPlayer = game.getPlayer(targetPointer.getFirst(game, source));
if (targetPlayer == null) {
return true;
}
targetPlayer.revealCards(source, targetPlayer.getHand(), game);
targetPlayer.discard(new CardsImpl(targetPlayer.getHand().getCards(filterCard, game)), false, source, game);
return true;
}
Aggregations