use of mage.abilities.effects.common.discard.DiscardEachPlayerEffect in project mage by magefree.
the class DispersalEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player == null) {
return false;
}
Set<PermanentIdPredicate> permsToReturn = new HashSet<>();
for (UUID opponentId : game.getOpponents(player.getId())) {
Player opponent = game.getPlayer(opponentId);
if (opponent == null) {
continue;
}
int highestCMC = 0;
for (Permanent permanent : game.getBattlefield().getAllActivePermanents(opponentId)) {
if (permanent != null) {
highestCMC = Math.max(highestCMC, permanent.getManaValue());
}
}
FilterPermanent filter = new FilterNonlandPermanent("permanent you control with mana value " + highestCMC);
filter.add(new ManaValuePredicate(ComparisonType.EQUAL_TO, highestCMC));
filter.add(new ControllerIdPredicate(opponentId));
Target target = new TargetPermanent(1, 1, filter, true);
if (opponent.choose(outcome, target, source.getSourceId(), game)) {
if (target.getFirstTarget() == null) {
continue;
}
permsToReturn.add(new PermanentIdPredicate(target.getFirstTarget()));
}
}
FilterPermanent filter = new FilterPermanent();
filter.add(Predicates.or(permsToReturn));
new ReturnToHandFromBattlefieldAllEffect(filter).apply(game, source);
new DiscardEachPlayerEffect(StaticValue.get(1), false, TargetController.OPPONENT).apply(game, source);
return true;
}
use of mage.abilities.effects.common.discard.DiscardEachPlayerEffect in project mage by magefree.
the class WordsOfWasteEffect method replaceEvent.
@Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
new DiscardEachPlayerEffect(TargetController.OPPONENT).apply(game, source);
this.discard();
return true;
}
return false;
}
use of mage.abilities.effects.common.discard.DiscardEachPlayerEffect in project mage by magefree.
the class BiteOfTheBlackRoseEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller == null) {
return false;
}
// Outcome.Detriment - AI will discard a card all the time (Psychosis choice)
// TODO: add AI hint logic in the choice method, see Tyrant's Choice as example
TwoChoiceVote vote = new TwoChoiceVote("Sickness (-2/-2)", "Psychosis (discard cards)", Outcome.Detriment);
vote.doVotes(source, game);
int sicknessCount = vote.getVoteCount(true);
int psychosisCount = vote.getVoteCount(false);
if (sicknessCount > psychosisCount) {
// sickness
game.addEffect(new BoostOpponentsEffect(-2, -2, Duration.EndOfTurn), source);
} else {
// psychosis or tied
new DiscardEachPlayerEffect(StaticValue.get(2), false, TargetController.OPPONENT).apply(game, source);
}
return true;
}
use of mage.abilities.effects.common.discard.DiscardEachPlayerEffect in project mage by magefree.
the class CapitalPunishmentEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
// Outcome.Detriment - AI will discard a card all the time (taxes choice)
// TODO: add AI hint logic in the choice method, see Tyrant's Choice as example
TwoChoiceVote vote = new TwoChoiceVote("Death (sacrifice creature)", "Taxes (discard card)", Outcome.Detriment);
vote.doVotes(source, game);
int deathCount = vote.getVoteCount(true);
int taxesCount = vote.getVoteCount(false);
if (deathCount > 0) {
new SacrificeOpponentsEffect(deathCount, StaticFilters.FILTER_CONTROLLED_CREATURE).apply(game, source);
}
if (taxesCount > 0) {
new DiscardEachPlayerEffect(StaticValue.get(taxesCount), false, TargetController.OPPONENT).apply(game, source);
}
return true;
}
Aggregations