mirror of
https://github.com/correl/mage.git
synced 2025-01-15 11:07:08 +00:00
Tests: added verify checks for wrong set's settings like parent set and block name (temporary disabled)
This commit is contained in:
parent
59d2b59a4f
commit
8f748b0f2c
4 changed files with 53 additions and 3 deletions
Mage.Verify/src
Mage/src/main/java/mage/cards
|
@ -13,6 +13,10 @@ public final class MtgJsonSet {
|
||||||
public String releaseDate;
|
public String releaseDate;
|
||||||
public int totalSetSize;
|
public int totalSetSize;
|
||||||
|
|
||||||
|
public String block;
|
||||||
|
|
||||||
|
public String parentCode;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return code + " - " + name;
|
return code + " - " + name;
|
||||||
|
|
|
@ -942,6 +942,50 @@ public class VerifyCardDataTest {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// CHECK: parent and block info
|
||||||
|
for (ExpansionSet set : sets) {
|
||||||
|
if (true) continue; // TODO: comments it and run to find a problems
|
||||||
|
MtgJsonSet jsonSet = MtgJsonService.sets().getOrDefault(set.getCode().toUpperCase(Locale.ENGLISH), null);
|
||||||
|
if (jsonSet == null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// parent set
|
||||||
|
MtgJsonSet jsonParentSet = jsonSet.parentCode == null ? null : MtgJsonService.sets().getOrDefault(jsonSet.parentCode, null);
|
||||||
|
ExpansionSet mageParentSet = set.getParentSet();
|
||||||
|
String jsonParentCode = jsonParentSet == null ? "null" : jsonParentSet.code;
|
||||||
|
String mageParentCode = mageParentSet == null ? "null" : mageParentSet.getCode();
|
||||||
|
|
||||||
|
String needMageClass = "";
|
||||||
|
if (!jsonParentCode.equals("null")) {
|
||||||
|
needMageClass = sets
|
||||||
|
.stream()
|
||||||
|
.filter(exp -> exp.getCode().equals(jsonParentCode))
|
||||||
|
.map(exp -> " - " + exp.getClass().getSimpleName() + ".getInstance()")
|
||||||
|
.findFirst()
|
||||||
|
.orElse("- error, can't find class");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!Objects.equals(jsonParentCode, mageParentCode)) {
|
||||||
|
errorsList.add(String.format("Error: set with wrong parentSet settings: %s (parentSet = %s, but must be %s%s)",
|
||||||
|
set.getCode() + " - " + set.getName(),
|
||||||
|
mageParentCode,
|
||||||
|
jsonParentCode,
|
||||||
|
needMageClass
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
// block info
|
||||||
|
if (!Objects.equals(set.getBlockName(), jsonSet.block)) {
|
||||||
|
if (true) continue; // TODO: comments it and run to find a problems
|
||||||
|
errorsList.add(String.format("Error: set with wrong blockName settings: %s (blockName = %s, but must be %s)",
|
||||||
|
set.getCode() + " - " + set.getName(),
|
||||||
|
set.getBlockName(),
|
||||||
|
jsonSet.block
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 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);
|
||||||
|
|
|
@ -104,13 +104,13 @@ public abstract class ExpansionSet implements Serializable {
|
||||||
protected String name;
|
protected String name;
|
||||||
protected String code;
|
protected String code;
|
||||||
protected Date releaseDate;
|
protected Date releaseDate;
|
||||||
protected ExpansionSet parentSet;
|
protected ExpansionSet parentSet; // used to search additional lands and reprints for booster
|
||||||
protected SetType setType;
|
protected SetType setType;
|
||||||
|
|
||||||
// TODO: 03.10.2018, hasBasicLands can be removed someday -- it's uses to optimize lands search in deck generation and lands adding (search all available lands from sets)
|
// TODO: 03.10.2018, hasBasicLands can be removed someday -- it's uses to optimize lands search in deck generation and lands adding (search all available lands from sets)
|
||||||
protected boolean hasBasicLands = true;
|
protected boolean hasBasicLands = true;
|
||||||
|
|
||||||
protected String blockName;
|
protected String blockName; // used to group sets in some GUI dialogs like choose set dialog
|
||||||
protected boolean hasBoosters = false;
|
protected boolean hasBoosters = false;
|
||||||
protected int numBoosterSpecial;
|
protected int numBoosterSpecial;
|
||||||
|
|
||||||
|
@ -539,6 +539,7 @@ public abstract class ExpansionSet implements Serializable {
|
||||||
List<String> needSets = new ArrayList<>();
|
List<String> needSets = new ArrayList<>();
|
||||||
needSets.add(this.code);
|
needSets.add(this.code);
|
||||||
if (this.parentSet != null) {
|
if (this.parentSet != null) {
|
||||||
|
// TODO: is it ok to put all parent's cards to booster instead lands only?
|
||||||
needSets.add(this.parentSet.code);
|
needSets.add(this.parentSet.code);
|
||||||
}
|
}
|
||||||
List<CardInfo> cardInfos = CardRepository.instance.findCards(new CardCriteria()
|
List<CardInfo> cardInfos = CardRepository.instance.findCards(new CardCriteria()
|
||||||
|
|
|
@ -6,6 +6,7 @@ import org.apache.log4j.Logger;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author North
|
* @author North
|
||||||
|
@ -38,7 +39,7 @@ public final class CardScanner {
|
||||||
setsToAdd.add(new ExpansionInfo(set));
|
setsToAdd.add(new ExpansionInfo(set));
|
||||||
} else if (!expansionInfo.name.equals(set.getName())
|
} else if (!expansionInfo.name.equals(set.getName())
|
||||||
|| !expansionInfo.code.equals(set.getCode())
|
|| !expansionInfo.code.equals(set.getCode())
|
||||||
|| (expansionInfo.blockName == null ? set.getBlockName() != null : !expansionInfo.blockName.equals(set.getBlockName()))
|
|| !(Objects.equals(expansionInfo.blockName, set.getBlockName()))
|
||||||
|| !expansionInfo.releaseDate.equals(set.getReleaseDate())
|
|| !expansionInfo.releaseDate.equals(set.getReleaseDate())
|
||||||
|| expansionInfo.type != set.getSetType()
|
|| expansionInfo.type != set.getSetType()
|
||||||
|| expansionInfo.boosters != set.hasBoosters()
|
|| expansionInfo.boosters != set.hasBoosters()
|
||||||
|
|
Loading…
Reference in a new issue