mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-18 11:48:02 +00:00
Introduced 2 quest preferences for the multiplier and the number of wild
opponents
This commit is contained in:
@@ -1,5 +1,7 @@
|
|||||||
package forge.screens.home.quest;
|
package forge.screens.home.quest;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
import javax.swing.SwingUtilities;
|
import javax.swing.SwingUtilities;
|
||||||
|
|
||||||
import com.google.common.primitives.Ints;
|
import com.google.common.primitives.Ints;
|
||||||
@@ -7,6 +9,7 @@ import com.google.common.primitives.Ints;
|
|||||||
import forge.gui.framework.ICDoc;
|
import forge.gui.framework.ICDoc;
|
||||||
import forge.model.FModel;
|
import forge.model.FModel;
|
||||||
import forge.quest.data.QuestPreferences;
|
import forge.quest.data.QuestPreferences;
|
||||||
|
import forge.quest.data.QuestPreferences.QPref;
|
||||||
import forge.screens.home.quest.VSubmenuQuestPrefs.PrefInput;
|
import forge.screens.home.quest.VSubmenuQuestPrefs.PrefInput;
|
||||||
import forge.util.Localizer;
|
import forge.util.Localizer;
|
||||||
|
|
||||||
@@ -50,16 +53,29 @@ public enum CSubmenuQuestPrefs implements ICDoc {
|
|||||||
public static void validateAndSave(final PrefInput i0) {
|
public static void validateAndSave(final PrefInput i0) {
|
||||||
if (i0.getText().equals(i0.getPreviousText())) { return; }
|
if (i0.getText().equals(i0.getPreviousText())) { return; }
|
||||||
final QuestPreferences prefs = FModel.getQuestPreferences();
|
final QuestPreferences prefs = FModel.getQuestPreferences();
|
||||||
|
|
||||||
final Integer val = Ints.tryParse(i0.getText());
|
String validationError = null;
|
||||||
resetErrors();
|
|
||||||
final Localizer localizer = Localizer.getInstance();
|
final Localizer localizer = Localizer.getInstance();
|
||||||
final String validationError = val == null ? localizer.getMessage("lblEnteraNumber") : prefs.validatePreference(i0.getQPref(), val.intValue());
|
resetErrors();
|
||||||
|
|
||||||
|
if(QPref.UNLOCK_DISTANCE_MULTIPLIER.equals(i0.getQPref())
|
||||||
|
|| QPref.WILD_OPPONENTS_MULTIPLIER.equals(i0.getQPref())) {
|
||||||
|
Double val = null;
|
||||||
|
try {
|
||||||
|
val = new Double(i0.getText());
|
||||||
|
} catch (Exception e) {
|
||||||
|
}
|
||||||
|
validationError = val == null ? localizer.getMessage("lblEnteraDecimal") : null;
|
||||||
|
} else {
|
||||||
|
final Integer val = Ints.tryParse(i0.getText());
|
||||||
|
validationError = val == null ? localizer.getMessage("lblEnteraNumber") : prefs.validatePreference(i0.getQPref(), val.intValue());
|
||||||
|
}
|
||||||
|
|
||||||
if (validationError != null) {
|
if (validationError != null) {
|
||||||
showError(i0, validationError);
|
showError(i0, validationError);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
prefs.setPref(i0.getQPref(), i0.getText());
|
prefs.setPref(i0.getQPref(), i0.getText());
|
||||||
prefs.save();
|
prefs.save();
|
||||||
i0.setPreviousText(i0.getText());
|
i0.setPreviousText(i0.getText());
|
||||||
|
|||||||
@@ -292,6 +292,10 @@ public enum VSubmenuQuestPrefs implements IVSubmenu<CSubmenuQuestPrefs> {
|
|||||||
pnlDifficulty.add(new PrefInput(QPref.PENALTY_LOSS, QuestPreferencesErrType.DIFFICULTY), fieldConstraints + ", wrap");
|
pnlDifficulty.add(new PrefInput(QPref.PENALTY_LOSS, QuestPreferencesErrType.DIFFICULTY), fieldConstraints + ", wrap");
|
||||||
pnlDifficulty.add(new FLabel.Builder().text(localizer.getMessage("lblMoreDuelChoices")).fontAlign(SwingConstants.RIGHT).build(), labelConstraints);
|
pnlDifficulty.add(new FLabel.Builder().text(localizer.getMessage("lblMoreDuelChoices")).fontAlign(SwingConstants.RIGHT).build(), labelConstraints);
|
||||||
pnlDifficulty.add(new PrefInput(QPref.MORE_DUEL_CHOICES, QuestPreferencesErrType.DIFFICULTY), fieldConstraints + ", wrap");
|
pnlDifficulty.add(new PrefInput(QPref.MORE_DUEL_CHOICES, QuestPreferencesErrType.DIFFICULTY), fieldConstraints + ", wrap");
|
||||||
|
pnlDifficulty.add(new FLabel.Builder().text(localizer.getMessage("lblWildOpponentMultiplier")).fontAlign(SwingConstants.RIGHT).build(), labelConstraints);
|
||||||
|
pnlDifficulty.add(new PrefInput(QPref.WILD_OPPONENTS_MULTIPLIER, QuestPreferencesErrType.DIFFICULTY), fieldConstraints + ", wrap");
|
||||||
|
pnlDifficulty.add(new FLabel.Builder().text(localizer.getMessage("lblWildOpponentNumber")).fontAlign(SwingConstants.RIGHT).build(), labelConstraints);
|
||||||
|
pnlDifficulty.add(new PrefInput(QPref.WILD_OPPONENTS_NUMBER, QuestPreferencesErrType.DIFFICULTY), fieldConstraints + ", wrap");
|
||||||
}
|
}
|
||||||
private void populateBooster() {
|
private void populateBooster() {
|
||||||
pnlBooster.setOpaque(false);
|
pnlBooster.setOpaque(false);
|
||||||
|
|||||||
@@ -2583,4 +2583,8 @@ lblEnterMessageToSend=Enter message to send
|
|||||||
#OnlineLobbyScreen.java
|
#OnlineLobbyScreen.java
|
||||||
lblDetectedInvalidHostAddress=Invalid host address ({0}) was detected.
|
lblDetectedInvalidHostAddress=Invalid host address ({0}) was detected.
|
||||||
#Player.java
|
#Player.java
|
||||||
lblChooseACompanion=Choose a companion
|
lblChooseACompanion=Choose a companion
|
||||||
|
lblWildOpponentMultiplier=Wild Multiplier
|
||||||
|
lblEnteraDecimal=Enter a decimal
|
||||||
|
lblWildOpponentNumber=Number of Wild Opponents
|
||||||
|
lblWildOpponentNumberError=Wild Opponents can only be 0 to 3
|
||||||
@@ -119,4 +119,8 @@ public abstract class PreferencesStore<T extends Enum<T>> {
|
|||||||
public final boolean getPrefBoolean(final T fp0) {
|
public final boolean getPrefBoolean(final T fp0) {
|
||||||
return Boolean.parseBoolean(getPref(fp0));
|
return Boolean.parseBoolean(getPref(fp0));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public final double getPrefDouble(final T fp0) {
|
||||||
|
return Double.parseDouble(getPref(fp0));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -188,7 +188,7 @@ public class MainWorldEventDuelManager implements QuestEventDuelManagerInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
//TODO put in preferences the number of wild duels to add
|
//TODO put in preferences the number of wild duels to add
|
||||||
addDuel(duelOpponents, QuestEventDifficulty.WILD, 3);
|
addDuel(duelOpponents, QuestEventDifficulty.WILD, FModel.getQuestPreferences().getPrefInt(QPref.WILD_OPPONENTS_NUMBER));
|
||||||
addRandomDuel(duelOpponents, randomDuelDifficulty);
|
addRandomDuel(duelOpponents, randomDuelDifficulty);
|
||||||
|
|
||||||
return duelOpponents;
|
return duelOpponents;
|
||||||
|
|||||||
@@ -2,6 +2,9 @@ package forge.quest;
|
|||||||
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
|
import forge.model.FModel;
|
||||||
|
import forge.quest.data.QuestPreferences.QPref;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TODO: Write javadoc for this type.
|
* TODO: Write javadoc for this type.
|
||||||
*
|
*
|
||||||
@@ -11,7 +14,7 @@ public enum QuestEventDifficulty {
|
|||||||
MEDIUM("medium", 1.5),
|
MEDIUM("medium", 1.5),
|
||||||
HARD ("hard", 2. ),
|
HARD ("hard", 2. ),
|
||||||
EXPERT("very hard", 3. ),
|
EXPERT("very hard", 3. ),
|
||||||
WILD("wild", 2. );
|
WILD("wild", FModel.getQuestPreferences().getPrefDouble(QPref.WILD_OPPONENTS_MULTIPLIER) );
|
||||||
|
|
||||||
private final String inFile;
|
private final String inFile;
|
||||||
private final double multiplier;
|
private final double multiplier;
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ package forge.quest.data;
|
|||||||
|
|
||||||
import forge.properties.ForgeConstants;
|
import forge.properties.ForgeConstants;
|
||||||
import forge.properties.PreferencesStore;
|
import forge.properties.PreferencesStore;
|
||||||
|
import forge.util.Localizer;
|
||||||
import forge.util.TextUtil;
|
import forge.util.TextUtil;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
@@ -173,6 +174,8 @@ public class QuestPreferences extends PreferencesStore<QuestPreferences.QPref> i
|
|||||||
SHOP_WINS_FOR_NO_SELL_LIMIT("50"),
|
SHOP_WINS_FOR_NO_SELL_LIMIT("50"),
|
||||||
// Duels of the current difficulty only, or that and all difficulties below it?
|
// Duels of the current difficulty only, or that and all difficulties below it?
|
||||||
MORE_DUEL_CHOICES("0"),
|
MORE_DUEL_CHOICES("0"),
|
||||||
|
WILD_OPPONENTS_MULTIPLIER("2.0"),
|
||||||
|
WILD_OPPONENTS_NUMBER("0"),
|
||||||
|
|
||||||
//The number of cards to keep before selling
|
//The number of cards to keep before selling
|
||||||
PLAYSET_SIZE("4"),
|
PLAYSET_SIZE("4"),
|
||||||
@@ -313,6 +316,11 @@ public class QuestPreferences extends PreferencesStore<QuestPreferences.QPref> i
|
|||||||
return "Value too small (minimum 1).";
|
return "Value too small (minimum 1).";
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case WILD_OPPONENTS_NUMBER:
|
||||||
|
if(val < 0 || val > 3) {
|
||||||
|
return Localizer.getInstance().getMessage("lblWildOpponentNumberError");
|
||||||
|
}
|
||||||
|
break;
|
||||||
case BOOSTER_COMMONS:
|
case BOOSTER_COMMONS:
|
||||||
case BOOSTER_UNCOMMONS:
|
case BOOSTER_UNCOMMONS:
|
||||||
case BOOSTER_RARES:
|
case BOOSTER_RARES:
|
||||||
|
|||||||
Reference in New Issue
Block a user