wrap out of bounds exception in game exception to show game context

master
melvinzhang 2016-01-07 12:03:06 +08:00
parent c4efbb9def
commit 0516c5e87b
1 changed files with 6 additions and 1 deletions

View File

@ -7,6 +7,7 @@ import magic.model.MagicGameLog;
import magic.model.MagicPlayer;
import magic.model.choice.MagicBuilderPayManaCostResult;
import magic.model.event.MagicEvent;
import magic.exception.GameException;
import java.util.ArrayList;
import java.util.Collections;
@ -412,7 +413,11 @@ public class MCTSAI implements MagicAI {
curr = next;
//update the game state and path
game.executeNextEvent(choices.get(curr.getChoice()));
try {
game.executeNextEvent(choices.get(curr.getChoice()));
} catch (final IndexOutOfBoundsException ex) {
throw new GameException(ex, game);
}
path.add(curr);
}
}