Adds an option to choose between draft rotation deleting, or replacing old drafts.

Also moves the draft rotation settings to appear under "draft torunaments" where they belong.
This commit is contained in:
Seravy
2018-02-08 14:13:11 +01:00
parent 36917c0d18
commit 569e884a2c
3 changed files with 21 additions and 8 deletions

View File

@@ -329,12 +329,6 @@ public enum VSubmenuQuestPrefs implements IVSubmenu<CSubmenuQuestPrefs> {
pnlDifficulty.add(new FLabel.Builder().text("Wins for New Challenge").fontAlign(SwingConstants.RIGHT).build(), labelConstraints); pnlDifficulty.add(new FLabel.Builder().text("Wins for New Challenge").fontAlign(SwingConstants.RIGHT).build(), labelConstraints);
pnlDifficulty.add(new PrefInput(QPref.WINS_NEW_CHALLENGE, QuestPreferencesErrType.DIFFICULTY), fieldConstraints + ", wrap"); pnlDifficulty.add(new PrefInput(QPref.WINS_NEW_CHALLENGE, QuestPreferencesErrType.DIFFICULTY), fieldConstraints + ", wrap");
pnlDifficulty.add(new FLabel.Builder().text("Wins for New Draft").fontAlign(SwingConstants.RIGHT).build(), labelConstraints);
pnlDifficulty.add(new PrefInput(QPref.WINS_NEW_DRAFT, QuestPreferencesErrType.DIFFICULTY), fieldConstraints + ", wrap");
pnlDifficulty.add(new FLabel.Builder().text("Wins per Draft Rotation").fontAlign(SwingConstants.RIGHT).build(), labelConstraints);
pnlDifficulty.add(new PrefInput(QPref.WINS_ROTATE_DRAFT, QuestPreferencesErrType.DIFFICULTY), fieldConstraints + ", wrap");
pnlDifficulty.add(new FLabel.Builder().text("Starting Snow Lands").fontAlign(SwingConstants.RIGHT).build(), labelConstraints); pnlDifficulty.add(new FLabel.Builder().text("Starting Snow Lands").fontAlign(SwingConstants.RIGHT).build(), labelConstraints);
pnlDifficulty.add(new PrefInput(QPref.STARTING_SNOW_LANDS, QuestPreferencesErrType.DIFFICULTY), fieldConstraints + ", wrap"); pnlDifficulty.add(new PrefInput(QPref.STARTING_SNOW_LANDS, QuestPreferencesErrType.DIFFICULTY), fieldConstraints + ", wrap");
@@ -455,6 +449,19 @@ public enum VSubmenuQuestPrefs implements IVSubmenu<CSubmenuQuestPrefs> {
pnlDraftTournaments.add(randomAIMatches, labelConstraints); pnlDraftTournaments.add(randomAIMatches, labelConstraints);
pnlDraftTournaments.add(new PrefInput(QPref.SIMULATE_AI_VS_AI_RESULTS, QuestPreferencesErrType.DRAFT_TOURNAMENTS), fieldConstraints); pnlDraftTournaments.add(new PrefInput(QPref.SIMULATE_AI_VS_AI_RESULTS, QuestPreferencesErrType.DRAFT_TOURNAMENTS), fieldConstraints);
pnlDraftTournaments.add(new FLabel.Builder().text("Wins for New Draft").fontAlign(SwingConstants.RIGHT).build(), labelConstraints);
pnlDraftTournaments.add(new PrefInput(QPref.WINS_NEW_DRAFT, QuestPreferencesErrType.DIFFICULTY), fieldConstraints + ", wrap");
FLabel rotam = new FLabel.Builder().text("Wins per Draft Rotation").fontAlign(SwingConstants.RIGHT).build();
rotam.setToolTipText("If a Draft is not played for this many match wins, it will be removed or replaced.");
pnlDraftTournaments.add(rotam, labelConstraints);
pnlDraftTournaments.add(new PrefInput(QPref.WINS_ROTATE_DRAFT, QuestPreferencesErrType.DIFFICULTY), fieldConstraints + ", wrap");
FLabel rottp = new FLabel.Builder().text("Rotation Type").fontAlign(SwingConstants.RIGHT).build();
rottp.setToolTipText("If set to 0, old drafts disappear, if set to 1, they are replaced with another one using different sets.");
pnlDraftTournaments.add(rottp, labelConstraints);
pnlDraftTournaments.add(new PrefInput(QPref.DRAFT_ROTATION, QuestPreferencesErrType.DIFFICULTY), fieldConstraints + ", wrap");
} }
/** */ /** */

View File

@@ -236,11 +236,16 @@ public class QuestAchievements {
draftsToGenerate = 1; draftsToGenerate = 1;
} }
// Draft too old, needs to rotate
Set<QuestEventDraft> toRemove = new HashSet<>(); Set<QuestEventDraft> toRemove = new HashSet<>();
for (QuestEventDraft draft : drafts) { for (QuestEventDraft draft : drafts) {
if (draft.getAge() <= 0 if (draft.getAge() <= 0
&& !(currentDraft != -1 && drafts.get(currentDraft) == draft)) { && !(currentDraft != -1 && drafts.get(currentDraft) == draft)) {
// Remove and generate another
toRemove.add(draft); toRemove.add(draft);
if (FModel.getQuestPreferences().getPrefInt(QPref.DRAFT_ROTATION) != 0) {
draftsToGenerate++;
}
break; break;
} }
} }

View File

@@ -176,7 +176,8 @@ public class QuestPreferences extends PreferencesStore<QuestPreferences.QPref> i
ITEM_LEVEL_RESTRICTION("1"), ITEM_LEVEL_RESTRICTION("1"),
SIMULATE_AI_VS_AI_RESULTS("0"); SIMULATE_AI_VS_AI_RESULTS("0"),
DRAFT_ROTATION("0");
private final String strDefaultVal; private final String strDefaultVal;
@@ -279,7 +280,7 @@ public class QuestPreferences extends PreferencesStore<QuestPreferences.QPref> i
return "Bias value too large (maximum 100)."; return "Bias value too large (maximum 100).";
} }
break; break;
case DRAFT_ROTATION:
case SPECIAL_BOOSTERS: case SPECIAL_BOOSTERS:
case ITEM_LEVEL_RESTRICTION: case ITEM_LEVEL_RESTRICTION:
if (val != 0 && val != 1) { if (val != 0 && val != 1) {