mirror of
https://github.com/correl/mage.git
synced 2024-11-29 03:00:12 +00:00
* Fixed a bug of check if two objects sharing a colors were also to colorless objects did return a positive result (e.g. caused Dream Halls to cast Artifacts by discarding lands).
This commit is contained in:
parent
82ca0266ba
commit
bf21de745a
7 changed files with 388 additions and 238 deletions
|
@ -58,7 +58,6 @@ public class DreamHalls extends CardImpl {
|
|||
super(ownerId, 28, "Dream Halls", Rarity.RARE, new CardType[]{CardType.ENCHANTMENT}, "{3}{U}{U}");
|
||||
this.expansionSetCode = "STH";
|
||||
|
||||
|
||||
// Rather than pay the mana cost for a spell, its controller may discard a card that shares a color with that spell.
|
||||
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new DreamHallsEffect()));
|
||||
}
|
||||
|
@ -102,7 +101,7 @@ class DreamHallsEffect extends ContinuousEffectImpl {
|
|||
public boolean apply(Layer layer, SubLayer sublayer, Ability source, Game game) {
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
if (controller != null) {
|
||||
for (UUID playerId: controller.getInRange()) {
|
||||
for (UUID playerId : controller.getInRange()) {
|
||||
Player player = game.getPlayer(playerId);
|
||||
if (player != null) {
|
||||
player.getAlternativeSourceCosts().add(alternativeCastingCostAbility);
|
||||
|
|
|
@ -29,6 +29,7 @@ package mage.sets.urzassaga;
|
|||
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import mage.MageObject;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.cards.Card;
|
||||
|
@ -52,7 +53,6 @@ public class Persecute extends CardImpl {
|
|||
super(ownerId, 146, "Persecute", Rarity.RARE, new CardType[]{CardType.SORCERY}, "{2}{B}{B}");
|
||||
this.expansionSetCode = "USG";
|
||||
|
||||
|
||||
// Choose a color. Target player reveals his or her hand and discards all cards of that color.
|
||||
this.getSpellAbility().addEffect(new PersecuteEffect());
|
||||
this.getSpellAbility().addTarget(new TargetPlayer());
|
||||
|
@ -88,7 +88,8 @@ class PersecuteEffect extends OneShotEffect {
|
|||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player controller = game.getPlayer(source.getFirstTarget());
|
||||
if (controller != null) {
|
||||
MageObject sourceObject = game.getObject(source.getSourceId());
|
||||
if (controller != null && sourceObject != null) {
|
||||
ChoiceColor choice = new ChoiceColor();
|
||||
while (!choice.isChosen()) {
|
||||
controller.choose(outcome, choice, game);
|
||||
|
@ -100,7 +101,7 @@ class PersecuteEffect extends OneShotEffect {
|
|||
return false;
|
||||
}
|
||||
Cards hand = controller.getHand();
|
||||
controller.revealCards("Persecute", hand, game);
|
||||
controller.revealCards(sourceObject.getIdName(), hand, game);
|
||||
Set<Card> cards = hand.getCards(game);
|
||||
for (Card card : cards) {
|
||||
if (card != null && card.getColor(game).shares(choice.getColor())) {
|
||||
|
|
|
@ -2,7 +2,6 @@ package org.mage.test.cards.cost.alternate;
|
|||
|
||||
import mage.constants.PhaseStep;
|
||||
import mage.constants.Zone;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.mage.test.serverside.base.CardTestPlayerBase;
|
||||
|
||||
|
@ -10,6 +9,7 @@ public class OmniscienceTest extends CardTestPlayerBase {
|
|||
|
||||
@Test
|
||||
public void testSpellNoCost() {
|
||||
// You may cast nonland cards from your hand without paying their mana costs.
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Omniscience", 1);
|
||||
|
||||
addCard(Zone.HAND, playerA, "Gray Ogre", 1);
|
||||
|
@ -25,6 +25,7 @@ public class OmniscienceTest extends CardTestPlayerBase {
|
|||
|
||||
@Test
|
||||
public void testSpellHasCostIfCastFromGraveyard() {
|
||||
// You may cast nonland cards from your hand without paying their mana costs.
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Omniscience", 1);
|
||||
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Haakon, Stromgald Scourge", 1);
|
||||
|
@ -40,6 +41,4 @@ public class OmniscienceTest extends CardTestPlayerBase {
|
|||
assertPermanentCount(playerA, "Knight of the White Orchid", 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,104 @@
|
|||
/*
|
||||
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are
|
||||
* permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* The views and conclusions contained in the software and documentation are those of the
|
||||
* authors and should not be interpreted as representing official policies, either expressed
|
||||
* or implied, of BetaSteward_at_googlemail.com.
|
||||
*/
|
||||
package org.mage.test.cards.cost.alternate;
|
||||
|
||||
import mage.constants.PhaseStep;
|
||||
import mage.constants.Zone;
|
||||
import org.junit.Test;
|
||||
import org.mage.test.serverside.base.CardTestPlayerBase;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author LevelX2
|
||||
*/
|
||||
public class UseAlternateSourceCostsTets extends CardTestPlayerBase {
|
||||
|
||||
@Test
|
||||
public void DreamHallsCastColoredSpell() {
|
||||
// Rather than pay the mana cost for a spell, its controller may discard a card that shares a color with that spell.
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Dream Halls", 1);
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Mountain", 3); // Add the mountains so the spell is included in teh available spells
|
||||
|
||||
addCard(Zone.HAND, playerA, "Gray Ogre", 1); // Creature 3/1
|
||||
addCard(Zone.HAND, playerA, "Lightning Bolt", 1);
|
||||
|
||||
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Gray Ogre"); // Cast Orgre by discarding the Lightning Bolt
|
||||
|
||||
setStopAt(1, PhaseStep.BEGIN_COMBAT);
|
||||
execute();
|
||||
|
||||
//Gray Ogre is cast with the discard
|
||||
assertPermanentCount(playerA, "Gray Ogre", 1);
|
||||
assertGraveyardCount(playerA, "Lightning Bolt", 1);
|
||||
assertTapped("Mountain", false);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void DreamHallsCantCastColorlessSpell() {
|
||||
// Rather than pay the mana cost for a spell, its controller may discard a card that shares a color with that spell.
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Dream Halls", 1);
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Mountain", 4); // Add the mountains so the spell is included in teh available spells
|
||||
|
||||
addCard(Zone.HAND, playerA, "Juggernaut", 1); // Creature 5/3 - {4}
|
||||
addCard(Zone.HAND, playerA, "Haunted Plate Mail", 1);
|
||||
|
||||
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Juggernaut"); // Cast Juggernaut by discarding Haunted Plate Mail may not work
|
||||
|
||||
setStopAt(1, PhaseStep.BEGIN_COMBAT);
|
||||
execute();
|
||||
|
||||
assertGraveyardCount(playerA, "Haunted Plate Mail", 0);
|
||||
assertTapped("Mountain", true);
|
||||
//Juggernaut is not cast by alternate casting costs
|
||||
assertPermanentCount(playerA, "Juggernaut", 1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void DreamHallsCastWithFutureSight() {
|
||||
// Rather than pay the mana cost for a spell, its controller may discard a card that shares a color with that spell.
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Dream Halls", 1);
|
||||
// Play with the top card of your library revealed.
|
||||
// You may play the top card of your library.
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Future Sight", 1);
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Mountain", 3); // Add the mountains so the spell is included in teh available spells
|
||||
|
||||
addCard(Zone.LIBRARY, playerA, "Gray Ogre", 1); // Creature 3/1
|
||||
addCard(Zone.HAND, playerA, "Lightning Bolt", 1);
|
||||
skipInitShuffling();
|
||||
|
||||
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Gray Ogre"); // Cast Orgre by discarding the Lightning Bolt
|
||||
|
||||
setStopAt(1, PhaseStep.BEGIN_COMBAT);
|
||||
execute();
|
||||
|
||||
assertTapped("Mountain", false);
|
||||
//Gray Ogre is cast with the discard
|
||||
assertPermanentCount(playerA, "Gray Ogre", 1);
|
||||
assertGraveyardCount(playerA, "Lightning Bolt", 1);
|
||||
}
|
||||
}
|
|
@ -48,6 +48,7 @@ public abstract class CardTestPlayerAPIImpl extends MageTestPlayerBase implement
|
|||
protected String deckNameB;
|
||||
|
||||
protected enum ExpectedType {
|
||||
|
||||
TURN_NUMBER,
|
||||
RESULT,
|
||||
LIFE,
|
||||
|
@ -62,7 +63,8 @@ public abstract class CardTestPlayerAPIImpl extends MageTestPlayerBase implement
|
|||
}
|
||||
|
||||
/**
|
||||
* Default game initialization params for red player (that plays with Mountains)
|
||||
* Default game initialization params for red player (that plays with
|
||||
* Mountains)
|
||||
*/
|
||||
@Override
|
||||
public void useRedDefault() {
|
||||
|
@ -88,7 +90,8 @@ public abstract class CardTestPlayerAPIImpl extends MageTestPlayerBase implement
|
|||
}
|
||||
|
||||
/**
|
||||
* Default game initialization params for white player (that plays with Plains)
|
||||
* Default game initialization params for white player (that plays with
|
||||
* Plains)
|
||||
*/
|
||||
public void useWhiteDefault() {
|
||||
// *** ComputerA ***
|
||||
|
@ -120,7 +123,7 @@ public abstract class CardTestPlayerAPIImpl extends MageTestPlayerBase implement
|
|||
stopAtStep = PhaseStep.UNTAP;
|
||||
|
||||
for (Player player : currentGame.getPlayers().values()) {
|
||||
TestPlayer testPlayer = (TestPlayer)player;
|
||||
TestPlayer testPlayer = (TestPlayer) player;
|
||||
getCommands(testPlayer).clear();
|
||||
getLibraryCards(testPlayer).clear();
|
||||
getHandCards(testPlayer).clear();
|
||||
|
@ -156,7 +159,8 @@ public abstract class CardTestPlayerAPIImpl extends MageTestPlayerBase implement
|
|||
/**
|
||||
* Starts testing card by starting current game.
|
||||
*
|
||||
* @throws IllegalStateException In case game wasn't created previously. Use {@link #load} method to initialize the game.
|
||||
* @throws IllegalStateException In case game wasn't created previously. Use
|
||||
* {@link #load} method to initialize the game.
|
||||
*/
|
||||
public void execute() throws IllegalStateException {
|
||||
if (currentGame == null || activePlayer == null) {
|
||||
|
@ -164,7 +168,7 @@ public abstract class CardTestPlayerAPIImpl extends MageTestPlayerBase implement
|
|||
}
|
||||
|
||||
for (Player player : currentGame.getPlayers().values()) {
|
||||
TestPlayer testPlayer = (TestPlayer)player;
|
||||
TestPlayer testPlayer = (TestPlayer) player;
|
||||
currentGame.cheat(player.getId(), getCommands(testPlayer));
|
||||
currentGame.cheat(player.getId(), getLibraryCards(testPlayer), getHandCards(testPlayer),
|
||||
getBattlefieldCards(testPlayer), getGraveCards(testPlayer));
|
||||
|
@ -183,8 +187,6 @@ public abstract class CardTestPlayerAPIImpl extends MageTestPlayerBase implement
|
|||
|
||||
}
|
||||
|
||||
|
||||
|
||||
protected TestPlayer createNewPlayer(String playerName) {
|
||||
return createPlayer(playerName);
|
||||
}
|
||||
|
@ -211,8 +213,9 @@ public abstract class CardTestPlayerAPIImpl extends MageTestPlayerBase implement
|
|||
}
|
||||
|
||||
/**
|
||||
* Removes all cards from player's library from the game.
|
||||
* Usually this should be used once before initialization to form the library in certain order.
|
||||
* Removes all cards from player's library from the game. Usually this
|
||||
* should be used once before initialization to form the library in certain
|
||||
* order.
|
||||
*
|
||||
* @param player {@link Player} to remove all library cards from.
|
||||
*/
|
||||
|
@ -221,8 +224,8 @@ public abstract class CardTestPlayerAPIImpl extends MageTestPlayerBase implement
|
|||
}
|
||||
|
||||
/**
|
||||
* Removes all cards from player's hand from the game.
|
||||
* Usually this should be used once before initialization to set the players hand.
|
||||
* Removes all cards from player's hand from the game. Usually this should
|
||||
* be used once before initialization to set the players hand.
|
||||
*
|
||||
* @param player {@link Player} to remove all cards from hand.
|
||||
*/
|
||||
|
@ -234,7 +237,8 @@ public abstract class CardTestPlayerAPIImpl extends MageTestPlayerBase implement
|
|||
* Add a card to specified zone of specified player.
|
||||
*
|
||||
* @param gameZone {@link mage.constants.Zone} to add cards to.
|
||||
* @param player {@link Player} to add cards for. Use either playerA or playerB.
|
||||
* @param player {@link Player} to add cards for. Use either playerA or
|
||||
* playerB.
|
||||
* @param cardName Card name in string format.
|
||||
*/
|
||||
public void addCard(Zone gameZone, TestPlayer player, String cardName) {
|
||||
|
@ -245,7 +249,8 @@ public abstract class CardTestPlayerAPIImpl extends MageTestPlayerBase implement
|
|||
* Add any amount of cards to specified zone of specified player.
|
||||
*
|
||||
* @param gameZone {@link mage.constants.Zone} to add cards to.
|
||||
* @param player {@link Player} to add cards for. Use either playerA or playerB.
|
||||
* @param player {@link Player} to add cards for. Use either playerA or
|
||||
* playerB.
|
||||
* @param cardName Card name in string format.
|
||||
* @param count Amount of cards to be added.
|
||||
*/
|
||||
|
@ -257,11 +262,13 @@ public abstract class CardTestPlayerAPIImpl extends MageTestPlayerBase implement
|
|||
* Add any amount of cards to specified zone of specified player.
|
||||
*
|
||||
* @param gameZone {@link mage.constants.Zone} to add cards to.
|
||||
* @param player {@link Player} to add cards for. Use either playerA or playerB.
|
||||
* @param player {@link Player} to add cards for. Use either playerA or
|
||||
* playerB.
|
||||
* @param cardName Card name in string format.
|
||||
* @param count Amount of cards to be added.
|
||||
* @param tapped In case gameZone is Battlefield, determines whether permanent should be tapped.
|
||||
* In case gameZone is other than Battlefield, {@link IllegalArgumentException} is thrown
|
||||
* @param tapped In case gameZone is Battlefield, determines whether
|
||||
* permanent should be tapped. In case gameZone is other than Battlefield,
|
||||
* {@link IllegalArgumentException} is thrown
|
||||
*/
|
||||
public void addCard(Zone gameZone, TestPlayer player, String cardName, int count, boolean tapped) {
|
||||
|
||||
|
@ -323,6 +330,7 @@ public abstract class CardTestPlayerAPIImpl extends MageTestPlayerBase implement
|
|||
|
||||
/**
|
||||
* Define turn number to stop the game on.
|
||||
*
|
||||
* @param turn
|
||||
*/
|
||||
@Override
|
||||
|
@ -332,8 +340,9 @@ public abstract class CardTestPlayerAPIImpl extends MageTestPlayerBase implement
|
|||
}
|
||||
|
||||
/**
|
||||
* Define turn number and step to stop the game on.
|
||||
* The game stops after executing the step
|
||||
* Define turn number and step to stop the game on. The game stops after
|
||||
* executing the step
|
||||
*
|
||||
* @param turn
|
||||
* @param step
|
||||
*/
|
||||
|
@ -400,19 +409,20 @@ public abstract class CardTestPlayerAPIImpl extends MageTestPlayerBase implement
|
|||
/**
|
||||
* Assert creature's power and toughness by card name.
|
||||
* <p/>
|
||||
* Throws {@link AssertionError} in the following cases:
|
||||
* 1. no such player
|
||||
* 2. no such creature under player's control
|
||||
* 3. depending on comparison scope:
|
||||
* 3a. any: no creature under player's control with the specified p\t params
|
||||
* 3b. all: there is at least one creature with the cardName with the different p\t params
|
||||
* Throws {@link AssertionError} in the following cases: 1. no such player
|
||||
* 2. no such creature under player's control 3. depending on comparison
|
||||
* scope: 3a. any: no creature under player's control with the specified p\t
|
||||
* params 3b. all: there is at least one creature with the cardName with the
|
||||
* different p\t params
|
||||
*
|
||||
* @param player {@link Player} to get creatures for comparison.
|
||||
* @param cardName Card name to compare with.
|
||||
* @param power Expected power to compare with.
|
||||
* @param toughness Expected toughness to compare with.
|
||||
* @param scope {@link mage.filter.Filter.ComparisonScope} Use ANY, if you want "at least one creature with given name should have specified p\t"
|
||||
* Use ALL, if you want "all creature with gived name should have specified p\t"
|
||||
* @param scope {@link mage.filter.Filter.ComparisonScope} Use ANY, if you
|
||||
* want "at least one creature with given name should have specified p\t"
|
||||
* Use ALL, if you want "all creature with gived name should have specified
|
||||
* p\t"
|
||||
*/
|
||||
@Override
|
||||
public void assertPowerToughness(Player player, String cardName, int power, int toughness, Filter.ComparisonScope scope)
|
||||
|
@ -442,17 +452,18 @@ public abstract class CardTestPlayerAPIImpl extends MageTestPlayerBase implement
|
|||
}
|
||||
}
|
||||
|
||||
Assert.assertTrue("There is no such permanent under player's control, player=" + player.getName() +
|
||||
", cardName=" + cardName, count > 0);
|
||||
Assert.assertTrue("There is no such permanent under player's control, player=" + player.getName()
|
||||
+ ", cardName=" + cardName, count > 0);
|
||||
|
||||
if (scope.equals(Filter.ComparisonScope.Any)) {
|
||||
Assert.assertTrue("There is no such creature under player's control with specified power&toughness, player=" + player.getName() +
|
||||
", cardName=" + cardName + " (found similar: " + found + ", one of them: power=" + foundPower + " toughness=" + foundToughness + ")", fit > 0);
|
||||
Assert.assertTrue("There is no such creature under player's control with specified power&toughness, player=" + player.getName()
|
||||
+ ", cardName=" + cardName + " (found similar: " + found + ", one of them: power=" + foundPower + " toughness=" + foundToughness + ")", fit > 0);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* See {@link #assertPowerToughness(mage.players.Player, String, int, int, mage.filter.Filter.ComparisonScope)}
|
||||
* See
|
||||
* {@link #assertPowerToughness(mage.players.Player, String, int, int, mage.filter.Filter.ComparisonScope)}
|
||||
*
|
||||
* @param player
|
||||
* @param cardName
|
||||
|
@ -478,15 +489,15 @@ public abstract class CardTestPlayerAPIImpl extends MageTestPlayerBase implement
|
|||
}
|
||||
}
|
||||
|
||||
Assert.assertNotNull("There is no such permanent under player's control, player=" + player.getName() +
|
||||
", cardName=" + cardName, found);
|
||||
Assert.assertNotNull("There is no such permanent under player's control, player=" + player.getName()
|
||||
+ ", cardName=" + cardName, found);
|
||||
|
||||
Assert.assertTrue("There is more than one such permanent under player's control, player=" + player.getName() +
|
||||
", cardName=" + cardName, count == 1);
|
||||
Assert.assertTrue("There is more than one such permanent under player's control, player=" + player.getName()
|
||||
+ ", cardName=" + cardName, count == 1);
|
||||
|
||||
for (Ability ability : abilities) {
|
||||
Assert.assertTrue("No such ability=" + ability.toString() + ", player=" + player.getName() +
|
||||
", cardName" + cardName, found.getAbilities().contains(ability));
|
||||
Assert.assertTrue("No such ability=" + ability.toString() + ", player=" + player.getName()
|
||||
+ ", cardName" + cardName, found.getAbilities().contains(ability));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -495,7 +506,8 @@ public abstract class CardTestPlayerAPIImpl extends MageTestPlayerBase implement
|
|||
* @param player
|
||||
* @param cardName
|
||||
* @param ability
|
||||
* @param flag true if creature should contain ability, false if it should NOT contain it instead
|
||||
* @param flag true if creature should contain ability, false if it should
|
||||
* NOT contain it instead
|
||||
* @throws AssertionError
|
||||
*/
|
||||
public void assertAbility(Player player, String cardName, Ability ability, boolean flag) throws AssertionError {
|
||||
|
@ -508,18 +520,18 @@ public abstract class CardTestPlayerAPIImpl extends MageTestPlayerBase implement
|
|||
}
|
||||
}
|
||||
|
||||
Assert.assertNotNull("There is no such permanent under player's control, player=" + player.getName() +
|
||||
", cardName=" + cardName, found);
|
||||
Assert.assertNotNull("There is no such permanent under player's control, player=" + player.getName()
|
||||
+ ", cardName=" + cardName, found);
|
||||
|
||||
Assert.assertTrue("There is more than one such permanent under player's control, player=" + player.getName() +
|
||||
", cardName=" + cardName, count == 1);
|
||||
Assert.assertTrue("There is more than one such permanent under player's control, player=" + player.getName()
|
||||
+ ", cardName=" + cardName, count == 1);
|
||||
|
||||
if (flag) {
|
||||
Assert.assertTrue("No such ability=" + ability.toString() + ", player=" + player.getName() +
|
||||
", cardName" + cardName, found.getAbilities().containsRule(ability));
|
||||
Assert.assertTrue("No such ability=" + ability.toString() + ", player=" + player.getName()
|
||||
+ ", cardName" + cardName, found.getAbilities().containsRule(ability));
|
||||
} else {
|
||||
Assert.assertFalse("Card shouldn't have such ability=" + ability.toString() + ", player=" + player.getName() +
|
||||
", cardName" + cardName, found.getAbilities().containsRule(ability));
|
||||
Assert.assertFalse("Card shouldn't have such ability=" + ability.toString() + ", player=" + player.getName()
|
||||
+ ", cardName" + cardName, found.getAbilities().containsRule(ability));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -595,6 +607,7 @@ public abstract class CardTestPlayerAPIImpl extends MageTestPlayerBase implement
|
|||
Assert.assertNotNull("There is no such permanent on the battlefield, cardName=" + cardName, found);
|
||||
Assert.assertEquals("(Battlefield) Counter counts are not equal (" + cardName + ":" + type + ")", count, found.getCounters().getCount(type));
|
||||
}
|
||||
|
||||
/**
|
||||
* Assert counter count on a card in exile
|
||||
*
|
||||
|
@ -684,7 +697,12 @@ public abstract class CardTestPlayerAPIImpl extends MageTestPlayerBase implement
|
|||
Permanent found = null;
|
||||
for (Permanent permanent : currentGame.getBattlefield().getAllActivePermanents()) {
|
||||
if (permanent.getName().equals(cardName)) {
|
||||
if (found == null) {
|
||||
found = permanent;
|
||||
} else if (tapped != found.isTapped()) { // try to find a not correct permanent
|
||||
found = permanent;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -756,7 +774,7 @@ public abstract class CardTestPlayerAPIImpl extends MageTestPlayerBase implement
|
|||
*/
|
||||
public void assertExileCount(String cardName, int count) throws AssertionError {
|
||||
int actualCount = 0;
|
||||
for (ExileZone exile: currentGame.getExile().getExileZones()) {
|
||||
for (ExileZone exile : currentGame.getExile().getExileZones()) {
|
||||
for (Card card : exile.getCards(currentGame)) {
|
||||
if (card.getName().equals(cardName)) {
|
||||
actualCount++;
|
||||
|
@ -775,7 +793,7 @@ public abstract class CardTestPlayerAPIImpl extends MageTestPlayerBase implement
|
|||
*/
|
||||
public void assertExileCount(Player owner, int count) throws AssertionError {
|
||||
int actualCount = 0;
|
||||
for (ExileZone exile: currentGame.getExile().getExileZones()) {
|
||||
for (ExileZone exile : currentGame.getExile().getExileZones()) {
|
||||
for (Card card : exile.getCards(currentGame)) {
|
||||
if (card.getOwnerId().equals(owner.getId())) {
|
||||
actualCount++;
|
||||
|
@ -805,7 +823,9 @@ public abstract class CardTestPlayerAPIImpl extends MageTestPlayerBase implement
|
|||
}
|
||||
|
||||
/**
|
||||
* Asserts added actions count. Usefull to make sure that all actions were executed.
|
||||
* Asserts added actions count. Usefull to make sure that all actions were
|
||||
* executed.
|
||||
*
|
||||
* @param player
|
||||
* @param count
|
||||
*/
|
||||
|
@ -855,19 +875,22 @@ public abstract class CardTestPlayerAPIImpl extends MageTestPlayerBase implement
|
|||
* @param step
|
||||
* @param player
|
||||
* @param cardName
|
||||
* @param targetName for modes you can add "mode=3" before target name, multiple targets can be seperated by ^
|
||||
* @param targetName for modes you can add "mode=3" before target name,
|
||||
* multiple targets can be seperated by ^
|
||||
*/
|
||||
public void castSpell(int turnNum, PhaseStep step, TestPlayer player, String cardName, String targetName) {
|
||||
player.addAction(turnNum, step, "activate:Cast " + cardName + "$target=" + targetName);
|
||||
}
|
||||
|
||||
public enum StackClause {
|
||||
|
||||
WHILE_ON_STACK,
|
||||
WHILE_NOT_ON_STACK;
|
||||
}
|
||||
|
||||
/**
|
||||
* Spell will only be cast, if a spell / ability with the given name is on the stack
|
||||
* Spell will only be cast, if a spell / ability with the given name is on
|
||||
* the stack
|
||||
*
|
||||
* @param turnNum
|
||||
* @param step
|
||||
|
@ -881,7 +904,8 @@ public abstract class CardTestPlayerAPIImpl extends MageTestPlayerBase implement
|
|||
}
|
||||
|
||||
/**
|
||||
* Spell will only be cast, if a spell / ability with the given name IS or IS NOT on the stack
|
||||
* Spell will only be cast, if a spell / ability with the given name IS or
|
||||
* IS NOT on the stack
|
||||
*
|
||||
* @param turnNum
|
||||
* @param step
|
||||
|
@ -932,13 +956,14 @@ public abstract class CardTestPlayerAPIImpl extends MageTestPlayerBase implement
|
|||
* @param step
|
||||
* @param player
|
||||
* @param ability
|
||||
* @param targetName if not target has to be defined use the constant NO_TARGET
|
||||
* @param targetName if not target has to be defined use the constant
|
||||
* NO_TARGET
|
||||
* @param spellOnStack
|
||||
*/
|
||||
public void activateAbility(int turnNum, PhaseStep step, TestPlayer player, String ability, String targetName, String spellOnStack) {
|
||||
StringBuilder sb = new StringBuilder("activate:").append(ability);
|
||||
if (targetName != null && !targetName.isEmpty()) {
|
||||
sb.append("$target=" ).append(targetName);
|
||||
sb.append("$target=").append(targetName);
|
||||
}
|
||||
if (spellOnStack != null && !spellOnStack.isEmpty()) {
|
||||
sb.append("$spellOnStack=").append(spellOnStack);
|
||||
|
@ -951,11 +976,11 @@ public abstract class CardTestPlayerAPIImpl extends MageTestPlayerBase implement
|
|||
}
|
||||
|
||||
public void attack(int turnNum, TestPlayer player, String attacker) {
|
||||
player.addAction(turnNum, PhaseStep.DECLARE_ATTACKERS, "attack:"+attacker);
|
||||
player.addAction(turnNum, PhaseStep.DECLARE_ATTACKERS, "attack:" + attacker);
|
||||
}
|
||||
|
||||
public void attack(int turnNum, TestPlayer player, String attacker, TestPlayer defendingPlayer) {
|
||||
player.addAction(turnNum, PhaseStep.DECLARE_ATTACKERS, "attack:"+attacker+"$defendingPlayer="+defendingPlayer.getName());
|
||||
player.addAction(turnNum, PhaseStep.DECLARE_ATTACKERS, "attack:" + attacker + "$defendingPlayer=" + defendingPlayer.getName());
|
||||
}
|
||||
|
||||
public void attack(int turnNum, TestPlayer player, String attacker, String planeswalker) {
|
||||
|
@ -963,12 +988,12 @@ public abstract class CardTestPlayerAPIImpl extends MageTestPlayerBase implement
|
|||
}
|
||||
|
||||
public void block(int turnNum, TestPlayer player, String blocker, String attacker) {
|
||||
player.addAction(turnNum, PhaseStep.DECLARE_BLOCKERS, "block:"+blocker+"$"+attacker);
|
||||
player.addAction(turnNum, PhaseStep.DECLARE_BLOCKERS, "block:" + blocker + "$" + attacker);
|
||||
}
|
||||
|
||||
/**
|
||||
* For use choices set "Yes" or "No" the the choice string.
|
||||
* For X values set "X=[xValue]" example: for X=3 set choice string to "X=3".
|
||||
* For use choices set "Yes" or "No" the the choice string. For X values set
|
||||
* "X=[xValue]" example: for X=3 set choice string to "X=3".
|
||||
*
|
||||
* @param player
|
||||
* @param choice
|
||||
|
@ -981,7 +1006,8 @@ public abstract class CardTestPlayerAPIImpl extends MageTestPlayerBase implement
|
|||
* Set the modes for modal spells
|
||||
*
|
||||
* @param player
|
||||
* @param choice starting with "1" for mode 1, "2" for mode 2 and so on (to set multiple modes call the command multiple times)
|
||||
* @param choice starting with "1" for mode 1, "2" for mode 2 and so on (to
|
||||
* set multiple modes call the command multiple times)
|
||||
*/
|
||||
public void setModeChoice(TestPlayer player, String choice) {
|
||||
player.addModeChoice(choice);
|
||||
|
@ -991,12 +1017,12 @@ public abstract class CardTestPlayerAPIImpl extends MageTestPlayerBase implement
|
|||
* Set target permanents
|
||||
*
|
||||
* @param player
|
||||
* @param target you can add multiple targets by seperating them by the "^" character
|
||||
* e.g. "creatureName1^creatureName2"
|
||||
* you can qualify the target additional by setcode
|
||||
* e.g. "creatureName-M15"
|
||||
* you can add [no copy] to the end of the target name to prohibite targets that are copied
|
||||
* you can add [only copy] to the end of the target name to allow only targets that are copies
|
||||
* @param target you can add multiple targets by seperating them by the "^"
|
||||
* character e.g. "creatureName1^creatureName2" you can qualify the target
|
||||
* additional by setcode e.g. "creatureName-M15" you can add [no copy] to
|
||||
* the end of the target name to prohibite targets that are copied you can
|
||||
* add [only copy] to the end of the target name to allow only targets that
|
||||
* are copies
|
||||
*/
|
||||
public void addTarget(TestPlayer player, String target) {
|
||||
player.addTarget(target);
|
||||
|
@ -1009,7 +1035,7 @@ public abstract class CardTestPlayerAPIImpl extends MageTestPlayerBase implement
|
|||
* @param targetPlayer
|
||||
*/
|
||||
public void addTarget(TestPlayer player, TestPlayer targetPlayer) {
|
||||
player.addTarget("targetPlayer="+targetPlayer.getName());
|
||||
player.addTarget("targetPlayer=" + targetPlayer.getName());
|
||||
}
|
||||
|
||||
public void setDecknamePlayerA(String deckname) {
|
||||
|
|
|
@ -1,31 +1,30 @@
|
|||
/*
|
||||
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are
|
||||
* permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* The views and conclusions contained in the software and documentation are those of the
|
||||
* authors and should not be interpreted as representing official policies, either expressed
|
||||
* or implied, of BetaSteward_at_googlemail.com.
|
||||
*/
|
||||
|
||||
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are
|
||||
* permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* The views and conclusions contained in the software and documentation are those of the
|
||||
* authors and should not be interpreted as representing official policies, either expressed
|
||||
* or implied, of BetaSteward_at_googlemail.com.
|
||||
*/
|
||||
package mage;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
@ -50,7 +49,8 @@ public class ObjectColor implements Serializable, Copyable<ObjectColor>, Compara
|
|||
private boolean red;
|
||||
private boolean green;
|
||||
|
||||
public ObjectColor() {}
|
||||
public ObjectColor() {
|
||||
}
|
||||
|
||||
public ObjectColor(String color) {
|
||||
for (int i = 0; i < color.length(); i++) {
|
||||
|
@ -157,30 +157,39 @@ public class ObjectColor implements Serializable, Copyable<ObjectColor>, Compara
|
|||
public boolean isWhite() {
|
||||
return white;
|
||||
}
|
||||
|
||||
public void setWhite(boolean white) {
|
||||
this.white = white;
|
||||
}
|
||||
|
||||
public boolean isBlue() {
|
||||
return blue;
|
||||
}
|
||||
|
||||
public void setBlue(boolean blue) {
|
||||
this.blue = blue;
|
||||
}
|
||||
|
||||
public boolean isBlack() {
|
||||
return black;
|
||||
}
|
||||
|
||||
public void setBlack(boolean black) {
|
||||
this.black = black;
|
||||
}
|
||||
|
||||
public boolean isRed() {
|
||||
return red;
|
||||
}
|
||||
|
||||
public void setRed(boolean red) {
|
||||
this.red = red;
|
||||
}
|
||||
|
||||
public boolean isGreen() {
|
||||
return green;
|
||||
}
|
||||
|
||||
public void setGreen(boolean green) {
|
||||
this.green = green;
|
||||
}
|
||||
|
@ -287,14 +296,10 @@ public class ObjectColor implements Serializable, Copyable<ObjectColor>, Compara
|
|||
}
|
||||
|
||||
public boolean shares(ObjectColor color) {
|
||||
if (this == color) {
|
||||
return true;
|
||||
}
|
||||
if (!hasColor() && !color.hasColor()) {
|
||||
return true;
|
||||
}
|
||||
return color.white && white || color.blue && blue || color.black && black ||
|
||||
color.red && red || color.green && green;
|
||||
// 105.4. [...] “Multicolored” is not a color. Neither is “colorless.”
|
||||
return !color.isColorless()
|
||||
&& (color.white && white || color.blue && blue || color.black && black
|
||||
|| color.red && red || color.green && green);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -309,32 +314,32 @@ public class ObjectColor implements Serializable, Copyable<ObjectColor>, Compara
|
|||
|
||||
if (this.isMulticolored()) {
|
||||
o1 = 6;
|
||||
} else if(this.isColorless()) {
|
||||
} else if (this.isColorless()) {
|
||||
o1 = 0;
|
||||
} else if(this.isBlack()) {
|
||||
} else if (this.isBlack()) {
|
||||
o1 = 1;
|
||||
} else if(this.isBlue()) {
|
||||
} else if (this.isBlue()) {
|
||||
o1 = 2;
|
||||
} else if(this.isGreen()) {
|
||||
} else if (this.isGreen()) {
|
||||
o1 = 3;
|
||||
} else if(this.isRed()) {
|
||||
} else if (this.isRed()) {
|
||||
o1 = 4;
|
||||
} else if(this.isWhite()) {
|
||||
} else if (this.isWhite()) {
|
||||
o1 = 5;
|
||||
}
|
||||
if (o.isMulticolored()) {
|
||||
o2 = 6;
|
||||
} else if(o.isColorless()) {
|
||||
} else if (o.isColorless()) {
|
||||
o2 = 0;
|
||||
} else if(o.isBlack()) {
|
||||
} else if (o.isBlack()) {
|
||||
o2 = 1;
|
||||
} else if(o.isBlue()) {
|
||||
} else if (o.isBlue()) {
|
||||
o2 = 2;
|
||||
} else if(o.isGreen()) {
|
||||
} else if (o.isGreen()) {
|
||||
o2 = 3;
|
||||
} else if(o.isRed()) {
|
||||
} else if (o.isRed()) {
|
||||
o2 = 4;
|
||||
} else if(o.isWhite()) {
|
||||
} else if (o.isWhite()) {
|
||||
o2 = 5;
|
||||
}
|
||||
return o1 - o2;
|
||||
|
|
|
@ -2459,6 +2459,22 @@ public abstract class PlayerImpl implements Player, Serializable {
|
|||
}
|
||||
}
|
||||
}
|
||||
// check if it's possible to play the top card of a library
|
||||
for (UUID playerInRangeId : game.getState().getPlayersInRange(getId(), game)) {
|
||||
Player player = game.getPlayer(playerInRangeId);
|
||||
if (player != null) {
|
||||
if (player.isTopCardRevealed() && player.getLibrary().size() > 0) {
|
||||
Card card = player.getLibrary().getFromTop(game);
|
||||
if (game.getContinuousEffects().asThough(card.getId(), AsThoughEffectType.PLAY_FROM_NOT_OWN_HAND_ZONE, getId(), game)) {
|
||||
for (ActivatedAbility ability : card.getAbilities().getActivatedAbilities(Zone.HAND)) {
|
||||
if (ability instanceof SpellAbility || ability instanceof PlayLandAbility) {
|
||||
playable.add(ability);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// eliminate duplicate activated abilities
|
||||
Map<String, Ability> playableActivated = new HashMap<>();
|
||||
for (Permanent permanent : game.getBattlefield().getAllActivePermanents(playerId)) {
|
||||
|
|
Loading…
Reference in a new issue