forked from External/mage
Merge branch 'master' into master
This commit is contained in:
commit
f741fce710
69 changed files with 433 additions and 164 deletions
|
|
@ -3,10 +3,13 @@ package mage.cards.repository;
|
|||
import com.j256.ormlite.stmt.QueryBuilder;
|
||||
import com.j256.ormlite.stmt.SelectArg;
|
||||
import com.j256.ormlite.stmt.Where;
|
||||
|
||||
import mage.MageObject;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Rarity;
|
||||
import mage.constants.SubType;
|
||||
import mage.constants.SuperType;
|
||||
import mage.filter.predicate.Predicate;
|
||||
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
|
|
@ -39,6 +42,7 @@ public class CardCriteria {
|
|||
private boolean red;
|
||||
private boolean white;
|
||||
private boolean colorless;
|
||||
private boolean limitColors;
|
||||
private Integer manaValue;
|
||||
private String sortBy;
|
||||
private Long start;
|
||||
|
|
@ -68,6 +72,12 @@ public class CardCriteria {
|
|||
this.minCardNumber = Integer.MIN_VALUE;
|
||||
this.maxCardNumber = Integer.MAX_VALUE;
|
||||
}
|
||||
|
||||
public CardCriteria limitColors(boolean limitColors) {
|
||||
this.limitColors = limitColors;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
public CardCriteria black(boolean black) {
|
||||
this.black = black;
|
||||
|
|
@ -311,35 +321,56 @@ public class CardCriteria {
|
|||
clausesCount++;
|
||||
}
|
||||
|
||||
List<String> exclusion = new ArrayList<>();
|
||||
|
||||
int colorClauses = 0;
|
||||
if (black) {
|
||||
where.eq("black", true);
|
||||
colorClauses++;
|
||||
} else {
|
||||
exclusion.add("black");
|
||||
}
|
||||
if (blue) {
|
||||
where.eq("blue", true);
|
||||
colorClauses++;
|
||||
} else {
|
||||
exclusion.add("blue");
|
||||
}
|
||||
if (green) {
|
||||
where.eq("green", true);
|
||||
colorClauses++;
|
||||
} else {
|
||||
exclusion.add("green");
|
||||
}
|
||||
if (red) {
|
||||
where.eq("red", true);
|
||||
colorClauses++;
|
||||
} else {
|
||||
exclusion.add("red");
|
||||
}
|
||||
if (white) {
|
||||
where.eq("white", true);
|
||||
colorClauses++;
|
||||
} else {
|
||||
exclusion.add("white");
|
||||
}
|
||||
if (colorless) {
|
||||
where.eq("black", false).eq("blue", false).eq("green", false).eq("red", false).eq("white", false);
|
||||
where.and(5);
|
||||
colorClauses++;
|
||||
}
|
||||
|
||||
if (colorClauses > 0) {
|
||||
where.or(colorClauses);
|
||||
clausesCount++;
|
||||
|
||||
if (this.limitColors) {
|
||||
for (String color : exclusion) {
|
||||
where.not();
|
||||
where.eq(color, true);
|
||||
clausesCount++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (minCardNumber != Integer.MIN_VALUE) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue