Search in sources :

Example 1 with DiscardEachPlayerEffect

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;
}
Also used : PermanentIdPredicate(mage.filter.predicate.permanent.PermanentIdPredicate) Player(mage.players.Player) FilterPermanent(mage.filter.FilterPermanent) FilterNonlandPermanent(mage.filter.common.FilterNonlandPermanent) FilterPermanent(mage.filter.FilterPermanent) Permanent(mage.game.permanent.Permanent) TargetPermanent(mage.target.TargetPermanent) ReturnToHandFromBattlefieldAllEffect(mage.abilities.effects.common.ReturnToHandFromBattlefieldAllEffect) DiscardEachPlayerEffect(mage.abilities.effects.common.discard.DiscardEachPlayerEffect) ManaValuePredicate(mage.filter.predicate.mageobject.ManaValuePredicate) Target(mage.target.Target) ControllerIdPredicate(mage.filter.predicate.permanent.ControllerIdPredicate) TargetPermanent(mage.target.TargetPermanent) UUID(java.util.UUID) FilterNonlandPermanent(mage.filter.common.FilterNonlandPermanent) HashSet(java.util.HashSet)

Example 2 with DiscardEachPlayerEffect

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;
}
Also used : Player(mage.players.Player) DiscardEachPlayerEffect(mage.abilities.effects.common.discard.DiscardEachPlayerEffect)

Example 3 with DiscardEachPlayerEffect

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;
}
Also used : Player(mage.players.Player) BoostOpponentsEffect(mage.abilities.effects.common.continuous.BoostOpponentsEffect) DiscardEachPlayerEffect(mage.abilities.effects.common.discard.DiscardEachPlayerEffect) TwoChoiceVote(mage.choices.TwoChoiceVote)

Example 4 with DiscardEachPlayerEffect

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;
}
Also used : SacrificeOpponentsEffect(mage.abilities.effects.common.SacrificeOpponentsEffect) DiscardEachPlayerEffect(mage.abilities.effects.common.discard.DiscardEachPlayerEffect) TwoChoiceVote(mage.choices.TwoChoiceVote)

Aggregations

DiscardEachPlayerEffect (mage.abilities.effects.common.discard.DiscardEachPlayerEffect)4 Player (mage.players.Player)3 TwoChoiceVote (mage.choices.TwoChoiceVote)2 HashSet (java.util.HashSet)1 UUID (java.util.UUID)1 ReturnToHandFromBattlefieldAllEffect (mage.abilities.effects.common.ReturnToHandFromBattlefieldAllEffect)1 SacrificeOpponentsEffect (mage.abilities.effects.common.SacrificeOpponentsEffect)1 BoostOpponentsEffect (mage.abilities.effects.common.continuous.BoostOpponentsEffect)1 FilterPermanent (mage.filter.FilterPermanent)1 FilterNonlandPermanent (mage.filter.common.FilterNonlandPermanent)1 ManaValuePredicate (mage.filter.predicate.mageobject.ManaValuePredicate)1 ControllerIdPredicate (mage.filter.predicate.permanent.ControllerIdPredicate)1 PermanentIdPredicate (mage.filter.predicate.permanent.PermanentIdPredicate)1 Permanent (mage.game.permanent.Permanent)1 Target (mage.target.Target)1 TargetPermanent (mage.target.TargetPermanent)1