mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-18 03:38:01 +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;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
import javax.swing.SwingUtilities;
|
||||
|
||||
import com.google.common.primitives.Ints;
|
||||
@@ -7,6 +9,7 @@ import com.google.common.primitives.Ints;
|
||||
import forge.gui.framework.ICDoc;
|
||||
import forge.model.FModel;
|
||||
import forge.quest.data.QuestPreferences;
|
||||
import forge.quest.data.QuestPreferences.QPref;
|
||||
import forge.screens.home.quest.VSubmenuQuestPrefs.PrefInput;
|
||||
import forge.util.Localizer;
|
||||
|
||||
@@ -51,10 +54,23 @@ public enum CSubmenuQuestPrefs implements ICDoc {
|
||||
if (i0.getText().equals(i0.getPreviousText())) { return; }
|
||||
final QuestPreferences prefs = FModel.getQuestPreferences();
|
||||
|
||||
final Integer val = Ints.tryParse(i0.getText());
|
||||
resetErrors();
|
||||
String validationError = null;
|
||||
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) {
|
||||
showError(i0, validationError);
|
||||
return;
|
||||
|
||||
@@ -292,6 +292,10 @@ public enum VSubmenuQuestPrefs implements IVSubmenu<CSubmenuQuestPrefs> {
|
||||
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 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() {
|
||||
pnlBooster.setOpaque(false);
|
||||
|
||||
@@ -2584,3 +2584,7 @@ lblEnterMessageToSend=Enter message to send
|
||||
lblDetectedInvalidHostAddress=Invalid host address ({0}) was detected.
|
||||
#Player.java
|
||||
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) {
|
||||
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
|
||||
addDuel(duelOpponents, QuestEventDifficulty.WILD, 3);
|
||||
addDuel(duelOpponents, QuestEventDifficulty.WILD, FModel.getQuestPreferences().getPrefInt(QPref.WILD_OPPONENTS_NUMBER));
|
||||
addRandomDuel(duelOpponents, randomDuelDifficulty);
|
||||
|
||||
return duelOpponents;
|
||||
|
||||
@@ -2,6 +2,9 @@ package forge.quest;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import forge.model.FModel;
|
||||
import forge.quest.data.QuestPreferences.QPref;
|
||||
|
||||
/**
|
||||
* TODO: Write javadoc for this type.
|
||||
*
|
||||
@@ -11,7 +14,7 @@ public enum QuestEventDifficulty {
|
||||
MEDIUM("medium", 1.5),
|
||||
HARD ("hard", 2. ),
|
||||
EXPERT("very hard", 3. ),
|
||||
WILD("wild", 2. );
|
||||
WILD("wild", FModel.getQuestPreferences().getPrefDouble(QPref.WILD_OPPONENTS_MULTIPLIER) );
|
||||
|
||||
private final String inFile;
|
||||
private final double multiplier;
|
||||
|
||||
@@ -19,6 +19,7 @@ package forge.quest.data;
|
||||
|
||||
import forge.properties.ForgeConstants;
|
||||
import forge.properties.PreferencesStore;
|
||||
import forge.util.Localizer;
|
||||
import forge.util.TextUtil;
|
||||
|
||||
import java.io.Serializable;
|
||||
@@ -173,6 +174,8 @@ public class QuestPreferences extends PreferencesStore<QuestPreferences.QPref> i
|
||||
SHOP_WINS_FOR_NO_SELL_LIMIT("50"),
|
||||
// Duels of the current difficulty only, or that and all difficulties below it?
|
||||
MORE_DUEL_CHOICES("0"),
|
||||
WILD_OPPONENTS_MULTIPLIER("2.0"),
|
||||
WILD_OPPONENTS_NUMBER("0"),
|
||||
|
||||
//The number of cards to keep before selling
|
||||
PLAYSET_SIZE("4"),
|
||||
@@ -313,6 +316,11 @@ public class QuestPreferences extends PreferencesStore<QuestPreferences.QPref> i
|
||||
return "Value too small (minimum 1).";
|
||||
}
|
||||
break;
|
||||
case WILD_OPPONENTS_NUMBER:
|
||||
if(val < 0 || val > 3) {
|
||||
return Localizer.getInstance().getMessage("lblWildOpponentNumberError");
|
||||
}
|
||||
break;
|
||||
case BOOSTER_COMMONS:
|
||||
case BOOSTER_UNCOMMONS:
|
||||
case BOOSTER_RARES:
|
||||
|
||||
Reference in New Issue
Block a user