Search in sources :

Example 1 with SacrificeOpponentsEffect

use of mage.abilities.effects.common.SacrificeOpponentsEffect in project mage by magefree.

the class TyrantsChoiceEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    TwoChoiceVote vote = new TwoChoiceVote("Death (sacrifice a creature)", "Torture (lose 4 life)", Outcome.Benefit);
    vote.doVotes(source, game, (voteHandler, aiPlayer, aiDecidingPlayer, aiSource, aiGame) -> {
        // ai hint
        if (aiSource.isControlledBy(aiDecidingPlayer.getId())) {
            // best for controller - lose life
            return Boolean.FALSE;
        } else {
            // best for opponent - sacrifice
            return Boolean.TRUE;
        }
    });
    int deathCount = vote.getVoteCount(true);
    int tortureCount = vote.getVoteCount(false);
    if (deathCount > tortureCount) {
        return new SacrificeOpponentsEffect(StaticFilters.FILTER_CONTROLLED_CREATURE_SHORT_TEXT).apply(game, source);
    } else {
        return new LoseLifeOpponentsEffect(4).apply(game, source);
    }
}
Also used : SacrificeOpponentsEffect(mage.abilities.effects.common.SacrificeOpponentsEffect) TwoChoiceVote(mage.choices.TwoChoiceVote) LoseLifeOpponentsEffect(mage.abilities.effects.common.LoseLifeOpponentsEffect)

Example 2 with SacrificeOpponentsEffect

use of mage.abilities.effects.common.SacrificeOpponentsEffect in project mage by magefree.

the class RavenousRotbellyEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    if (player == null) {
        return false;
    }
    TargetPermanent target = new TargetPermanent(0, 3, filter, true);
    player.choose(outcome, target, source.getSourceId(), game);
    int amount = 0;
    for (UUID permanentId : target.getTargets()) {
        Permanent permanent = game.getPermanent(permanentId);
        if (permanent != null && permanent.sacrifice(source, game)) {
            amount++;
        }
    }
    if (amount < 1) {
        return false;
    }
    game.fireReflexiveTriggeredAbility(new ReflexiveTriggeredAbility(new SacrificeOpponentsEffect(amount, StaticFilters.FILTER_PERMANENT_CREATURES), false, "each opponent sacrifices that many creatures"), source);
    return true;
}
Also used : SacrificeOpponentsEffect(mage.abilities.effects.common.SacrificeOpponentsEffect) Player(mage.players.Player) FilterPermanent(mage.filter.FilterPermanent) FilterControlledPermanent(mage.filter.common.FilterControlledPermanent) Permanent(mage.game.permanent.Permanent) TargetPermanent(mage.target.TargetPermanent) ReflexiveTriggeredAbility(mage.abilities.common.delayed.ReflexiveTriggeredAbility) TargetPermanent(mage.target.TargetPermanent) UUID(java.util.UUID)

Example 3 with SacrificeOpponentsEffect

use of mage.abilities.effects.common.SacrificeOpponentsEffect in project mage by magefree.

the class MalfegorEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller == null) {
        return false;
    }
    int sacrificeNumber = controller.getHand().size();
    if (sacrificeNumber == 0) {
        return true;
    }
    new DiscardHandControllerEffect().apply(game, source);
    return new SacrificeOpponentsEffect(sacrificeNumber, StaticFilters.FILTER_CONTROLLED_CREATURE).apply(game, source);
}
Also used : SacrificeOpponentsEffect(mage.abilities.effects.common.SacrificeOpponentsEffect) Player(mage.players.Player) DiscardHandControllerEffect(mage.abilities.effects.common.discard.DiscardHandControllerEffect)

Example 4 with SacrificeOpponentsEffect

use of mage.abilities.effects.common.SacrificeOpponentsEffect 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

SacrificeOpponentsEffect (mage.abilities.effects.common.SacrificeOpponentsEffect)4 TwoChoiceVote (mage.choices.TwoChoiceVote)2 Player (mage.players.Player)2 UUID (java.util.UUID)1 ReflexiveTriggeredAbility (mage.abilities.common.delayed.ReflexiveTriggeredAbility)1 LoseLifeOpponentsEffect (mage.abilities.effects.common.LoseLifeOpponentsEffect)1 DiscardEachPlayerEffect (mage.abilities.effects.common.discard.DiscardEachPlayerEffect)1 DiscardHandControllerEffect (mage.abilities.effects.common.discard.DiscardHandControllerEffect)1 FilterPermanent (mage.filter.FilterPermanent)1 FilterControlledPermanent (mage.filter.common.FilterControlledPermanent)1 Permanent (mage.game.permanent.Permanent)1 TargetPermanent (mage.target.TargetPermanent)1