mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-15 02:08:00 +00:00
Add more documentation
This commit is contained in:
@@ -179,28 +179,33 @@ public class BoosterDraft implements IBoosterDraft {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case Chaos:
|
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 List<ThemedChaosDraft> themes = new ArrayList<>();
|
||||||
final IStorage<ThemedChaosDraft> themeStorage = FModel.getThemedChaosDrafts();
|
final IStorage<ThemedChaosDraft> themeStorage = FModel.getThemedChaosDrafts();
|
||||||
|
|
||||||
for (final ThemedChaosDraft theme : themeStorage) {
|
for (final ThemedChaosDraft theme : themeStorage) {
|
||||||
themes.add(theme);
|
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 String dialogQuestion = Localizer.getInstance().getMessage("lblChooseChaosTheme");
|
||||||
final ThemedChaosDraft theme = SGuiChoose.oneOrNone(dialogQuestion, themes);
|
final ThemedChaosDraft theme = SGuiChoose.oneOrNone(dialogQuestion, themes);
|
||||||
if (theme == null) {
|
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 Predicate<CardEdition> themeFilter = theme.getEditionFilter();
|
||||||
|
|
||||||
final CardEdition.Collection allEditions = StaticData.instance().getEditions();
|
final CardEdition.Collection allEditions = StaticData.instance().getEditions();
|
||||||
final Iterable<CardEdition> chaosDraftEditions = Iterables.filter(
|
final Iterable<CardEdition> chaosDraftEditions = Iterables.filter(
|
||||||
allEditions.getOrderedEditions(),
|
allEditions.getOrderedEditions(),
|
||||||
themeFilter);
|
themeFilter);
|
||||||
|
// Add chaos "boosters" as special suppliers
|
||||||
final Supplier<List<PaperCard>> ChaosDraftSupplier;
|
final Supplier<List<PaperCard>> ChaosDraftSupplier;
|
||||||
try{
|
try{
|
||||||
ChaosDraftSupplier = new ChaosBoosterSupplier(chaosDraftEditions);
|
ChaosDraftSupplier = new ChaosBoosterSupplier(chaosDraftEditions);
|
||||||
@@ -208,7 +213,6 @@ public class BoosterDraft implements IBoosterDraft {
|
|||||||
System.out.println(e.getMessage());
|
System.out.println(e.getMessage());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < 3; i++) {
|
for (int i = 0; i < 3; i++) {
|
||||||
this.product.add(ChaosDraftSupplier);
|
this.product.add(ChaosDraftSupplier);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -46,6 +46,9 @@ public class ThemedChaosDraft implements Comparable<ThemedChaosDraft> {
|
|||||||
*/
|
*/
|
||||||
public int getOrderNumber() { return orderNumber; }
|
public int getOrderNumber() { return orderNumber; }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Predicate to sort out editions not belonging to the chaos draft theme
|
||||||
|
*/
|
||||||
public Predicate<CardEdition> getEditionFilter() {
|
public Predicate<CardEdition> getEditionFilter() {
|
||||||
Predicate<CardEdition> filter;
|
Predicate<CardEdition> filter;
|
||||||
switch(tag) {
|
switch(tag) {
|
||||||
@@ -63,6 +66,10 @@ public class ThemedChaosDraft implements Comparable<ThemedChaosDraft> {
|
|||||||
return filter;
|
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>() {
|
private final Predicate<CardEdition> themedFilter = new Predicate<CardEdition>() {
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(final CardEdition cardEdition) {
|
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) {
|
private Predicate<CardEdition> getFormatFilter(String formatName) {
|
||||||
GameFormat.Collection formats = FModel.getFormats();
|
GameFormat.Collection formats = FModel.getFormats();
|
||||||
GameFormat format;
|
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>() {
|
private static final Predicate<CardEdition> DEFAULT_FILTER = new Predicate<CardEdition>() {
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(final CardEdition cardEdition) {
|
public boolean apply(final CardEdition cardEdition) {
|
||||||
|
|||||||
Reference in New Issue
Block a user