mirror of
https://github.com/magefree/mage.git
synced 2025-12-20 10:40:06 -08:00
Make Add Land dialog no longer add a random mix of regular and snow-covered basic lands (#9353)
The Add Land dialog now only adds regular basic lands and never snow-covered ones, unless you specifically select a set that only contains snow basics (e.g. MH1) Sets that only contain snow basics are not selectable when adding lands to a Limited deck.
This commit is contained in:
parent
ebdb6b53a4
commit
7554a2b6b5
7 changed files with 32 additions and 13 deletions
|
|
@ -291,7 +291,7 @@ public final class DeckGenerator {
|
||||||
|
|
||||||
for (ColoredManaSymbol c : ColoredManaSymbol.values()) {
|
for (ColoredManaSymbol c : ColoredManaSymbol.values()) {
|
||||||
String landName = DeckGeneratorPool.getBasicLandName(c.toString());
|
String landName = DeckGeneratorPool.getBasicLandName(c.toString());
|
||||||
criteria.rarities(Rarity.LAND).name(landName);
|
criteria.rarities(Rarity.LAND).nameExact(landName);
|
||||||
List<CardInfo> cards = CardRepository.instance.findCards(criteria);
|
List<CardInfo> cards = CardRepository.instance.findCards(criteria);
|
||||||
if (cards.isEmpty()) { // Workaround to get basic lands if lands are not available for the given sets
|
if (cards.isEmpty()) { // Workaround to get basic lands if lands are not available for the given sets
|
||||||
criteria.setCodes("M15");
|
criteria.setCodes("M15");
|
||||||
|
|
|
||||||
|
|
@ -32,6 +32,8 @@ public class AddLandDialog extends MageDialog {
|
||||||
|
|
||||||
private Deck deck;
|
private Deck deck;
|
||||||
|
|
||||||
|
private DeckEditorMode mode;
|
||||||
|
|
||||||
private static final int DEFAULT_SEALED_DECK_CARD_NUMBER = 40;
|
private static final int DEFAULT_SEALED_DECK_CARD_NUMBER = 40;
|
||||||
|
|
||||||
public AddLandDialog() {
|
public AddLandDialog() {
|
||||||
|
|
@ -41,6 +43,7 @@ public class AddLandDialog extends MageDialog {
|
||||||
|
|
||||||
public void showDialog(Deck deck, DeckEditorMode mode) {
|
public void showDialog(Deck deck, DeckEditorMode mode) {
|
||||||
this.deck = deck;
|
this.deck = deck;
|
||||||
|
this.mode = mode;
|
||||||
SortedSet<String> landSetNames = new TreeSet<>();
|
SortedSet<String> landSetNames = new TreeSet<>();
|
||||||
String defaultSetName = null;
|
String defaultSetName = null;
|
||||||
if (mode != DeckEditorMode.FREE_BUILDING) {
|
if (mode != DeckEditorMode.FREE_BUILDING) {
|
||||||
|
|
@ -139,10 +142,11 @@ public class AddLandDialog extends MageDialog {
|
||||||
|
|
||||||
private void addLands(String landName, int number, boolean useFullArt) {
|
private void addLands(String landName, int number, boolean useFullArt) {
|
||||||
String landSetName = (String) cbLandSet.getSelectedItem();
|
String landSetName = (String) cbLandSet.getSelectedItem();
|
||||||
|
ExpansionInfo expansionInfo = null;
|
||||||
|
|
||||||
CardCriteria criteria = new CardCriteria();
|
CardCriteria criteria = new CardCriteria();
|
||||||
if (!landSetName.equals("<Random lands>")) {
|
if (!landSetName.equals("<Random lands>")) {
|
||||||
ExpansionInfo expansionInfo = ExpansionRepository.instance.getSetByName(landSetName);
|
expansionInfo = ExpansionRepository.instance.getSetByName(landSetName);
|
||||||
if (expansionInfo == null) {
|
if (expansionInfo == null) {
|
||||||
throw new IllegalArgumentException("Code of Set " + landSetName + " not found");
|
throw new IllegalArgumentException("Code of Set " + landSetName + " not found");
|
||||||
}
|
}
|
||||||
|
|
@ -150,7 +154,12 @@ public class AddLandDialog extends MageDialog {
|
||||||
} else {
|
} else {
|
||||||
criteria.ignoreSetsWithSnowLands();
|
criteria.ignoreSetsWithSnowLands();
|
||||||
}
|
}
|
||||||
criteria.rarities(Rarity.LAND).name(landName);
|
if (mode == DeckEditorMode.FREE_BUILDING && expansionInfo != null && CardRepository.haveSnowLands(expansionInfo.getCode())) {
|
||||||
|
criteria.name(landName); // snow basics added only if in free mode and the chosen set has exclusively snow basics
|
||||||
|
} else {
|
||||||
|
criteria.nameExact(landName);
|
||||||
|
}
|
||||||
|
criteria.rarities(Rarity.LAND);
|
||||||
List<CardInfo> cards = CardRepository.instance.findCards(criteria);
|
List<CardInfo> cards = CardRepository.instance.findCards(criteria);
|
||||||
if (cards.isEmpty()) {
|
if (cards.isEmpty()) {
|
||||||
logger.error("No basic lands found in Set: " + landSetName);
|
logger.error("No basic lands found in Set: " + landSetName);
|
||||||
|
|
|
||||||
|
|
@ -2212,7 +2212,7 @@ public class ComputerPlayer extends PlayerImpl implements Player {
|
||||||
if (!landSets.isEmpty()) {
|
if (!landSets.isEmpty()) {
|
||||||
criteria.setCodes(landSets.toArray(new String[landSets.size()]));
|
criteria.setCodes(landSets.toArray(new String[landSets.size()]));
|
||||||
}
|
}
|
||||||
criteria.rarities(Rarity.LAND).name(landName);
|
criteria.rarities(Rarity.LAND).nameExact(landName);
|
||||||
List<CardInfo> cards = CardRepository.instance.findCards(criteria);
|
List<CardInfo> cards = CardRepository.instance.findCards(criteria);
|
||||||
|
|
||||||
if (cards.isEmpty()) {
|
if (cards.isEmpty()) {
|
||||||
|
|
|
||||||
|
|
@ -870,19 +870,23 @@ public class VerifyCardDataTest {
|
||||||
// TODO: add test to check num cards (hasBasicLands and numLand > 0)
|
// TODO: add test to check num cards (hasBasicLands and numLand > 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
// CHECK: wrong snow land info
|
// CHECK: wrong snow land info - set needs to have exclusively snow basics to qualify
|
||||||
for (ExpansionSet set : sets) {
|
for (ExpansionSet set : sets) {
|
||||||
boolean needSnow = CardRepository.haveSnowLands(set.getCode());
|
boolean needSnow = CardRepository.haveSnowLands(set.getCode());
|
||||||
boolean haveSnow = false;
|
boolean haveSnow = false;
|
||||||
|
boolean haveNonSnow = false;
|
||||||
for (ExpansionSet.SetCardInfo card : set.getSetCardInfo()) {
|
for (ExpansionSet.SetCardInfo card : set.getSetCardInfo()) {
|
||||||
if (card.getName().startsWith("Snow-Covered ")) {
|
if (card.getName().startsWith("Snow-Covered ")) {
|
||||||
haveSnow = true;
|
haveSnow = true;
|
||||||
|
}
|
||||||
|
if (isNonSnowBasicLandName(card.getName())) {
|
||||||
|
haveNonSnow = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (needSnow != haveSnow) {
|
if (needSnow != (haveSnow && !haveNonSnow)) {
|
||||||
errorsList.add("Error: found incorrect snow land info in set " + set.getCode() + ": "
|
errorsList.add("Error: found incorrect snow land info in set " + set.getCode() + ": "
|
||||||
+ (haveSnow ? "set has snow cards" : "set doesn't have snow card")
|
+ ((haveSnow && !haveNonSnow) ? "set has exclusively snow basics" : "set doesn't have exclusively snow basics")
|
||||||
+ ", but xmage thinks that it " + (needSnow ? "does" : "doesn't"));
|
+ ", but xmage thinks that it " + (needSnow ? "does" : "doesn't"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1821,6 +1825,14 @@ public class VerifyCardDataTest {
|
||||||
|| checkName.equals("Mountain");
|
|| checkName.equals("Mountain");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean isNonSnowBasicLandName(String name) {
|
||||||
|
return name.equals("Island")
|
||||||
|
|| name.equals("Forest")
|
||||||
|
|| name.equals("Swamp")
|
||||||
|
|| name.equals("Plains")
|
||||||
|
|| name.equals("Mountain");
|
||||||
|
}
|
||||||
|
|
||||||
private void checkBasicLands(Card card, MtgJsonCard ref) {
|
private void checkBasicLands(Card card, MtgJsonCard ref) {
|
||||||
|
|
||||||
// basic lands must have Rarity.LAND and SuperType.BASIC
|
// basic lands must have Rarity.LAND and SuperType.BASIC
|
||||||
|
|
|
||||||
|
|
@ -246,7 +246,7 @@ public class CardCriteria {
|
||||||
where.ne("setCode", ignoreSetCode);
|
where.ne("setCode", ignoreSetCode);
|
||||||
}
|
}
|
||||||
if (!ignoreSetCodes.isEmpty()) {
|
if (!ignoreSetCodes.isEmpty()) {
|
||||||
where.or(ignoreSetCodes.size());
|
where.and(ignoreSetCodes.size());
|
||||||
clausesCount++;
|
clausesCount++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -37,13 +37,11 @@ public enum CardRepository {
|
||||||
private Dao<CardInfo, Object> cardDao;
|
private Dao<CardInfo, Object> cardDao;
|
||||||
private Set<String> classNames;
|
private Set<String> classNames;
|
||||||
|
|
||||||
|
// sets with exclusively snow basics
|
||||||
public static final Set<String> snowLandSetCodes = new HashSet<>(Arrays.asList(
|
public static final Set<String> snowLandSetCodes = new HashSet<>(Arrays.asList(
|
||||||
"CSP",
|
"CSP",
|
||||||
"MH1",
|
"MH1",
|
||||||
"SLD",
|
"ME2"
|
||||||
"ME2",
|
|
||||||
"ICE",
|
|
||||||
"KHM"
|
|
||||||
));
|
));
|
||||||
|
|
||||||
CardRepository() {
|
CardRepository() {
|
||||||
|
|
|
||||||
|
|
@ -68,7 +68,7 @@ public final class TournamentUtil {
|
||||||
} else {
|
} else {
|
||||||
criteria.ignoreSetsWithSnowLands();
|
criteria.ignoreSetsWithSnowLands();
|
||||||
}
|
}
|
||||||
criteria.rarities(Rarity.LAND).name(landName);
|
criteria.rarities(Rarity.LAND).nameExact(landName);
|
||||||
List<CardInfo> lands = CardRepository.instance.findCards(criteria);
|
List<CardInfo> lands = CardRepository.instance.findCards(criteria);
|
||||||
List<Card> cards = new ArrayList<>();
|
List<Card> cards = new ArrayList<>();
|
||||||
if (!lands.isEmpty()) {
|
if (!lands.isEmpty()) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue