mirror of
https://github.com/correl/mage.git
synced 2024-11-25 03:00:11 +00:00
Tests: improved performance
This commit is contained in:
parent
49308bcd4f
commit
b9db36eb22
2 changed files with 11 additions and 16 deletions
|
@ -150,7 +150,7 @@ public abstract class CardTestPlayerAPIImpl extends MageTestPlayerBase implement
|
||||||
public CardTestPlayerAPIImpl() {
|
public CardTestPlayerAPIImpl() {
|
||||||
// load all cards to db from class list
|
// load all cards to db from class list
|
||||||
ArrayList<String> errorsList = new ArrayList<>();
|
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.scanned = true;
|
||||||
}
|
}
|
||||||
CardScanner.scan(errorsList);
|
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());
|
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) {
|
if (gameZone == Zone.BATTLEFIELD) {
|
||||||
for (int i = 0; i < count; i++) {
|
for (int i = 0; i < count; i++) {
|
||||||
CardInfo cardInfo = CardRepository.instance.findCard(cardName);
|
Card newCard = cardInfo.getCard();
|
||||||
Card newCard = cardInfo != null ? cardInfo.getCard() : null;
|
|
||||||
if (newCard == null) {
|
|
||||||
throw new IllegalArgumentException("[TEST] Couldn't find a card: " + cardName);
|
|
||||||
}
|
|
||||||
|
|
||||||
Card permCard = CardUtil.getDefaultCardSideForBattlefield(newCard);
|
Card permCard = CardUtil.getDefaultCardSideForBattlefield(newCard);
|
||||||
|
|
||||||
PermanentCard p = new PermanentCard(permCard, player.getId(), currentGame);
|
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);
|
List<Card> cards = getCardList(gameZone, player);
|
||||||
for (int i = 0; i < count; i++) {
|
for (int i = 0; i < count; i++) {
|
||||||
CardInfo cardInfo = CardRepository.instance.findCard(cardName);
|
Card newCard = cardInfo.getCard();
|
||||||
Card card = cardInfo != null ? cardInfo.getCard() : null;
|
cards.add(newCard);
|
||||||
if (card == null) {
|
|
||||||
throw new AssertionError("Couldn't find a card in db: " + cardName);
|
|
||||||
}
|
|
||||||
cards.add(card);
|
|
||||||
|
|
||||||
if (!aliasName.isEmpty()) {
|
if (!aliasName.isEmpty()) {
|
||||||
player.addAlias(player.generateAliasName(aliasName, useAliasMultiNames, i + 1), card.getId());
|
player.addAlias(player.generateAliasName(aliasName, useAliasMultiNames, i + 1), newCard.getId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -127,7 +127,7 @@ public class Modes extends LinkedHashMap<UUID, Mode> {
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<UUID> getSelectedModes() {
|
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<>();
|
List<UUID> res = new ArrayList<>();
|
||||||
for (Mode mode : this.values()) {
|
for (Mode mode : this.values()) {
|
||||||
for (UUID selectedId : this.selectedModes) {
|
for (UUID selectedId : this.selectedModes) {
|
||||||
|
|
Loading…
Reference in a new issue