mirror of
https://github.com/correl/mage.git
synced 2024-12-24 11:50:45 +00: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()) {
|
||||
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);
|
||||
if (cards.isEmpty()) { // Workaround to get basic lands if lands are not available for the given sets
|
||||
criteria.setCodes("M15");
|
||||
|
|
|
@ -31,6 +31,8 @@ public class AddLandDialog extends MageDialog {
|
|||
private static final Logger logger = Logger.getLogger(MageDialog.class);
|
||||
|
||||
private Deck deck;
|
||||
|
||||
private DeckEditorMode mode;
|
||||
|
||||
private static final int DEFAULT_SEALED_DECK_CARD_NUMBER = 40;
|
||||
|
||||
|
@ -41,6 +43,7 @@ public class AddLandDialog extends MageDialog {
|
|||
|
||||
public void showDialog(Deck deck, DeckEditorMode mode) {
|
||||
this.deck = deck;
|
||||
this.mode = mode;
|
||||
SortedSet<String> landSetNames = new TreeSet<>();
|
||||
String defaultSetName = null;
|
||||
if (mode != DeckEditorMode.FREE_BUILDING) {
|
||||
|
@ -139,10 +142,11 @@ public class AddLandDialog extends MageDialog {
|
|||
|
||||
private void addLands(String landName, int number, boolean useFullArt) {
|
||||
String landSetName = (String) cbLandSet.getSelectedItem();
|
||||
ExpansionInfo expansionInfo = null;
|
||||
|
||||
CardCriteria criteria = new CardCriteria();
|
||||
if (!landSetName.equals("<Random lands>")) {
|
||||
ExpansionInfo expansionInfo = ExpansionRepository.instance.getSetByName(landSetName);
|
||||
expansionInfo = ExpansionRepository.instance.getSetByName(landSetName);
|
||||
if (expansionInfo == null) {
|
||||
throw new IllegalArgumentException("Code of Set " + landSetName + " not found");
|
||||
}
|
||||
|
@ -150,7 +154,12 @@ public class AddLandDialog extends MageDialog {
|
|||
} else {
|
||||
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);
|
||||
if (cards.isEmpty()) {
|
||||
logger.error("No basic lands found in Set: " + landSetName);
|
||||
|
|
|
@ -2212,7 +2212,7 @@ public class ComputerPlayer extends PlayerImpl implements Player {
|
|||
if (!landSets.isEmpty()) {
|
||||
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);
|
||||
|
||||
if (cards.isEmpty()) {
|
||||
|
|
|
@ -870,19 +870,23 @@ public class VerifyCardDataTest {
|
|||
// 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) {
|
||||
boolean needSnow = CardRepository.haveSnowLands(set.getCode());
|
||||
boolean haveSnow = false;
|
||||
boolean haveNonSnow = false;
|
||||
for (ExpansionSet.SetCardInfo card : set.getSetCardInfo()) {
|
||||
if (card.getName().startsWith("Snow-Covered ")) {
|
||||
haveSnow = true;
|
||||
}
|
||||
if (isNonSnowBasicLandName(card.getName())) {
|
||||
haveNonSnow = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (needSnow != haveSnow) {
|
||||
if (needSnow != (haveSnow && !haveNonSnow)) {
|
||||
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"));
|
||||
}
|
||||
}
|
||||
|
@ -1820,6 +1824,14 @@ public class VerifyCardDataTest {
|
|||
|| checkName.equals("Plains")
|
||||
|| 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) {
|
||||
|
||||
|
|
|
@ -246,7 +246,7 @@ public class CardCriteria {
|
|||
where.ne("setCode", ignoreSetCode);
|
||||
}
|
||||
if (!ignoreSetCodes.isEmpty()) {
|
||||
where.or(ignoreSetCodes.size());
|
||||
where.and(ignoreSetCodes.size());
|
||||
clausesCount++;
|
||||
}
|
||||
|
||||
|
|
|
@ -37,13 +37,11 @@ public enum CardRepository {
|
|||
private Dao<CardInfo, Object> cardDao;
|
||||
private Set<String> classNames;
|
||||
|
||||
// sets with exclusively snow basics
|
||||
public static final Set<String> snowLandSetCodes = new HashSet<>(Arrays.asList(
|
||||
"CSP",
|
||||
"MH1",
|
||||
"SLD",
|
||||
"ME2",
|
||||
"ICE",
|
||||
"KHM"
|
||||
"ME2"
|
||||
));
|
||||
|
||||
CardRepository() {
|
||||
|
|
|
@ -68,7 +68,7 @@ public final class TournamentUtil {
|
|||
} else {
|
||||
criteria.ignoreSetsWithSnowLands();
|
||||
}
|
||||
criteria.rarities(Rarity.LAND).name(landName);
|
||||
criteria.rarities(Rarity.LAND).nameExact(landName);
|
||||
List<CardInfo> lands = CardRepository.instance.findCards(criteria);
|
||||
List<Card> cards = new ArrayList<>();
|
||||
if (!lands.isEmpty()) {
|
||||
|
|
Loading…
Reference in a new issue