Search in sources :

Example 1 with DistributeCountersEffect

use of mage.abilities.effects.common.counter.DistributeCountersEffect in project mage by magefree.

the class YannikScavengingSentinelEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    Permanent sourcePermanent = game.getPermanent(source.getSourceId());
    if (player == null || sourcePermanent == null || game.getBattlefield().count(filter, source.getSourceId(), source.getControllerId(), game) < 1) {
        return false;
    }
    TargetPermanent target = new TargetPermanent(filter);
    target.setNotTarget(true);
    player.choose(outcome, target, source.getSourceId(), game);
    Permanent permanent = game.getPermanent(target.getFirstTarget());
    if (permanent == null) {
        return false;
    }
    int power = permanent.getPower().getValue();
    new ExileTargetEffect(CardUtil.getExileZoneId(game, source.getSourceId(), source.getSourceObjectZoneChangeCounter()), permanent.getIdName()).setTargetPointer(new FixedTarget(permanent, game)).apply(game, source);
    game.addDelayedTriggeredAbility(new OnLeaveReturnExiledToBattlefieldAbility(), source);
    if (game.getState().getZone(permanent.getId()) != Zone.BATTLEFIELD) {
        ReflexiveTriggeredAbility ability = new ReflexiveTriggeredAbility(new DistributeCountersEffect(CounterType.P1P1, power, false, ""), false, "distribute X +1/+1 counters among any number of target creatures, " + "where X is the exiled creature's power");
        ability.addTarget(new TargetCreaturePermanentAmount(power));
        game.fireReflexiveTriggeredAbility(ability, source);
    }
    return true;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Player(mage.players.Player) TargetCreaturePermanentAmount(mage.target.common.TargetCreaturePermanentAmount) FilterPermanent(mage.filter.FilterPermanent) FilterControlledCreaturePermanent(mage.filter.common.FilterControlledCreaturePermanent) Permanent(mage.game.permanent.Permanent) TargetPermanent(mage.target.TargetPermanent) ReflexiveTriggeredAbility(mage.abilities.common.delayed.ReflexiveTriggeredAbility) TargetPermanent(mage.target.TargetPermanent) DistributeCountersEffect(mage.abilities.effects.common.counter.DistributeCountersEffect) OnLeaveReturnExiledToBattlefieldAbility(mage.abilities.common.delayed.OnLeaveReturnExiledToBattlefieldAbility) ExileTargetEffect(mage.abilities.effects.common.ExileTargetEffect)

Example 2 with DistributeCountersEffect

use of mage.abilities.effects.common.counter.DistributeCountersEffect in project mage by magefree.

the class NumaJoragaChieftainEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    if (player == null) {
        return false;
    }
    ManaCosts cost = new ManaCostsImpl("{X}{X}");
    if (!player.chooseUse(Outcome.BoostCreature, "Pay " + cost.getText() + "?", source, game)) {
        return false;
    }
    int costX = player.announceXMana(0, Integer.MAX_VALUE, "Announce the value for {X}", game, source);
    cost.add(new GenericManaCost(2 * costX));
    if (!cost.pay(source, game, source, source.getControllerId(), false, null)) {
        return false;
    }
    ReflexiveTriggeredAbility ability = new ReflexiveTriggeredAbility(new DistributeCountersEffect(CounterType.P1P1, costX, false, ""), false, "distribute " + costX + " +1/+1 counters among any number of target Elves");
    ability.addTarget(new TargetCreaturePermanentAmount(costX, filter));
    game.fireReflexiveTriggeredAbility(ability, source);
    return true;
}
Also used : ManaCosts(mage.abilities.costs.mana.ManaCosts) Player(mage.players.Player) TargetCreaturePermanentAmount(mage.target.common.TargetCreaturePermanentAmount) GenericManaCost(mage.abilities.costs.mana.GenericManaCost) ReflexiveTriggeredAbility(mage.abilities.common.delayed.ReflexiveTriggeredAbility) DistributeCountersEffect(mage.abilities.effects.common.counter.DistributeCountersEffect) ManaCostsImpl(mage.abilities.costs.mana.ManaCostsImpl)

Aggregations

ReflexiveTriggeredAbility (mage.abilities.common.delayed.ReflexiveTriggeredAbility)2 DistributeCountersEffect (mage.abilities.effects.common.counter.DistributeCountersEffect)2 Player (mage.players.Player)2 TargetCreaturePermanentAmount (mage.target.common.TargetCreaturePermanentAmount)2 OnLeaveReturnExiledToBattlefieldAbility (mage.abilities.common.delayed.OnLeaveReturnExiledToBattlefieldAbility)1 GenericManaCost (mage.abilities.costs.mana.GenericManaCost)1 ManaCosts (mage.abilities.costs.mana.ManaCosts)1 ManaCostsImpl (mage.abilities.costs.mana.ManaCostsImpl)1 ExileTargetEffect (mage.abilities.effects.common.ExileTargetEffect)1 FilterPermanent (mage.filter.FilterPermanent)1 FilterControlledCreaturePermanent (mage.filter.common.FilterControlledCreaturePermanent)1 Permanent (mage.game.permanent.Permanent)1 TargetPermanent (mage.target.TargetPermanent)1 FixedTarget (mage.target.targetpointer.FixedTarget)1