diff --git a/Mage.Client/src/main/java/mage/client/table/TablesPanel.java b/Mage.Client/src/main/java/mage/client/table/TablesPanel.java index 62b0294b4cb..a92e06a60f0 100644 --- a/Mage.Client/src/main/java/mage/client/table/TablesPanel.java +++ b/Mage.Client/src/main/java/mage/client/table/TablesPanel.java @@ -1146,6 +1146,7 @@ public class TablesPanel extends javax.swing.JPanel { options.setMatchTimeLimit(MatchTimeLimit.NONE); options.setFreeMulligans(2); options.setSkillLevel(SkillLevel.CASUAL); + options.setRollbackTurnsAllowed(true); table = session.createTable(roomId, options); session.joinTable(roomId, table.getTableId(), "Human", "Human", 1, DeckImporterUtil.importDeck("test.dck"),""); diff --git a/Mage.Server.Plugins/Mage.Player.AI/src/main/java/mage/player/ai/ComputerPlayer.java b/Mage.Server.Plugins/Mage.Player.AI/src/main/java/mage/player/ai/ComputerPlayer.java index 7daf4cb517b..49399a7889b 100644 --- a/Mage.Server.Plugins/Mage.Player.AI/src/main/java/mage/player/ai/ComputerPlayer.java +++ b/Mage.Server.Plugins/Mage.Player.AI/src/main/java/mage/player/ai/ComputerPlayer.java @@ -208,7 +208,7 @@ public class ComputerPlayer extends PlayerImpl implements Player { if (log.isDebugEnabled()) { log.debug("chooseTarget: " + outcome.toString() + ":" + target.toString()); } - // sometimes a target aelection can be made from a player that does not control the ability + // sometimes a target selection can be made from a player that does not control the ability UUID abilityControllerId = playerId; if (target.getTargetController() != null && target.getAbilityController() != null) { abilityControllerId = target.getAbilityController(); diff --git a/Mage.Tests/src/test/java/org/mage/test/cards/abilities/activated/ReturnToHandTest.java b/Mage.Tests/src/test/java/org/mage/test/cards/abilities/activated/ReturnToHandTest.java index 3b87ec843a1..7d4ea0d43cd 100644 --- a/Mage.Tests/src/test/java/org/mage/test/cards/abilities/activated/ReturnToHandTest.java +++ b/Mage.Tests/src/test/java/org/mage/test/cards/abilities/activated/ReturnToHandTest.java @@ -27,7 +27,6 @@ */ package org.mage.test.cards.abilities.activated; -import mage.abilities.keyword.BloodthirstAbility; import mage.constants.PhaseStep; import mage.constants.Zone; import org.junit.Test; diff --git a/Mage.Tests/src/test/java/org/mage/test/cards/abilities/keywords/DiscardTest.java b/Mage.Tests/src/test/java/org/mage/test/cards/abilities/keywords/DiscardTest.java index f9dcd57ecdd..146a5eb9256 100644 --- a/Mage.Tests/src/test/java/org/mage/test/cards/abilities/keywords/DiscardTest.java +++ b/Mage.Tests/src/test/java/org/mage/test/cards/abilities/keywords/DiscardTest.java @@ -25,7 +25,6 @@ * authors and should not be interpreted as representing official policies, either expressed * or implied, of BetaSteward_at_googlemail.com. */ - package org.mage.test.cards.abilities.keywords; import mage.constants.PhaseStep; @@ -37,16 +36,14 @@ import org.mage.test.serverside.base.CardTestPlayerBase; * * @author LevelX2 */ - public class DiscardTest extends CardTestPlayerBase { - /* - * If Rest in Peace is in play, every card going to the graveyard goes to exile instead. - * If a card is discarded while Rest in Peace is on the battlefield, abilities that function - * when a card is discarded (such as madness) still work, even though that card never reaches - * a graveyard. - */ - + /* + * If Rest in Peace is in play, every card going to the graveyard goes to exile instead. + * If a card is discarded while Rest in Peace is on the battlefield, abilities that function + * when a card is discarded (such as madness) still work, even though that card never reaches + * a graveyard. + */ @Test public void testRestInPeaceAndCycle() { @@ -67,4 +64,26 @@ public class DiscardTest extends CardTestPlayerBase { assertHandCount(playerA, 1); // the card drawn by Cycling } -} \ No newline at end of file + /** + * With Bazaar of Baghdad, if you use it when you have no cards in hand, you + * draw 2, it asks for you to discard 3, but you can't. So the game can't + * progress and you lose on time. + */ + @Test + public void testBazaarOfBaghdad() { + // {T}: Draw two cards, then discard three cards. + addCard(Zone.BATTLEFIELD, playerA, "Bazaar of Baghdad", 1); + + activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}: Draw two cards, then discard three cards"); + + setStopAt(1, PhaseStep.BEGIN_COMBAT); + execute(); + + assertLife(playerA, 20); + assertLife(playerB, 20); + + assertHandCount(playerA, 0); + assertGraveyardCount(playerA, 2); + + } +} diff --git a/Mage/src/mage/players/PlayerImpl.java b/Mage/src/mage/players/PlayerImpl.java index 732fe47137e..65228de1e6b 100644 --- a/Mage/src/mage/players/PlayerImpl.java +++ b/Mage/src/mage/players/PlayerImpl.java @@ -709,7 +709,8 @@ public abstract class PlayerImpl implements Player, Serializable { } } } else { - TargetDiscard target = new TargetDiscard(amount, amount, new FilterCard(CardUtil.numberToText(amount, "a") + " card" + (amount > 1 ? "s" : "")), playerId); + int possibleAmount = Math.min(getHand().size(), amount); + TargetDiscard target = new TargetDiscard(possibleAmount, possibleAmount, new FilterCard(CardUtil.numberToText(possibleAmount, "a") + " card" + (possibleAmount > 1 ? "s" : "")), playerId); choose(Outcome.Discard, target, source == null ? null : source.getSourceId(), game); for (UUID cardId : target.getTargets()) { Card card = this.getHand().get(cardId, game);