mirror of
https://github.com/correl/mage.git
synced 2024-11-15 19:19:33 +00:00
Fixed Issue#79: Cost reduction does not work properly
This commit is contained in:
parent
3a4eae3bca
commit
ded2979dab
18 changed files with 160 additions and 45 deletions
|
@ -34,6 +34,8 @@ import mage.abilities.Ability;
|
||||||
import mage.abilities.SpellAbility;
|
import mage.abilities.SpellAbility;
|
||||||
import mage.abilities.common.SimpleStaticAbility;
|
import mage.abilities.common.SimpleStaticAbility;
|
||||||
import mage.abilities.effects.CostModificationEffectImpl;
|
import mage.abilities.effects.CostModificationEffectImpl;
|
||||||
|
import mage.abilities.keyword.FlashbackAbility;
|
||||||
|
import mage.abilities.keyword.RetraceAbility;
|
||||||
import mage.cards.Card;
|
import mage.cards.Card;
|
||||||
import mage.cards.CardImpl;
|
import mage.cards.CardImpl;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
|
@ -87,7 +89,7 @@ class ArcaneMeleeCostReductionEffect extends CostModificationEffectImpl<ArcaneMe
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean applies(Ability abilityToModify, Ability source, Game game) {
|
public boolean applies(Ability abilityToModify, Ability source, Game game) {
|
||||||
if ( abilityToModify instanceof SpellAbility ) {
|
if ( abilityToModify instanceof SpellAbility || abilityToModify instanceof FlashbackAbility || abilityToModify instanceof RetraceAbility) {
|
||||||
Card sourceCard = game.getCard(((SpellAbility)abilityToModify).getSourceId());
|
Card sourceCard = game.getCard(((SpellAbility)abilityToModify).getSourceId());
|
||||||
if ( sourceCard != null && (sourceCard.getCardType().contains(CardType.INSTANT) || sourceCard.getCardType().contains(CardType.SORCERY))) {
|
if ( sourceCard != null && (sourceCard.getCardType().contains(CardType.INSTANT) || sourceCard.getCardType().contains(CardType.SORCERY))) {
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -37,7 +37,9 @@ import mage.abilities.common.AttacksTriggeredAbility;
|
||||||
import mage.abilities.common.SimpleStaticAbility;
|
import mage.abilities.common.SimpleStaticAbility;
|
||||||
import mage.abilities.effects.CostModificationEffectImpl;
|
import mage.abilities.effects.CostModificationEffectImpl;
|
||||||
import mage.abilities.effects.common.counter.AddCountersSourceEffect;
|
import mage.abilities.effects.common.counter.AddCountersSourceEffect;
|
||||||
|
import mage.abilities.keyword.FlashbackAbility;
|
||||||
import mage.abilities.keyword.FlyingAbility;
|
import mage.abilities.keyword.FlyingAbility;
|
||||||
|
import mage.abilities.keyword.RetraceAbility;
|
||||||
import mage.cards.Card;
|
import mage.cards.Card;
|
||||||
import mage.cards.CardImpl;
|
import mage.cards.CardImpl;
|
||||||
import mage.counters.CounterType;
|
import mage.counters.CounterType;
|
||||||
|
@ -107,8 +109,8 @@ class HeraldOfWarCostReductionEffect extends CostModificationEffectImpl<HeraldOf
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean applies(Ability abilityToModify, Ability source, Game game) {
|
public boolean applies(Ability abilityToModify, Ability source, Game game) {
|
||||||
if (abilityToModify instanceof SpellAbility) {
|
if (abilityToModify instanceof SpellAbility || abilityToModify instanceof FlashbackAbility || abilityToModify instanceof RetraceAbility) {
|
||||||
Card sourceCard = game.getCard(((SpellAbility) abilityToModify).getSourceId());
|
Card sourceCard = game.getCard(abilityToModify.getSourceId());
|
||||||
if (sourceCard != null && abilityToModify.getControllerId().equals(source.getControllerId()) && (sourceCard.hasSubtype("Angel") || sourceCard.hasSubtype("Human"))) {
|
if (sourceCard != null && abilityToModify.getControllerId().equals(source.getControllerId()) && (sourceCard.hasSubtype("Angel") || sourceCard.hasSubtype("Human"))) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,7 +27,6 @@
|
||||||
*/
|
*/
|
||||||
package mage.sets.betrayersofkamigawa;
|
package mage.sets.betrayersofkamigawa;
|
||||||
|
|
||||||
import java.util.UUID;
|
|
||||||
import mage.Constants;
|
import mage.Constants;
|
||||||
import mage.Constants.CardType;
|
import mage.Constants.CardType;
|
||||||
import mage.Constants.Rarity;
|
import mage.Constants.Rarity;
|
||||||
|
@ -37,11 +36,15 @@ import mage.abilities.SpellAbility;
|
||||||
import mage.abilities.common.SimpleStaticAbility;
|
import mage.abilities.common.SimpleStaticAbility;
|
||||||
import mage.abilities.effects.CostModificationEffectImpl;
|
import mage.abilities.effects.CostModificationEffectImpl;
|
||||||
import mage.abilities.keyword.BushidoAbility;
|
import mage.abilities.keyword.BushidoAbility;
|
||||||
|
import mage.abilities.keyword.FlashbackAbility;
|
||||||
|
import mage.abilities.keyword.RetraceAbility;
|
||||||
import mage.cards.Card;
|
import mage.cards.Card;
|
||||||
import mage.cards.CardImpl;
|
import mage.cards.CardImpl;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
import mage.players.Player;
|
import mage.players.Player;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author LevelX2
|
* @author LevelX2
|
||||||
*/
|
*/
|
||||||
|
@ -96,8 +99,8 @@ public class KentaroTheSmilingCat extends CardImpl<KentaroTheSmilingCat> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean applies(Ability abilityToModify, Ability source, Game game) {
|
public boolean applies(Ability abilityToModify, Ability source, Game game) {
|
||||||
if (abilityToModify instanceof SpellAbility) {
|
if (abilityToModify instanceof SpellAbility || abilityToModify instanceof FlashbackAbility || abilityToModify instanceof RetraceAbility) {
|
||||||
SpellAbility spell = (SpellAbility) abilityToModify;
|
Ability spell = abilityToModify;
|
||||||
if (spell.getControllerId().equals(source.getControllerId())) {
|
if (spell.getControllerId().equals(source.getControllerId())) {
|
||||||
Card sourceCard = game.getCard(spell.getSourceId());
|
Card sourceCard = game.getCard(spell.getSourceId());
|
||||||
if (sourceCard != null && sourceCard.hasSubtype("Samurai")) {
|
if (sourceCard != null && sourceCard.hasSubtype("Samurai")) {
|
||||||
|
|
|
@ -27,7 +27,6 @@
|
||||||
*/
|
*/
|
||||||
package mage.sets.darkascension;
|
package mage.sets.darkascension;
|
||||||
|
|
||||||
import java.util.UUID;
|
|
||||||
import mage.Constants;
|
import mage.Constants;
|
||||||
import mage.Constants.CardType;
|
import mage.Constants.CardType;
|
||||||
import mage.Constants.Rarity;
|
import mage.Constants.Rarity;
|
||||||
|
@ -35,12 +34,16 @@ import mage.MageInt;
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
import mage.abilities.SpellAbility;
|
import mage.abilities.SpellAbility;
|
||||||
import mage.abilities.common.SimpleStaticAbility;
|
import mage.abilities.common.SimpleStaticAbility;
|
||||||
import mage.abilities.costs.mana.GenericManaCost;
|
|
||||||
import mage.abilities.effects.CostModificationEffectImpl;
|
import mage.abilities.effects.CostModificationEffectImpl;
|
||||||
import mage.abilities.keyword.FirstStrikeAbility;
|
import mage.abilities.keyword.FirstStrikeAbility;
|
||||||
|
import mage.abilities.keyword.FlashbackAbility;
|
||||||
|
import mage.abilities.keyword.RetraceAbility;
|
||||||
import mage.cards.Card;
|
import mage.cards.Card;
|
||||||
import mage.cards.CardImpl;
|
import mage.cards.CardImpl;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
|
import mage.util.CardUtil;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -89,14 +92,13 @@ class ThaliaGuardianOfThrabenCostReductionEffect extends CostModificationEffectI
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Game game, Ability source, Ability abilityToModify) {
|
public boolean apply(Game game, Ability source, Ability abilityToModify) {
|
||||||
SpellAbility spellAbility = (SpellAbility) abilityToModify;
|
CardUtil.increaseCost(abilityToModify, 1);
|
||||||
spellAbility.getManaCostsToPay().add(new GenericManaCost(1));
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean applies(Ability abilityToModify, Ability source, Game game) {
|
public boolean applies(Ability abilityToModify, Ability source, Game game) {
|
||||||
if (abilityToModify instanceof SpellAbility) {
|
if (abilityToModify instanceof SpellAbility || abilityToModify instanceof FlashbackAbility || abilityToModify instanceof RetraceAbility) {
|
||||||
Card card = game.getCard(abilityToModify.getSourceId());
|
Card card = game.getCard(abilityToModify.getSourceId());
|
||||||
if (card != null && !card.getCardType().contains(CardType.CREATURE)) {
|
if (card != null && !card.getCardType().contains(CardType.CREATURE)) {
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -27,7 +27,6 @@
|
||||||
*/
|
*/
|
||||||
package mage.sets.innistrad;
|
package mage.sets.innistrad;
|
||||||
|
|
||||||
import java.util.UUID;
|
|
||||||
import mage.Constants;
|
import mage.Constants;
|
||||||
import mage.Constants.CardType;
|
import mage.Constants.CardType;
|
||||||
import mage.Constants.Outcome;
|
import mage.Constants.Outcome;
|
||||||
|
@ -37,12 +36,16 @@ import mage.abilities.SpellAbility;
|
||||||
import mage.abilities.common.SimpleStaticAbility;
|
import mage.abilities.common.SimpleStaticAbility;
|
||||||
import mage.abilities.costs.mana.ManaCostsImpl;
|
import mage.abilities.costs.mana.ManaCostsImpl;
|
||||||
import mage.abilities.effects.CostModificationEffectImpl;
|
import mage.abilities.effects.CostModificationEffectImpl;
|
||||||
|
import mage.abilities.keyword.FlashbackAbility;
|
||||||
|
import mage.abilities.keyword.RetraceAbility;
|
||||||
import mage.cards.Card;
|
import mage.cards.Card;
|
||||||
import mage.cards.CardImpl;
|
import mage.cards.CardImpl;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
import mage.players.Player;
|
import mage.players.Player;
|
||||||
import mage.util.CardUtil;
|
import mage.util.CardUtil;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author BetaSteward
|
* @author BetaSteward
|
||||||
|
@ -92,8 +95,8 @@ class RooftopStormCostReductionEffect extends CostModificationEffectImpl<Rooftop
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean applies(Ability abilityToModify, Ability source, Game game) {
|
public boolean applies(Ability abilityToModify, Ability source, Game game) {
|
||||||
if (abilityToModify instanceof SpellAbility) {
|
if (abilityToModify instanceof SpellAbility || abilityToModify instanceof FlashbackAbility || abilityToModify instanceof RetraceAbility) {
|
||||||
SpellAbility spell = (SpellAbility) abilityToModify;
|
Ability spell = abilityToModify;
|
||||||
if (spell.getControllerId().equals(source.getControllerId())) {
|
if (spell.getControllerId().equals(source.getControllerId())) {
|
||||||
Card sourceCard = game.getCard(spell.getSourceId());
|
Card sourceCard = game.getCard(spell.getSourceId());
|
||||||
if (sourceCard != null && sourceCard.hasSubtype("Zombie")) {
|
if (sourceCard != null && sourceCard.hasSubtype("Zombie")) {
|
||||||
|
|
|
@ -32,6 +32,8 @@ import mage.abilities.Ability;
|
||||||
import mage.abilities.SpellAbility;
|
import mage.abilities.SpellAbility;
|
||||||
import mage.abilities.common.SimpleStaticAbility;
|
import mage.abilities.common.SimpleStaticAbility;
|
||||||
import mage.abilities.effects.CostModificationEffectImpl;
|
import mage.abilities.effects.CostModificationEffectImpl;
|
||||||
|
import mage.abilities.keyword.FlashbackAbility;
|
||||||
|
import mage.abilities.keyword.RetraceAbility;
|
||||||
import mage.cards.Card;
|
import mage.cards.Card;
|
||||||
import mage.cards.CardImpl;
|
import mage.cards.CardImpl;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
|
@ -87,7 +89,7 @@ class OmniscienceEffect extends CostModificationEffectImpl<OmniscienceEffect> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean applies(Ability abilityToModify, Ability source, Game game) {
|
public boolean applies(Ability abilityToModify, Ability source, Game game) {
|
||||||
if (abilityToModify instanceof SpellAbility) {
|
if (abilityToModify instanceof SpellAbility || abilityToModify instanceof FlashbackAbility || abilityToModify instanceof RetraceAbility) {
|
||||||
Card sourceCard = game.getCard(abilityToModify.getSourceId());
|
Card sourceCard = game.getCard(abilityToModify.getSourceId());
|
||||||
StackObject stackObject = game.getStack().getStackObject(abilityToModify.getSourceId());
|
StackObject stackObject = game.getStack().getStackObject(abilityToModify.getSourceId());
|
||||||
if (stackObject != null && stackObject instanceof Spell) {
|
if (stackObject != null && stackObject instanceof Spell) {
|
||||||
|
|
|
@ -27,7 +27,6 @@
|
||||||
*/
|
*/
|
||||||
package mage.sets.ninthedition;
|
package mage.sets.ninthedition;
|
||||||
|
|
||||||
import java.util.UUID;
|
|
||||||
import mage.Constants;
|
import mage.Constants;
|
||||||
import mage.Constants.CardType;
|
import mage.Constants.CardType;
|
||||||
import mage.Constants.Rarity;
|
import mage.Constants.Rarity;
|
||||||
|
@ -36,9 +35,13 @@ import mage.abilities.SpellAbility;
|
||||||
import mage.abilities.common.SimpleStaticAbility;
|
import mage.abilities.common.SimpleStaticAbility;
|
||||||
import mage.abilities.costs.mana.GenericManaCost;
|
import mage.abilities.costs.mana.GenericManaCost;
|
||||||
import mage.abilities.effects.CostModificationEffectImpl;
|
import mage.abilities.effects.CostModificationEffectImpl;
|
||||||
|
import mage.abilities.keyword.FlashbackAbility;
|
||||||
|
import mage.abilities.keyword.RetraceAbility;
|
||||||
import mage.cards.CardImpl;
|
import mage.cards.CardImpl;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author Plopman
|
* @author Plopman
|
||||||
|
@ -84,7 +87,7 @@ class DefenseGridCostModificationEffect extends CostModificationEffectImpl<Defen
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean applies(Ability abilityToModify, Ability source, Game game) {
|
public boolean applies(Ability abilityToModify, Ability source, Game game) {
|
||||||
if (abilityToModify instanceof SpellAbility) {
|
if (abilityToModify instanceof SpellAbility || abilityToModify instanceof FlashbackAbility || abilityToModify instanceof RetraceAbility) {
|
||||||
if(!abilityToModify.getControllerId().equals(game.getActivePlayerId())) {
|
if(!abilityToModify.getControllerId().equals(game.getActivePlayerId())) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,7 +27,6 @@
|
||||||
*/
|
*/
|
||||||
package mage.sets.planechase2012;
|
package mage.sets.planechase2012;
|
||||||
|
|
||||||
import java.util.UUID;
|
|
||||||
import mage.Constants;
|
import mage.Constants;
|
||||||
import mage.Constants.CardType;
|
import mage.Constants.CardType;
|
||||||
import mage.Constants.Rarity;
|
import mage.Constants.Rarity;
|
||||||
|
@ -37,13 +36,17 @@ import mage.abilities.Ability;
|
||||||
import mage.abilities.SpellAbility;
|
import mage.abilities.SpellAbility;
|
||||||
import mage.abilities.common.SimpleStaticAbility;
|
import mage.abilities.common.SimpleStaticAbility;
|
||||||
import mage.abilities.effects.CostModificationEffectImpl;
|
import mage.abilities.effects.CostModificationEffectImpl;
|
||||||
|
import mage.abilities.keyword.FlashbackAbility;
|
||||||
import mage.abilities.keyword.LifelinkAbility;
|
import mage.abilities.keyword.LifelinkAbility;
|
||||||
|
import mage.abilities.keyword.RetraceAbility;
|
||||||
import mage.abilities.keyword.TrampleAbility;
|
import mage.abilities.keyword.TrampleAbility;
|
||||||
import mage.cards.CardImpl;
|
import mage.cards.CardImpl;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
import mage.target.Target;
|
import mage.target.Target;
|
||||||
import mage.util.CardUtil;
|
import mage.util.CardUtil;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author LevelX2
|
* @author LevelX2
|
||||||
|
@ -102,7 +105,7 @@ class ElderwoodScionCostReductionEffect extends CostModificationEffectImpl<Elder
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean applies(Ability abilityToModify, Ability source, Game game) {
|
public boolean applies(Ability abilityToModify, Ability source, Game game) {
|
||||||
if (abilityToModify instanceof SpellAbility) {
|
if (abilityToModify instanceof SpellAbility || abilityToModify instanceof FlashbackAbility || abilityToModify instanceof RetraceAbility) {
|
||||||
if (abilityToModify.getControllerId().equals(source.getControllerId())) {
|
if (abilityToModify.getControllerId().equals(source.getControllerId())) {
|
||||||
for (Target target :abilityToModify.getTargets()) {
|
for (Target target :abilityToModify.getTargets()) {
|
||||||
for (UUID targetUUID :target.getTargets()) {
|
for (UUID targetUUID :target.getTargets()) {
|
||||||
|
|
|
@ -27,7 +27,6 @@
|
||||||
*/
|
*/
|
||||||
package mage.sets.prophecy;
|
package mage.sets.prophecy;
|
||||||
|
|
||||||
import java.util.UUID;
|
|
||||||
import mage.Constants;
|
import mage.Constants;
|
||||||
import mage.Constants.CardType;
|
import mage.Constants.CardType;
|
||||||
import mage.Constants.Rarity;
|
import mage.Constants.Rarity;
|
||||||
|
@ -40,12 +39,16 @@ import mage.abilities.common.SimpleStaticAbility;
|
||||||
import mage.abilities.costs.AdjustingSourceCosts;
|
import mage.abilities.costs.AdjustingSourceCosts;
|
||||||
import mage.abilities.effects.CostModificationEffectImpl;
|
import mage.abilities.effects.CostModificationEffectImpl;
|
||||||
import mage.abilities.effects.common.continious.CanBlockAdditionalCreatureEffect;
|
import mage.abilities.effects.common.continious.CanBlockAdditionalCreatureEffect;
|
||||||
|
import mage.abilities.keyword.FlashbackAbility;
|
||||||
import mage.abilities.keyword.FlyingAbility;
|
import mage.abilities.keyword.FlyingAbility;
|
||||||
|
import mage.abilities.keyword.RetraceAbility;
|
||||||
import mage.cards.CardImpl;
|
import mage.cards.CardImpl;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
import mage.players.Player;
|
import mage.players.Player;
|
||||||
import mage.util.CardUtil;
|
import mage.util.CardUtil;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author Plopman
|
* @author Plopman
|
||||||
|
@ -138,7 +141,8 @@ class AdjustingCostsEffect extends CostModificationEffectImpl<AdjustingCostsEffe
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean applies(Ability abilityToModify, Ability source, Game game) {
|
public boolean applies(Ability abilityToModify, Ability source, Game game) {
|
||||||
if (abilityToModify instanceof SpellAbility && abilityToModify.getSourceId().equals(source.getSourceId())) {
|
if ((abilityToModify instanceof SpellAbility || abilityToModify instanceof FlashbackAbility || abilityToModify instanceof RetraceAbility)
|
||||||
|
&& abilityToModify.getSourceId().equals(source.getSourceId())) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -27,7 +27,6 @@
|
||||||
*/
|
*/
|
||||||
package mage.sets.returntoravnica;
|
package mage.sets.returntoravnica;
|
||||||
|
|
||||||
import java.util.UUID;
|
|
||||||
import mage.Constants;
|
import mage.Constants;
|
||||||
import mage.Constants.CardType;
|
import mage.Constants.CardType;
|
||||||
import mage.Constants.Rarity;
|
import mage.Constants.Rarity;
|
||||||
|
@ -38,7 +37,9 @@ import mage.abilities.common.SimpleStaticAbility;
|
||||||
import mage.abilities.costs.CostImpl;
|
import mage.abilities.costs.CostImpl;
|
||||||
import mage.abilities.dynamicvalue.common.OpponentsLostLifeCount;
|
import mage.abilities.dynamicvalue.common.OpponentsLostLifeCount;
|
||||||
import mage.abilities.effects.CostModificationEffectImpl;
|
import mage.abilities.effects.CostModificationEffectImpl;
|
||||||
|
import mage.abilities.keyword.FlashbackAbility;
|
||||||
import mage.abilities.keyword.FlyingAbility;
|
import mage.abilities.keyword.FlyingAbility;
|
||||||
|
import mage.abilities.keyword.RetraceAbility;
|
||||||
import mage.abilities.keyword.TrampleAbility;
|
import mage.abilities.keyword.TrampleAbility;
|
||||||
import mage.cards.Card;
|
import mage.cards.Card;
|
||||||
import mage.cards.CardImpl;
|
import mage.cards.CardImpl;
|
||||||
|
@ -46,6 +47,8 @@ import mage.game.Game;
|
||||||
import mage.players.Player;
|
import mage.players.Player;
|
||||||
import mage.util.CardUtil;
|
import mage.util.CardUtil;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author LevelX2
|
* @author LevelX2
|
||||||
|
@ -138,12 +141,12 @@ class RakdosLordOfRiotsCostReductionEffect extends CostModificationEffectImpl<Ra
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Game game, Ability source, Ability abilityToModify) {
|
public boolean apply(Game game, Ability source, Ability abilityToModify) {
|
||||||
SpellAbility spellAbility = (SpellAbility) abilityToModify;
|
Ability spellAbility = (SpellAbility) abilityToModify;
|
||||||
if (spellAbility != null) {
|
if (spellAbility != null) {
|
||||||
OpponentsLostLifeCount dynamicValue = new OpponentsLostLifeCount();
|
OpponentsLostLifeCount dynamicValue = new OpponentsLostLifeCount();
|
||||||
int amount = dynamicValue.calculate(game, source);
|
int amount = dynamicValue.calculate(game, source);
|
||||||
if (amount > 0) {
|
if (amount > 0) {
|
||||||
CardUtil.adjustCost(spellAbility, amount);
|
CardUtil.reduceCost(spellAbility, amount);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -152,8 +155,8 @@ class RakdosLordOfRiotsCostReductionEffect extends CostModificationEffectImpl<Ra
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean applies(Ability abilityToModify, Ability source, Game game) {
|
public boolean applies(Ability abilityToModify, Ability source, Game game) {
|
||||||
if (abilityToModify instanceof SpellAbility) {
|
if (abilityToModify instanceof SpellAbility || abilityToModify instanceof FlashbackAbility || abilityToModify instanceof RetraceAbility) {
|
||||||
Card sourceCard = game.getCard(((SpellAbility) abilityToModify).getSourceId());
|
Card sourceCard = game.getCard(abilityToModify.getSourceId());
|
||||||
if (sourceCard != null && abilityToModify.getControllerId().equals(source.getControllerId()) && (sourceCard.getCardType().contains(CardType.CREATURE))) {
|
if (sourceCard != null && abilityToModify.getControllerId().equals(source.getControllerId()) && (sourceCard.getCardType().contains(CardType.CREATURE))) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,6 +36,8 @@ import mage.abilities.common.EntersBattlefieldTriggeredAbility;
|
||||||
import mage.abilities.common.SimpleStaticAbility;
|
import mage.abilities.common.SimpleStaticAbility;
|
||||||
import mage.abilities.effects.CostModificationEffectImpl;
|
import mage.abilities.effects.CostModificationEffectImpl;
|
||||||
import mage.abilities.effects.OneShotEffect;
|
import mage.abilities.effects.OneShotEffect;
|
||||||
|
import mage.abilities.keyword.FlashbackAbility;
|
||||||
|
import mage.abilities.keyword.RetraceAbility;
|
||||||
import mage.cards.Card;
|
import mage.cards.Card;
|
||||||
import mage.cards.CardImpl;
|
import mage.cards.CardImpl;
|
||||||
import mage.filter.FilterCard;
|
import mage.filter.FilterCard;
|
||||||
|
@ -136,8 +138,8 @@ class SemblanceAnvilCostReductionEffect extends CostModificationEffectImpl<Sembl
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean applies(Ability abilityToModify, Ability source, Game game) {
|
public boolean applies(Ability abilityToModify, Ability source, Game game) {
|
||||||
if (abilityToModify instanceof SpellAbility) {
|
if (abilityToModify instanceof SpellAbility || abilityToModify instanceof FlashbackAbility || abilityToModify instanceof RetraceAbility) {
|
||||||
Card sourceCard = game.getCard(((SpellAbility) abilityToModify).getSourceId());
|
Card sourceCard = game.getCard(abilityToModify.getSourceId());
|
||||||
if (sourceCard != null && sourceCard.getOwnerId().equals(source.getControllerId())) {
|
if (sourceCard != null && sourceCard.getOwnerId().equals(source.getControllerId())) {
|
||||||
Permanent permanent = game.getPermanent(source.getSourceId());
|
Permanent permanent = game.getPermanent(source.getSourceId());
|
||||||
if (permanent != null) {
|
if (permanent != null) {
|
||||||
|
|
|
@ -27,7 +27,6 @@
|
||||||
*/
|
*/
|
||||||
package mage.sets.worldwake;
|
package mage.sets.worldwake;
|
||||||
|
|
||||||
import java.util.UUID;
|
|
||||||
import mage.Constants;
|
import mage.Constants;
|
||||||
import mage.Constants.CardType;
|
import mage.Constants.CardType;
|
||||||
import mage.Constants.Rarity;
|
import mage.Constants.Rarity;
|
||||||
|
@ -37,10 +36,14 @@ import mage.abilities.SpellAbility;
|
||||||
import mage.abilities.common.SimpleStaticAbility;
|
import mage.abilities.common.SimpleStaticAbility;
|
||||||
import mage.abilities.costs.mana.GenericManaCost;
|
import mage.abilities.costs.mana.GenericManaCost;
|
||||||
import mage.abilities.effects.CostModificationEffectImpl;
|
import mage.abilities.effects.CostModificationEffectImpl;
|
||||||
|
import mage.abilities.keyword.FlashbackAbility;
|
||||||
|
import mage.abilities.keyword.RetraceAbility;
|
||||||
import mage.cards.Card;
|
import mage.cards.Card;
|
||||||
import mage.cards.CardImpl;
|
import mage.cards.CardImpl;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author jeffwadsworth
|
* @author jeffwadsworth
|
||||||
|
@ -89,7 +92,7 @@ class LodestoneGolemCostReductionEffect extends CostModificationEffectImpl<Lodes
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean applies(Ability abilityToModify, Ability source, Game game) {
|
public boolean applies(Ability abilityToModify, Ability source, Game game) {
|
||||||
if (abilityToModify instanceof SpellAbility) {
|
if (abilityToModify instanceof SpellAbility || abilityToModify instanceof FlashbackAbility || abilityToModify instanceof RetraceAbility) {
|
||||||
Card card = game.getCard(abilityToModify.getSourceId());
|
Card card = game.getCard(abilityToModify.getSourceId());
|
||||||
if (card != null && !card.getCardType().contains(CardType.ARTIFACT)) {
|
if (card != null && !card.getCardType().contains(CardType.ARTIFACT)) {
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -27,7 +27,6 @@
|
||||||
*/
|
*/
|
||||||
package mage.sets.worldwake;
|
package mage.sets.worldwake;
|
||||||
|
|
||||||
import java.util.UUID;
|
|
||||||
import mage.Constants;
|
import mage.Constants;
|
||||||
import mage.Constants.CardType;
|
import mage.Constants.CardType;
|
||||||
import mage.Constants.Duration;
|
import mage.Constants.Duration;
|
||||||
|
@ -43,6 +42,7 @@ import mage.abilities.effects.CostModificationEffectImpl;
|
||||||
import mage.abilities.effects.OneShotEffect;
|
import mage.abilities.effects.OneShotEffect;
|
||||||
import mage.abilities.effects.common.ExileTargetEffect;
|
import mage.abilities.effects.common.ExileTargetEffect;
|
||||||
import mage.abilities.keyword.FlashbackAbility;
|
import mage.abilities.keyword.FlashbackAbility;
|
||||||
|
import mage.abilities.keyword.RetraceAbility;
|
||||||
import mage.abilities.keyword.TrampleAbility;
|
import mage.abilities.keyword.TrampleAbility;
|
||||||
import mage.cards.CardImpl;
|
import mage.cards.CardImpl;
|
||||||
import mage.filter.common.FilterCreaturePermanent;
|
import mage.filter.common.FilterCreaturePermanent;
|
||||||
|
@ -52,6 +52,8 @@ import mage.game.permanent.token.Token;
|
||||||
import mage.target.targetpointer.FixedTarget;
|
import mage.target.targetpointer.FixedTarget;
|
||||||
import mage.util.CardUtil;
|
import mage.util.CardUtil;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author jeffwadsworth
|
* @author jeffwadsworth
|
||||||
|
@ -104,13 +106,13 @@ class StoneIdolTrapCostReductionEffect extends CostModificationEffectImpl<StoneI
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Game game, Ability source, Ability abilityToModify) {
|
public boolean apply(Game game, Ability source, Ability abilityToModify) {
|
||||||
int reductionAmount = game.getBattlefield().count(filter, source.getSourceId(), source.getControllerId(),game);
|
int reductionAmount = game.getBattlefield().count(filter, source.getSourceId(), source.getControllerId(),game);
|
||||||
CardUtil.adjustCost(abilityToModify, reductionAmount);
|
CardUtil.reduceCost(abilityToModify, reductionAmount);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean applies(Ability abilityToModify, Ability source, Game game) {
|
public boolean applies(Ability abilityToModify, Ability source, Game game) {
|
||||||
if ((abilityToModify instanceof SpellAbility || abilityToModify instanceof FlashbackAbility)
|
if ((abilityToModify instanceof SpellAbility || abilityToModify instanceof FlashbackAbility || abilityToModify instanceof RetraceAbility)
|
||||||
&& abilityToModify.getSourceId().equals(source.getSourceId())) {
|
&& abilityToModify.getSourceId().equals(source.getSourceId())) {
|
||||||
return game.getCard(abilityToModify.getSourceId()) != null;
|
return game.getCard(abilityToModify.getSourceId()) != null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -266,10 +266,11 @@ public abstract class AbilityImpl<T extends AbilityImpl<T>> implements Ability {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!useAlternativeCost(game)) {
|
|
||||||
//20101001 - 601.2e
|
//20101001 - 601.2e
|
||||||
game.getContinuousEffects().costModification(this, game);
|
game.getContinuousEffects().costModification(this, game);
|
||||||
|
|
||||||
|
if (!useAlternativeCost(game)) {
|
||||||
|
|
||||||
//20100716 - 601.2f
|
//20100716 - 601.2f
|
||||||
if (!manaCostsToPay.pay(this, game, sourceId, controllerId, noMana)) {
|
if (!manaCostsToPay.pay(this, game, sourceId, controllerId, noMana)) {
|
||||||
logger.debug("activate failed - mana");
|
logger.debug("activate failed - mana");
|
||||||
|
|
|
@ -33,7 +33,9 @@ import mage.Constants.AsThoughEffectType;
|
||||||
import mage.Constants.CardType;
|
import mage.Constants.CardType;
|
||||||
import mage.Constants.Zone;
|
import mage.Constants.Zone;
|
||||||
import mage.MageObject;
|
import mage.MageObject;
|
||||||
|
import mage.abilities.costs.Cost;
|
||||||
import mage.abilities.costs.mana.ManaCost;
|
import mage.abilities.costs.mana.ManaCost;
|
||||||
|
import mage.abilities.effects.Effect;
|
||||||
import mage.abilities.keyword.FlashAbility;
|
import mage.abilities.keyword.FlashAbility;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
|
|
||||||
|
@ -46,11 +48,20 @@ import java.util.UUID;
|
||||||
public class SpellAbility extends ActivatedAbilityImpl<SpellAbility> {
|
public class SpellAbility extends ActivatedAbilityImpl<SpellAbility> {
|
||||||
|
|
||||||
public SpellAbility(ManaCost cost, String cardName) {
|
public SpellAbility(ManaCost cost, String cardName) {
|
||||||
super(AbilityType.SPELL, Zone.HAND);
|
this(cost, cardName, Zone.HAND);
|
||||||
|
}
|
||||||
|
|
||||||
|
public SpellAbility(ManaCost cost, String cardName, Zone zone) {
|
||||||
|
super(AbilityType.SPELL, zone);
|
||||||
this.addManaCost(cost);
|
this.addManaCost(cost);
|
||||||
this.name = "Cast " + cardName;
|
this.name = "Cast " + cardName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public SpellAbility(Cost cost, String cardName, Effect effect, Zone zone) {
|
||||||
|
super(zone, effect, cost);
|
||||||
|
this.name = "Cast " + cardName;
|
||||||
|
}
|
||||||
|
|
||||||
public SpellAbility(SpellAbility ability) {
|
public SpellAbility(SpellAbility ability) {
|
||||||
super(ability);
|
super(ability);
|
||||||
}
|
}
|
||||||
|
|
|
@ -65,7 +65,7 @@ public class SpellsCostReductionEffect extends CostModificationEffectImpl<Spells
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Game game, Ability source, Ability abilityToModify) {
|
public boolean apply(Game game, Ability source, Ability abilityToModify) {
|
||||||
CardUtil.adjustCost(abilityToModify, this.amount);
|
CardUtil.reduceCost(abilityToModify, this.amount);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -46,9 +46,10 @@ import mage.target.Target;
|
||||||
*
|
*
|
||||||
* @author nantuko
|
* @author nantuko
|
||||||
*/
|
*/
|
||||||
public class FlashbackAbility extends ActivatedAbilityImpl<FlashbackAbility> {
|
public class FlashbackAbility extends /*SpellAbility*/ ActivatedAbilityImpl<FlashbackAbility> {
|
||||||
|
|
||||||
public FlashbackAbility(Cost cost, Constants.TimingRule timingRule) {
|
public FlashbackAbility(Cost cost, Constants.TimingRule timingRule) {
|
||||||
|
//super(cost, "", new FlashbackEffect(), Constants.Zone.GRAVEYARD);
|
||||||
super(Constants.Zone.GRAVEYARD, new FlashbackEffect(), cost);
|
super(Constants.Zone.GRAVEYARD, new FlashbackEffect(), cost);
|
||||||
this.timing = timingRule;
|
this.timing = timingRule;
|
||||||
this.usesStack = false;
|
this.usesStack = false;
|
||||||
|
|
|
@ -32,6 +32,8 @@ import mage.Constants;
|
||||||
import mage.Mana;
|
import mage.Mana;
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
import mage.abilities.SpellAbility;
|
import mage.abilities.SpellAbility;
|
||||||
|
import mage.abilities.costs.AlternativeCost;
|
||||||
|
import mage.abilities.costs.AlternativeCostImpl;
|
||||||
import mage.abilities.costs.mana.GenericManaCost;
|
import mage.abilities.costs.mana.GenericManaCost;
|
||||||
import mage.abilities.costs.mana.ManaCost;
|
import mage.abilities.costs.mana.ManaCost;
|
||||||
import mage.abilities.costs.mana.ManaCosts;
|
import mage.abilities.costs.mana.ManaCosts;
|
||||||
|
@ -41,6 +43,8 @@ import mage.game.permanent.token.Token;
|
||||||
import mage.util.functions.CopyFunction;
|
import mage.util.functions.CopyFunction;
|
||||||
import mage.util.functions.CopyTokenFunction;
|
import mage.util.functions.CopyTokenFunction;
|
||||||
|
|
||||||
|
import java.util.Iterator;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author nantuko
|
* @author nantuko
|
||||||
*/
|
*/
|
||||||
|
@ -88,6 +92,63 @@ public class CardUtil {
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Increase spell or ability cost to be paid.
|
||||||
|
*
|
||||||
|
* @param ability
|
||||||
|
* @param increaseCount
|
||||||
|
*/
|
||||||
|
public static void increaseCost(Ability ability, int increaseCount) {
|
||||||
|
adjustCost(ability, -increaseCount);
|
||||||
|
adjustAlternativeCosts(ability, -increaseCount);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reduces ability cost to be paid.
|
||||||
|
*
|
||||||
|
* @param ability
|
||||||
|
* @param reduceCount
|
||||||
|
*/
|
||||||
|
public static void reduceCost(Ability ability, int reduceCount) {
|
||||||
|
adjustCost(ability, reduceCount);
|
||||||
|
adjustAlternativeCosts(ability, reduceCount);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void adjustAlternativeCosts(Ability ability, int reduceCount) {
|
||||||
|
for (AlternativeCost alternativeCost : ability.getAlternativeCosts()) {
|
||||||
|
if (alternativeCost instanceof AlternativeCostImpl) {
|
||||||
|
AlternativeCostImpl impl = (AlternativeCostImpl) alternativeCost;
|
||||||
|
ManaCosts<ManaCost> adjustedCost = new ManaCostsImpl<ManaCost>();
|
||||||
|
boolean updated = false;
|
||||||
|
Iterator it = impl.iterator();
|
||||||
|
while (it.hasNext()) {
|
||||||
|
Object cost = it.next();
|
||||||
|
if (cost instanceof ManaCosts) {
|
||||||
|
for (Object object : ((ManaCosts) cost)) {
|
||||||
|
if (object instanceof ManaCost) {
|
||||||
|
ManaCost manaCost = (ManaCost) object;
|
||||||
|
Mana mana = manaCost.getOptions().get(0);
|
||||||
|
int colorless = mana != null ? mana.getColorless() : 0;
|
||||||
|
if (!updated && colorless > 0) {
|
||||||
|
if ((colorless - reduceCount) > 0) {
|
||||||
|
int newColorless = colorless - reduceCount;
|
||||||
|
it.remove();
|
||||||
|
adjustedCost.add(new GenericManaCost(newColorless));
|
||||||
|
}
|
||||||
|
updated = true;
|
||||||
|
} else {
|
||||||
|
adjustedCost.add(manaCost);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
impl.add(adjustedCost);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adjusts spell or ability cost to be paid.
|
* Adjusts spell or ability cost to be paid.
|
||||||
*
|
*
|
||||||
|
@ -95,32 +156,39 @@ public class CardUtil {
|
||||||
* @param reduceCount
|
* @param reduceCount
|
||||||
*/
|
*/
|
||||||
public static void adjustCost(SpellAbility spellAbility, int reduceCount) {
|
public static void adjustCost(SpellAbility spellAbility, int reduceCount) {
|
||||||
Ability ability = (Ability) spellAbility;
|
CardUtil.adjustCost(spellAbility, reduceCount);
|
||||||
CardUtil.adjustCost(ability, reduceCount);
|
adjustAlternativeCosts(spellAbility, reduceCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adjusts ability cost to be paid.
|
* Adjusts ability cost to be paid.
|
||||||
*
|
*
|
||||||
* @param ability
|
* @param ability
|
||||||
* @param reduceCount
|
* @param reduceCount
|
||||||
*/
|
*/
|
||||||
public static void adjustCost(Ability ability, int reduceCount) {
|
private static void adjustCost(Ability ability, int reduceCount) {
|
||||||
ManaCosts<ManaCost> previousCost = ability.getManaCostsToPay();
|
ManaCosts<ManaCost> previousCost = ability.getManaCostsToPay();
|
||||||
ManaCosts<ManaCost> adjustedCost = new ManaCostsImpl<ManaCost>();
|
ManaCosts<ManaCost> adjustedCost = new ManaCostsImpl<ManaCost>();
|
||||||
boolean reduced = false;
|
boolean updated = false;
|
||||||
for (ManaCost manaCost : previousCost) {
|
for (ManaCost manaCost : previousCost) {
|
||||||
Mana mana = manaCost.getOptions().get(0);
|
Mana mana = manaCost.getOptions().get(0);
|
||||||
int colorless = mana != null ? mana.getColorless() : 0;
|
int colorless = mana != null ? mana.getColorless() : 0;
|
||||||
if (!reduced && colorless > 0) {
|
if (!updated && colorless > 0) {
|
||||||
if ((colorless - reduceCount) > 0) {
|
if ((colorless - reduceCount) > 0) {
|
||||||
int newColorless = colorless - reduceCount;
|
int newColorless = colorless - reduceCount;
|
||||||
adjustedCost.add(new GenericManaCost(newColorless));
|
adjustedCost.add(new GenericManaCost(newColorless));
|
||||||
}
|
}
|
||||||
reduced = true;
|
updated = true;
|
||||||
} else {
|
} else {
|
||||||
adjustedCost.add(manaCost);
|
adjustedCost.add(manaCost);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// for increasing spell cost effects
|
||||||
|
if (!updated && reduceCount < 0) {
|
||||||
|
adjustedCost.add(new GenericManaCost(-reduceCount));
|
||||||
|
}
|
||||||
|
|
||||||
ability.getManaCostsToPay().clear();
|
ability.getManaCostsToPay().clear();
|
||||||
ability.getManaCostsToPay().addAll(adjustedCost);
|
ability.getManaCostsToPay().addAll(adjustedCost);
|
||||||
}
|
}
|
||||||
|
@ -129,7 +197,7 @@ public class CardUtil {
|
||||||
* Adjusts spell or ability cost to be paid by colored and generic mana.
|
* Adjusts spell or ability cost to be paid by colored and generic mana.
|
||||||
*
|
*
|
||||||
* @param spellAbility
|
* @param spellAbility
|
||||||
* @param mana costs to reduce
|
* @param manaCostsToReduce costs to reduce
|
||||||
*/
|
*/
|
||||||
public static void adjustCost(SpellAbility spellAbility, ManaCosts<ManaCost> manaCostsToReduce) {
|
public static void adjustCost(SpellAbility spellAbility, ManaCosts<ManaCost> manaCostsToReduce) {
|
||||||
ManaCosts<ManaCost> previousCost = spellAbility.getManaCostsToPay();
|
ManaCosts<ManaCost> previousCost = spellAbility.getManaCostsToPay();
|
||||||
|
|
Loading…
Reference in a new issue