Search in sources :

Example 61 with SpellAbility

use of mage.abilities.SpellAbility in project mage by magefree.

the class LocketOfYesterdaysCostReductionEffect method apply.

@Override
public boolean apply(Game game, Ability source, Ability abilityToModify) {
    MageObject sourceObject = game.getObject(abilityToModify.getSourceId());
    if (sourceObject != null) {
        int amount = 0;
        for (UUID cardId : game.getPlayer(source.getControllerId()).getGraveyard()) {
            Card card = game.getCard(cardId);
            if (card != null && card.getName().equals(sourceObject.getName())) {
                amount++;
            }
        }
        if (amount > 0) {
            SpellAbility spellAbility = (SpellAbility) abilityToModify;
            CardUtil.adjustCost(spellAbility, amount);
        }
        return true;
    }
    return false;
}
Also used : MageObject(mage.MageObject) SpellAbility(mage.abilities.SpellAbility) UUID(java.util.UUID) Card(mage.cards.Card)

Example 62 with SpellAbility

use of mage.abilities.SpellAbility in project mage by magefree.

the class MizzixOfTheIzmagnusCostReductionEffect method apply.

@Override
public boolean apply(Game game, Ability source, Ability abilityToModify) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null) {
        SpellAbility spellAbility = (SpellAbility) abilityToModify;
        CardUtil.adjustCost(spellAbility, controller.getCounters().getCount(CounterType.EXPERIENCE));
        return true;
    }
    return false;
}
Also used : Player(mage.players.Player) SpellAbility(mage.abilities.SpellAbility)

Example 63 with SpellAbility

use of mage.abilities.SpellAbility in project mage by magefree.

the class SemblanceAnvilCostReductionEffect method apply.

@Override
public boolean apply(Game game, Ability source, Ability abilityToModify) {
    SpellAbility spellAbility = (SpellAbility) abilityToModify;
    CardUtil.adjustCost(spellAbility, 2);
    return true;
}
Also used : SpellAbility(mage.abilities.SpellAbility)

Example 64 with SpellAbility

use of mage.abilities.SpellAbility in project mage by magefree.

the class ReplicateCopyEffect method addOptionalAdditionalCosts.

@Override
public void addOptionalAdditionalCosts(Ability ability, Game game) {
    if (ability instanceof SpellAbility) {
        Player player = game.getPlayer(ability.getControllerId());
        if (player != null) {
            this.resetReplicate();
            boolean again = true;
            while (player.canRespond() && again) {
                String times = "";
                if (additionalCost.isRepeatable()) {
                    int numActivations = additionalCost.getActivateCount();
                    times = (numActivations + 1) + (numActivations == 0 ? " time " : " times ");
                }
                // canPay checks only single mana available, not total mana usage
                if (additionalCost.canPay(ability, this, ability.getControllerId(), game) && player.chooseUse(/*Outcome.Benefit*/
                Outcome.AIDontUseIt, new StringBuilder("Pay ").append(times).append(additionalCost.getText(false)).append(" ?").toString(), ability, game)) {
                    additionalCost.activate();
                    for (Iterator it = ((Costs) additionalCost).iterator(); it.hasNext(); ) {
                        Cost cost = (Cost) it.next();
                        if (cost instanceof ManaCostsImpl) {
                            ability.getManaCostsToPay().add((ManaCostsImpl) cost.copy());
                        } else {
                            ability.getCosts().add(cost.copy());
                        }
                    }
                } else {
                    again = false;
                }
            }
        }
    }
}
Also used : Player(mage.players.Player) Iterator(java.util.Iterator) SpellAbility(mage.abilities.SpellAbility) ManaCostsImpl(mage.abilities.costs.mana.ManaCostsImpl)

Example 65 with SpellAbility

use of mage.abilities.SpellAbility in project mage by magefree.

the class SpliceOntoInstantOrSorceryEffect method apply.

@Override
public boolean apply(Game game, Ability source, Ability abilityToModify) {
    Player controller = game.getPlayer(source.getControllerId());
    Card spliceCard = game.getCard(source.getSourceId());
    if (spliceCard != null && controller != null) {
        Spell spell = game.getStack().getSpell(abilityToModify.getId());
        if (spell != null) {
            SpellAbility splicedAbility = spliceCard.getSpellAbility().copy();
            splicedAbility.setSpellAbilityType(SpellAbilityType.SPLICE);
            splicedAbility.setSourceId(abilityToModify.getSourceId());
            spell.addSpellAbility(splicedAbility);
            for (Iterator it = ((SpliceOntoInstantOrSorceryAbility) source).getSpliceCosts().iterator(); it.hasNext(); ) {
                spell.getSpellAbility().getCosts().add(((Cost) it.next()).copy());
            }
        }
        return true;
    }
    return false;
}
Also used : Player(mage.players.Player) Iterator(java.util.Iterator) SpellAbility(mage.abilities.SpellAbility) Spell(mage.game.stack.Spell) Card(mage.cards.Card)

Aggregations

SpellAbility (mage.abilities.SpellAbility)75 Player (mage.players.Player)32 UUID (java.util.UUID)22 Card (mage.cards.Card)21 Permanent (mage.game.permanent.Permanent)21 Ability (mage.abilities.Ability)16 Spell (mage.game.stack.Spell)12 ManaCostsImpl (mage.abilities.costs.mana.ManaCostsImpl)10 FilterCard (mage.filter.FilterCard)9 Iterator (java.util.Iterator)8 MageObject (mage.MageObject)7 Target (mage.target.Target)7 ArrayList (java.util.ArrayList)6 ApprovingObject (mage.ApprovingObject)4 ActivatedAbility (mage.abilities.ActivatedAbility)4 Cost (mage.abilities.costs.Cost)4 Effect (mage.abilities.effects.Effect)4 Outcome (mage.constants.Outcome)4 FilterPermanent (mage.filter.FilterPermanent)4 PassAbility (mage.abilities.common.PassAbility)3