Search in sources :

Example 1 with ColorsOfManaSpentToCastCount

use of mage.abilities.dynamicvalue.common.ColorsOfManaSpentToCastCount in project mage by magefree.

the class ExertInfluenceEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    MageObject sourceObject = game.getObject(source.getSourceId());
    Player controller = game.getPlayer(source.getControllerId());
    Permanent targetCreature = game.getPermanent(getTargetPointer().getFirst(game, source));
    if (controller != null && sourceObject != null) {
        int colors = new ColorsOfManaSpentToCastCount().calculate(game, source, this);
        if (targetCreature.getPower().getValue() <= colors) {
            game.addEffect(new GainControlTargetEffect(Duration.Custom, true), source);
        }
        return true;
    }
    return false;
}
Also used : Player(mage.players.Player) Permanent(mage.game.permanent.Permanent) TargetCreaturePermanent(mage.target.common.TargetCreaturePermanent) MageObject(mage.MageObject) GainControlTargetEffect(mage.abilities.effects.common.continuous.GainControlTargetEffect) ColorsOfManaSpentToCastCount(mage.abilities.dynamicvalue.common.ColorsOfManaSpentToCastCount)

Aggregations

MageObject (mage.MageObject)1 ColorsOfManaSpentToCastCount (mage.abilities.dynamicvalue.common.ColorsOfManaSpentToCastCount)1 GainControlTargetEffect (mage.abilities.effects.common.continuous.GainControlTargetEffect)1 Permanent (mage.game.permanent.Permanent)1 Player (mage.players.Player)1 TargetCreaturePermanent (mage.target.common.TargetCreaturePermanent)1