mirror of
https://github.com/magefree/mage.git
synced 2025-12-30 15:32:08 -08:00
Additional fix and simplified for playable abilities (see comments b94344341b)
This commit is contained in:
parent
bd40d90286
commit
cce467a5ec
13 changed files with 142 additions and 137 deletions
|
|
@ -37,7 +37,7 @@ public class CastSplitCardsWithFlashbackTest extends CardTestPlayerBase {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void test_Flashback_Split() {
|
||||
public void test_Flashback_SplitLeft() {
|
||||
// {1}{U}
|
||||
// When Snapcaster Mage enters the battlefield, target instant or sorcery card in your graveyard gains flashback until end of turn.
|
||||
addCard(Zone.HAND, playerA, "Snapcaster Mage", 1);
|
||||
|
|
@ -67,4 +67,36 @@ public class CastSplitCardsWithFlashbackTest extends CardTestPlayerBase {
|
|||
assertGraveyardCount(playerB, "Bident of Thassa", 1);
|
||||
assertPermanentCount(playerB, "Bow of Nylea", 1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_Flashback_SplitRight() {
|
||||
// {1}{U}
|
||||
// When Snapcaster Mage enters the battlefield, target instant or sorcery card in your graveyard gains flashback until end of turn.
|
||||
addCard(Zone.HAND, playerA, "Snapcaster Mage", 1);
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Island", 2);
|
||||
//
|
||||
// Wear {1}{R} Destroy target artifact.
|
||||
// Tear {W} Destroy target enchantment.
|
||||
addCard(Zone.GRAVEYARD, playerA, "Wear // Tear", 1);
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Mountain", 2);
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Plains", 2);
|
||||
addCard(Zone.BATTLEFIELD, playerB, "Bident of Thassa", 1); // Legendary Enchantment Artifact
|
||||
addCard(Zone.BATTLEFIELD, playerB, "Bow of Nylea", 1); // Legendary Enchantment Artifact
|
||||
|
||||
// add flashback
|
||||
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Snapcaster Mage");
|
||||
addTarget(playerA, "Wear // Tear");
|
||||
|
||||
// cast as flashback
|
||||
waitStackResolved(1, PhaseStep.PRECOMBAT_MAIN);
|
||||
activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Flashback {W}", "Bident of Thassa");
|
||||
|
||||
setStrictChooseMode(true);
|
||||
setStopAt(1, PhaseStep.BEGIN_COMBAT);
|
||||
execute();
|
||||
assertAllCommandsUsed();
|
||||
|
||||
assertGraveyardCount(playerB, "Bident of Thassa", 1);
|
||||
assertPermanentCount(playerB, "Bow of Nylea", 1);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -73,7 +73,7 @@ public class RandomPlayer extends ComputerPlayer {
|
|||
}
|
||||
|
||||
private Ability getAction(Game game) {
|
||||
List<Ability> playables = getPlayableAbilities(game);
|
||||
List<ActivatedAbility> playables = getPlayableAbilities(game);
|
||||
Ability ability;
|
||||
while (true) {
|
||||
if (playables.size() == 1) {
|
||||
|
|
@ -115,8 +115,8 @@ public class RandomPlayer extends ComputerPlayer {
|
|||
return ability;
|
||||
}
|
||||
|
||||
protected List<Ability> getPlayableAbilities(Game game) {
|
||||
List<Ability> playables = getPlayable(game, true);
|
||||
protected List<ActivatedAbility> getPlayableAbilities(Game game) {
|
||||
List<ActivatedAbility> playables = getPlayable(game, true);
|
||||
playables.add(pass);
|
||||
return playables;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -587,14 +587,14 @@ public class TestPlayer implements Player {
|
|||
if (groups.length > 2 && !checkExecuteCondition(groups, game)) {
|
||||
break;
|
||||
}
|
||||
for (Ability ability : computerPlayer.getPlayable(game, true)) { // add wrong action log?
|
||||
for (ActivatedAbility ability : computerPlayer.getPlayable(game, true)) { // add wrong action log?
|
||||
if (isAbilityHaveTargetNameOrAlias(game, ability, groups[0])) {
|
||||
int bookmark = game.bookmarkState();
|
||||
Ability newAbility = ability.copy();
|
||||
ActivatedAbility newAbility = ability.copy();
|
||||
if (groups.length > 1 && !groups[1].equals("target=" + NO_TARGET)) {
|
||||
groupsForTargetHandling = groups;
|
||||
}
|
||||
if (computerPlayer.activateAbility((ActivatedAbility) newAbility, game)) {
|
||||
if (computerPlayer.activateAbility(newAbility, game)) {
|
||||
actions.remove(action);
|
||||
groupsForTargetHandling = null;
|
||||
foundNoAction = 0; // Reset enless loop check because of no action
|
||||
|
|
@ -1078,7 +1078,7 @@ public class TestPlayer implements Player {
|
|||
});
|
||||
}
|
||||
|
||||
private void printAbilities(Game game, List<Ability> abilities) {
|
||||
private void printAbilities(Game game, List<? extends Ability> abilities) {
|
||||
System.out.println("Total abilities: " + (abilities != null ? abilities.size() : 0));
|
||||
if (abilities == null) {
|
||||
return;
|
||||
|
|
@ -1714,6 +1714,8 @@ public class TestPlayer implements Player {
|
|||
private void chooseStrictModeFailed(String choiceType, Game game, String reason, boolean printAbilities) {
|
||||
if (strictChooseMode && !AICanChooseInStrictMode) {
|
||||
if (printAbilities) {
|
||||
printStart("Available mana for " + computerPlayer.getName());
|
||||
printMana(game, computerPlayer.getManaAvailable(game));
|
||||
printStart("Available abilities for " + computerPlayer.getName());
|
||||
printAbilities(game, computerPlayer.getPlayable(game, true));
|
||||
printEnd();
|
||||
|
|
@ -2712,8 +2714,8 @@ public class TestPlayer implements Player {
|
|||
}
|
||||
|
||||
@Override
|
||||
public LinkedHashMap<UUID, ActivatedAbility> getUseableActivatedAbilities(MageObject object, Zone zone, Game game) {
|
||||
return computerPlayer.getUseableActivatedAbilities(object, zone, game);
|
||||
public LinkedHashMap<UUID, ActivatedAbility> getPlayableActivatedAbilities(MageObject object, Zone zone, Game game) {
|
||||
return computerPlayer.getPlayableActivatedAbilities(object, zone, game);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -3171,12 +3173,8 @@ public class TestPlayer implements Player {
|
|||
return computerPlayer.getManaAvailable(game);
|
||||
}
|
||||
|
||||
public List<Permanent> getAvailableManaProducersWithCost(Game game) {
|
||||
return computerPlayer.getAvailableManaProducersWithCost(game);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Ability> getPlayable(Game game, boolean hidden) {
|
||||
public List<ActivatedAbility> getPlayable(Game game, boolean hidden) {
|
||||
return computerPlayer.getPlayable(game, hidden);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1023,7 +1023,7 @@ public class PlayerStub implements Player {
|
|||
}
|
||||
|
||||
@Override
|
||||
public List<Ability> getPlayable(Game game, boolean hidden) {
|
||||
public List<ActivatedAbility> getPlayable(Game game, boolean hidden) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
@ -1038,7 +1038,7 @@ public class PlayerStub implements Player {
|
|||
}
|
||||
|
||||
@Override
|
||||
public LinkedHashMap<UUID, ActivatedAbility> getUseableActivatedAbilities(MageObject object, Zone zone, Game game) {
|
||||
public LinkedHashMap<UUID, ActivatedAbility> getPlayableActivatedAbilities(MageObject object, Zone zone, Game game) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue