mirror of
https://github.com/correl/mage.git
synced 2024-11-14 19:19:32 +00:00
* Fixed that snow lands can be added in draft and sealed modes (#5831);
This commit is contained in:
parent
6d518c62e6
commit
77e92d9186
3 changed files with 35 additions and 3 deletions
|
@ -37,6 +37,10 @@ public class AddLandDialog extends MageDialog {
|
||||||
this.setModal(true);
|
this.setModal(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean setHaveSnowLands(ExpansionInfo exp) {
|
||||||
|
return CardRepository.instance.haveSnowLands(exp.getCode());
|
||||||
|
}
|
||||||
|
|
||||||
public void showDialog(Deck deck, DeckEditorMode mode) {
|
public void showDialog(Deck deck, DeckEditorMode mode) {
|
||||||
this.deck = deck;
|
this.deck = deck;
|
||||||
SortedSet<String> landSetNames = new TreeSet<>();
|
SortedSet<String> landSetNames = new TreeSet<>();
|
||||||
|
@ -45,7 +49,7 @@ public class AddLandDialog extends MageDialog {
|
||||||
// decide from which sets basic lands are taken from
|
// decide from which sets basic lands are taken from
|
||||||
for (String setCode : deck.getExpansionSetCodes()) {
|
for (String setCode : deck.getExpansionSetCodes()) {
|
||||||
ExpansionInfo expansionInfo = ExpansionRepository.instance.getSetByCode(setCode);
|
ExpansionInfo expansionInfo = ExpansionRepository.instance.getSetByCode(setCode);
|
||||||
if (expansionInfo != null && expansionInfo.hasBasicLands()) {
|
if (expansionInfo != null && expansionInfo.hasBasicLands() && !setHaveSnowLands(expansionInfo)) {
|
||||||
defaultSetName = expansionInfo.getName();
|
defaultSetName = expansionInfo.getName();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -58,7 +62,7 @@ public class AddLandDialog extends MageDialog {
|
||||||
if (expansionInfo != null) {
|
if (expansionInfo != null) {
|
||||||
List<ExpansionInfo> blockSets = ExpansionRepository.instance.getSetsFromBlock(expansionInfo.getBlockName());
|
List<ExpansionInfo> blockSets = ExpansionRepository.instance.getSetsFromBlock(expansionInfo.getBlockName());
|
||||||
for (ExpansionInfo blockSet : blockSets) {
|
for (ExpansionInfo blockSet : blockSets) {
|
||||||
if (blockSet.hasBasicLands()) {
|
if (blockSet.hasBasicLands() && !setHaveSnowLands(expansionInfo)) {
|
||||||
defaultSetName = expansionInfo.getName();
|
defaultSetName = expansionInfo.getName();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -70,6 +74,10 @@ public class AddLandDialog extends MageDialog {
|
||||||
// if still no set with lands found, add list of all available
|
// if still no set with lands found, add list of all available
|
||||||
List<ExpansionInfo> basicLandSets = ExpansionRepository.instance.getSetsWithBasicLandsByReleaseDate();
|
List<ExpansionInfo> basicLandSets = ExpansionRepository.instance.getSetsWithBasicLandsByReleaseDate();
|
||||||
for (ExpansionInfo expansionInfo : basicLandSets) {
|
for (ExpansionInfo expansionInfo : basicLandSets) {
|
||||||
|
// snow lands only in free mode
|
||||||
|
if (mode != DeckEditorMode.FREE_BUILDING && setHaveSnowLands(expansionInfo)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
landSetNames.add(expansionInfo.getName());
|
landSetNames.add(expansionInfo.getName());
|
||||||
}
|
}
|
||||||
if (landSetNames.isEmpty()) {
|
if (landSetNames.isEmpty()) {
|
||||||
|
|
|
@ -358,6 +358,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)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 3. wrong snow land info
|
||||||
|
for (ExpansionSet set : sets) {
|
||||||
|
boolean needSnow = CardRepository.instance.haveSnowLands(set.getCode());
|
||||||
|
boolean haveSnow = false;
|
||||||
|
for (ExpansionSet.SetCardInfo card : set.getSetCardInfo()) {
|
||||||
|
if (card.getName().startsWith("Snow-Covered ")) {
|
||||||
|
haveSnow = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (needSnow != haveSnow) {
|
||||||
|
errorsList.add("error, found wrong snow lands info in set " + set.getCode() + ": "
|
||||||
|
+ (haveSnow ? "set have snow card" : "set haven't snow card")
|
||||||
|
+ ", but xmage think that it " + (needSnow ? "have" : "haven't"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// TODO: add test to check num cards for rarity (rarityStats > 0 and numRarity > 0)
|
// TODO: add test to check num cards for rarity (rarityStats > 0 and numRarity > 0)
|
||||||
printMessages(warningsList);
|
printMessages(warningsList);
|
||||||
printMessages(errorsList);
|
printMessages(errorsList);
|
||||||
|
@ -740,7 +757,7 @@ public class VerifyCardDataTest {
|
||||||
|
|
||||||
private void checkWrongAbilitiesText(Card card, JsonCard ref) {
|
private void checkWrongAbilitiesText(Card card, JsonCard ref) {
|
||||||
// checks missing or wrong text
|
// checks missing or wrong text
|
||||||
if (!card.getExpansionSetCode().equals("WAR")) {
|
if (!card.getExpansionSetCode().equals("MH1")) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -176,6 +176,13 @@ public enum CardRepository {
|
||||||
return names;
|
return names;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Boolean haveSnowLands(String setCode) {
|
||||||
|
return setCode.equals("CSP")
|
||||||
|
|| setCode.equals("MH1")
|
||||||
|
|| setCode.equals("ME2")
|
||||||
|
|| setCode.equals("ICE");
|
||||||
|
}
|
||||||
|
|
||||||
public Set<String> getNonbasicLandNames() {
|
public Set<String> getNonbasicLandNames() {
|
||||||
Set<String> names = new TreeSet<>();
|
Set<String> names = new TreeSet<>();
|
||||||
try {
|
try {
|
||||||
|
|
Loading…
Reference in a new issue