mirror of
https://github.com/correl/mage.git
synced 2025-03-07 20:53:18 -10:00
fixed issue where second face was considered a card
This commit is contained in:
parent
4c83fd7d6a
commit
a43bc8bed6
4 changed files with 15 additions and 4 deletions
|
@ -236,6 +236,13 @@ public class DownloadPictures extends DefaultBoundedRangeModel implements Runnab
|
|||
url.setSplitCard(card.isSplitCard());
|
||||
|
||||
allCardsUrls.add(url);
|
||||
if (card.isDoubleFaced()) {
|
||||
if (card.getSecondSideName() == null || card.getSecondSideName().trim().isEmpty()) {
|
||||
throw new IllegalStateException("Second side card can't have empty name.");
|
||||
}
|
||||
url = new CardDownloadData(card.getSecondSideName(), card.getSetCode(), card.getCardNumber(), usesVariousArt(card), 0, false, card.isDoubleFaced(), true);
|
||||
allCardsUrls.add(url);
|
||||
}
|
||||
if (card.isFlipCard()) {
|
||||
if (card.getFlipCardName() == null || card.getFlipCardName().trim().isEmpty()) {
|
||||
throw new IllegalStateException("Flipped card can't have empty name.");
|
||||
|
|
|
@ -171,7 +171,8 @@ public class CardCriteria {
|
|||
|
||||
public void buildQuery(QueryBuilder qb) throws SQLException {
|
||||
Where where = qb.where();
|
||||
int clausesCount = 0;
|
||||
where.eq("nightCard", false);
|
||||
int clausesCount = 1;
|
||||
if (name != null) {
|
||||
where.like("name", new SelectArg('%' + name + '%'));
|
||||
clausesCount++;
|
||||
|
|
|
@ -117,7 +117,7 @@ public class CardInfo {
|
|||
this.flipCard = card.isFlipCard();
|
||||
this.flipCardName = card.getFlipCardName();
|
||||
|
||||
this.doubleFaced = card.canTransform();
|
||||
this.doubleFaced = card.canTransform() && card.getSecondCardFace() != null;
|
||||
this.nightCard = card.isNightCard();
|
||||
Card secondSide = card.getSecondCardFace();
|
||||
if (secondSide != null) {
|
||||
|
|
|
@ -54,7 +54,7 @@ public enum CardRepository {
|
|||
|
||||
private static final String JDBC_URL = "jdbc:sqlite:db/cards.db";
|
||||
private static final String VERSION_ENTITY_NAME = "card";
|
||||
private static final long CARD_DB_VERSION = 7;
|
||||
private static final long CARD_DB_VERSION = 8;
|
||||
|
||||
private Random random = new Random();
|
||||
private Dao<CardInfo, Object> cardDao;
|
||||
|
@ -247,7 +247,10 @@ public enum CardRepository {
|
|||
|
||||
public List<CardInfo> getAllCards() {
|
||||
try {
|
||||
return cardDao.queryForAll();
|
||||
QueryBuilder<CardInfo, Object> queryBuilder = cardDao.queryBuilder();
|
||||
queryBuilder.where().eq("nightCard", false);
|
||||
|
||||
return cardDao.query(queryBuilder.prepare());
|
||||
} catch (SQLException ex) {
|
||||
}
|
||||
return new ArrayList<CardInfo>();
|
||||
|
|
Loading…
Add table
Reference in a new issue