Tests: improved performance

This commit is contained in:
Oleg Agafonov 2021-08-13 09:17:33 +04:00
parent 49308bcd4f
commit b9db36eb22
2 changed files with 11 additions and 16 deletions

View file

@ -150,7 +150,7 @@ public abstract class CardTestPlayerAPIImpl extends MageTestPlayerBase implement
public CardTestPlayerAPIImpl() {
// load all cards to db from class list
ArrayList<String> errorsList = new ArrayList<>();
if (FAST_SCAN_WITHOUT_DATABASE_CREATE && CardRepository.instance.findCard("Mountain") != null) {
if (FAST_SCAN_WITHOUT_DATABASE_CREATE && CardRepository.instance.findCard("XLN", "272") != null) {
CardScanner.scanned = true;
}
CardScanner.scan(errorsList);
@ -665,14 +665,14 @@ public abstract class CardTestPlayerAPIImpl extends MageTestPlayerBase implement
Assert.fail("Can't add card " + cardName + " - alias " + aliasName + " already exists for " + player.getName());
}
CardInfo cardInfo = CardRepository.instance.findCard(cardName);
if (cardInfo == null) {
throw new IllegalArgumentException("[TEST] Couldn't find a card: " + cardName);
}
if (gameZone == Zone.BATTLEFIELD) {
for (int i = 0; i < count; i++) {
CardInfo cardInfo = CardRepository.instance.findCard(cardName);
Card newCard = cardInfo != null ? cardInfo.getCard() : null;
if (newCard == null) {
throw new IllegalArgumentException("[TEST] Couldn't find a card: " + cardName);
}
Card newCard = cardInfo.getCard();
Card permCard = CardUtil.getDefaultCardSideForBattlefield(newCard);
PermanentCard p = new PermanentCard(permCard, player.getId(), currentGame);
@ -689,15 +689,10 @@ public abstract class CardTestPlayerAPIImpl extends MageTestPlayerBase implement
}
List<Card> cards = getCardList(gameZone, player);
for (int i = 0; i < count; i++) {
CardInfo cardInfo = CardRepository.instance.findCard(cardName);
Card card = cardInfo != null ? cardInfo.getCard() : null;
if (card == null) {
throw new AssertionError("Couldn't find a card in db: " + cardName);
}
cards.add(card);
Card newCard = cardInfo.getCard();
cards.add(newCard);
if (!aliasName.isEmpty()) {
player.addAlias(player.generateAliasName(aliasName, useAliasMultiNames, i + 1), card.getId());
player.addAlias(player.generateAliasName(aliasName, useAliasMultiNames, i + 1), newCard.getId());
}
}
}

View file

@ -127,7 +127,7 @@ public class Modes extends LinkedHashMap<UUID, Mode> {
}
public List<UUID> getSelectedModes() {
// sorted as original modes
// modes can be selected in any order by user, but execution must be in rule's order
List<UUID> res = new ArrayList<>();
for (Mode mode : this.values()) {
for (UUID selectedId : this.selectedModes) {