* Commander: added support of lands as commander (#5795);

This commit is contained in:
Oleg Agafonov 2019-05-23 12:40:45 +04:00
parent b3e7c4f136
commit 42ed14df52
18 changed files with 441 additions and 201 deletions

View file

@ -1,15 +1,13 @@
package mage.abilities.common;
import mage.abilities.SpellAbility;
import mage.abilities.costs.CostsImpl;
import mage.abilities.costs.common.CommanderAdditionalCost;
import mage.cards.Card;
import mage.constants.SpellAbilityType;
import mage.constants.TimingRule;
import mage.constants.Zone;
import mage.game.Game;
/**
* @author Plopman
* @author Plopman, JayDi85
*/
public class CastCommanderAbility extends SpellAbility {
@ -20,9 +18,11 @@ public class CastCommanderAbility extends SpellAbility {
this.getEffects().addAll(card.getSpellAbility().getEffects().copy());
this.getTargets().addAll(card.getSpellAbility().getTargets().copy());
this.timing = card.getSpellAbility().getTiming();
// extra cost
this.addCost(new CommanderAdditionalCost());
} else {
this.costs = new CostsImpl<>();
this.timing = TimingRule.SORCERY;
throw new IllegalStateException("Cast commander ability must be used with spell ability only: " + card.getName());
}
this.usesStack = true;
this.controllerId = card.getOwnerId();
@ -33,22 +33,6 @@ public class CastCommanderAbility extends SpellAbility {
super(ability);
}
@Override
public boolean activate(Game game, boolean noMana) {
if (super.activate(game, noMana)) {
// save amount of times commander was cast
Integer castCount = (Integer) game.getState().getValue(sourceId + "_castCount");
if (castCount == null) {
castCount = 1;
} else {
castCount++;
}
game.getState().setValue(sourceId + "_castCount", castCount);
return true;
}
return false;
}
@Override
public CastCommanderAbility copy() {
return new CastCommanderAbility(this);