* Commander abilities - added support of cards with alternative spells like overload;

This commit is contained in:
Oleg Agafonov 2019-07-14 01:06:07 +04:00
parent cb2730e0d5
commit 9db80a0cf3
4 changed files with 65 additions and 9 deletions

View file

@ -2,7 +2,6 @@ package mage.abilities.common;
import mage.abilities.SpellAbility;
import mage.cards.Card;
import mage.constants.SpellAbilityType;
import mage.constants.Zone;
/**
@ -10,12 +9,12 @@ import mage.constants.Zone;
*/
public class CastCommanderAbility extends SpellAbility {
public CastCommanderAbility(Card card) {
super(card.getSpellAbility());
public CastCommanderAbility(Card card, SpellAbility spellTemplate) {
super(spellTemplate);
this.newId();
this.setCardName(card.getName());
this.setCardName(spellTemplate.getCardName());
zone = Zone.COMMAND;
spellAbilityType = SpellAbilityType.BASE;
spellAbilityType = spellTemplate.getSpellAbilityType();
}
public CastCommanderAbility(final CastCommanderAbility ability) {

View file

@ -12,6 +12,7 @@ import mage.abilities.text.TextPart;
import mage.cards.Card;
import mage.cards.FrameStyle;
import mage.constants.CardType;
import mage.constants.SpellAbilityType;
import mage.constants.SubType;
import mage.constants.SuperType;
import mage.game.Game;
@ -19,7 +20,6 @@ import mage.game.events.ZoneChangeEvent;
import mage.util.GameLog;
import mage.util.SubTypeList;
import java.util.EnumSet;
import java.util.List;
import java.util.Set;
import java.util.UUID;
@ -36,7 +36,17 @@ public class Commander implements CommandObject {
// replace spell ability by commander cast spell (to cast from command zone)
if (card.getSpellAbility() != null) {
abilities.add(new CastCommanderAbility(card));
abilities.add(new CastCommanderAbility(card, card.getSpellAbility()));
}
// replace alternative spell abilities by commander cast spell (to cast from command zone)
for (Ability ability : card.getAbilities()) {
if (ability instanceof SpellAbility) {
SpellAbility spellAbility = (SpellAbility) ability;
if (spellAbility.getSpellAbilityType() == SpellAbilityType.BASE_ALTERNATE) {
abilities.add(new CastCommanderAbility(card, spellAbility));
}
}
}
// replace play land with commander play land (to play from command zone)