mirror of
https://github.com/correl/mage.git
synced 2024-12-25 03:00:15 +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.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();
|
||||
|
|
|
@ -43,6 +43,7 @@ import org.apache.log4j.Logger;
|
|||
public abstract class DraftCube {
|
||||
|
||||
public class CardIdentity {
|
||||
|
||||
private String name;
|
||||
private String extension;
|
||||
|
||||
|
@ -69,7 +70,7 @@ public abstract class DraftCube {
|
|||
}
|
||||
|
||||
private static final Logger logger = Logger.getLogger(DraftCube.class);
|
||||
|
||||
|
||||
private static final Random rnd = new Random();
|
||||
private final String name;
|
||||
private final int boosterSize = 15;
|
||||
|
@ -88,13 +89,13 @@ public abstract class DraftCube {
|
|||
public List<CardIdentity> getCubeCards() {
|
||||
return cubeCards;
|
||||
}
|
||||
|
||||
|
||||
public List<Card> createBooster() {
|
||||
List<Card> booster = new ArrayList<>();
|
||||
if (leftCubeCards.isEmpty()) {
|
||||
leftCubeCards.addAll(cubeCards);
|
||||
}
|
||||
|
||||
|
||||
for (int i = 0; i < boosterSize; i++) {
|
||||
boolean done = false;
|
||||
int notValid = 0;
|
||||
|
@ -111,9 +112,9 @@ public abstract class DraftCube {
|
|||
cardInfo = cardList.get(0);
|
||||
}
|
||||
} else {
|
||||
cardInfo = CardRepository.instance.findCard(cardId.getName());
|
||||
cardInfo = CardRepository.instance.findPreferedCoreExpansionCard(cardId.getName());
|
||||
}
|
||||
|
||||
|
||||
if (cardInfo != null) {
|
||||
booster.add(cardInfo.getCard());
|
||||
done = true;
|
||||
|
|
Loading…
Reference in a new issue