* Cube Draft/Sealed - Fixed that cards where taken from promo/special sets if they also did exist in Core or Expansion sets.

This commit is contained in:
LevelX2 2015-08-06 15:29:50 +02:00
parent 2ee8fc62a3
commit f6075b32cf
2 changed files with 28 additions and 5 deletions

View file

@ -44,7 +44,10 @@ import java.util.Random;
import java.util.Set;
import java.util.TreeSet;
import java.util.concurrent.Callable;
import mage.cards.ExpansionSet;
import mage.cards.Sets;
import mage.constants.CardType;
import mage.constants.SetType;
import org.apache.log4j.Logger;
/**
@ -297,6 +300,25 @@ public enum CardRepository {
return null;
}
public CardInfo findPreferedCoreExpansionCard(String name) {
List<CardInfo> cards = findCards(name);
if (!cards.isEmpty()) {
CardInfo cardInfo = cards.get(random.nextInt(cards.size()));
ExpansionSet set = Sets.getInstance().get(cardInfo.getSetCode());
if (set.getSetType().equals(SetType.EXPANSION) || set.getSetType().equals(SetType.CORE)) {
return cardInfo;
}
for (CardInfo cardInfoToCheck : cards) {
set = Sets.getInstance().get(cardInfoToCheck.getSetCode());
if (set.getSetType().equals(SetType.CORE) || set.getSetType().equals(SetType.EXPANSION)) {
return cardInfoToCheck;
}
}
return cardInfo;
}
return null;
}
public List<CardInfo> findCards(String name) {
try {
QueryBuilder<CardInfo, Object> queryBuilder = cardDao.queryBuilder();

View file

@ -43,6 +43,7 @@ import org.apache.log4j.Logger;
public abstract class DraftCube {
public class CardIdentity {
private String name;
private String extension;
@ -111,7 +112,7 @@ public abstract class DraftCube {
cardInfo = cardList.get(0);
}
} else {
cardInfo = CardRepository.instance.findCard(cardId.getName());
cardInfo = CardRepository.instance.findPreferedCoreExpansionCard(cardId.getName());
}
if (cardInfo != null) {