* Overload - Fixed that Overload ability can't be used to cast a spell without mana to pay.

This commit is contained in:
LevelX2 2014-10-24 22:42:53 +02:00
parent 209f3bc8c8
commit ea7921c3de
4 changed files with 14 additions and 5 deletions

View file

@ -37,6 +37,7 @@ import mage.game.Game;
import mage.game.events.GameEvent;
import java.util.UUID;
import mage.players.Player;
/**
*
@ -44,7 +45,7 @@ import java.util.UUID;
*/
public class SpellAbility extends ActivatedAbilityImpl {
private SpellAbilityType spellAbilityType;
protected SpellAbilityType spellAbilityType;
public SpellAbility(ManaCost cost, String cardName) {
this(cost, cardName, Zone.HAND);
@ -102,7 +103,13 @@ public class SpellAbility extends ActivatedAbilityImpl {
return false;
}
}
// Alternate spell abilities (Flashback, Overload) can't be cast with no mana to pay option
if (getSpellAbilityType().equals(SpellAbilityType.BASE_ALTERNATE)) {
Player player = game.getPlayer(playerId);
if (player != null && getSourceId().equals(player.getCastSourceIdWithoutMana())) {
return false;
}
}
if (costs.canPay(this, sourceId, controllerId, game)) {
if (getSpellAbilityType().equals(SpellAbilityType.SPLIT_FUSED)) {
SplitCard splitCard = (SplitCard) game.getCard(getSourceId());

View file

@ -63,7 +63,6 @@ import mage.players.Player;
*/
public class FlashbackAbility extends SpellAbility {
private SpellAbilityType spellAbilityType;
private String abilityName;
public FlashbackAbility(Cost cost, TimingRule timingRule) {
@ -74,7 +73,7 @@ public class FlashbackAbility extends SpellAbility {
this.addCost(cost);
this.timing = timingRule;
this.usesStack = false;
this.spellAbilityType = SpellAbilityType.BASE;
this.spellAbilityType = SpellAbilityType.BASE_ALTERNATE;
this.addEffect(new CreateDelayedTriggeredAbilityEffect(new FlashbackTriggeredAbility()));
}

View file

@ -32,6 +32,7 @@ import mage.abilities.SpellAbility;
import mage.abilities.costs.mana.ManaCosts;
import mage.abilities.effects.Effect;
import mage.cards.Card;
import mage.constants.SpellAbilityType;
import mage.constants.TimingRule;
@ -61,6 +62,7 @@ public class OverloadAbility extends SpellAbility {
public OverloadAbility(Card card,Effect effect, ManaCosts costs) {
this(card, effect, costs, TimingRule.INSTANT);
this.spellAbilityType = SpellAbilityType.BASE_ALTERNATE;
}
public OverloadAbility(Card card,Effect effect, ManaCosts costs, TimingRule timingRule) {

View file

@ -6,6 +6,7 @@ package mage.constants;
*/
public enum SpellAbilityType {
BASE("Basic SpellAbility"),
BASE_ALTERNATE("Basic SpellAbility Alternate"), // used for Overload, Flashback to know they must be handled as Alternate casting costs
SPLIT("Split SpellAbility"),
SPLIT_FUSED("Split SpellAbility"),
SPLIT_LEFT("LeftSplit SpellAbility"),
@ -13,7 +14,7 @@ public enum SpellAbilityType {
MODE("Mode SpellAbility"),
SPLICE("Spliced SpellAbility");
private String text;
private final String text;
SpellAbilityType(String text) {
this.text = text;