use of mage.target.common.TargetDiscard in project mage by magefree.
the class BlimComedicGeniusEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
game.addEffect(new GainControlTargetEffect(Duration.Custom, true, targetPointer.getFirst(game, source)).setTargetPointer(new FixedTarget(source.getFirstTarget(), game)), source);
game.getState().processAction(game);
Map<UUID, Cards> cardsMap = new HashMap<>();
for (UUID playerId : game.getState().getPlayersInRange(source.getControllerId(), game)) {
Player player = game.getPlayer(playerId);
if (player == null) {
continue;
}
int count = game.getBattlefield().count(filter, source.getSourceId(), playerId, game);
if (count < 1) {
continue;
}
player.loseLife(count, game, source, true);
TargetDiscard target = new TargetDiscard(StaticFilters.FILTER_CARD, playerId);
player.choose(outcome, target, source.getSourceId(), game);
cardsMap.put(playerId, new CardsImpl(target.getTargets()));
}
for (Map.Entry<UUID, Cards> entry : cardsMap.entrySet()) {
Player player = game.getPlayer(entry.getKey());
if (player == null) {
continue;
}
player.discard(entry.getValue(), false, source, game);
}
return true;
}
use of mage.target.common.TargetDiscard in project mage by magefree.
the class BlastOfGeniusEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player != null) {
player.drawCards(3, source, game);
TargetDiscard target = new TargetDiscard(player.getId());
if (target.canChoose(source.getSourceId(), player.getId(), game)) {
player.choose(Outcome.Discard, target, source.getSourceId(), game);
Card card = player.getHand().get(target.getFirstTarget(), game);
if (card != null) {
player.discard(card, false, source, game);
int damage = card.getManaValue();
Permanent creature = game.getPermanent(this.getTargetPointer().getFirst(game, source));
if (creature != null) {
creature.damage(damage, source.getSourceId(), source, game, false, true);
return true;
}
Player targetPlayer = game.getPlayer(this.getTargetPointer().getFirst(game, source));
if (targetPlayer != null) {
targetPlayer.damage(damage, source.getSourceId(), source, game);
return true;
}
}
}
}
return false;
}
use of mage.target.common.TargetDiscard in project mage by magefree.
the class AzraBladeseekerEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
List<PlayerCard> playerCardList = new ArrayList<>();
for (UUID playerId : game.getState().getPlayersInRange(source.getControllerId(), game)) {
Player player = game.getPlayer(playerId);
if (player == null || player.hasOpponent(source.getControllerId(), game) || player.getHand().isEmpty() || !player.chooseUse(Outcome.DrawCard, "Discard a card?", source, game)) {
continue;
}
Target target = new TargetDiscard(playerId);
if (target.choose(Outcome.DrawCard, playerId, source.getSourceId(), game)) {
Card card = game.getCard(target.getFirstTarget());
if (card != null) {
playerCardList.add(new PlayerCard(player, card));
}
}
}
for (PlayerCard playerCard : playerCardList) {
if (playerCard.getPlayer().discard(playerCard.getCard(), false, source, game)) {
playerCard.getPlayer().drawCards(1, source, game);
}
}
return true;
}
Aggregations