Add more documentation

This commit is contained in:
pfirpfel
2020-10-22 21:42:06 +02:00
parent dd1642670f
commit fd1ece9aea
2 changed files with 27 additions and 9 deletions

View File

@@ -179,28 +179,33 @@ public class BoosterDraft implements IBoosterDraft {
break;
case Chaos:
/**
* A chaos draft consists of boosters from many different sets.
* Default settings are boosters from all sets with a booster size of 15 cards.
* Alternatively, the sets can be restricted to a format like Modern or to a theme.
* Examples for themes: sets that take place on a certain plane, core sets, masters sets,
* or sets that share a mechanic.
*/
// Get chaos draft themes
final List<ThemedChaosDraft> themes = new ArrayList<>();
final IStorage<ThemedChaosDraft> themeStorage = FModel.getThemedChaosDrafts();
for (final ThemedChaosDraft theme : themeStorage) {
themes.add(theme);
}
Collections.sort(themes);
Collections.sort(themes); // sort for user interface
// Ask user to select theme
final String dialogQuestion = Localizer.getInstance().getMessage("lblChooseChaosTheme");
final ThemedChaosDraft theme = SGuiChoose.oneOrNone(dialogQuestion, themes);
if (theme == null) {
return false;
return false; // abort if no theme is selected
}
// Filter all sets by theme restrictions
final Predicate<CardEdition> themeFilter = theme.getEditionFilter();
final CardEdition.Collection allEditions = StaticData.instance().getEditions();
final Iterable<CardEdition> chaosDraftEditions = Iterables.filter(
allEditions.getOrderedEditions(),
themeFilter);
// Add chaos "boosters" as special suppliers
final Supplier<List<PaperCard>> ChaosDraftSupplier;
try{
ChaosDraftSupplier = new ChaosBoosterSupplier(chaosDraftEditions);
@@ -208,7 +213,6 @@ public class BoosterDraft implements IBoosterDraft {
System.out.println(e.getMessage());
return false;
}
for (int i = 0; i < 3; i++) {
this.product.add(ChaosDraftSupplier);
}

View File

@@ -46,6 +46,9 @@ public class ThemedChaosDraft implements Comparable<ThemedChaosDraft> {
*/
public int getOrderNumber() { return orderNumber; }
/**
* @return Predicate to sort out editions not belonging to the chaos draft theme
*/
public Predicate<CardEdition> getEditionFilter() {
Predicate<CardEdition> filter;
switch(tag) {
@@ -63,6 +66,10 @@ public class ThemedChaosDraft implements Comparable<ThemedChaosDraft> {
return filter;
}
/**
* Filter to select editions by ChaosDraftThemes tag defined in edition files.
* Tag must be defined in res/blockdata/chaosdraftthemes.txt
*/
private final Predicate<CardEdition> themedFilter = new Predicate<CardEdition>() {
@Override
public boolean apply(final CardEdition cardEdition) {
@@ -74,6 +81,10 @@ public class ThemedChaosDraft implements Comparable<ThemedChaosDraft> {
}
};
/**
* @param formatName format to filter by, currently supported: MODERN, PIONEER, STANDARD
* @return Filter to select editions belonging to a certain constructed format.
*/
private Predicate<CardEdition> getFormatFilter(String formatName) {
GameFormat.Collection formats = FModel.getFormats();
GameFormat format;
@@ -96,6 +107,9 @@ public class ThemedChaosDraft implements Comparable<ThemedChaosDraft> {
};
}
/**
* Default filter that only allows actual sets that were printed as 15-card boosters
*/
private static final Predicate<CardEdition> DEFAULT_FILTER = new Predicate<CardEdition>() {
@Override
public boolean apply(final CardEdition cardEdition) {