Search in sources :

Example 1 with ReturnFromGraveyardToBattlefieldWithCounterTargetEffect

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

the class GraveEndeavorEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    if (player == null) {
        return false;
    }
    List<Integer> results = player.rollDice(outcome, source, game, 10, 2, 0);
    int firstResult = results.get(0);
    int secondResult = results.get(1);
    int first, second;
    if (firstResult != secondResult && player.chooseUse(outcome, "Choose a number of +1/+1 counters to put on the creature you return", "The other number will be the amount of life your opponents lose and you gain", "" + firstResult, "" + secondResult, source, game)) {
        first = firstResult;
        second = secondResult;
    } else {
        first = secondResult;
        second = firstResult;
    }
    if (player.getGraveyard().count(StaticFilters.FILTER_CARD_CREATURE, game) > 0) {
        TargetCard target = new TargetCardInYourGraveyard(StaticFilters.FILTER_CARD_CREATURE_YOUR_GRAVEYARD);
        target.setNotTarget(true);
        player.choose(outcome, target, source.getControllerId(), game);
        if (target.getFirstTarget() != null) {
            new ReturnFromGraveyardToBattlefieldWithCounterTargetEffect(CounterType.P1P1.createInstance(first)).setTargetPointer(new FixedTarget(target.getFirstTarget(), game)).apply(game, source);
        }
    }
    for (UUID playerId : game.getOpponents(source.getControllerId())) {
        Player opponent = game.getPlayer(playerId);
        if (opponent == null) {
            continue;
        }
        opponent.loseLife(second, game, source, false);
    }
    player.gainLife(second, game, source);
    return true;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) ReturnFromGraveyardToBattlefieldWithCounterTargetEffect(mage.abilities.effects.common.ReturnFromGraveyardToBattlefieldWithCounterTargetEffect) Player(mage.players.Player) TargetCard(mage.target.TargetCard) TargetCardInYourGraveyard(mage.target.common.TargetCardInYourGraveyard) UUID(java.util.UUID)

Aggregations

UUID (java.util.UUID)1 ReturnFromGraveyardToBattlefieldWithCounterTargetEffect (mage.abilities.effects.common.ReturnFromGraveyardToBattlefieldWithCounterTargetEffect)1 Player (mage.players.Player)1 TargetCard (mage.target.TargetCard)1 TargetCardInYourGraveyard (mage.target.common.TargetCardInYourGraveyard)1 FixedTarget (mage.target.targetpointer.FixedTarget)1