- Add a Quest Preference for Item Level Restriction, defaulting to enabled (1).

This commit is contained in:
Sol
2014-09-29 23:55:44 +00:00
parent 72cf37406f
commit 239f49c53d
4 changed files with 17 additions and 2 deletions

View File

@@ -234,6 +234,9 @@ public class QuestPreferencesHandler extends SkinnedPanel {
pnlShop.add(new FLabel.Builder().text("Rare Singles").build(), constraints2); pnlShop.add(new FLabel.Builder().text("Rare Singles").build(), constraints2);
pnlShop.add(new PrefInput(QPref.SHOP_SINGLES_RARE, ErrType.SHOP), constraints1); pnlShop.add(new PrefInput(QPref.SHOP_SINGLES_RARE, ErrType.SHOP), constraints1);
pnlShop.add(new FLabel.Builder().text("Item Level Restriction").build(), constraints2);
pnlShop.add(new PrefInput(QPref.ITEM_LEVEL_RESTRICTION, ErrType.SHOP), constraints1);
constraints1 = "w 100%!, gap 0 0 20px 0"; constraints1 = "w 100%!, gap 0 0 20px 0";
this.add(pnlRewards, constraints1); this.add(pnlRewards, constraints1);
this.add(pnlDifficulty, constraints1); this.add(pnlDifficulty, constraints1);

View File

@@ -372,6 +372,9 @@ public enum VSubmenuQuestPrefs implements IVSubmenu<CSubmenuQuestPrefs> {
pnlShop.add(new FLabel.Builder().text("Rare Singles").fontAlign(SwingConstants.RIGHT).build(), constraints2); pnlShop.add(new FLabel.Builder().text("Rare Singles").fontAlign(SwingConstants.RIGHT).build(), constraints2);
pnlShop.add(new PrefInput(QPref.SHOP_SINGLES_RARE, QuestPreferencesErrType.SHOP), constraints1); pnlShop.add(new PrefInput(QPref.SHOP_SINGLES_RARE, QuestPreferencesErrType.SHOP), constraints1);
pnlShop.add(new FLabel.Builder().text("Item Level Restriction").fontAlign(SwingConstants.RIGHT).build(), constraints2);
pnlShop.add(new PrefInput(QPref.ITEM_LEVEL_RESTRICTION, QuestPreferencesErrType.SHOP), constraints1);
} }
/** */ /** */

View File

@@ -24,9 +24,11 @@ import com.thoughtworks.xstream.annotations.XStreamAlias;
import com.thoughtworks.xstream.annotations.XStreamAsAttribute; import com.thoughtworks.xstream.annotations.XStreamAsAttribute;
import forge.item.PaperToken; import forge.item.PaperToken;
import forge.model.FModel;
import forge.properties.ForgeConstants; import forge.properties.ForgeConstants;
import forge.quest.QuestController; import forge.quest.QuestController;
import forge.quest.data.QuestAssets; import forge.quest.data.QuestAssets;
import forge.quest.data.QuestPreferences;
/** /**
* <p> * <p>
@@ -243,7 +245,8 @@ public class QuestPetController implements IQuestBazaarItem {
@Override @Override
public boolean isAvailableForPurchase(final QuestAssets qA, QuestController qCtrl) { public boolean isAvailableForPurchase(final QuestAssets qA, QuestController qCtrl) {
return this.getPetLevel(qA) < this.getMaxLevel() && return this.getPetLevel(qA) < this.getMaxLevel() &&
(qCtrl == null || qCtrl.getLevel() >= this.getPetLevel(qA)); (qCtrl == null || qCtrl.getLevel() >= this.getPetLevel(qA) ||
FModel.getQuestPreferences().getPrefInt(QuestPreferences.QPref.ITEM_LEVEL_RESTRICTION) == 0);
} }
/** /**

View File

@@ -146,7 +146,9 @@ public class QuestPreferences extends PreferencesStore<QuestPreferences.QPref> i
// How many wins it takes to open an additional pack in the shop // How many wins it takes to open an additional pack in the shop
SHOP_WINS_FOR_ADDITIONAL_PACK("10"), SHOP_WINS_FOR_ADDITIONAL_PACK("10"),
// How many packs the shop start with. // How many packs the shop start with.
SHOP_STARTING_PACKS("5"); SHOP_STARTING_PACKS("5"),
ITEM_LEVEL_RESTRICTION("1");
private final String strDefaultVal; private final String strDefaultVal;
@@ -335,6 +337,10 @@ public class QuestPreferences extends PreferencesStore<QuestPreferences.QPref> i
return "Bias value too large (maximum 10)."; return "Bias value too large (maximum 10).";
} }
break; break;
case ITEM_LEVEL_RESTRICTION:
if (val != 0 && val != 1) {
return "Only values 0 or 1 are acceptable. 1 for enabled, 0 for disabled.";
}
default: default:
if (val > 100) { if (val > 100) {
return "Value too large (maximum 100)."; return "Value too large (maximum 100).";