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;
}
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;
}
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;
}
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;
}
}
}
}
}
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;
}
Aggregations