mirror of
https://github.com/magefree/mage.git
synced 2026-01-10 21:02:08 -08:00
* Special mana abilities: fixed that it can be used to skip card's mana payments (#6937);
This commit is contained in:
parent
f69477d8d5
commit
bb148c9cb5
3 changed files with 85 additions and 83 deletions
|
|
@ -2,7 +2,6 @@ package org.mage.test.cards.abilities.keywords;
|
|||
|
||||
import mage.constants.PhaseStep;
|
||||
import mage.constants.Zone;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.mage.test.player.TestPlayer;
|
||||
import org.mage.test.serverside.base.CardTestPlayerBaseWithAIHelps;
|
||||
|
|
@ -85,7 +84,6 @@ public class DelveTest extends CardTestPlayerBaseWithAIHelps {
|
|||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
public void test_CheatWithCancel() {
|
||||
// possible bug: users can start to pay delve special action with nothing (done button) and gets no mana cast
|
||||
// https://github.com/magefree/mage/issues/6937
|
||||
|
|
@ -99,7 +97,7 @@ public class DelveTest extends CardTestPlayerBaseWithAIHelps {
|
|||
addCard(Zone.BATTLEFIELD, playerA, "Island", 1);
|
||||
addCard(Zone.GRAVEYARD, playerA, "Balduvian Bears", 7); // delve pay
|
||||
|
||||
// user case:
|
||||
// use case:
|
||||
// 1. Use mana from land (fill mana pool)
|
||||
// 2. Use delve as special action
|
||||
// 3. Press done without real delve pay
|
||||
|
|
@ -107,20 +105,17 @@ public class DelveTest extends CardTestPlayerBaseWithAIHelps {
|
|||
|
||||
activateManaAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}: Add {U}");
|
||||
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Treasure Cruise");
|
||||
//setChoice(playerA, "Blue");
|
||||
setChoice(playerA, "Exile cards"); // delve activate
|
||||
setChoice(playerA, TestPlayer.CHOICE_SKIP);
|
||||
setChoice(playerA, TestPlayer.MANA_CANCEL);
|
||||
setChoice(playerA, "Exile cards"); // delve activate (special button in UI)
|
||||
setChoice(playerA, TestPlayer.CHOICE_SKIP); // devle cost with nothing (done button in UI)
|
||||
setChoice(playerA, TestPlayer.MANA_CANCEL); // mana payment cancel (cancel button in UI)
|
||||
setChoice(playerA, TestPlayer.SKIP_FAILED_COMMAND); // delete cast/activate command from queue
|
||||
|
||||
waitStackResolved(1, PhaseStep.PRECOMBAT_MAIN);
|
||||
showGraveyard("hmm", 1, PhaseStep.PRECOMBAT_MAIN, playerA);
|
||||
|
||||
// it uses bug with rollback, so test commands restores with rollback too (no strict or commands usage check)
|
||||
//setStrictChooseMode(true);
|
||||
// it uses bug with rollback, so test player will execute it multiple times
|
||||
setStrictChooseMode(true);
|
||||
setStopAt(1, PhaseStep.END_TURN);
|
||||
execute();
|
||||
//assertAllCommandsUsed();
|
||||
assertAllCommandsUsed();
|
||||
|
||||
assertHandCount(playerA, 0); // no resolve, so no draw cards (if rollback bug active then it shows 3 cards)
|
||||
assertHandCount(playerA, 1); // no resolve, so no draw cards (if rollback bug active then it shows 3 cards)
|
||||
}
|
||||
}
|
||||
|
|
@ -1,15 +1,6 @@
|
|||
package org.mage.test.player;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.*;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.stream.Collectors;
|
||||
import mage.MageItem;
|
||||
import mage.MageObject;
|
||||
import mage.MageObjectReference;
|
||||
import mage.Mana;
|
||||
import mage.ObjectColor;
|
||||
import mage.*;
|
||||
import mage.abilities.*;
|
||||
import mage.abilities.costs.AlternativeSourceCosts;
|
||||
import mage.abilities.costs.Cost;
|
||||
|
|
@ -63,6 +54,13 @@ import mage.util.CardUtil;
|
|||
import org.apache.log4j.Logger;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Ignore;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.*;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static org.mage.test.serverside.base.impl.CardTestPlayerAPIImpl.*;
|
||||
|
||||
/**
|
||||
|
|
@ -78,6 +76,7 @@ public class TestPlayer implements Player {
|
|||
public static final String TARGET_SKIP = "[target_skip]"; // stop/skip targeting
|
||||
public static final String CHOICE_SKIP = "[choice_skip]"; // stop/skip choice
|
||||
public static final String MANA_CANCEL = "[mana_cancel]"; // cancel payment
|
||||
public static final String SKIP_FAILED_COMMAND = "[skip_failed_command]"; // skip next command in player's queue (can remove cast commands after try to activate)
|
||||
public static final String BLOCK_SKIP = "[block_skip]";
|
||||
public static final String ATTACK_SKIP = "[attack_skip]";
|
||||
public static final String NO_TARGET = "NO_TARGET"; // cast spell or activate ability without target defines
|
||||
|
|
@ -592,7 +591,14 @@ public class TestPlayer implements Player {
|
|||
foundNoAction = 0; // Reset enless loop check because of no action
|
||||
return true;
|
||||
} else {
|
||||
game.restoreState(bookmark, ability.getRule());
|
||||
computerPlayer.restoreState(bookmark, ability.getRule(), game);
|
||||
|
||||
// skip failed command
|
||||
if (!choices.isEmpty() && choices.get(0).equals(SKIP_FAILED_COMMAND)) {
|
||||
actions.remove(action);
|
||||
choices.remove(0);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
groupsForTargetHandling = null;
|
||||
}
|
||||
|
|
@ -1112,13 +1118,13 @@ public class TestPlayer implements Player {
|
|||
|
||||
List<String> data = cards.stream()
|
||||
.map(c -> (((c instanceof PermanentToken) ? "[T] " : "[C] ")
|
||||
+ c.getIdName()
|
||||
+ (c.isCopy() ? " [copy of " + c.getCopyFrom().getId().toString().substring(0, 3) + "]" : "")
|
||||
+ " - " + c.getPower().getValue() + "/" + c.getToughness().getValue()
|
||||
+ (c.isPlaneswalker() ? " - L" + c.getCounters(game).getCount(CounterType.LOYALTY) : "")
|
||||
+ ", " + (c.isTapped() ? "Tapped" : "Untapped")
|
||||
+ getPrintableAliases(", [", c.getId(), "]")
|
||||
+ (c.getAttachedTo() == null ? "" : ", attached to " + game.getPermanent(c.getAttachedTo()).getIdName())))
|
||||
+ c.getIdName()
|
||||
+ (c.isCopy() ? " [copy of " + c.getCopyFrom().getId().toString().substring(0, 3) + "]" : "")
|
||||
+ " - " + c.getPower().getValue() + "/" + c.getToughness().getValue()
|
||||
+ (c.isPlaneswalker() ? " - L" + c.getCounters(game).getCount(CounterType.LOYALTY) : "")
|
||||
+ ", " + (c.isTapped() ? "Tapped" : "Untapped")
|
||||
+ getPrintableAliases(", [", c.getId(), "]")
|
||||
+ (c.getAttachedTo() == null ? "" : ", attached to " + game.getPermanent(c.getAttachedTo()).getIdName())))
|
||||
.sorted()
|
||||
.collect(Collectors.toList());
|
||||
|
||||
|
|
@ -1142,12 +1148,12 @@ public class TestPlayer implements Player {
|
|||
|
||||
List<String> data = abilities.stream()
|
||||
.map(a -> (a.getZone() + " -> "
|
||||
+ a.getSourceObject(game).getIdName() + " -> "
|
||||
+ (a.toString().startsWith("Cast ") ? "[" + a.getManaCostsToPay().getText() + "] -> " : "") // printed cost, not modified
|
||||
+ (a.toString().length() > 0
|
||||
? a.toString().substring(0, Math.min(20, a.toString().length()))
|
||||
: a.getClass().getSimpleName())
|
||||
+ "..."))
|
||||
+ a.getSourceObject(game).getIdName() + " -> "
|
||||
+ (a.toString().startsWith("Cast ") ? "[" + a.getManaCostsToPay().getText() + "] -> " : "") // printed cost, not modified
|
||||
+ (a.toString().length() > 0
|
||||
? a.toString().substring(0, Math.min(20, a.toString().length()))
|
||||
: a.getClass().getSimpleName())
|
||||
+ "..."))
|
||||
.sorted()
|
||||
.collect(Collectors.toList());
|
||||
|
||||
|
|
@ -1562,7 +1568,7 @@ public class TestPlayer implements Player {
|
|||
UUID defenderId = null;
|
||||
boolean mustAttackByAction = false;
|
||||
boolean madeAttackByAction = false;
|
||||
for (Iterator<org.mage.test.player.PlayerAction> it = actions.iterator(); it.hasNext();) {
|
||||
for (Iterator<org.mage.test.player.PlayerAction> it = actions.iterator(); it.hasNext(); ) {
|
||||
PlayerAction action = it.next();
|
||||
|
||||
// aiXXX commands
|
||||
|
|
@ -2153,7 +2159,7 @@ public class TestPlayer implements Player {
|
|||
// skip targets
|
||||
if (targets.get(0).equals(TARGET_SKIP)) {
|
||||
Assert.assertTrue("found skip target, but it require more targets, needs "
|
||||
+ (target.getMinNumberOfTargets() - target.getTargets().size()) + " more",
|
||||
+ (target.getMinNumberOfTargets() - target.getTargets().size()) + " more",
|
||||
target.getTargets().size() >= target.getMinNumberOfTargets());
|
||||
targets.remove(0);
|
||||
return true;
|
||||
|
|
@ -2464,7 +2470,7 @@ public class TestPlayer implements Player {
|
|||
|
||||
this.chooseStrictModeFailed("choice", game,
|
||||
"Triggered list (total " + abilities.size() + "):\n"
|
||||
+ abilities.stream().map(a -> getInfo(a, game)).collect(Collectors.joining("\n")));
|
||||
+ abilities.stream().map(a -> getInfo(a, game)).collect(Collectors.joining("\n")));
|
||||
return computerPlayer.chooseTriggeredAbility(abilities, game);
|
||||
}
|
||||
|
||||
|
|
@ -3713,7 +3719,7 @@ public class TestPlayer implements Player {
|
|||
// skip targets
|
||||
if (targets.get(0).equals(TARGET_SKIP)) {
|
||||
Assert.assertTrue("found skip target, but it require more targets, needs "
|
||||
+ (target.getMinNumberOfTargets() - target.getTargets().size()) + " more",
|
||||
+ (target.getMinNumberOfTargets() - target.getTargets().size()) + " more",
|
||||
target.getTargets().size() >= target.getMinNumberOfTargets());
|
||||
targets.remove(0);
|
||||
return false; // false in chooseTargetAmount = stop to choose
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue