* Momir format - Fixed that AI turn calculation caused H2 DB errors (fixes #7014).

This commit is contained in:
LevelX2 2020-12-28 15:11:39 +01:00
parent 482712200a
commit dbea1e35eb

View file

@ -22,6 +22,8 @@ import mage.util.CardUtil;
import mage.util.RandomUtil; import mage.util.RandomUtil;
import java.util.List; import java.util.List;
import mage.game.permanent.token.Token;
import mage.game.permanent.token.custom.CreatureToken;
/** /**
* @author spjspj * @author spjspj
@ -61,7 +63,12 @@ class MomirEffect extends OneShotEffect {
@Override @Override
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
int value = source.getManaCostsToPay().getX(); int value = source.getManaCostsToPay().getX();
if (game.isSimulation()) {
// Create dummy token to prevent multiple DB find cards what causes H2 java.lang.IllegalStateException if AI cancels calculation because of time out
Token token = new CreatureToken(value, value +1);
token.putOntoBattlefield(1, game, source, source.getControllerId(), false, false);
return true;
}
// should this be random across card names // should this be random across card names
CardCriteria criteria = new CardCriteria().types(CardType.CREATURE).convertedManaCost(value); CardCriteria criteria = new CardCriteria().types(CardType.CREATURE).convertedManaCost(value);
List<CardInfo> options = CardRepository.instance.findCards(criteria); List<CardInfo> options = CardRepository.instance.findCards(criteria);