From aa359cd1b66190f8d80089524886e08b4f676b61 Mon Sep 17 00:00:00 2001 From: LevelX2 Date: Tue, 11 Feb 2014 15:53:35 +0100 Subject: [PATCH] Set the correct TimingRule for Spells != Instants, some minor changes to can be cast checks. --- .../test/cards/asthough/AlchemistsRefugeTest.java | 1 + Mage/src/mage/abilities/SpellAbility.java | 9 +++------ .../effects/common/HideawayPlayEffect.java | 4 +--- Mage/src/mage/cards/CardImpl.java | 14 +++++++++++--- pom.xml | 4 ++-- 5 files changed, 18 insertions(+), 14 deletions(-) diff --git a/Mage.Tests/src/test/java/org/mage/test/cards/asthough/AlchemistsRefugeTest.java b/Mage.Tests/src/test/java/org/mage/test/cards/asthough/AlchemistsRefugeTest.java index 2d152d0634..9832ac41dc 100644 --- a/Mage.Tests/src/test/java/org/mage/test/cards/asthough/AlchemistsRefugeTest.java +++ b/Mage.Tests/src/test/java/org/mage/test/cards/asthough/AlchemistsRefugeTest.java @@ -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}:"); diff --git a/Mage/src/mage/abilities/SpellAbility.java b/Mage/src/mage/abilities/SpellAbility.java index 0e801b6835..8393f0e25e 100644 --- a/Mage/src/mage/abilities/SpellAbility.java +++ b/Mage/src/mage/abilities/SpellAbility.java @@ -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 { 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 diff --git a/Mage/src/mage/abilities/effects/common/HideawayPlayEffect.java b/Mage/src/mage/abilities/effects/common/HideawayPlayEffect.java index 8b4bfa4179..c40d4c2e7b 100644 --- a/Mage/src/mage/abilities/effects/common/HideawayPlayEffect.java +++ b/Mage/src/mage/abilities/effects/common/HideawayPlayEffect.java @@ -74,9 +74,7 @@ public class HideawayPlayEffect extends OneShotEffect { } } } 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); } diff --git a/Mage/src/mage/cards/CardImpl.java b/Mage/src/mage/cards/CardImpl.java index 7c1bbe6f50..4fb0e7328b 100644 --- a/Mage/src/mage/cards/CardImpl.java +++ b/Mage/src/mage/cards/CardImpl.java @@ -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> extends MageObjectImpl 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)); + else { + 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(); diff --git a/pom.xml b/pom.xml index b7df237c8d..b2a3b868f0 100644 --- a/pom.xml +++ b/pom.xml @@ -17,8 +17,8 @@ maven-compiler-plugin 2.0.2 - 1.6 - 1.6 + 1.7 + 1.7 UTF-8