mirror of
https://github.com/magefree/mage.git
synced 2025-12-22 19:41:59 -08: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.setMatchTimeLimit(MatchTimeLimit.NONE);
|
||||||
options.setFreeMulligans(2);
|
options.setFreeMulligans(2);
|
||||||
options.setSkillLevel(SkillLevel.CASUAL);
|
options.setSkillLevel(SkillLevel.CASUAL);
|
||||||
|
options.setRollbackTurnsAllowed(true);
|
||||||
table = session.createTable(roomId, options);
|
table = session.createTable(roomId, options);
|
||||||
|
|
||||||
session.joinTable(roomId, table.getTableId(), "Human", "Human", 1, DeckImporterUtil.importDeck("test.dck"),"");
|
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()) {
|
if (log.isDebugEnabled()) {
|
||||||
log.debug("chooseTarget: " + outcome.toString() + ":" + target.toString());
|
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;
|
UUID abilityControllerId = playerId;
|
||||||
if (target.getTargetController() != null && target.getAbilityController() != null) {
|
if (target.getTargetController() != null && target.getAbilityController() != null) {
|
||||||
abilityControllerId = target.getAbilityController();
|
abilityControllerId = target.getAbilityController();
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,6 @@
|
||||||
*/
|
*/
|
||||||
package org.mage.test.cards.abilities.activated;
|
package org.mage.test.cards.abilities.activated;
|
||||||
|
|
||||||
import mage.abilities.keyword.BloodthirstAbility;
|
|
||||||
import mage.constants.PhaseStep;
|
import mage.constants.PhaseStep;
|
||||||
import mage.constants.Zone;
|
import mage.constants.Zone;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,6 @@
|
||||||
* authors and should not be interpreted as representing official policies, either expressed
|
* authors and should not be interpreted as representing official policies, either expressed
|
||||||
* or implied, of BetaSteward_at_googlemail.com.
|
* or implied, of BetaSteward_at_googlemail.com.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.mage.test.cards.abilities.keywords;
|
package org.mage.test.cards.abilities.keywords;
|
||||||
|
|
||||||
import mage.constants.PhaseStep;
|
import mage.constants.PhaseStep;
|
||||||
|
|
@ -37,7 +36,6 @@ import org.mage.test.serverside.base.CardTestPlayerBase;
|
||||||
*
|
*
|
||||||
* @author LevelX2
|
* @author LevelX2
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class DiscardTest extends CardTestPlayerBase {
|
public class DiscardTest extends CardTestPlayerBase {
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
@ -46,7 +44,6 @@ public class DiscardTest extends CardTestPlayerBase {
|
||||||
* when a card is discarded (such as madness) still work, even though that card never reaches
|
* when a card is discarded (such as madness) still work, even though that card never reaches
|
||||||
* a graveyard.
|
* a graveyard.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testRestInPeaceAndCycle() {
|
public void testRestInPeaceAndCycle() {
|
||||||
|
|
||||||
|
|
@ -67,4 +64,26 @@ public class DiscardTest extends CardTestPlayerBase {
|
||||||
assertHandCount(playerA, 1); // the card drawn by Cycling
|
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 {
|
} 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);
|
choose(Outcome.Discard, target, source == null ? null : source.getSourceId(), game);
|
||||||
for (UUID cardId : target.getTargets()) {
|
for (UUID cardId : target.getTargets()) {
|
||||||
Card card = this.getHand().get(cardId, game);
|
Card card = this.getHand().get(cardId, game);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue