Package mage.abilities.dynamicvalue.common

Source Code of mage.abilities.dynamicvalue.common.SacrificeCostCreaturesPower

package mage.abilities.dynamicvalue.common;

import mage.abilities.Ability;
import mage.abilities.costs.Cost;
import mage.abilities.costs.common.SacrificeTargetCost;
import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.effects.Effect;
import mage.game.Game;
import mage.game.permanent.Permanent;

/**
* @author LevelX2
*/
public class SacrificeCostCreaturesPower implements DynamicValue {

    @Override
    public int calculate(Game game, Ability sourceAbility, Effect effect) {
        for (Cost cost: sourceAbility.getCosts()) {
            if (cost instanceof SacrificeTargetCost) {
                SacrificeTargetCost sacrificeCost = (SacrificeTargetCost) cost;
                int powerSum = 0;
                for (Permanent permanent :sacrificeCost.getPermanents()) {
                    powerSum += permanent.getPower().getValue();
                }
                return powerSum;
            }
        }
        return 0;
    }

    @Override
    public DynamicValue copy() {
        return new SacrificeCostCreaturesPower();
    }

    @Override
    public String toString() {
        return "X";
    }


    @Override
    public String getMessage() {
        return "the sacrificed creature's power";
    }
}
TOP

Related Classes of mage.abilities.dynamicvalue.common.SacrificeCostCreaturesPower

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.