Search in sources :

Example 6 with TargetAmount

use of mage.target.TargetAmount in project mage by magefree.

the class StumpsquallHydraEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    int xValue = ManacostVariableValue.ETB.calculate(game, source, this);
    if (player == null || xValue < 1) {
        return false;
    }
    TargetAmount targetAmount = new TargetCreatureOrPlaneswalkerAmount(xValue, filter);
    targetAmount.setNotTarget(true);
    player.choose(outcome, targetAmount, source.getSourceId(), game);
    for (UUID targetId : targetAmount.getTargets()) {
        Permanent permanent = game.getPermanent(targetId);
        if (permanent == null) {
            continue;
        }
        permanent.addCounters(CounterType.P1P1.createInstance(targetAmount.getTargetAmount(targetId)), source.getControllerId(), source, game);
    }
    return true;
}
Also used : Player(mage.players.Player) ObjectSourcePlayer(mage.filter.predicate.ObjectSourcePlayer) TargetCreatureOrPlaneswalkerAmount(mage.target.common.TargetCreatureOrPlaneswalkerAmount) FilterPermanent(mage.filter.FilterPermanent) Permanent(mage.game.permanent.Permanent) UUID(java.util.UUID) TargetAmount(mage.target.TargetAmount)

Example 7 with TargetAmount

use of mage.target.TargetAmount in project mage by magefree.

the class BlessingOfFrostEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    if (player == null) {
        return false;
    }
    int snow = ManaPaidSourceWatcher.getSnowPaid(source.getId(), game);
    if (snow > 0) {
        TargetAmount target = new TargetCreaturePermanentAmount(snow, StaticFilters.FILTER_CONTROLLED_CREATURE);
        target.setNotTarget(true);
        target.chooseTarget(outcome, player.getId(), source, game);
        for (UUID targetId : target.getTargets()) {
            Permanent permanent = game.getPermanent(targetId);
            if (permanent == null) {
                continue;
            }
            permanent.addCounters(CounterType.P1P1.createInstance(target.getTargetAmount(targetId)), source.getControllerId(), source, game);
        }
    }
    game.getState().processAction(game);
    player.drawCards(game.getBattlefield().count(filter, source.getSourceId(), source.getControllerId(), game), source, game);
    return true;
}
Also used : Player(mage.players.Player) TargetCreaturePermanentAmount(mage.target.common.TargetCreaturePermanentAmount) FilterPermanent(mage.filter.FilterPermanent) Permanent(mage.game.permanent.Permanent) FilterControlledCreaturePermanent(mage.filter.common.FilterControlledCreaturePermanent) UUID(java.util.UUID) TargetAmount(mage.target.TargetAmount)

Aggregations

TargetAmount (mage.target.TargetAmount)7 UUID (java.util.UUID)4 Permanent (mage.game.permanent.Permanent)4 Player (mage.players.Player)4 Target (mage.target.Target)4 FilterPermanent (mage.filter.FilterPermanent)3 MageObject (mage.MageObject)2 PassAbility (mage.abilities.common.PassAbility)1 PlayLandAsCommanderAbility (mage.abilities.common.PlayLandAsCommanderAbility)1 WhileSearchingPlayFromLibraryAbility (mage.abilities.common.WhileSearchingPlayFromLibraryAbility)1 AtTheEndOfTurnStepPostDelayedTriggeredAbility (mage.abilities.common.delayed.AtTheEndOfTurnStepPostDelayedTriggeredAbility)1 AlternateManaPaymentAbility (mage.abilities.costs.mana.AlternateManaPaymentAbility)1 Outcome (mage.constants.Outcome)1 FilterControlledCreaturePermanent (mage.filter.common.FilterControlledCreaturePermanent)1 ObjectSourcePlayer (mage.filter.predicate.ObjectSourcePlayer)1 ControllerIdPredicate (mage.filter.predicate.permanent.ControllerIdPredicate)1 StackAbility (mage.game.stack.StackAbility)1 TargetPlayer (mage.target.TargetPlayer)1 TargetCreatureOrPlaneswalkerAmount (mage.target.common.TargetCreatureOrPlaneswalkerAmount)1 TargetCreaturePermanentAmount (mage.target.common.TargetCreaturePermanentAmount)1