add exclusive color button
All checks were successful
/ example-docker-compose (push) Successful in 14m48s

This commit is contained in:
Failure 2025-01-25 21:36:00 -08:00
parent 7795e06b1c
commit f551ff8f2c
4 changed files with 76 additions and 3 deletions

View file

@ -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) {