mirror of
https://github.com/correl/mage.git
synced 2024-12-26 03:00:11 +00:00
* 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:
parent
2ee8fc62a3
commit
f6075b32cf
2 changed files with 28 additions and 5 deletions
|
@ -44,7 +44,10 @@ import java.util.Random;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.TreeSet;
|
import java.util.TreeSet;
|
||||||
import java.util.concurrent.Callable;
|
import java.util.concurrent.Callable;
|
||||||
|
import mage.cards.ExpansionSet;
|
||||||
|
import mage.cards.Sets;
|
||||||
import mage.constants.CardType;
|
import mage.constants.CardType;
|
||||||
|
import mage.constants.SetType;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -297,6 +300,25 @@ public enum CardRepository {
|
||||||
return null;
|
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) {
|
public List<CardInfo> findCards(String name) {
|
||||||
try {
|
try {
|
||||||
QueryBuilder<CardInfo, Object> queryBuilder = cardDao.queryBuilder();
|
QueryBuilder<CardInfo, Object> queryBuilder = cardDao.queryBuilder();
|
||||||
|
|
|
@ -43,6 +43,7 @@ import org.apache.log4j.Logger;
|
||||||
public abstract class DraftCube {
|
public abstract class DraftCube {
|
||||||
|
|
||||||
public class CardIdentity {
|
public class CardIdentity {
|
||||||
|
|
||||||
private String name;
|
private String name;
|
||||||
private String extension;
|
private String extension;
|
||||||
|
|
||||||
|
@ -111,7 +112,7 @@ public abstract class DraftCube {
|
||||||
cardInfo = cardList.get(0);
|
cardInfo = cardList.get(0);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
cardInfo = CardRepository.instance.findCard(cardId.getName());
|
cardInfo = CardRepository.instance.findPreferedCoreExpansionCard(cardId.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cardInfo != null) {
|
if (cardInfo != null) {
|
||||||
|
|
Loading…
Reference in a new issue