forked from External/mage
tests: added tests for auto-lands suggestion in deck editor and tourney (related to #13127)
This commit is contained in:
parent
40e2cf7cda
commit
2955535927
4 changed files with 180 additions and 21 deletions
|
|
@ -15,14 +15,12 @@ public final class TournamentUtil {
|
|||
/**
|
||||
* Tries to calculate the most appropriate sets to add basic lands for cards of a deck
|
||||
*
|
||||
* @param setCodesDeck
|
||||
* @return setCode for lands
|
||||
* @param setCodesDeck all sets in current deck
|
||||
*/
|
||||
|
||||
public static Set<String> getLandSetCodeForDeckSets(Collection<String> setCodesDeck) {
|
||||
|
||||
Set<String> landSetCodes = new HashSet<>();
|
||||
// decide from which sets basic lands are taken from
|
||||
|
||||
// from deck's sets
|
||||
for (String setCode : setCodesDeck) {
|
||||
ExpansionInfo expansionInfo = ExpansionRepository.instance.getSetByCode(setCode);
|
||||
if (expansionInfo.hasBasicLands() && !CardRepository.haveSnowLands(setCode)) {
|
||||
|
|
@ -30,7 +28,7 @@ public final class TournamentUtil {
|
|||
}
|
||||
}
|
||||
|
||||
// if sets have no basic land, take land from block
|
||||
// from deck's blocks
|
||||
if (landSetCodes.isEmpty()) {
|
||||
for (String setCode : setCodesDeck) {
|
||||
ExpansionInfo expansionInfo = ExpansionRepository.instance.getSetByCode(setCode);
|
||||
|
|
@ -42,10 +40,9 @@ public final class TournamentUtil {
|
|||
}
|
||||
}
|
||||
}
|
||||
// if still no set with lands found, take one by random
|
||||
|
||||
// from random
|
||||
if (landSetCodes.isEmpty()) {
|
||||
// if sets have no basic lands and also it has no parent or parent has no lands get last set with lands
|
||||
// select a set with basic lands by random
|
||||
List<ExpansionInfo> basicLandSets = ExpansionRepository.instance.getSetsWithBasicLandsByReleaseDate()
|
||||
.stream()
|
||||
.filter(exp -> !CardRepository.haveSnowLands(exp.getCode()))
|
||||
|
|
@ -56,7 +53,7 @@ public final class TournamentUtil {
|
|||
}
|
||||
|
||||
if (landSetCodes.isEmpty()) {
|
||||
throw new IllegalArgumentException("No set with basic land was found");
|
||||
throw new IllegalArgumentException("No set with basic land was found (possible memory problems, need server restart)");
|
||||
}
|
||||
return landSetCodes;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue