Search in sources :

Example 1 with TargetCreatureOrPlaneswalkerAmount

use of mage.target.common.TargetCreatureOrPlaneswalkerAmount 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)

Aggregations

UUID (java.util.UUID)1 FilterPermanent (mage.filter.FilterPermanent)1 ObjectSourcePlayer (mage.filter.predicate.ObjectSourcePlayer)1 Permanent (mage.game.permanent.Permanent)1 Player (mage.players.Player)1 TargetAmount (mage.target.TargetAmount)1 TargetCreatureOrPlaneswalkerAmount (mage.target.common.TargetCreatureOrPlaneswalkerAmount)1