mirror of
https://github.com/magefree/mage.git
synced 2025-12-29 23:12:10 -08:00
Fix casting commander transformed (#10790)
Remove CastCommanderAbility and instead apply the modification directly
This commit is contained in:
parent
921b640c33
commit
a756529e05
4 changed files with 12 additions and 42 deletions
|
|
@ -1453,4 +1453,11 @@ public abstract class AbilityImpl implements Ability {
|
|||
.filter(Objects::nonNull)
|
||||
.anyMatch(Condition::caresAboutManaColor);
|
||||
}
|
||||
|
||||
public AbilityImpl copyWithZone(Zone zone) {
|
||||
AbilityImpl copy = ((AbilityImpl)this.copy());
|
||||
copy.zone = zone;
|
||||
copy.newId();
|
||||
return copy;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,38 +0,0 @@
|
|||
package mage.abilities.common;
|
||||
|
||||
import mage.abilities.SpellAbility;
|
||||
import mage.cards.Card;
|
||||
import mage.constants.Zone;
|
||||
|
||||
/**
|
||||
* @author Plopman, JayDi85
|
||||
*/
|
||||
public class CastCommanderAbility extends SpellAbility {
|
||||
|
||||
private final String ruleText;
|
||||
|
||||
public CastCommanderAbility(Card card, SpellAbility spellTemplate) {
|
||||
super(spellTemplate);
|
||||
this.newId();
|
||||
this.setCardName(spellTemplate.getCardName());
|
||||
this.zone = Zone.COMMAND;
|
||||
this.spellAbilityType = spellTemplate.getSpellAbilityType();
|
||||
this.ruleText = spellTemplate.getRule(); // need to support custom rule texts like OverloadAbility
|
||||
}
|
||||
|
||||
protected CastCommanderAbility(final CastCommanderAbility ability) {
|
||||
super(ability);
|
||||
this.ruleText = ability.ruleText;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CastCommanderAbility copy() {
|
||||
return new CastCommanderAbility(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRule() {
|
||||
return ruleText;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,12 +1,13 @@
|
|||
package mage.abilities.effects.common.cost;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.CastCommanderAbility;
|
||||
import mage.abilities.SpellAbility;
|
||||
import mage.abilities.common.PlayLandAsCommanderAbility;
|
||||
import mage.cards.Card;
|
||||
import mage.constants.CostModificationType;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.Zone;
|
||||
import mage.game.Game;
|
||||
|
||||
/**
|
||||
|
|
@ -47,7 +48,7 @@ public class CommanderCostModification extends CostModificationEffectImpl {
|
|||
}
|
||||
|
||||
return commander.getId().equals(cardToCheck.getMainCard().getId())
|
||||
&& (abilityToModify instanceof CastCommanderAbility
|
||||
&& ((abilityToModify instanceof SpellAbility && abilityToModify.getZone() == Zone.COMMAND)
|
||||
|| abilityToModify instanceof PlayLandAsCommanderAbility);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@ import mage.MageInt;
|
|||
import mage.MageObject;
|
||||
import mage.ObjectColor;
|
||||
import mage.abilities.*;
|
||||
import mage.abilities.common.CastCommanderAbility;
|
||||
import mage.abilities.common.PlayLandAsCommanderAbility;
|
||||
import mage.abilities.costs.mana.ManaCost;
|
||||
import mage.abilities.costs.mana.ManaCosts;
|
||||
|
|
@ -13,6 +12,7 @@ import mage.cards.FrameStyle;
|
|||
import mage.constants.CardType;
|
||||
import mage.constants.SubType;
|
||||
import mage.constants.SuperType;
|
||||
import mage.constants.Zone;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.ZoneChangeEvent;
|
||||
import mage.util.SubTypes;
|
||||
|
|
@ -55,7 +55,7 @@ public class Commander extends CommandObjectImpl {
|
|||
case ADVENTURE_SPELL:
|
||||
// can be used from command zone
|
||||
if (canUseAbilityFromCommandZone(spellAbility)) {
|
||||
abilities.add(new CastCommanderAbility(card, spellAbility));
|
||||
abilities.add(spellAbility.copyWithZone(Zone.COMMAND));
|
||||
}
|
||||
break;
|
||||
case FACE_DOWN_CREATURE: // dynamic added spell for alternative cost like cast as face down
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue