filtered out split card halves in card searches

This commit is contained in:
North 2013-06-29 18:00:43 +03:00
parent dc0db40428
commit d6ac1070c5
3 changed files with 20 additions and 3 deletions

View file

@ -172,7 +172,8 @@ public class CardCriteria {
public void buildQuery(QueryBuilder qb) throws SQLException { public void buildQuery(QueryBuilder qb) throws SQLException {
Where where = qb.where(); Where where = qb.where();
where.eq("nightCard", false); where.eq("nightCard", false);
int clausesCount = 1; where.eq("splitCardHalf", false);
int clausesCount = 2;
if (name != null) { if (name != null) {
where.like("name", new SelectArg('%' + name + '%')); where.like("name", new SelectArg('%' + name + '%'));
clausesCount++; clausesCount++;

View file

@ -38,10 +38,12 @@ import java.util.List;
import mage.constants.CardType; import mage.constants.CardType;
import mage.constants.Rarity; import mage.constants.Rarity;
import mage.ObjectColor; import mage.ObjectColor;
import mage.abilities.SpellAbility;
import mage.cards.Card; import mage.cards.Card;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.cards.mock.MockCard; import mage.cards.mock.MockCard;
import mage.cards.mock.MockSplitCard; import mage.cards.mock.MockSplitCard;
import mage.constants.SpellAbilityType;
/** /**
* *
@ -90,6 +92,8 @@ public class CardInfo {
@DatabaseField @DatabaseField
protected boolean splitCard; protected boolean splitCard;
@DatabaseField @DatabaseField
protected boolean splitCardHalf;
@DatabaseField
protected boolean flipCard; protected boolean flipCard;
@DatabaseField @DatabaseField
protected boolean doubleFaced; protected boolean doubleFaced;
@ -135,6 +139,14 @@ public class CardInfo {
this.setSuperTypes(card.getSupertype()); this.setSuperTypes(card.getSupertype());
this.setManaCosts(card.getManaCost().getSymbols()); this.setManaCosts(card.getManaCost().getSymbols());
this.setRules(card.getRules()); this.setRules(card.getRules());
SpellAbility spellAbility = card.getSpellAbility();
if (spellAbility != null) {
SpellAbilityType spellAbilityType = spellAbility.getSpellAbilityType();
if (spellAbilityType == SpellAbilityType.SPLIT_LEFT || spellAbilityType == SpellAbilityType.SPLIT_RIGHT) {
this.splitCardHalf = true;
}
}
} }
public Card getCard() { public Card getCard() {
@ -262,6 +274,10 @@ public class CardInfo {
return splitCard; return splitCard;
} }
public boolean isSplitCardHalf() {
return splitCardHalf;
}
public boolean isFlipCard() { public boolean isFlipCard() {
return flipCard; return flipCard;
} }

View file

@ -54,7 +54,7 @@ public enum CardRepository {
private static final String JDBC_URL = "jdbc:sqlite:db/cards.db"; private static final String JDBC_URL = "jdbc:sqlite:db/cards.db";
private static final String VERSION_ENTITY_NAME = "card"; private static final String VERSION_ENTITY_NAME = "card";
private static final long CARD_DB_VERSION = 8; private static final long CARD_DB_VERSION = 9;
private Random random = new Random(); private Random random = new Random();
private Dao<CardInfo, Object> cardDao; private Dao<CardInfo, Object> cardDao;
@ -248,7 +248,7 @@ public enum CardRepository {
public List<CardInfo> getAllCards() { public List<CardInfo> getAllCards() {
try { try {
QueryBuilder<CardInfo, Object> queryBuilder = cardDao.queryBuilder(); QueryBuilder<CardInfo, Object> queryBuilder = cardDao.queryBuilder();
queryBuilder.where().eq("nightCard", false); queryBuilder.where().eq("nightCard", false).and().eq("splitCardHalf", false);
return cardDao.query(queryBuilder.prepare()); return cardDao.query(queryBuilder.prepare());
} catch (SQLException ex) { } catch (SQLException ex) {