mirror of
https://github.com/correl/mage.git
synced 2024-12-25 11:11:16 +00:00
Test framework: added aliases support for activated abilities (related to #7036);
This commit is contained in:
parent
7a1795660a
commit
535e49b89f
5 changed files with 22 additions and 13 deletions
|
@ -33,9 +33,9 @@ public class LightningStormTest extends CardTestPlayerBase {
|
||||||
|
|
||||||
// B discard and re-target
|
// B discard and re-target
|
||||||
activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerB, "Discard");
|
activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerB, "Discard");
|
||||||
setChoice(playerB, "Mountain");
|
setChoice(playerB, "Yes"); // change target
|
||||||
setChoice(playerB, "Yes");
|
addTarget(playerB, playerA); // new target
|
||||||
addTarget(playerB, playerA);
|
setChoice(playerB, "Mountain"); // discard cost
|
||||||
|
|
||||||
// A discard and re-target
|
// A discard and re-target
|
||||||
activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Discard");
|
activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Discard");
|
||||||
|
|
|
@ -578,7 +578,8 @@ public class TestPlayer implements Player {
|
||||||
if (groups.length > 2 && !checkExecuteCondition(groups, game)) {
|
if (groups.length > 2 && !checkExecuteCondition(groups, game)) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
for (ActivatedAbility ability : computerPlayer.getPlayable(game, true)) { // add wrong action log?
|
// must process all duplicated abilities (aliases need objects to search)
|
||||||
|
for (ActivatedAbility ability : computerPlayer.getPlayable(game, true, Zone.ALL, false)) { // add wrong action log?
|
||||||
if (hasAbilityTargetNameOrAlias(game, ability, groups[0])) {
|
if (hasAbilityTargetNameOrAlias(game, ability, groups[0])) {
|
||||||
int bookmark = game.bookmarkState();
|
int bookmark = game.bookmarkState();
|
||||||
ActivatedAbility newAbility = ability.copy();
|
ActivatedAbility newAbility = ability.copy();
|
||||||
|
|
|
@ -1728,19 +1728,19 @@ public abstract class CardTestPlayerAPIImpl extends MageTestPlayerBase implement
|
||||||
|
|
||||||
public void activateAbility(int turnNum, PhaseStep step, TestPlayer player, String ability) {
|
public void activateAbility(int turnNum, PhaseStep step, TestPlayer player, String ability) {
|
||||||
// TODO: it's uses computerPlayer to execute, only ability target will work, but choices and targets commands aren't
|
// TODO: it's uses computerPlayer to execute, only ability target will work, but choices and targets commands aren't
|
||||||
assertAliaseSupportInActivateCommand(ability, false);
|
assertAliaseSupportInActivateCommand(ability, true);
|
||||||
addPlayerAction(player, turnNum, step, ACTIVATE_ABILITY + ability);
|
addPlayerAction(player, turnNum, step, ACTIVATE_ABILITY + ability);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void activateAbility(int turnNum, PhaseStep step, TestPlayer player, String ability, Player target) {
|
public void activateAbility(int turnNum, PhaseStep step, TestPlayer player, String ability, Player target) {
|
||||||
// TODO: it's uses computerPlayer to execute, only ability target will work, but choices and targets commands aren't
|
// TODO: it's uses computerPlayer to execute, only ability target will work, but choices and targets commands aren't
|
||||||
assertAliaseSupportInActivateCommand(ability, false);
|
assertAliaseSupportInActivateCommand(ability, true);
|
||||||
addPlayerAction(player, turnNum, step, ACTIVATE_ABILITY + ability + "$targetPlayer=" + target.getName());
|
addPlayerAction(player, turnNum, step, ACTIVATE_ABILITY + ability + "$targetPlayer=" + target.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void activateAbility(int turnNum, PhaseStep step, TestPlayer player, String ability, String... targetNames) {
|
public void activateAbility(int turnNum, PhaseStep step, TestPlayer player, String ability, String... targetNames) {
|
||||||
// TODO: it's uses computerPlayer to execute, only ability target will work, but choices and targets commands aren't
|
// TODO: it's uses computerPlayer to execute, only ability target will work, but choices and targets commands aren't
|
||||||
assertAliaseSupportInActivateCommand(ability, false);
|
assertAliaseSupportInActivateCommand(ability, true);
|
||||||
Arrays.stream(targetNames).forEach(n -> {
|
Arrays.stream(targetNames).forEach(n -> {
|
||||||
assertAliaseSupportInActivateCommand(n, true);
|
assertAliaseSupportInActivateCommand(n, true);
|
||||||
});
|
});
|
||||||
|
@ -1771,8 +1771,8 @@ public abstract class CardTestPlayerAPIImpl extends MageTestPlayerBase implement
|
||||||
* @param clause
|
* @param clause
|
||||||
*/
|
*/
|
||||||
public void activateAbility(int turnNum, PhaseStep step, TestPlayer player, String ability, String targetName, String spellOnStack, StackClause clause) {
|
public void activateAbility(int turnNum, PhaseStep step, TestPlayer player, String ability, String targetName, String spellOnStack, StackClause clause) {
|
||||||
assertAliaseSupportInActivateCommand(ability, false);
|
assertAliaseSupportInActivateCommand(ability, true);
|
||||||
assertAliaseSupportInActivateCommand(targetName, false);
|
assertAliaseSupportInActivateCommand(targetName, true);
|
||||||
StringBuilder sb = new StringBuilder(ACTIVATE_ABILITY).append(ability);
|
StringBuilder sb = new StringBuilder(ACTIVATE_ABILITY).append(ability);
|
||||||
if (targetName != null && !targetName.isEmpty()) {
|
if (targetName != null && !targetName.isEmpty()) {
|
||||||
sb.append("$target=").append(targetName);
|
sb.append("$target=").append(targetName);
|
||||||
|
|
|
@ -205,12 +205,14 @@ public class TestAliases extends CardTestPlayerBase {
|
||||||
@Test
|
@Test
|
||||||
public void test_ActivateAbility_Alias() {
|
public void test_ActivateAbility_Alias() {
|
||||||
// {T}: Embermage Goblin deals 1 damage to any target.
|
// {T}: Embermage Goblin deals 1 damage to any target.
|
||||||
addCard(Zone.BATTLEFIELD, playerA, "Embermage Goblin@goblin", 2);
|
addCard(Zone.BATTLEFIELD, playerA, "Embermage Goblin@goblin", 3);
|
||||||
addCard(Zone.BATTLEFIELD, playerA, "Silvercoat Lion@lion", 1);
|
addCard(Zone.BATTLEFIELD, playerA, "Silvercoat Lion@lion", 1);
|
||||||
|
|
||||||
|
// use 2 of 3 goblins
|
||||||
showAvailableAbilities("before", 1, PhaseStep.PRECOMBAT_MAIN, playerA);
|
showAvailableAbilities("before", 1, PhaseStep.PRECOMBAT_MAIN, playerA);
|
||||||
activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}: {this} deals", "@lion");
|
showAliases("before", 1, PhaseStep.PRECOMBAT_MAIN, playerA);
|
||||||
activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}: {this} deals", "@lion");
|
activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "@goblin.1 {T}: {this} deals", "@lion");
|
||||||
|
activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "@goblin.3 {T}: {this} deals", "@lion");
|
||||||
|
|
||||||
setStopAt(1, PhaseStep.END_TURN);
|
setStopAt(1, PhaseStep.END_TURN);
|
||||||
execute();
|
execute();
|
||||||
|
@ -218,7 +220,11 @@ public class TestAliases extends CardTestPlayerBase {
|
||||||
|
|
||||||
assertPermanentCount(playerA, "@goblin.1", 1);
|
assertPermanentCount(playerA, "@goblin.1", 1);
|
||||||
assertPermanentCount(playerA, "@goblin.2", 1);
|
assertPermanentCount(playerA, "@goblin.2", 1);
|
||||||
|
assertPermanentCount(playerA, "@goblin.3", 1);
|
||||||
assertGraveyardCount(playerA, "@lion", 1);
|
assertGraveyardCount(playerA, "@lion", 1);
|
||||||
|
assertTapped("@goblin.1", true);
|
||||||
|
assertTapped("@goblin.2", false);
|
||||||
|
assertTapped("@goblin.3", true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -3390,8 +3390,10 @@ public abstract class PlayerImpl implements Player, Serializable {
|
||||||
getPlayableFromObjectSingle(game, fromZone, adventureCard, adventureCard.getSharedAbilities(game), availableMana, output);
|
getPlayableFromObjectSingle(game, fromZone, adventureCard, adventureCard.getSharedAbilities(game), availableMana, output);
|
||||||
} else if (object instanceof Card) {
|
} else if (object instanceof Card) {
|
||||||
getPlayableFromObjectSingle(game, fromZone, object, ((Card) object).getAbilities(game), availableMana, output);
|
getPlayableFromObjectSingle(game, fromZone, object, ((Card) object).getAbilities(game), availableMana, output);
|
||||||
|
} else if (object instanceof StackObject) {
|
||||||
|
// spells on stack are processing by Card above, other stack objects must be ignored
|
||||||
} else {
|
} else {
|
||||||
// other things like StackObject or CommandObject
|
// other things like CommandObject
|
||||||
getPlayableFromObjectSingle(game, fromZone, object, object.getAbilities(), availableMana, output);
|
getPlayableFromObjectSingle(game, fromZone, object, object.getAbilities(), availableMana, output);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue