mirror of
https://github.com/correl/mage.git
synced 2024-11-15 19:19:33 +00:00
Merge pull request #3153 from spjspj/master
Increased performance function for finding a card in DB with a specif…
This commit is contained in:
commit
0c6c81e58b
3 changed files with 20 additions and 6 deletions
|
@ -49,7 +49,7 @@ public class CubeFromDeck extends DraftCube {
|
|||
|
||||
if (cards != null) {
|
||||
for (DeckCardInfo card : cards.getCards()) {
|
||||
cubeCards.add(new CardIdentity(card.getCardName(), ""));
|
||||
cubeCards.add(new CardIdentity(card.getCardName(), card.getSetCode()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -419,6 +419,24 @@ public enum CardRepository {
|
|||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public CardInfo findCardWPreferredSet(String name, String expansion, boolean caseInsensitive) {
|
||||
List<CardInfo> cards;
|
||||
if (caseInsensitive) {
|
||||
cards = findCardsCaseInsensitive(name);
|
||||
} else {
|
||||
cards = findCards(name);
|
||||
}
|
||||
if (!cards.isEmpty()) {
|
||||
CardInfo cardToUse = null;
|
||||
for (CardInfo cardinfo : cards) {
|
||||
if (cardinfo.getSetCode() != null && expansion != null && expansion.equalsIgnoreCase(cardinfo.getSetCode())) {
|
||||
return cardinfo;
|
||||
}
|
||||
}
|
||||
}
|
||||
return findPreferedCoreExpansionCard(name, true);
|
||||
}
|
||||
|
||||
public List<CardInfo> findCards(String name) {
|
||||
try {
|
||||
|
|
|
@ -107,11 +107,7 @@ public abstract class DraftCube {
|
|||
if (!cardId.getName().isEmpty()) {
|
||||
CardInfo cardInfo = null;
|
||||
if (!cardId.getExtension().isEmpty()) {
|
||||
CardCriteria criteria = new CardCriteria().name(cardId.getName()).setCodes(cardId.extension);
|
||||
List<CardInfo> cardList = CardRepository.instance.findCards(criteria);
|
||||
if (cardList != null && !cardList.isEmpty()) {
|
||||
cardInfo = cardList.get(0);
|
||||
}
|
||||
cardInfo = CardRepository.instance.findCardWPreferredSet(cardId.getName(), cardId.getExtension(), false);
|
||||
} else {
|
||||
cardInfo = CardRepository.instance.findPreferedCoreExpansionCard(cardId.getName(), false);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue