Search in sources :

Example 1 with PayLoyaltyCost

use of mage.abilities.costs.common.PayLoyaltyCost in project mage by magefree.

the class LoyaltyAbility method increaseLoyaltyCost.

/**
 * Change loyalty cost by amount value
 *
 * @param amount
 */
public void increaseLoyaltyCost(int amount) {
    // loyalty cost modification rules from Carth the Lion
    // If a planeswalker’s loyalty ability normally has a cost of [+1], Carth’s ability makes it cost [+2] instead.
    // A cost of [0] would become [+1], and a cost of [-6] would become [-5].
    // (2021-06-18)
    // 
    // If you somehow manage to control two Carths (perhaps because of Spark Double), the cost-changing effect is
    // cumulative. In total, loyalty abilities will cost an additional [+2] to activate.
    // (2021-06-18)
    // 
    // The total cost of a planeswalker’s loyalty ability is calculated before any counters are added or removed.
    // If a loyalty ability normally costs [-3] to activate, you do not remove three counters from it and then
    // put one counter on it. You remove two counters at one time when you pay the cost.
    // (2021-06-18)
    // 
    // If an effect replaces the number of counters that would be placed on a planeswalker, such as that of
    // Vorinclex, Monstrous Raider, that replacement happens only once, at the time payment is made.
    // (2021-06-18)
    // cost modification support only 1 cost item
    int staticCount = 0;
    for (Cost cost : costs) {
        if (cost instanceof PayLoyaltyCost) {
            // static cost
            PayLoyaltyCost staticCost = (PayLoyaltyCost) cost;
            staticCost.setAmount(staticCost.getAmount() + amount);
            staticCount++;
        } else if (cost instanceof PayVariableLoyaltyCost) {
            // x cost (after x announce: x cost + static cost)
            PayVariableLoyaltyCost xCost = (PayVariableLoyaltyCost) cost;
            xCost.setCostModification(xCost.getCostModification() + amount);
        }
    }
    if (staticCount > 1) {
        throw new IllegalArgumentException(String.format("Loyalty ability must have only 1 static cost, but has %d: %s", staticCount, this.getRule()));
    }
}
Also used : PayLoyaltyCost(mage.abilities.costs.common.PayLoyaltyCost) PayVariableLoyaltyCost(mage.abilities.costs.common.PayVariableLoyaltyCost) Cost(mage.abilities.costs.Cost) PayVariableLoyaltyCost(mage.abilities.costs.common.PayVariableLoyaltyCost) PayLoyaltyCost(mage.abilities.costs.common.PayLoyaltyCost)

Aggregations

Cost (mage.abilities.costs.Cost)1 PayLoyaltyCost (mage.abilities.costs.common.PayLoyaltyCost)1 PayVariableLoyaltyCost (mage.abilities.costs.common.PayVariableLoyaltyCost)1