Multiplayer test - added option to attack specific player.

This commit is contained in:
LevelX2 2015-06-02 14:58:54 +02:00
parent d5cbc5b87c
commit 3115bbdcb6
2 changed files with 23 additions and 7 deletions

View file

@ -135,7 +135,7 @@ public class TestPlayer extends ComputerPlayer {
if (ability.toString().startsWith(groups[0])) {
Ability newAbility = ability.copy();
if (groups.length > 1 && !groups[1].equals("target=NO_TARGET")) {
if (!addTargets(newAbility, groups, game)) {
if (!addTargets(newAbility, groups, game)) {
// targets could not be set -> try next priority
break;
}
@ -198,12 +198,7 @@ public class TestPlayer extends ComputerPlayer {
UUID defenderId = null;
for (PlayerAction action: actions) {
if (action.getTurnNum() == game.getTurnNum() && action.getAction().startsWith("attack:")) {
for (UUID uuid: game.getCombat().getDefenders()) {
Player defender = game.getPlayer(uuid);
if (defender != null) {
defenderId = uuid;
}
}
String command = action.getAction();
command = command.substring(command.indexOf("attack:") + 7);
String[] groups = command.split("\\$");
@ -217,6 +212,23 @@ public class TestPlayer extends ComputerPlayer {
}
}
}
if (group.startsWith("defendingPlayer=")) {
String defendingPlayerName = group.substring(group.indexOf("defendingPlayer=") + 16);
for (Player defendingPlayer :game.getPlayers().values()) {
if (defendingPlayer.getName().equals(defendingPlayerName)) {
defenderId = defendingPlayer.getId();
break;
}
}
}
}
if (defenderId == null) {
for (UUID uuid: game.getCombat().getDefenders()) {
Player defender = game.getPlayer(uuid);
if (defender != null) {
defenderId = uuid;
}
}
}
FilterCreatureForCombat filter = new FilterCreatureForCombat();
filter.add(new NamePredicate(groups[0]));

View file

@ -955,6 +955,10 @@ public abstract class CardTestPlayerAPIImpl extends MageTestPlayerBase implement
player.addAction(turnNum, PhaseStep.DECLARE_ATTACKERS, "attack:"+attacker);
}
public void attack(int turnNum, TestPlayer player, String attacker, TestPlayer defendingPlayer) {
player.addAction(turnNum, PhaseStep.DECLARE_ATTACKERS, "attack:"+attacker+"$defendingPlayer="+defendingPlayer.getName());
}
public void attack(int turnNum, TestPlayer player, String attacker, String planeswalker) {
player.addAction(turnNum, PhaseStep.DECLARE_ATTACKERS, new StringBuilder("attack:").append(attacker).append("$planeswalker=").append(planeswalker).toString());
}