mirror of
https://github.com/magefree/mage.git
synced 2025-12-22 19:41:59 -08:00
TestPlayer fixed that target events created by RestPlayer are reset back if ability activation failed.
This commit is contained in:
parent
d10e63bea4
commit
f6ec543b1b
2 changed files with 9 additions and 4 deletions
|
|
@ -370,6 +370,7 @@ public class TestPlayer implements Player {
|
||||||
}
|
}
|
||||||
for (Ability ability : computerPlayer.getPlayable(game, true)) {
|
for (Ability ability : computerPlayer.getPlayable(game, true)) {
|
||||||
if (ability.toString().startsWith(groups[0])) {
|
if (ability.toString().startsWith(groups[0])) {
|
||||||
|
int bookmark = game.bookmarkState();
|
||||||
Ability newAbility = ability.copy();
|
Ability newAbility = ability.copy();
|
||||||
if (groups.length > 1 && !groups[1].equals("target=NO_TARGET")) {
|
if (groups.length > 1 && !groups[1].equals("target=NO_TARGET")) {
|
||||||
if (!addTargets(newAbility, groups, game)) {
|
if (!addTargets(newAbility, groups, game)) {
|
||||||
|
|
@ -377,9 +378,13 @@ public class TestPlayer implements Player {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
computerPlayer.activateAbility((ActivatedAbility) newAbility, game);
|
if (computerPlayer.activateAbility((ActivatedAbility) newAbility, game)) {
|
||||||
actions.remove(action);
|
actions.remove(action);
|
||||||
return true;
|
return true;
|
||||||
|
} else {
|
||||||
|
game.restoreState(bookmark, ability.getRule());
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (action.getAction().startsWith("manaActivate:")) {
|
} else if (action.getAction().startsWith("manaActivate:")) {
|
||||||
|
|
|
||||||
|
|
@ -1105,7 +1105,7 @@ public abstract class PlayerImpl implements Player, Serializable {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void restoreState(int bookmark, String text, Game game) {
|
protected void restoreState(int bookmark, String text, Game game) {
|
||||||
game.restoreState(bookmark, text);
|
game.restoreState(bookmark, text);
|
||||||
if (storedBookmark >= bookmark) {
|
if (storedBookmark >= bookmark) {
|
||||||
resetStoredBookmark(game);
|
resetStoredBookmark(game);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue