mirror of
https://github.com/magefree/mage.git
synced 2025-12-25 13:02:06 -08:00
* Fixed spell cost reduction for bestow not working during calculation of castable spells (#6698).
This commit is contained in:
parent
a90dbd8533
commit
98ebcc07ca
19 changed files with 132 additions and 94 deletions
|
|
@ -18,7 +18,7 @@ import mage.util.CardUtil;
|
|||
*/
|
||||
public class AbilitiesCostReductionControllerEffect extends CostModificationEffectImpl {
|
||||
|
||||
private Class activatedAbility;
|
||||
private final Class activatedAbility;
|
||||
|
||||
public AbilitiesCostReductionControllerEffect(Class activatedAbility, String activatedAbilityName) {
|
||||
super(Duration.WhileOnBattlefield, Outcome.Benefit, CostModificationType.REDUCE_COST);
|
||||
|
|
|
|||
|
|
@ -10,8 +10,6 @@ import mage.game.Game;
|
|||
import mage.players.Player;
|
||||
import mage.util.CardUtil;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public class CostModificationSourceEffect extends CostModificationEffectImpl {
|
||||
|
||||
private final Class<? extends Ability> abilityType;
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ import mage.util.CardUtil;
|
|||
public class SpellCostReductionForEachSourceEffect extends CostModificationEffectImpl {
|
||||
|
||||
private final DynamicValue eachAmount;
|
||||
private ManaCosts<ManaCost> reduceManaCosts;
|
||||
private final ManaCosts<ManaCost> reduceManaCosts;
|
||||
private final int reduceGenericMana;
|
||||
|
||||
public SpellCostReductionForEachSourceEffect(int reduceGenericMana, DynamicValue eachAmount) {
|
||||
|
|
@ -50,7 +50,6 @@ public class SpellCostReductionForEachSourceEffect extends CostModificationEffec
|
|||
this.staticText = sb.toString();
|
||||
}
|
||||
|
||||
|
||||
protected SpellCostReductionForEachSourceEffect(final SpellCostReductionForEachSourceEffect effect) {
|
||||
super(effect);
|
||||
this.eachAmount = effect.eachAmount;
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ public class SpellsCostIncreasingAllEffect extends CostModificationEffectImpl {
|
|||
private final FilterCard filter;
|
||||
private final TargetController targetController;
|
||||
private final int increaseGenericCost;
|
||||
private ManaCosts<ManaCost> increaseManaCosts;
|
||||
private final ManaCosts<ManaCost> increaseManaCosts;
|
||||
|
||||
public SpellsCostIncreasingAllEffect(int increaseGenericCost, FilterCard filter, TargetController targetController) {
|
||||
super(Duration.WhileOnBattlefield, Outcome.Detriment, CostModificationType.INCREASE_COST);
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
package mage.abilities.effects.common.cost;
|
||||
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.SpellAbility;
|
||||
import mage.constants.CostModificationType;
|
||||
|
|
@ -12,9 +14,6 @@ import mage.game.stack.Spell;
|
|||
import mage.players.Player;
|
||||
import mage.util.CardUtil;
|
||||
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* @author JayDi85
|
||||
*/
|
||||
|
|
@ -23,7 +22,7 @@ public class SpellsCostModificationThatTargetSourceEffect extends CostModificati
|
|||
private final FilterCard spellFilter;
|
||||
private final int modificationAmount;
|
||||
private String targetName = "{this}";
|
||||
private TargetController targetController;
|
||||
private final TargetController targetController;
|
||||
|
||||
public SpellsCostModificationThatTargetSourceEffect(int modificationAmount, FilterCard spellFilter, TargetController targetController) {
|
||||
super(Duration.WhileOnBattlefield, Outcome.Neutral, modificationAmount < 0 ? CostModificationType.REDUCE_COST : CostModificationType.INCREASE_COST);
|
||||
|
|
|
|||
|
|
@ -1,5 +1,8 @@
|
|||
package mage.abilities.effects.common.cost;
|
||||
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import mage.Mana;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.SpellAbility;
|
||||
|
|
@ -8,16 +11,12 @@ import mage.choices.ChoiceImpl;
|
|||
import mage.constants.CostModificationType;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.SpellAbilityCastMode;
|
||||
import mage.filter.FilterCard;
|
||||
import mage.game.Game;
|
||||
import mage.game.stack.Spell;
|
||||
import mage.players.Player;
|
||||
import mage.util.CardUtil;
|
||||
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* @author LevelX2
|
||||
*/
|
||||
|
|
@ -123,15 +122,12 @@ public class SpellsCostReductionAllEffect extends CostModificationEffectImpl {
|
|||
return false;
|
||||
}
|
||||
if (abilityToModify instanceof SpellAbility) {
|
||||
Spell spell = (Spell) game.getStack().getStackObject(abilityToModify.getId());
|
||||
if (spell != null) {
|
||||
// real cast with put on stack
|
||||
return this.filter.match(spell, game) && selectedByRuntimeData(spell, source, game);
|
||||
} else {
|
||||
// get playable and other staff without put on stack
|
||||
// used at least for flashback ability because Flashback ability doesn't use stack
|
||||
Card sourceCard = game.getCard(abilityToModify.getSourceId());
|
||||
return sourceCard != null && this.filter.match(sourceCard, game) && selectedByRuntimeData(sourceCard, source, game);
|
||||
Card spellCard = ((SpellAbility) abilityToModify).getCharacteristics(game);
|
||||
if (spellCard != null) {
|
||||
if (((SpellAbility) abilityToModify).getSpellAbilityCastMode() != SpellAbilityCastMode.NORMAL) {
|
||||
spellCard = ((SpellAbility) abilityToModify).getSpellAbilityCastMode().getTypeModifiedCardObjectCopy(spellCard, game);
|
||||
}
|
||||
return this.filter.match(spellCard, game) && selectedByRuntimeData(spellCard, source, game);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
package mage.abilities.effects.common.cost;
|
||||
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.Set;
|
||||
import mage.MageObject;
|
||||
import mage.Mana;
|
||||
import mage.abilities.Ability;
|
||||
|
|
@ -11,15 +13,12 @@ import mage.choices.ChoiceImpl;
|
|||
import mage.constants.CostModificationType;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.SpellAbilityCastMode;
|
||||
import mage.filter.FilterCard;
|
||||
import mage.game.Game;
|
||||
import mage.game.stack.Spell;
|
||||
import mage.players.Player;
|
||||
import mage.util.CardUtil;
|
||||
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author North
|
||||
*/
|
||||
|
|
@ -114,15 +113,12 @@ public class SpellsCostReductionControllerEffect extends CostModificationEffectI
|
|||
public boolean applies(Ability abilityToModify, Ability source, Game game) {
|
||||
if (abilityToModify instanceof SpellAbility) {
|
||||
if (abilityToModify.isControlledBy(source.getControllerId())) {
|
||||
Spell spell = (Spell) game.getStack().getStackObject(abilityToModify.getId());
|
||||
if (spell != null) {
|
||||
// real cast with put on stack
|
||||
return this.filter.match(spell, source.getSourceId(), source.getControllerId(), game);
|
||||
} else {
|
||||
// get playable and other staff without put on stack
|
||||
// used at least for flashback ability because Flashback ability doesn't use stack
|
||||
Card sourceCard = game.getCard(abilityToModify.getSourceId());
|
||||
return sourceCard != null && this.filter.match(sourceCard, source.getSourceId(), source.getControllerId(), game);
|
||||
Card spellCard = ((SpellAbility) abilityToModify).getCharacteristics(game);;
|
||||
if (spellCard != null) {
|
||||
if (((SpellAbility) abilityToModify).getSpellAbilityCastMode() != SpellAbilityCastMode.NORMAL) {
|
||||
spellCard = ((SpellAbility) abilityToModify).getSpellAbilityCastMode().getTypeModifiedCardObjectCopy(spellCard, game);
|
||||
}
|
||||
return this.filter.match(spellCard, source.getSourceId(), source.getControllerId(), game);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
package mage.abilities.keyword;
|
||||
|
||||
import mage.MageObject;
|
||||
|
|
@ -138,6 +137,14 @@ public class BestowAbility extends SpellAbility {
|
|||
|
||||
}
|
||||
}
|
||||
|
||||
static public void becomeAura(Card card) {
|
||||
if (card != null) {
|
||||
card.getSubtype(null).add(SubType.AURA);
|
||||
card.getCardType().remove(CardType.CREATURE);
|
||||
card.getCardType().add(CardType.ENCHANTMENT);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class BestowEntersBattlefieldEffect extends ReplacementEffectImpl {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,9 @@
|
|||
|
||||
package mage.constants;
|
||||
|
||||
import mage.abilities.keyword.BestowAbility;
|
||||
import mage.cards.Card;
|
||||
import mage.game.Game;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author LevelX2
|
||||
|
|
@ -21,4 +24,12 @@ public enum SpellAbilityCastMode {
|
|||
public String toString() {
|
||||
return text;
|
||||
}
|
||||
|
||||
public Card getTypeModifiedCardObjectCopy(Card card, Game game) {
|
||||
Card cardCopy = card.copy();
|
||||
if (this.equals(BESTOW)) {
|
||||
BestowAbility.becomeAura(cardCopy);
|
||||
}
|
||||
return cardCopy;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
package mage.game.command.planes;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import mage.MageObject;
|
||||
import mage.ObjectColor;
|
||||
import mage.abilities.Ability;
|
||||
|
|
@ -29,9 +31,6 @@ import mage.target.common.TargetCreaturePermanent;
|
|||
import mage.util.CardUtil;
|
||||
import mage.watchers.common.PlanarRollWatcher;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author spjspj
|
||||
*/
|
||||
|
|
@ -52,9 +51,9 @@ public class FeedingGroundsPlane extends Plane {
|
|||
Effect chaosEffect = new AddCountersTargetEffect(CounterType.P1P1.createInstance(), TargetConvertedManaCost.instance);
|
||||
Target chaosTarget = new TargetCreaturePermanent(1, 1, filter, false);
|
||||
|
||||
List<Effect> chaosEffects = new ArrayList<Effect>();
|
||||
List<Effect> chaosEffects = new ArrayList<>();
|
||||
chaosEffects.add(chaosEffect);
|
||||
List<Target> chaosTargets = new ArrayList<Target>();
|
||||
List<Target> chaosTargets = new ArrayList<>();
|
||||
chaosTargets.add(chaosTarget);
|
||||
|
||||
ActivateIfConditionActivatedAbility chaosAbility = new ActivateIfConditionActivatedAbility(Zone.COMMAND, new RollPlanarDieEffect(chaosEffects, chaosTargets), new GenericManaCost(0), MainPhaseStackEmptyCondition.instance);
|
||||
|
|
|
|||
|
|
@ -17,7 +17,6 @@ import mage.filter.FilterCard;
|
|||
import mage.filter.common.FilterCreatureCard;
|
||||
import mage.game.Game;
|
||||
import mage.game.command.Plane;
|
||||
import mage.game.stack.Spell;
|
||||
import mage.target.Target;
|
||||
import mage.util.CardUtil;
|
||||
import mage.watchers.common.PlanarRollWatcher;
|
||||
|
|
@ -42,9 +41,9 @@ public class TurriIslandPlane extends Plane {
|
|||
Effect chaosEffect = new RevealLibraryPutIntoHandEffect(3, new FilterCreatureCard("creature cards"), Zone.GRAVEYARD);
|
||||
Target chaosTarget = null;
|
||||
|
||||
List<Effect> chaosEffects = new ArrayList<Effect>();
|
||||
List<Effect> chaosEffects = new ArrayList<>();
|
||||
chaosEffects.add(chaosEffect);
|
||||
List<Target> chaosTargets = new ArrayList<Target>();
|
||||
List<Target> chaosTargets = new ArrayList<>();
|
||||
chaosTargets.add(chaosTarget);
|
||||
|
||||
ActivateIfConditionActivatedAbility chaosAbility = new ActivateIfConditionActivatedAbility(Zone.COMMAND, new RollPlanarDieEffect(chaosEffects, chaosTargets), new GenericManaCost(0), MainPhaseStackEmptyCondition.instance);
|
||||
|
|
@ -110,14 +109,12 @@ class TurriIslandEffect extends CostModificationEffectImpl {
|
|||
if (!cPlane.getPlaneType().equals(Planes.PLANE_TURRI_ISLAND)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Spell spell = (Spell) game.getStack().getStackObject(abilityToModify.getId());
|
||||
if (spell != null) {
|
||||
return filter.match(spell, game) && selectedByRuntimeData(spell, source, game);
|
||||
} else {
|
||||
// used at least for flashback ability because Flashback ability doesn't use stack
|
||||
Card sourceCard = game.getCard(abilityToModify.getSourceId());
|
||||
return sourceCard != null && filter.match(sourceCard, game) && selectedByRuntimeData(sourceCard, source, game);
|
||||
Card spellCard = ((SpellAbility) abilityToModify).getCharacteristics(game);
|
||||
if (spellCard != null) {
|
||||
if (((SpellAbility) abilityToModify).getSpellAbilityCastMode() != SpellAbilityCastMode.NORMAL) {
|
||||
spellCard = ((SpellAbility) abilityToModify).getSpellAbilityCastMode().getTypeModifiedCardObjectCopy(spellCard, game);
|
||||
}
|
||||
return filter.match(spellCard, game) && selectedByRuntimeData(spellCard, source, game);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue