mirror of
https://github.com/correl/mage.git
synced 2024-11-14 19:19:32 +00:00
Fixed a bug that if a human player had to discard more cards than he had on hand, the game UI was blocked.
This commit is contained in:
parent
09dd373909
commit
cd0f273122
5 changed files with 33 additions and 13 deletions
|
@ -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"),"");
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
||||
}
|
||||
/**
|
||||
* 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);
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue