TestPlayer fixed that target events created by RestPlayer are reset back if ability activation failed.

This commit is contained in:
LevelX2 2015-10-03 18:20:59 +02:00
parent d10e63bea4
commit f6ec543b1b
2 changed files with 9 additions and 4 deletions

View file

@ -370,6 +370,7 @@ public class TestPlayer implements Player {
}
for (Ability ability : computerPlayer.getPlayable(game, true)) {
if (ability.toString().startsWith(groups[0])) {
int bookmark = game.bookmarkState();
Ability newAbility = ability.copy();
if (groups.length > 1 && !groups[1].equals("target=NO_TARGET")) {
if (!addTargets(newAbility, groups, game)) {
@ -377,9 +378,13 @@ public class TestPlayer implements Player {
break;
}
}
computerPlayer.activateAbility((ActivatedAbility) newAbility, game);
actions.remove(action);
return true;
if (computerPlayer.activateAbility((ActivatedAbility) newAbility, game)) {
actions.remove(action);
return true;
} else {
game.restoreState(bookmark, ability.getRule());
}
}
}
} else if (action.getAction().startsWith("manaActivate:")) {

View file

@ -1105,7 +1105,7 @@ public abstract class PlayerImpl implements Player, Serializable {
return false;
}
private void restoreState(int bookmark, String text, Game game) {
protected void restoreState(int bookmark, String text, Game game) {
game.restoreState(bookmark, text);
if (storedBookmark >= bookmark) {
resetStoredBookmark(game);