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, "Forest");
addCard(Zone.BATTLEFIELD, playerA, "Island"); addCard(Zone.BATTLEFIELD, playerA, "Island");
addCard(Zone.BATTLEFIELD, playerA, "Plains"); addCard(Zone.BATTLEFIELD, playerA, "Plains");
// Elite Vanguard 2/1
addCard(Zone.HAND, playerA, "Elite Vanguard"); addCard(Zone.HAND, playerA, "Elite Vanguard");
activateAbility(2, PhaseStep.PRECOMBAT_MAIN, playerA, "{G}{U}, {T}:"); 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.cards.SplitCard;
import mage.constants.AbilityType; import mage.constants.AbilityType;
import mage.constants.AsThoughEffectType; import mage.constants.AsThoughEffectType;
import mage.constants.CardType;
import mage.constants.SpellAbilityType; import mage.constants.SpellAbilityType;
import mage.constants.TimingRule;
import mage.constants.Zone; import mage.constants.Zone;
import mage.game.Game; import mage.game.Game;
@ -77,12 +77,9 @@ public class SpellAbility extends ActivatedAbilityImpl<SpellAbility> {
public boolean spellCanBeActivatedRegularlyNow(UUID playerId, Game game) { public boolean spellCanBeActivatedRegularlyNow(UUID playerId, Game game) {
MageObject object = game.getObject(sourceId); MageObject object = game.getObject(sourceId);
if ((object.getCardType().contains(CardType.INSTANT) || return timing == TimingRule.INSTANT ||
object.getAbilities().containsKey(FlashAbility.getInstance().getId()) || object.getAbilities().containsKey(FlashAbility.getInstance().getId()) ||
game.canPlaySorcery(playerId))) { game.canPlaySorcery(playerId);
return true;
}
return false;
} }
@Override @Override

View file

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

View file

@ -51,6 +51,7 @@ import java.lang.reflect.Constructor;
import java.util.*; import java.util.*;
import mage.MageObject; import mage.MageObject;
import mage.constants.SpellAbilityType; import mage.constants.SpellAbilityType;
import mage.constants.TimingRule;
import static mage.constants.Zone.EXILED; import static mage.constants.Zone.EXILED;
import mage.game.command.Commander; 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.cardType.addAll(Arrays.asList(cardTypes));
this.manaCost.load(costs); this.manaCost.load(costs);
if (cardType.contains(CardType.LAND)) { if (cardType.contains(CardType.LAND)) {
addAbility(new PlayLandAbility(name)); Ability ability = new PlayLandAbility(name);
ability.setSourceId(this.getId());
abilities.add(ability);
} }
else { 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.usesVariousArt = Character.isDigit(this.getClass().getName().charAt(this.getClass().getName().length()-1));
this.counters = new Counters(); this.counters = new Counters();

View file

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