mirror of
https://github.com/correl/mage.git
synced 2024-12-26 03:00:11 +00:00
filtered out split card halves in card searches
This commit is contained in:
parent
dc0db40428
commit
d6ac1070c5
3 changed files with 20 additions and 3 deletions
|
@ -172,7 +172,8 @@ public class CardCriteria {
|
|||
public void buildQuery(QueryBuilder qb) throws SQLException {
|
||||
Where where = qb.where();
|
||||
where.eq("nightCard", false);
|
||||
int clausesCount = 1;
|
||||
where.eq("splitCardHalf", false);
|
||||
int clausesCount = 2;
|
||||
if (name != null) {
|
||||
where.like("name", new SelectArg('%' + name + '%'));
|
||||
clausesCount++;
|
||||
|
|
|
@ -38,10 +38,12 @@ import java.util.List;
|
|||
import mage.constants.CardType;
|
||||
import mage.constants.Rarity;
|
||||
import mage.ObjectColor;
|
||||
import mage.abilities.SpellAbility;
|
||||
import mage.cards.Card;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.cards.mock.MockCard;
|
||||
import mage.cards.mock.MockSplitCard;
|
||||
import mage.constants.SpellAbilityType;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -90,6 +92,8 @@ public class CardInfo {
|
|||
@DatabaseField
|
||||
protected boolean splitCard;
|
||||
@DatabaseField
|
||||
protected boolean splitCardHalf;
|
||||
@DatabaseField
|
||||
protected boolean flipCard;
|
||||
@DatabaseField
|
||||
protected boolean doubleFaced;
|
||||
|
@ -135,6 +139,14 @@ public class CardInfo {
|
|||
this.setSuperTypes(card.getSupertype());
|
||||
this.setManaCosts(card.getManaCost().getSymbols());
|
||||
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() {
|
||||
|
@ -262,6 +274,10 @@ public class CardInfo {
|
|||
return splitCard;
|
||||
}
|
||||
|
||||
public boolean isSplitCardHalf() {
|
||||
return splitCardHalf;
|
||||
}
|
||||
|
||||
public boolean isFlipCard() {
|
||||
return flipCard;
|
||||
}
|
||||
|
|
|
@ -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 = 8;
|
||||
private static final long CARD_DB_VERSION = 9;
|
||||
|
||||
private Random random = new Random();
|
||||
private Dao<CardInfo, Object> cardDao;
|
||||
|
@ -248,7 +248,7 @@ public enum CardRepository {
|
|||
public List<CardInfo> getAllCards() {
|
||||
try {
|
||||
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());
|
||||
} catch (SQLException ex) {
|
||||
|
|
Loading…
Reference in a new issue