1
0
Fork 0
mirror of https://github.com/correl/mage.git synced 2025-04-04 01:06:04 -09:00

Increased performance function for finding a card in DB with a specific set. Cube from deck (custom cube) now respects chosen set for a given card.

This commit is contained in:
spjspj 2017-04-18 20:58:03 +10:00
parent d55c82adf4
commit 8c46f23e02
3 changed files with 20 additions and 6 deletions
Mage.Server.Plugins/Mage.Tournament.BoosterDraft/src/mage/tournament/cubes
Mage/src/main/java/mage
cards/repository
game/draft

View file

@ -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()));
}
}
}

View file

@ -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 {

View file

@ -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);
}