From d6ac1070c55435d09f2461d57efbe7670f78bf49 Mon Sep 17 00:00:00 2001 From: North Date: Sat, 29 Jun 2013 18:00:43 +0300 Subject: [PATCH] filtered out split card halves in card searches --- Mage/src/mage/cards/repository/CardCriteria.java | 3 ++- Mage/src/mage/cards/repository/CardInfo.java | 16 ++++++++++++++++ .../mage/cards/repository/CardRepository.java | 4 ++-- 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/Mage/src/mage/cards/repository/CardCriteria.java b/Mage/src/mage/cards/repository/CardCriteria.java index 4997a61235..63717c6706 100644 --- a/Mage/src/mage/cards/repository/CardCriteria.java +++ b/Mage/src/mage/cards/repository/CardCriteria.java @@ -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++; diff --git a/Mage/src/mage/cards/repository/CardInfo.java b/Mage/src/mage/cards/repository/CardInfo.java index 78bb542c22..50d140698d 100644 --- a/Mage/src/mage/cards/repository/CardInfo.java +++ b/Mage/src/mage/cards/repository/CardInfo.java @@ -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; } diff --git a/Mage/src/mage/cards/repository/CardRepository.java b/Mage/src/mage/cards/repository/CardRepository.java index f30c038ee8..63b224f1ac 100644 --- a/Mage/src/mage/cards/repository/CardRepository.java +++ b/Mage/src/mage/cards/repository/CardRepository.java @@ -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 cardDao; @@ -248,7 +248,7 @@ public enum CardRepository { public List getAllCards() { try { QueryBuilder 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) {