* Cleaned up some unnecessary checks for FlashbackAbility due to the old Flashback implementation.

This commit is contained in:
LevelX2 2018-05-01 01:11:47 +02:00
parent c7f23a8ba4
commit a84dc233c3
14 changed files with 57 additions and 82 deletions

View file

@ -38,7 +38,6 @@ import mage.abilities.costs.common.SacrificeTargetCost;
import mage.abilities.effects.ContinuousEffectImpl;
import mage.abilities.effects.common.continuous.BoostControlledEffect;
import mage.abilities.effects.common.cost.CostModificationEffectImpl;
import mage.abilities.keyword.FlashbackAbility;
import mage.abilities.keyword.FlyingAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
@ -63,7 +62,7 @@ public class AngelOfJubilation extends CardImpl {
}
public AngelOfJubilation(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{1}{W}{W}{W}");
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{1}{W}{W}{W}");
this.subtype.add(SubType.ANGEL);
this.power = new MageInt(3);
@ -129,7 +128,7 @@ class AngelOfJubilationSacrificeFilterEffect extends CostModificationEffectImpl
@Override
public boolean apply(Game game, Ability source, Ability abilityToModify) {
for (Cost cost : abilityToModify.getCosts()) {
if(cost instanceof SacrificeTargetCost) {
if (cost instanceof SacrificeTargetCost) {
SacrificeTargetCost sacrificeCost = (SacrificeTargetCost) cost;
Filter filter = sacrificeCost.getTargets().get(0).getFilter();
filter.add(Predicates.not(new CardTypePredicate(CardType.CREATURE)));
@ -140,8 +139,8 @@ class AngelOfJubilationSacrificeFilterEffect extends CostModificationEffectImpl
@Override
public boolean applies(Ability abilityToModify, Ability source, Game game) {
return abilityToModify.getAbilityType() == AbilityType.ACTIVATED ||
abilityToModify instanceof SpellAbility || abilityToModify instanceof FlashbackAbility;
return abilityToModify.getAbilityType() == AbilityType.ACTIVATED
|| abilityToModify instanceof SpellAbility;
}
@Override

View file

@ -36,9 +36,7 @@ import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.common.SpellCastControllerTriggeredAbility;
import mage.abilities.effects.common.cost.CostModificationEffectImpl;
import mage.abilities.effects.common.counter.AddCountersSourceEffect;
import mage.abilities.keyword.FlashbackAbility;
import mage.abilities.keyword.ProtectionAbility;
import mage.cards.Card;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.*;
@ -111,15 +109,11 @@ class AnimarCostReductionEffect extends CostModificationEffectImpl {
@Override
public boolean applies(Ability abilityToModify, Ability source, Game game) {
if (abilityToModify instanceof SpellAbility || abilityToModify instanceof FlashbackAbility) {
if (abilityToModify instanceof SpellAbility) {
if (abilityToModify.getControllerId().equals(source.getControllerId())) {
Spell spell = (Spell) game.getStack().getStackObject(abilityToModify.getId());
if (spell != null) {
return spell.isCreature();
} else {
// used at least for flashback ability because Flashback ability doesn't use stack or for getPlayables where spell is not cast yet
Card sourceCard = game.getCard(abilityToModify.getSourceId());
return sourceCard != null && sourceCard.isCreature();
}
}
}

View file

@ -32,7 +32,6 @@ import mage.abilities.Ability;
import mage.abilities.SpellAbility;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.effects.common.cost.CostModificationEffectImpl;
import mage.abilities.keyword.FlashbackAbility;
import mage.cards.Card;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
@ -82,7 +81,7 @@ class ArcaneMeleeCostReductionEffect extends CostModificationEffectImpl {
@Override
public boolean applies(Ability abilityToModify, Ability source, Game game) {
if (abilityToModify instanceof SpellAbility || abilityToModify instanceof FlashbackAbility) {
if (abilityToModify instanceof SpellAbility) {
Card sourceCard = game.getCard((abilityToModify).getSourceId());
if (sourceCard != null && (sourceCard.isInstant() || sourceCard.isSorcery())) {
return true;

View file

@ -36,7 +36,6 @@ import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.costs.AdjustingSourceCosts;
import mage.abilities.effects.common.combat.CanBlockAdditionalCreatureEffect;
import mage.abilities.effects.common.cost.CostModificationEffectImpl;
import mage.abilities.keyword.FlashbackAbility;
import mage.abilities.keyword.FlyingAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
@ -52,7 +51,7 @@ import mage.util.CardUtil;
public class AvatarOfHope extends CardImpl {
public AvatarOfHope(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{6}{W}{W}");
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{6}{W}{W}");
this.subtype.add(SubType.AVATAR);
this.power = new MageInt(4);
@ -93,7 +92,7 @@ class AdjustingCostsAbility extends SimpleStaticAbility implements AdjustingSour
@Override
public String getRule() {
return "If you have 3 or less life, Avatar of Hope costs {6} less to cast";
return "If you have 3 or less life, {this} costs {6} less to cast";
}
@Override
@ -101,7 +100,7 @@ class AdjustingCostsAbility extends SimpleStaticAbility implements AdjustingSour
if (ability.getAbilityType() == AbilityType.SPELL) {
Player player = game.getPlayer(ability.getControllerId());
if (player != null && player.getLife() < 4) {
CardUtil.adjustCost((SpellAbility)ability, 6);
CardUtil.adjustCost((SpellAbility) ability, 6);
}
}
}
@ -119,7 +118,7 @@ class AdjustingCostsEffect extends CostModificationEffectImpl {
@Override
public boolean apply(Game game, Ability source, Ability abilityToModify) {
SpellAbility spellAbility = (SpellAbility)abilityToModify;
SpellAbility spellAbility = (SpellAbility) abilityToModify;
Mana mana = spellAbility.getManaCostsToPay().getMana();
Player player = game.getPlayer(source.getControllerId());
@ -137,7 +136,7 @@ class AdjustingCostsEffect extends CostModificationEffectImpl {
@Override
public boolean applies(Ability abilityToModify, Ability source, Game game) {
if ((abilityToModify instanceof SpellAbility || abilityToModify instanceof FlashbackAbility)
if ((abilityToModify instanceof SpellAbility)
&& abilityToModify.getSourceId().equals(source.getSourceId())) {
return true;
}

View file

@ -37,7 +37,6 @@ import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.effects.ContinuousRuleModifyingEffectImpl;
import mage.abilities.effects.common.NameACardEffect;
import mage.abilities.effects.common.cost.CostModificationEffectImpl;
import mage.abilities.keyword.FlashbackAbility;
import mage.cards.Card;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
@ -54,7 +53,7 @@ import mage.util.CardUtil;
public class CouncilOfTheAbsolute extends CardImpl {
public CouncilOfTheAbsolute(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{2}{W}{U}");
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{2}{W}{U}");
this.subtype.add(SubType.HUMAN);
this.subtype.add(SubType.ADVISOR);
@ -147,7 +146,7 @@ class CouncilOfTheAbsoluteCostReductionEffect extends CostModificationEffectImpl
@Override
public boolean applies(Ability abilityToModify, Ability source, Game game) {
if ((abilityToModify instanceof SpellAbility || abilityToModify instanceof FlashbackAbility)
if ((abilityToModify instanceof SpellAbility)
&& abilityToModify.getControllerId().equals(source.getControllerId())) {
Card card = game.getCard(abilityToModify.getSourceId());
return card.getName().equals(game.getState().getValue(source.getSourceId().toString() + NameACardEffect.INFO_KEY));

View file

@ -33,7 +33,6 @@ import mage.abilities.SpellAbility;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.costs.mana.GenericManaCost;
import mage.abilities.effects.common.cost.CostModificationEffectImpl;
import mage.abilities.keyword.FlashbackAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.*;
@ -46,7 +45,7 @@ import mage.game.Game;
public class DefenseGrid extends CardImpl {
public DefenseGrid(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.ARTIFACT},"{2}");
super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT}, "{2}");
// Each spell costs {3} more to cast except during its controller's turn.
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new DefenseGridCostModificationEffect()));
@ -65,7 +64,7 @@ public class DefenseGrid extends CardImpl {
class DefenseGridCostModificationEffect extends CostModificationEffectImpl {
DefenseGridCostModificationEffect ( ) {
DefenseGridCostModificationEffect() {
super(Duration.WhileOnBattlefield, Outcome.Benefit, CostModificationType.INCREASE_COST);
staticText = "Each spell costs {3} more to cast except during its controller's turn";
}
@ -83,8 +82,8 @@ class DefenseGridCostModificationEffect extends CostModificationEffectImpl {
@Override
public boolean applies(Ability abilityToModify, Ability source, Game game) {
if (abilityToModify instanceof SpellAbility || abilityToModify instanceof FlashbackAbility) {
if(!abilityToModify.getControllerId().equals(game.getActivePlayerId())) {
if (abilityToModify instanceof SpellAbility) {
if (!abilityToModify.getControllerId().equals(game.getActivePlayerId())) {
return true;
}
}

View file

@ -33,7 +33,6 @@ import mage.abilities.Ability;
import mage.abilities.SpellAbility;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.effects.common.cost.CostModificationEffectImpl;
import mage.abilities.keyword.FlashbackAbility;
import mage.cards.Card;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
@ -48,7 +47,7 @@ import mage.util.CardUtil;
public class Glowrider extends CardImpl {
public Glowrider(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{2}{W}");
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{2}{W}");
this.subtype.add(SubType.HUMAN);
this.subtype.add(SubType.CLERIC);
this.power = new MageInt(2);
@ -70,7 +69,7 @@ public class Glowrider extends CardImpl {
class GlowriderCostReductionEffect extends CostModificationEffectImpl {
GlowriderCostReductionEffect ( ) {
GlowriderCostReductionEffect() {
super(Duration.WhileOnBattlefield, Outcome.Benefit, CostModificationType.INCREASE_COST);
staticText = "Noncreature spells cost {1} more to cast";
}
@ -87,7 +86,7 @@ class GlowriderCostReductionEffect extends CostModificationEffectImpl {
@Override
public boolean applies(Ability abilityToModify, Ability source, Game game) {
if (abilityToModify instanceof SpellAbility || abilityToModify instanceof FlashbackAbility) {
if (abilityToModify instanceof SpellAbility) {
Card card = game.getCard(abilityToModify.getSourceId());
if (card != null && !card.isCreature()) {
return true;

View file

@ -33,7 +33,6 @@ import mage.abilities.Ability;
import mage.abilities.SpellAbility;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.effects.common.cost.CostModificationEffectImpl;
import mage.abilities.keyword.FlashbackAbility;
import mage.cards.Card;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
@ -48,7 +47,7 @@ import mage.util.CardUtil;
public class LocketOfYesterdays extends CardImpl {
public LocketOfYesterdays(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.ARTIFACT},"{1}");
super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT}, "{1}");
// Spells you cast cost {1} less to cast for each card with the same name as that spell in your graveyard.
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new LocketOfYesterdaysCostReductionEffect()));
@ -80,7 +79,7 @@ class LocketOfYesterdaysCostReductionEffect extends CostModificationEffectImpl {
MageObject sourceObject = game.getObject(abilityToModify.getSourceId());
if (sourceObject != null) {
int amount = 0;
for (UUID cardId :game.getPlayer(source.getControllerId()).getGraveyard()) {
for (UUID cardId : game.getPlayer(source.getControllerId()).getGraveyard()) {
Card card = game.getCard(cardId);
if (card != null && card.getName().equals(sourceObject.getName())) {
amount++;
@ -97,8 +96,8 @@ class LocketOfYesterdaysCostReductionEffect extends CostModificationEffectImpl {
@Override
public boolean applies(Ability abilityToModify, Ability source, Game game) {
if (abilityToModify.getControllerId().equals(source.getControllerId()) &&
(abilityToModify instanceof SpellAbility || abilityToModify instanceof FlashbackAbility)) {
if (abilityToModify.getControllerId().equals(source.getControllerId())
&& (abilityToModify instanceof SpellAbility)) {
return true;
}
return false;

View file

@ -34,7 +34,6 @@ import mage.abilities.SpellAbility;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.costs.mana.GenericManaCost;
import mage.abilities.effects.common.cost.CostModificationEffectImpl;
import mage.abilities.keyword.FlashbackAbility;
import mage.cards.Card;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
@ -53,7 +52,7 @@ import mage.game.Game;
public class LodestoneGolem extends CardImpl {
public LodestoneGolem(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.ARTIFACT,CardType.CREATURE},"{4}");
super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT, CardType.CREATURE}, "{4}");
this.subtype.add(SubType.GOLEM);
this.power = new MageInt(5);
@ -75,7 +74,7 @@ public class LodestoneGolem extends CardImpl {
class LodestoneGolemCostReductionEffect extends CostModificationEffectImpl {
LodestoneGolemCostReductionEffect ( ) {
LodestoneGolemCostReductionEffect() {
super(Duration.WhileOnBattlefield, Outcome.Benefit, CostModificationType.INCREASE_COST);
staticText = "Nonartifact spells cost {1} more to cast";
}
@ -93,7 +92,7 @@ class LodestoneGolemCostReductionEffect extends CostModificationEffectImpl {
@Override
public boolean applies(Ability abilityToModify, Ability source, Game game) {
if (abilityToModify instanceof SpellAbility || abilityToModify instanceof FlashbackAbility) {
if (abilityToModify instanceof SpellAbility) {
Card card = game.getCard(abilityToModify.getSourceId());
if (card != null && !card.isArtifact()) {
return true;
@ -108,4 +107,3 @@ class LodestoneGolemCostReductionEffect extends CostModificationEffectImpl {
}
}

View file

@ -35,10 +35,8 @@ import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.dynamicvalue.common.OpponentsLostLifeCount;
import mage.abilities.effects.ContinuousRuleModifyingEffectImpl;
import mage.abilities.effects.common.cost.CostModificationEffectImpl;
import mage.abilities.keyword.FlashbackAbility;
import mage.abilities.keyword.FlyingAbility;
import mage.abilities.keyword.TrampleAbility;
import mage.cards.Card;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.*;
@ -147,15 +145,11 @@ class RakdosLordOfRiotsCostReductionEffect extends CostModificationEffectImpl {
@Override
public boolean applies(Ability abilityToModify, Ability source, Game game) {
if (abilityToModify instanceof SpellAbility || abilityToModify instanceof FlashbackAbility) {
if (abilityToModify instanceof SpellAbility) {
if (abilityToModify.getControllerId().equals(source.getControllerId())) {
Spell spell = (Spell) game.getStack().getStackObject(abilityToModify.getId());
if (spell != null) {
return spell.isCreature();
} else {
// used at least for flashback ability because Flashback ability doesn't use stack or for getPlayables where spell is not cast yet
Card sourceCard = game.getCard(abilityToModify.getSourceId());
return sourceCard != null && sourceCard.isCreature();
}
}
}

View file

@ -35,7 +35,6 @@ import mage.abilities.common.EntersBattlefieldTriggeredAbility;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.cost.CostModificationEffectImpl;
import mage.abilities.keyword.FlashbackAbility;
import mage.cards.Card;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
@ -54,7 +53,7 @@ import mage.util.CardUtil;
public class SemblanceAnvil extends CardImpl {
public SemblanceAnvil(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.ARTIFACT},"{3}");
super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT}, "{3}");
// Imprint - When Semblance Anvil enters the battlefield, you may exile a nonland card from your hand.
this.addAbility(new EntersBattlefieldTriggeredAbility(new SemblanceAnvilEffect(), true));
@ -134,7 +133,7 @@ class SemblanceAnvilCostReductionEffect extends CostModificationEffectImpl {
@Override
public boolean applies(Ability abilityToModify, Ability source, Game game) {
if (abilityToModify instanceof SpellAbility || abilityToModify instanceof FlashbackAbility) {
if (abilityToModify instanceof SpellAbility) {
Card sourceCard = game.getCard(abilityToModify.getSourceId());
if (sourceCard != null && sourceCard.getOwnerId().equals(source.getControllerId())) {
Permanent permanent = game.getPermanent(source.getSourceId());

View file

@ -34,7 +34,6 @@ import mage.abilities.Mode;
import mage.abilities.SpellAbility;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.effects.common.cost.CostModificationEffectImpl;
import mage.abilities.keyword.FlashbackAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.*;
@ -90,7 +89,7 @@ class SpellwildOupheCostReductionEffect extends CostModificationEffectImpl {
@Override
public boolean applies(Ability abilityToModify, Ability source, Game game) {
if (abilityToModify instanceof SpellAbility || abilityToModify instanceof FlashbackAbility) {
if (abilityToModify instanceof SpellAbility) {
for (UUID modeId : abilityToModify.getModes().getSelectedModes()) {
Mode mode = abilityToModify.getModes().get(modeId);
for (Target target : mode.getTargets()) {

View file

@ -34,7 +34,6 @@ import mage.abilities.SpellAbility;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.effects.common.cost.CostModificationEffectImpl;
import mage.abilities.keyword.FirstStrikeAbility;
import mage.abilities.keyword.FlashbackAbility;
import mage.cards.Card;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
@ -49,7 +48,7 @@ import mage.util.CardUtil;
public class ThaliaGuardianOfThraben extends CardImpl {
public ThaliaGuardianOfThraben(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{1}{W}");
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{1}{W}");
addSuperType(SuperType.LEGENDARY);
this.subtype.add(SubType.HUMAN);
this.subtype.add(SubType.SOLDIER);
@ -76,7 +75,7 @@ public class ThaliaGuardianOfThraben extends CardImpl {
class ThaliaGuardianOfThrabenCostReductionEffect extends CostModificationEffectImpl {
ThaliaGuardianOfThrabenCostReductionEffect ( ) {
ThaliaGuardianOfThrabenCostReductionEffect() {
super(Duration.WhileOnBattlefield, Outcome.Benefit, CostModificationType.INCREASE_COST);
staticText = "Noncreature spells cost {1} more to cast";
}
@ -93,7 +92,7 @@ class ThaliaGuardianOfThrabenCostReductionEffect extends CostModificationEffectI
@Override
public boolean applies(Ability abilityToModify, Ability source, Game game) {
if (abilityToModify instanceof SpellAbility || abilityToModify instanceof FlashbackAbility) {
if (abilityToModify instanceof SpellAbility) {
Card card = game.getCard(abilityToModify.getSourceId());
if (card != null && !card.isCreature()) {
return true;

View file

@ -33,7 +33,6 @@ import mage.abilities.Ability;
import mage.abilities.SpellAbility;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.effects.common.cost.CostModificationEffectImpl;
import mage.abilities.keyword.FlashbackAbility;
import mage.abilities.keyword.FlyingAbility;
import mage.cards.Card;
import mage.cards.CardImpl;
@ -54,7 +53,7 @@ import mage.util.CardUtil;
public class VrynWingmare extends CardImpl {
public VrynWingmare(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{2}{W}");
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{2}{W}");
this.subtype.add(SubType.PEGASUS);
this.power = new MageInt(2);
this.toughness = new MageInt(1);
@ -78,7 +77,7 @@ public class VrynWingmare extends CardImpl {
class VrynWingmareCostReductionEffect extends CostModificationEffectImpl {
VrynWingmareCostReductionEffect ( ) {
VrynWingmareCostReductionEffect() {
super(Duration.WhileOnBattlefield, Outcome.Benefit, CostModificationType.INCREASE_COST);
staticText = "Noncreature spells cost {1} more to cast";
}
@ -95,7 +94,7 @@ class VrynWingmareCostReductionEffect extends CostModificationEffectImpl {
@Override
public boolean applies(Ability abilityToModify, Ability source, Game game) {
if (abilityToModify instanceof SpellAbility || abilityToModify instanceof FlashbackAbility) {
if (abilityToModify instanceof SpellAbility) {
Card card = game.getCard(abilityToModify.getSourceId());
if (card != null && !card.isCreature()) {
return true;