Merge remote-tracking branch 'origin/master'

This commit is contained in:
Loki 2012-08-04 09:17:15 +12:00
commit ec6cd7ef42
19 changed files with 579 additions and 14 deletions

View file

@ -48,7 +48,6 @@ import mage.client.dialog.*;
import mage.client.game.FeedbackPanel.FeedbackMode;
import mage.client.plugins.adapters.MageActionCallback;
import mage.client.plugins.impl.Plugins;
import mage.client.util.AudioManager;
import mage.client.util.Config;
import mage.client.util.GameManager;
import mage.client.util.PhaseManager;
@ -408,7 +407,7 @@ public class GamePanel extends javax.swing.JPanel {
this.txtPhase.setText("");
}
if (game.getPhase() != null && game.getPhase().toString().equals("End") && game.getStep().toString().equals("End Turn")) {
AudioManager.playEndTurn();
//AudioManager.playEndTurn();
}
if (game.getStep() != null)
@ -598,11 +597,13 @@ public class GamePanel extends javax.swing.JPanel {
public void playMana(String message, GameView gameView) {
updateGame(gameView);
DialogManager.getManager().fadeOut();
this.feedbackPanel.getFeedback(FeedbackMode.CANCEL, message, gameView.getSpecial(), null);
}
public void playXMana(String message, GameView gameView) {
updateGame(gameView);
DialogManager.getManager().fadeOut();
this.feedbackPanel.getFeedback(FeedbackMode.CONFIRM, message, gameView.getSpecial(), null);
}
@ -611,6 +612,7 @@ public class GamePanel extends javax.swing.JPanel {
}
public void pickAbility(AbilityPickerView choices) {
DialogManager.getManager().fadeOut();
this.abilityPicker.show(choices, MageFrame.getDesktop().getMousePosition());
}

View file

@ -97,9 +97,9 @@ public class PlayAreaPanel extends javax.swing.JPanel {
public final void init(PlayerView player, BigCard bigCard, UUID gameId) {
this.playerPanel.init(gameId, player.getPlayerId(), bigCard);
this.battlefieldPanel.init(gameId, bigCard);
this.gameId = gameId;
if (MageFrame.getSession().isTestMode()) {
this.playerId = player.getPlayerId();
this.gameId = gameId;
this.btnCheat.setVisible(true);
}
else {

View file

@ -55,6 +55,7 @@ import mage.game.stack.StackAbility;
import mage.game.stack.StackObject;
import mage.game.turn.*;
import mage.player.ai.ma.optimizers.TreeOptimizer;
import mage.player.ai.ma.optimizers.impl.DiscardCardOptimizer;
import mage.player.ai.ma.optimizers.impl.EquipOptimizer;
import mage.player.ai.ma.optimizers.impl.LevelUpOptimizer;
import mage.player.ai.util.CombatInfo;
@ -96,6 +97,7 @@ public class ComputerPlayer6 extends ComputerPlayer<ComputerPlayer6> implements
static {
optimizers.add(new LevelUpOptimizer());
optimizers.add(new EquipOptimizer());
optimizers.add(new DiscardCardOptimizer());
}
public ComputerPlayer6(String name, RangeOfInfluence range, int skill) {

View file

@ -62,7 +62,7 @@ public class GameStateEvaluator2 {
int permanentScore = 0;
try {
for (Permanent permanent: game.getBattlefield().getAllActivePermanents(playerId)) {
permanentScore += 10 * evaluatePermanent(permanent, game);
permanentScore += evaluatePermanent(permanent, game);
}
for (Permanent permanent: game.getBattlefield().getAllActivePermanents(opponent.getId())) {
permanentScore -= evaluatePermanent(permanent, game);

View file

@ -101,7 +101,7 @@ public class SimulatedPlayer2 extends ComputerPlayer<SimulatedPlayer2> {
}
for (Ability a : allActions) {
System.out.println("ability=="+a);
//System.out.println("ability=="+a);
if (a.getTargets().size() > 0) {
Player player = game.getPlayer(a.getFirstTarget());
if (player != null) {

View file

@ -119,9 +119,9 @@ public class ArtificialScoringSystem {
if (permanent.getCardType().contains(Constants.CardType.CREATURE)) {
return -100;
} else if (permanent.getCardType().contains(Constants.CardType.LAND)) {
return -10;
return -1;
} else {
return -50;
return -2;
}
}

View file

@ -0,0 +1,23 @@
package mage.player.ai.ma.optimizers.impl;
import mage.abilities.Ability;
import mage.game.Game;
import java.util.List;
/**
* Removes abilities that require only discard a card for activation.
*
* @author magenoxx_at_gmail.com
*/
public class DiscardCardOptimizer extends BaseTreeOptimizer {
@Override
public void filter(Game game, List<Ability> actions) {
for (Ability ability : actions) {
if (ability.toString().startsWith("Discard card")) {
removeAbility(ability);
}
}
}
}

View file

@ -0,0 +1,126 @@
/*
* 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.sets.darksteel;
import java.util.UUID;
import mage.Constants.CardType;
import mage.Constants.Outcome;
import mage.Constants.Rarity;
import mage.Constants.TargetController;
import mage.Constants.Zone;
import mage.abilities.Ability;
import mage.abilities.common.BeginningOfUpkeepTriggeredAbility;
import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.costs.common.TapSourceCost;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.counter.AddCountersSourceEffect;
import mage.cards.Card;
import mage.cards.CardImpl;
import mage.counters.CounterType;
import mage.filter.Filter;
import mage.filter.common.FilterCreatureCard;
import mage.filter.predicate.mageobject.ConvertedManaCostPredicate;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.players.Player;
import mage.target.common.TargetCardInHand;
/**
*
* @author North
*/
public class AEtherVial extends CardImpl<AEtherVial> {
public AEtherVial(UUID ownerId) {
super(ownerId, 91, "AEther Vial", Rarity.UNCOMMON, new CardType[]{CardType.ARTIFACT}, "{1}");
this.expansionSetCode = "DST";
// At the beginning of your upkeep, you may put a charge counter on AEther Vial.
this.addAbility(new BeginningOfUpkeepTriggeredAbility(new AddCountersSourceEffect(CounterType.CHARGE.createInstance()), TargetController.YOU, true));
// {tap}: You may put a creature card with converted mana cost equal to the number of charge counters on AEther Vial from your hand onto the battlefield.
this.addAbility(new SimpleActivatedAbility(Zone.BATTLEFIELD, new AEtherVialEffect(), new TapSourceCost()));
}
public AEtherVial(final AEtherVial card) {
super(card);
}
@Override
public AEtherVial copy() {
return new AEtherVial(this);
}
}
class AEtherVialEffect extends OneShotEffect<AEtherVialEffect> {
public AEtherVialEffect() {
super(Outcome.PutCreatureInPlay);
this.staticText = "You may put a creature card with converted mana cost equal to the number of charge counters on {this} from your hand onto the battlefield";
}
public AEtherVialEffect(final AEtherVialEffect effect) {
super(effect);
}
@Override
public AEtherVialEffect copy() {
return new AEtherVialEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Permanent permanent = game.getBattlefield().getPermanent(source.getSourceId());
if (permanent == null) {
permanent = (Permanent) game.getLastKnownInformation(source.getSourceId(), Zone.BATTLEFIELD);
if (permanent == null) {
return false;
}
}
int count = permanent.getCounters().getCount(CounterType.CHARGE);
FilterCreatureCard filter = new FilterCreatureCard("creature card with converted mana cost equal to " + count);
filter.add(new ConvertedManaCostPredicate(Filter.ComparisonType.Equal, count));
String choiceText = "Put a " + filter.getMessage() + " from your hand onto the battlefield?";
Player player = game.getPlayer(source.getControllerId());
if (player == null || player.getHand().count(filter, game) == 0
|| !player.chooseUse(this.outcome, choiceText, game)) {
return false;
}
TargetCardInHand target = new TargetCardInHand(filter);
if (player.choose(this.outcome, target, source.getSourceId(), game)) {
Card card = game.getCard(target.getFirstTarget());
if (card != null) {
card.putOntoBattlefield(game, Zone.HAND, source.getId(), source.getControllerId());
return true;
}
}
return false;
}
}

View file

@ -35,6 +35,8 @@ import mage.abilities.effects.SearchEffect;
import mage.abilities.keyword.FlashbackAbility;
import mage.cards.Card;
import mage.cards.CardImpl;
import mage.cards.Cards;
import mage.cards.CardsImpl;
import mage.filter.FilterCard;
import mage.filter.predicate.mageobject.AbilityPredicate;
import mage.game.Game;
@ -103,12 +105,17 @@ class SearchLibraryPutInGraveEffect extends SearchEffect<SearchLibraryPutInGrave
}
if (player.searchLibrary(target, game)) {
if (target.getTargets().size() > 0) {
Cards cards = new CardsImpl();
for (UUID cardId: (List<UUID>)target.getTargets()) {
Card card = player.getLibrary().remove(cardId, game);
if (card != null){
card.moveToZone(Constants.Zone.GRAVEYARD, source.getId(), game, false);
cards.add(card);
}
}
if (cards.size() > 0) {
player.revealCards("Quiet Speculation", cards, game);
}
}
player.shuffleLibrary(game);
return true;

View file

@ -0,0 +1,91 @@
/*
* 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.sets.judgment;
import mage.Constants;
import mage.Constants.CardType;
import mage.Constants.Rarity;
import mage.MageInt;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.condition.common.ControlsPermanentCondition;
import mage.abilities.decorator.ConditionalContinousEffect;
import mage.abilities.effects.ContinuousEffect;
import mage.abilities.effects.common.continious.GainAbilityControlledEffect;
import mage.abilities.keyword.FlyingAbility;
import mage.cards.CardImpl;
import mage.filter.common.FilterControlledPermanent;
import mage.filter.common.FilterCreaturePermanent;
import mage.filter.predicate.mageobject.CardTypePredicate;
import mage.filter.predicate.mageobject.SubtypePredicate;
import java.util.UUID;
/**
*
* @author magenoxx_at_gmail.com
*/
public class Wonder extends CardImpl<Wonder> {
private static final String ruleText = "As long as Wonder is in your graveyard and you control an Island, creatures you control have flying";
private static final FilterControlledPermanent filter = new FilterControlledPermanent("Island");
static {
filter.add(new CardTypePredicate(CardType.LAND));
filter.add(new SubtypePredicate("Island"));
}
public Wonder(UUID ownerId) {
super(ownerId, 54, "Wonder", Rarity.UNCOMMON, new CardType[]{CardType.CREATURE}, "{3}{U}");
this.expansionSetCode = "JUD";
this.subtype.add("Incarnation");
this.color.setBlue(true);
this.power = new MageInt(2);
this.toughness = new MageInt(2);
// Flying
this.addAbility(FlyingAbility.getInstance());
// As long as Wonder is in your graveyard and you control an Island, creatures you control have flying.
ContinuousEffect effect = new GainAbilityControlledEffect(FlyingAbility.getInstance(),
Constants.Duration.WhileOnBattlefield, new FilterCreaturePermanent());
ConditionalContinousEffect wonderEffect = new ConditionalContinousEffect(effect,
new ControlsPermanentCondition(filter), ruleText);
this.addAbility(new SimpleStaticAbility(Constants.Zone.GRAVEYARD, wonderEffect));
}
public Wonder(final Wonder card) {
super(card);
}
@Override
public Wonder copy() {
return new Wonder(this);
}
}

View file

@ -0,0 +1,181 @@
/*
* 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.sets.scourge;
import java.util.UUID;
import mage.Constants;
import mage.Constants.CardType;
import mage.Constants.Rarity;
import mage.Constants.TargetController;
import mage.MageInt;
import mage.ObjectColor;
import mage.abilities.Ability;
import mage.abilities.common.EntersBattlefieldTriggeredAbility;
import mage.abilities.common.LeavesBattlefieldTriggeredAbility;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.keyword.FlyingAbility;
import mage.cards.Card;
import mage.cards.CardImpl;
import mage.filter.FilterPermanent;
import mage.filter.predicate.mageobject.CardTypePredicate;
import mage.filter.predicate.mageobject.SubtypePredicate;
import mage.filter.predicate.permanent.ControllerPredicate;
import mage.game.ExileZone;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.game.permanent.token.Token;
/**
*
* @author jeffwadsworth
*/
public class DayOfTheDragons extends CardImpl<DayOfTheDragons> {
public DayOfTheDragons(UUID ownerId) {
super(ownerId, 31, "Day of the Dragons", Rarity.RARE, new CardType[]{CardType.ENCHANTMENT}, "{4}{U}{U}{U}");
this.expansionSetCode = "SCG";
this.color.setBlue(true);
// When Day of the Dragons enters the battlefield, exile all creatures you control. Then put that many 5/5 red Dragon creature tokens with flying onto the battlefield.
this.addAbility(new EntersBattlefieldTriggeredAbility(new DayOfTheDragonsEntersEffect(), false));
// When Day of the Dragons leaves the battlefield, sacrifice all Dragons you control. Then return the exiled cards to the battlefield under your control.
this.addAbility(new LeavesBattlefieldTriggeredAbility(new DayOfTheDragonsLeavesEffect(), false));
}
public DayOfTheDragons(final DayOfTheDragons card) {
super(card);
}
@Override
public DayOfTheDragons copy() {
return new DayOfTheDragons(this);
}
}
class DayOfTheDragonsEntersEffect extends OneShotEffect<DayOfTheDragonsEntersEffect> {
private static final FilterPermanent filter = new FilterPermanent("all creatures you control");
static {
filter.add(new ControllerPredicate(TargetController.YOU));
filter.add(new CardTypePredicate(CardType.CREATURE));
}
public DayOfTheDragonsEntersEffect() {
super(Constants.Outcome.Benefit);
staticText = "exile all creatures you control. Then put that many 5/5 red Dragon creature tokens with flying onto the battlefield";
}
public DayOfTheDragonsEntersEffect(final DayOfTheDragonsEntersEffect effect) {
super(effect);
}
@Override
public boolean apply(Game game, Ability source) {
UUID exileId = source.getSourceId();
int creaturesExiled = 0;
if (exileId != null) {
for (Permanent creature : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), game)) {
if (creature != null) {
if (creature.moveToExile(exileId, "Day of the Dragons", source.getId(), game)) {
creaturesExiled++;
}
}
}
DragonToken token = new DragonToken();
token.putOntoBattlefield(creaturesExiled, game, source.getId(), source.getControllerId());
return true;
}
return false;
}
@Override
public DayOfTheDragonsEntersEffect copy() {
return new DayOfTheDragonsEntersEffect(this);
}
}
class DayOfTheDragonsLeavesEffect extends OneShotEffect<DayOfTheDragonsLeavesEffect> {
private static final FilterPermanent filter = new FilterPermanent("all Dragons you control");
static {
filter.add(new ControllerPredicate(TargetController.YOU));
filter.add(new SubtypePredicate("Dragon"));
}
public DayOfTheDragonsLeavesEffect() {
super(Constants.Outcome.Neutral);
staticText = "sacrifice all Dragons you control. Then return the exiled cards to the battlefield under your control";
}
public DayOfTheDragonsLeavesEffect(final DayOfTheDragonsLeavesEffect effect) {
super(effect);
}
@Override
public boolean apply(Game game, Ability source) {
UUID exileId = source.getSourceId();
for (Permanent dragon : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), game)) {
if (dragon != null) {
dragon.sacrifice(source.getId(), game);
}
}
ExileZone exile = game.getExile().getExileZone(exileId);
if (exile != null) {
exile = exile.copy();
for (UUID cardId : exile) {
Card card = game.getCard(cardId);
card.putOntoBattlefield(game, Constants.Zone.EXILED, source.getId(), source.getControllerId());
}
game.getExile().getExileZone(exileId).clear();
return true;
}
return false;
}
@Override
public DayOfTheDragonsLeavesEffect copy() {
return new DayOfTheDragonsLeavesEffect(this);
}
}
class DragonToken extends Token {
public DragonToken() {
super("Dragon", "5/5 red Dragon creature token with flying");
cardType.add(CardType.CREATURE);
color = ObjectColor.RED;
subtype.add("Dragon");
power = new MageInt(5);
toughness = new MageInt(5);
addAbility(FlyingAbility.getInstance());
}
}

View file

@ -0,0 +1,92 @@
package org.mage.test.cards.continuous;
import mage.Constants;
import mage.abilities.keyword.FlyingAbility;
import mage.cards.Card;
import org.junit.Assert;
import org.junit.Test;
import org.mage.test.serverside.base.CardTestPlayerBase;
/**
* Wonder
* As long as Wonder is in your graveyard and you control an Island, creatures you control have flying.
*
* @author magenoxx_at_gmail.com
*/
public class WonderTest extends CardTestPlayerBase {
/**
* Tests creatures for Flying gained from Wonder ability when all conditions were met
*/
@Test
public void testCardWithAllConditionsMet() {
addCard(Constants.Zone.GRAVEYARD, playerA, "Wonder");
addCard(Constants.Zone.GRAVEYARD, playerA, "Runeclaw Bear");
addCard(Constants.Zone.BATTLEFIELD, playerA, "Island");
addCard(Constants.Zone.BATTLEFIELD, playerA, "Elite Vanguard");
addCard(Constants.Zone.BATTLEFIELD, playerA, "Corpse Traders");
addCard(Constants.Zone.BATTLEFIELD, playerB, "Llanowar Elves");
setStopAt(1, Constants.PhaseStep.BEGIN_COMBAT);
execute();
assertAbility(playerA, "Elite Vanguard", FlyingAbility.getInstance(), true);
assertAbility(playerA, "Corpse Traders", FlyingAbility.getInstance(), true);
assertAbility(playerB, "Llanowar Elves", FlyingAbility.getInstance(), false);
// check no flying in graveyard
for (Card card : playerA.getGraveyard().getCards(currentGame)) {
if (card.equals("Runeclaw Bear")) {
Assert.assertFalse(card.getAbilities().contains(FlyingAbility.getInstance()));
}
}
}
@Test
public void testNoIsland() {
addCard(Constants.Zone.GRAVEYARD, playerA, "Wonder");
addCard(Constants.Zone.BATTLEFIELD, playerA, "Forest");
addCard(Constants.Zone.BATTLEFIELD, playerA, "Mountain");
addCard(Constants.Zone.BATTLEFIELD, playerA, "Plains");
addCard(Constants.Zone.BATTLEFIELD, playerA, "Swamp");
addCard(Constants.Zone.BATTLEFIELD, playerA, "Elite Vanguard");
setStopAt(1, Constants.PhaseStep.BEGIN_COMBAT);
execute();
assertAbility(playerA, "Elite Vanguard", FlyingAbility.getInstance(), false);
}
@Test
public void testOtherZones() {
addCard(Constants.Zone.BATTLEFIELD, playerA, "Wonder");
addCard(Constants.Zone.HAND, playerA, "Wonder");
addCard(Constants.Zone.LIBRARY, playerA, "Wonder");
addCard(Constants.Zone.BATTLEFIELD, playerA, "Island");
addCard(Constants.Zone.BATTLEFIELD, playerA, "Elite Vanguard");
setStopAt(1, Constants.PhaseStep.BEGIN_COMBAT);
execute();
assertAbility(playerA, "Elite Vanguard", FlyingAbility.getInstance(), false);
}
@Test
public void testDestroyIsland() {
addCard(Constants.Zone.GRAVEYARD, playerA, "Wonder");
addCard(Constants.Zone.BATTLEFIELD, playerA, "Island");
addCard(Constants.Zone.BATTLEFIELD, playerA, "Mountain", 4);
addCard(Constants.Zone.BATTLEFIELD, playerA, "Elite Vanguard");
addCard(Constants.Zone.HAND, playerA, "Demolish");
castSpell(1, Constants.PhaseStep.PRECOMBAT_MAIN, playerA, "Demolish", "Island");
setStopAt(1, Constants.PhaseStep.BEGIN_COMBAT);
execute();
assertAbility(playerA, "Elite Vanguard", FlyingAbility.getInstance(), false);
}
}

View file

@ -357,6 +357,39 @@ public abstract class CardTestPlayerAPIImpl extends MageTestPlayerBase implement
}
}
/**
*
* @param player
* @param cardName
* @param ability
* @param flag true if creature should contain ability, false otherwise
* @throws AssertionError
*/
public void assertAbility(Player player, String cardName, Ability ability, boolean flag) throws AssertionError {
int count = 0;
Permanent found = null;
for (Permanent permanent : currentGame.getBattlefield().getAllActivePermanents(player.getId())) {
if (permanent.getName().equals(cardName)) {
found = permanent;
count++;
}
}
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);
if (flag) {
Assert.assertTrue("No such ability=" + ability.toString() + ", player=" + player.getName() +
", cardName" + cardName, found.getAbilities().contains(ability));
} else {
Assert.assertFalse("Card shouldn't have such ability=" + ability.toString() + ", player=" + player.getName() +
", cardName" + cardName, found.getAbilities().contains(ability));
}
}
/**
* Assert permanent count under player's control.
*

View file

@ -211,6 +211,7 @@ public abstract class AbilityImpl<T extends AbilityImpl<T>> implements Ability {
return false;
}
}
//20100716 - 601.2g
if (!costs.pay(this, game, sourceId, controllerId, noMana)) {
logger.debug("activate failed - non mana costs");

View file

@ -8,6 +8,7 @@ import mage.abilities.StaticAbility;
import mage.abilities.TriggeredAbilityImpl;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.costs.Cost;
import mage.abilities.costs.mana.ManaCost;
import mage.abilities.effects.AsThoughEffectImpl;
import mage.abilities.effects.OneShotEffect;
import mage.cards.Card;
@ -105,13 +106,18 @@ class MadnessPlayEffect extends AsThoughEffectImpl<MadnessPlayEffect> {
if (card != null && card.getOwnerId().equals(source.getControllerId()) && game.getState().getZone(source.getSourceId()) == Constants.Zone.EXILED) {
Object object = game.getState().getValue("madness_" + card.getId());
if (object != null && object.equals(true)) {
Object alfreadyConfirmed = game.getState().getValue("madness_ok_" + card.getId());
if (alfreadyConfirmed != null) {
return true;
}
Player player = game.getPlayer(card.getOwnerId());
String message = "Cast " + card.getName() + " by its madness cost?";
if (player != null && player.chooseUse(Constants.Outcome.Benefit, message, game)) {
if (cost.pay(card.getSpellAbility(), game, sourceId, player.getId(), false)) {
card.getSpellAbility().getManaCostsToPay().clear();
return true;
}
Cost costToPay = cost.copy();
card.getSpellAbility().getManaCostsToPay().clear();
card.getSpellAbility().getManaCostsToPay().add((ManaCost)costToPay);
game.getState().setValue("madness_ok_" + card.getId(), true);
return true;
}
}
}
@ -229,11 +235,12 @@ class MadnessCleanUpWatcher extends WatcherImpl<MadnessCleanUpWatcher> {
for (Card card : game.getExile().getAllCards(game)) {
Object object = game.getState().getValue("madness_" + card.getId());
if (object != null && object.equals(true)) {
game.informPlayers("Madness cost wasn't paied. " + card.getName() + " was put to its owner's graveyard.");
game.informPlayers("Madness cost wasn't payed. " + card.getName() + " was put to its owner's graveyard.");
// reset
game.getState().setValue("madness_" + card.getId(), null);
game.getState().setValue("madness_ok_" + card.getId(), null);
card.moveToZone(Constants.Zone.GRAVEYARD, sourceId, game, true);
}
card.moveToZone(Constants.Zone.GRAVEYARD, sourceId, game, true);
}
}
}

View file

@ -49,7 +49,7 @@ public abstract class IntComparePredicate<T extends MageObject> implements Predi
@Override
public final boolean apply(T input, Game game) {
int inputValue = input.getPower().getValue();
int inputValue = getInputValue(input);
switch (type) {
case Equal:
if (inputValue != value) {