diff --git a/Mage.Client/src/main/java/mage/client/game/GamePanel.java b/Mage.Client/src/main/java/mage/client/game/GamePanel.java index 1db5a0b7e2..b5a6b67857 100644 --- a/Mage.Client/src/main/java/mage/client/game/GamePanel.java +++ b/Mage.Client/src/main/java/mage/client/game/GamePanel.java @@ -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()); } diff --git a/Mage.Client/src/main/java/mage/client/game/PlayAreaPanel.java b/Mage.Client/src/main/java/mage/client/game/PlayAreaPanel.java index 65ac7d53fa..8777a93f86 100644 --- a/Mage.Client/src/main/java/mage/client/game/PlayAreaPanel.java +++ b/Mage.Client/src/main/java/mage/client/game/PlayAreaPanel.java @@ -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 { diff --git a/Mage.Server.Plugins/Mage.Player.AI.MA/src/mage/player/ai/ComputerPlayer6.java b/Mage.Server.Plugins/Mage.Player.AI.MA/src/mage/player/ai/ComputerPlayer6.java index 0a8e95acce..83dd306a5e 100644 --- a/Mage.Server.Plugins/Mage.Player.AI.MA/src/mage/player/ai/ComputerPlayer6.java +++ b/Mage.Server.Plugins/Mage.Player.AI.MA/src/mage/player/ai/ComputerPlayer6.java @@ -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 implements static { optimizers.add(new LevelUpOptimizer()); optimizers.add(new EquipOptimizer()); + optimizers.add(new DiscardCardOptimizer()); } public ComputerPlayer6(String name, RangeOfInfluence range, int skill) { diff --git a/Mage.Server.Plugins/Mage.Player.AI.MA/src/mage/player/ai/GameStateEvaluator2.java b/Mage.Server.Plugins/Mage.Player.AI.MA/src/mage/player/ai/GameStateEvaluator2.java index 57e6306662..42f990a8b1 100644 --- a/Mage.Server.Plugins/Mage.Player.AI.MA/src/mage/player/ai/GameStateEvaluator2.java +++ b/Mage.Server.Plugins/Mage.Player.AI.MA/src/mage/player/ai/GameStateEvaluator2.java @@ -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); diff --git a/Mage.Server.Plugins/Mage.Player.AI.MA/src/mage/player/ai/SimulatedPlayer2.java b/Mage.Server.Plugins/Mage.Player.AI.MA/src/mage/player/ai/SimulatedPlayer2.java index 0f63ac787f..d5c7fad04d 100644 --- a/Mage.Server.Plugins/Mage.Player.AI.MA/src/mage/player/ai/SimulatedPlayer2.java +++ b/Mage.Server.Plugins/Mage.Player.AI.MA/src/mage/player/ai/SimulatedPlayer2.java @@ -101,7 +101,7 @@ public class SimulatedPlayer2 extends ComputerPlayer { } 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) { diff --git a/Mage.Server.Plugins/Mage.Player.AI.MA/src/mage/player/ai/ma/ArtificialScoringSystem.java b/Mage.Server.Plugins/Mage.Player.AI.MA/src/mage/player/ai/ma/ArtificialScoringSystem.java index 108cd9191f..72c87c9899 100644 --- a/Mage.Server.Plugins/Mage.Player.AI.MA/src/mage/player/ai/ma/ArtificialScoringSystem.java +++ b/Mage.Server.Plugins/Mage.Player.AI.MA/src/mage/player/ai/ma/ArtificialScoringSystem.java @@ -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; } } diff --git a/Mage.Server.Plugins/Mage.Player.AI.MA/src/mage/player/ai/ma/optimizers/impl/DiscardCardOptimizer.java b/Mage.Server.Plugins/Mage.Player.AI.MA/src/mage/player/ai/ma/optimizers/impl/DiscardCardOptimizer.java new file mode 100644 index 0000000000..a4875452ad --- /dev/null +++ b/Mage.Server.Plugins/Mage.Player.AI.MA/src/mage/player/ai/ma/optimizers/impl/DiscardCardOptimizer.java @@ -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 actions) { + for (Ability ability : actions) { + if (ability.toString().startsWith("Discard card")) { + removeAbility(ability); + } + } + } +} diff --git a/Mage.Server/plugins/mage-player-ai-ma.jar b/Mage.Server/plugins/mage-player-ai-ma.jar index ae0c9abc9f..5c41f24024 100644 Binary files a/Mage.Server/plugins/mage-player-ai-ma.jar and b/Mage.Server/plugins/mage-player-ai-ma.jar differ diff --git a/Mage.Server/plugins/mage-player-ai.jar b/Mage.Server/plugins/mage-player-ai.jar index 8dfc3c893e..5cb22be62c 100644 Binary files a/Mage.Server/plugins/mage-player-ai.jar and b/Mage.Server/plugins/mage-player-ai.jar differ diff --git a/Mage.Server/plugins/mage-player-aiminimax.jar b/Mage.Server/plugins/mage-player-aiminimax.jar index 9f8516089c..63de76241b 100644 Binary files a/Mage.Server/plugins/mage-player-aiminimax.jar and b/Mage.Server/plugins/mage-player-aiminimax.jar differ diff --git a/Mage.Sets/src/mage/sets/darksteel/AEtherVial.java b/Mage.Sets/src/mage/sets/darksteel/AEtherVial.java new file mode 100644 index 0000000000..4e943dcb7e --- /dev/null +++ b/Mage.Sets/src/mage/sets/darksteel/AEtherVial.java @@ -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 { + + 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 { + + 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; + } +} diff --git a/Mage.Sets/src/mage/sets/judgment/QuietSpeculation.java b/Mage.Sets/src/mage/sets/judgment/QuietSpeculation.java index 143e9e1887..8f94503077 100644 --- a/Mage.Sets/src/mage/sets/judgment/QuietSpeculation.java +++ b/Mage.Sets/src/mage/sets/judgment/QuietSpeculation.java @@ -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 0) { + Cards cards = new CardsImpl(); for (UUID cardId: (List)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; diff --git a/Mage.Sets/src/mage/sets/judgment/Wonder.java b/Mage.Sets/src/mage/sets/judgment/Wonder.java new file mode 100644 index 0000000000..c9899963f8 --- /dev/null +++ b/Mage.Sets/src/mage/sets/judgment/Wonder.java @@ -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 { + + 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); + } +} diff --git a/Mage.Sets/src/mage/sets/scourge/DayOfTheDragons.java b/Mage.Sets/src/mage/sets/scourge/DayOfTheDragons.java new file mode 100644 index 0000000000..3579f5048c --- /dev/null +++ b/Mage.Sets/src/mage/sets/scourge/DayOfTheDragons.java @@ -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 { + + 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 { + + 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 { + + 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()); + } +} \ No newline at end of file diff --git a/Mage.Tests/src/test/java/org/mage/test/cards/continuous/WonderTest.java b/Mage.Tests/src/test/java/org/mage/test/cards/continuous/WonderTest.java new file mode 100644 index 0000000000..5166b3115d --- /dev/null +++ b/Mage.Tests/src/test/java/org/mage/test/cards/continuous/WonderTest.java @@ -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); + } + +} diff --git a/Mage.Tests/src/test/java/org/mage/test/serverside/base/impl/CardTestPlayerAPIImpl.java b/Mage.Tests/src/test/java/org/mage/test/serverside/base/impl/CardTestPlayerAPIImpl.java index 5c0be829e8..bcd655259b 100644 --- a/Mage.Tests/src/test/java/org/mage/test/serverside/base/impl/CardTestPlayerAPIImpl.java +++ b/Mage.Tests/src/test/java/org/mage/test/serverside/base/impl/CardTestPlayerAPIImpl.java @@ -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. * diff --git a/Mage/src/mage/abilities/AbilityImpl.java b/Mage/src/mage/abilities/AbilityImpl.java index 0834f352e4..40632a1579 100644 --- a/Mage/src/mage/abilities/AbilityImpl.java +++ b/Mage/src/mage/abilities/AbilityImpl.java @@ -211,6 +211,7 @@ public abstract class AbilityImpl> implements Ability { return false; } } + //20100716 - 601.2g if (!costs.pay(this, game, sourceId, controllerId, noMana)) { logger.debug("activate failed - non mana costs"); diff --git a/Mage/src/mage/abilities/keyword/MadnessAbility.java b/Mage/src/mage/abilities/keyword/MadnessAbility.java index 7e67b220d9..0311794fc8 100644 --- a/Mage/src/mage/abilities/keyword/MadnessAbility.java +++ b/Mage/src/mage/abilities/keyword/MadnessAbility.java @@ -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 { 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 { 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); } } } diff --git a/Mage/src/mage/filter/predicate/IntComparePredicate.java b/Mage/src/mage/filter/predicate/IntComparePredicate.java index a40f138b90..961c60e88d 100644 --- a/Mage/src/mage/filter/predicate/IntComparePredicate.java +++ b/Mage/src/mage/filter/predicate/IntComparePredicate.java @@ -49,7 +49,7 @@ public abstract class IntComparePredicate 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) {