mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-16 02:38:02 +00:00
- Sort custom drafts / cubes alphabetically in the list.
This commit is contained in:
@@ -43,6 +43,7 @@ import java.util.*;
|
|||||||
* Booster Draft Format.
|
* Booster Draft Format.
|
||||||
*/
|
*/
|
||||||
public class BoosterDraft implements IBoosterDraft {
|
public class BoosterDraft implements IBoosterDraft {
|
||||||
|
|
||||||
private static final int N_PLAYERS = 8;
|
private static final int N_PLAYERS = 8;
|
||||||
public static final String FILE_EXT = ".draft";
|
public static final String FILE_EXT = ".draft";
|
||||||
private final List<LimitedPlayer> players = new ArrayList<>();
|
private final List<LimitedPlayer> players = new ArrayList<>();
|
||||||
@@ -60,7 +61,9 @@ public class BoosterDraft implements IBoosterDraft {
|
|||||||
|
|
||||||
public static BoosterDraft createDraft(final LimitedPoolType draftType) {
|
public static BoosterDraft createDraft(final LimitedPoolType draftType) {
|
||||||
final BoosterDraft draft = new BoosterDraft(draftType);
|
final BoosterDraft draft = new BoosterDraft(draftType);
|
||||||
if (!draft.generateProduct()) { return null; }
|
if (!draft.generateProduct()) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
draft.initializeBoosters();
|
draft.initializeBoosters();
|
||||||
return draft;
|
return draft;
|
||||||
}
|
}
|
||||||
@@ -91,7 +94,9 @@ public class BoosterDraft implements IBoosterDraft {
|
|||||||
}
|
}
|
||||||
|
|
||||||
final CardBlock block = SGuiChoose.oneOrNone("Choose Block", blocks);
|
final CardBlock block = SGuiChoose.oneOrNone("Choose Block", blocks);
|
||||||
if (block == null) { return false; }
|
if (block == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
final List<CardEdition> cardSets = block.getSets();
|
final List<CardEdition> cardSets = block.getSets();
|
||||||
final Stack<String> sets = new Stack<>();
|
final Stack<String> sets = new Stack<>();
|
||||||
@@ -120,14 +125,15 @@ public class BoosterDraft implements IBoosterDraft {
|
|||||||
p = choosePackByPack(sets, nPacks);
|
p = choosePackByPack(sets, nPacks);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (p == null) { return false; }
|
if (p == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
final String[] pp = p.toString().split("/");
|
final String[] pp = p.toString().split("/");
|
||||||
for (int i = 0; i < nPacks; i++) {
|
for (int i = 0; i < nPacks; i++) {
|
||||||
this.product.add(block.getBooster(pp[i]));
|
this.product.add(block.getBooster(pp[i]));
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
final IUnOpenedProduct product1 = block.getBooster(sets.get(0));
|
final IUnOpenedProduct product1 = block.getBooster(sets.get(0));
|
||||||
|
|
||||||
for (int i = 0; i < nPacks; i++) {
|
for (int i = 0; i < nPacks; i++) {
|
||||||
@@ -142,12 +148,20 @@ public class BoosterDraft implements IBoosterDraft {
|
|||||||
case Custom:
|
case Custom:
|
||||||
final List<CustomLimited> myDrafts = loadCustomDrafts();
|
final List<CustomLimited> myDrafts = loadCustomDrafts();
|
||||||
|
|
||||||
|
myDrafts.sort(new Comparator<CustomLimited>() {
|
||||||
|
@Override
|
||||||
|
public int compare(CustomLimited o1, CustomLimited o2) {
|
||||||
|
return o1.getName().compareTo(o2.getName());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
if (myDrafts.isEmpty()) {
|
if (myDrafts.isEmpty()) {
|
||||||
SOptionPane.showMessageDialog("No custom draft files found.");
|
SOptionPane.showMessageDialog("No custom draft files found.");
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
final CustomLimited customDraft = SGuiChoose.oneOrNone("Choose Custom Draft", myDrafts);
|
final CustomLimited customDraft = SGuiChoose.oneOrNone("Choose Custom Draft", myDrafts);
|
||||||
if (customDraft == null) { return false; }
|
if (customDraft == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
this.setupCustomDraft(customDraft);
|
this.setupCustomDraft(customDraft);
|
||||||
}
|
}
|
||||||
@@ -177,6 +191,7 @@ public class BoosterDraft implements IBoosterDraft {
|
|||||||
protected BoosterDraft() {
|
protected BoosterDraft() {
|
||||||
this(LimitedPoolType.Full);
|
this(LimitedPoolType.Full);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected BoosterDraft(final LimitedPoolType draftType) {
|
protected BoosterDraft(final LimitedPoolType draftType) {
|
||||||
this.draftFormat = draftType;
|
this.draftFormat = draftType;
|
||||||
|
|
||||||
@@ -210,7 +225,9 @@ public class BoosterDraft implements IBoosterDraft {
|
|||||||
IBoosterDraft.CUSTOM_RANKINGS_FILE[0] = draft.getCustomRankingsFileName();
|
IBoosterDraft.CUSTOM_RANKINGS_FILE[0] = draft.getCustomRankingsFileName();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Looks for draft files, reads them, returns a list. */
|
/**
|
||||||
|
* Looks for draft files, reads them, returns a list.
|
||||||
|
*/
|
||||||
private static List<CustomLimited> loadCustomDrafts() {
|
private static List<CustomLimited> loadCustomDrafts() {
|
||||||
String[] dList;
|
String[] dList;
|
||||||
final List<CustomLimited> customs = new ArrayList<>();
|
final List<CustomLimited> customs = new ArrayList<>();
|
||||||
@@ -335,7 +352,9 @@ public class BoosterDraft implements IBoosterDraft {
|
|||||||
return !this.isRoundOver() || !this.localPlayer.unopenedPacks.isEmpty();
|
return !this.isRoundOver() || !this.localPlayer.unopenedPacks.isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** {@inheritDoc} */
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void setChoice(final PaperCard c) {
|
public void setChoice(final PaperCard c) {
|
||||||
final List<PaperCard> thisBooster = this.localPlayer.nextChoice();
|
final List<PaperCard> thisBooster = this.localPlayer.nextChoice();
|
||||||
@@ -352,7 +371,6 @@ public class BoosterDraft implements IBoosterDraft {
|
|||||||
this.passPacks();
|
this.passPacks();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private static String choosePackByPack(final List<String> setz, int packs) {
|
private static String choosePackByPack(final List<String> setz, int packs) {
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
|
|
||||||
@@ -443,15 +461,13 @@ public class BoosterDraft implements IBoosterDraft {
|
|||||||
if (cc.equals(c)) {
|
if (cc.equals(c)) {
|
||||||
pickValue = thisBooster.size()
|
pickValue = thisBooster.size()
|
||||||
* (1f - (((float) this.currentBoosterPick / this.currentBoosterSize) * 2f));
|
* (1f - (((float) this.currentBoosterPick / this.currentBoosterSize) * 2f));
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
pickValue = 0;
|
pickValue = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!this.draftPicks.containsKey(cnBk)) {
|
if (!this.draftPicks.containsKey(cnBk)) {
|
||||||
this.draftPicks.put(cnBk, pickValue);
|
this.draftPicks.put(cnBk, pickValue);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
final float curValue = this.draftPicks.get(cnBk);
|
final float curValue = this.draftPicks.get(cnBk);
|
||||||
final float newValue = (curValue + pickValue) / 2;
|
final float newValue = (curValue + pickValue) / 2;
|
||||||
this.draftPicks.put(cnBk, newValue);
|
this.draftPicks.put(cnBk, newValue);
|
||||||
|
|||||||
Reference in New Issue
Block a user