Set the correct TimingRule for Spells != Instants, some minor changes to can be cast checks.

This commit is contained in:
LevelX2 2014-02-11 15:53:35 +01:00
parent 7f8ced259a
commit aa359cd1b6
5 changed files with 18 additions and 14 deletions

View file

@ -19,6 +19,7 @@ public class AlchemistsRefugeTest extends CardTestPlayerBase {
addCard(Zone.BATTLEFIELD, playerA, "Forest");
addCard(Zone.BATTLEFIELD, playerA, "Island");
addCard(Zone.BATTLEFIELD, playerA, "Plains");
// Elite Vanguard 2/1
addCard(Zone.HAND, playerA, "Elite Vanguard");
activateAbility(2, PhaseStep.PRECOMBAT_MAIN, playerA, "{G}{U}, {T}:");

View file

@ -35,8 +35,8 @@ import mage.abilities.keyword.FlashAbility;
import mage.cards.SplitCard;
import mage.constants.AbilityType;
import mage.constants.AsThoughEffectType;
import mage.constants.CardType;
import mage.constants.SpellAbilityType;
import mage.constants.TimingRule;
import mage.constants.Zone;
import mage.game.Game;
@ -77,12 +77,9 @@ public class SpellAbility extends ActivatedAbilityImpl<SpellAbility> {
public boolean spellCanBeActivatedRegularlyNow(UUID playerId, Game game) {
MageObject object = game.getObject(sourceId);
if ((object.getCardType().contains(CardType.INSTANT) ||
return timing == TimingRule.INSTANT ||
object.getAbilities().containsKey(FlashAbility.getInstance().getId()) ||
game.canPlaySorcery(playerId))) {
return true;
}
return false;
game.canPlaySorcery(playerId);
}
@Override

View file

@ -74,9 +74,7 @@ public class HideawayPlayEffect extends OneShotEffect<HideawayPlayEffect> {
}
}
} else {
if (card.getCardType().contains(CardType.INSTANT)
|| card.getAbilities().containsKey(FlashAbility.getInstance().getId())
|| (game.getActivePlayerId().equals(controller.getId()) && game.isMainPhase())) {
if (card.getSpellAbility().spellCanBeActivatedRegularlyNow(controller.getId(), game)) {
if (controller.chooseUse(Outcome.Benefit, "Cast the card without paying mana cost?", game)) {
controller.cast(card.getSpellAbility(), game, true);
}

View file

@ -51,6 +51,7 @@ import java.lang.reflect.Constructor;
import java.util.*;
import mage.MageObject;
import mage.constants.SpellAbilityType;
import mage.constants.TimingRule;
import static mage.constants.Zone.EXILED;
import mage.game.command.Commander;
@ -90,10 +91,17 @@ public abstract class CardImpl<T extends CardImpl<T>> extends MageObjectImpl<T>
this.cardType.addAll(Arrays.asList(cardTypes));
this.manaCost.load(costs);
if (cardType.contains(CardType.LAND)) {
addAbility(new PlayLandAbility(name));
Ability ability = new PlayLandAbility(name);
ability.setSourceId(this.getId());
abilities.add(ability);
}
else {
addAbility(new SpellAbility(manaCost, name, Zone.HAND, spellAbilityType));
SpellAbility ability = new SpellAbility(manaCost, name, Zone.HAND, spellAbilityType);
if (!cardType.contains(CardType.INSTANT)) {
ability.setTiming(TimingRule.SORCERY);
}
ability.setSourceId(this.getId());
abilities.add(ability);
}
this.usesVariousArt = Character.isDigit(this.getClass().getName().charAt(this.getClass().getName().length()-1));
this.counters = new Counters();

View file

@ -17,8 +17,8 @@
<artifactId>maven-compiler-plugin</artifactId>
<version>2.0.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
<source>1.7</source>
<target>1.7</target>
<encoding>UTF-8</encoding>
</configuration>
</plugin>