* AI: fixed game freezes with Karn Liberated in the game (#7922);

This commit is contained in:
Oleg Agafonov 2021-07-02 15:03:06 +04:00
parent d9e414db34
commit b929b28e43
7 changed files with 192 additions and 59 deletions

View file

@ -193,6 +193,45 @@ public class GameState implements Serializable, Copyable<GameState> {
this.commandersToStay.addAll(state.commandersToStay);
}
public void clearOnGameRestart() {
// special code for Karn Liberated
// must clear game data on restart, but also must keep some info (wtf, why?)
// if you catch freezes or bugs with Karn then research here
// test example: testCommanderRestoredToBattlefieldAfterKarnUltimate
// TODO: must be implemented as full data clear?
battlefield.clear();
effects.clear();
triggers.clear();
delayed.clear();
triggered.clear();
stack.clear();
exile.clear();
command.clear();
designations.clear();
seenPlanes.clear();
isPlaneChase = false;
revealed.clear();
lookedAt.clear();
companion.clear();
turnNum = 1;
stepNum = 0;
extraTurn = false;
legendaryRuleActive = true;
gameOver = false;
specialActions.clear();
cardState.clear();
combat.clear();
turnMods.clear();
watchers.clear();
values.clear();
zones.clear();
simultaneousEvents.clear();
copiedCards.clear();
usePowerInsteadOfToughnessForDamageLethalityFilters.clear();
permanentOrderNumber = 0;
}
public void restoreForRollBack(GameState state) {
restore(state);
this.turn = state.turn;
@ -1124,7 +1163,7 @@ public class GameState implements Serializable, Copyable<GameState> {
if (attachedTo instanceof PermanentCard) {
throw new IllegalArgumentException("Error, wrong code usage. If you want to add new ability to the "
+ "permanent then use a permanent.addAbility(a, source, game): "
+ ability.getClass().getCanonicalName() + " - " + ability.toString());
+ ability.getClass().getCanonicalName() + " - " + ability);
}
}
@ -1153,39 +1192,6 @@ public class GameState implements Serializable, Copyable<GameState> {
this.setManaBurn(false);
}
public void clear() {
battlefield.clear();
effects.clear();
triggers.clear();
delayed.clear();
triggered.clear();
stack.clear();
exile.clear();
command.clear();
designations.clear();
seenPlanes.clear();
isPlaneChase = false;
revealed.clear();
lookedAt.clear();
companion.clear();
turnNum = 0;
stepNum = 0;
extraTurn = false;
legendaryRuleActive = true;
gameOver = false;
specialActions.clear();
cardState.clear();
combat.clear();
turnMods.clear();
watchers.clear();
values.clear();
zones.clear();
simultaneousEvents.clear();
copiedCards.clear();
usePowerInsteadOfToughnessForDamageLethalityFilters.clear();
permanentOrderNumber = 0;
}
public void pause() {
this.paused = true;
}