From 0e5ad8bd2d056509f6841cb73b6137f35bf33428 Mon Sep 17 00:00:00 2001 From: RumbleBBU Date: Fri, 16 Nov 2012 07:00:33 +0000 Subject: [PATCH] New formula for unlock prices, minor checkstyle. --- .../java/forge/quest/QuestUtilUnlockSets.java | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/main/java/forge/quest/QuestUtilUnlockSets.java b/src/main/java/forge/quest/QuestUtilUnlockSets.java index 46e1f51e7e0..7e4ecc1c0e8 100644 --- a/src/main/java/forge/quest/QuestUtilUnlockSets.java +++ b/src/main/java/forge/quest/QuestUtilUnlockSets.java @@ -61,12 +61,13 @@ public class QuestUtilUnlockSets { final ReadPriceList prices = new ReadPriceList(); final Map mapPrices = prices.getPriceList(); - final List> setPrices = new ArrayList>(); + final List> setPrices = new ArrayList>(); for (CardEdition ed : getUnlockableEditions(qData)) { int price = 7500; if (mapPrices.containsKey(ed.getName() + " Booster Pack")) { - price = Math.max( 50 * mapPrices.get(ed.getName() + " Booster Pack"), 7500 ); + price = Math.max(new Double(60 * Math.pow(Math.sqrt(mapPrices.get(ed.getName() + + " Booster Pack")), 1.65)).intValue(), 7500); } setPrices.add(ImmutablePair.of(ed, price)); } @@ -82,12 +83,10 @@ public class QuestUtilUnlockSets { return null; } - ImmutablePair toBuy = setPrices.get(index); int price = toBuy.right; CardEdition choosenEdition = toBuy.left; - if (qData.getAssets().getCredits() < price) { JOptionPane.showMessageDialog(null, "Unfortunately, you cannot afford that set yet.\n" @@ -129,19 +128,20 @@ public class QuestUtilUnlockSets { // Sort current sets by index List allowedSets = Lists.newArrayList(Iterables.transform(qData.getFormat().getAllowedSetCodes(), Singletons.getModel().getEditions().FN_EDITION_BY_CODE)); Collections.sort(allowedSets); - + // Sort unlockable sets by index List excludedSets = Lists.newArrayList(Iterables.transform(qData.getFormat().getLockedSets(), Singletons.getModel().getEditions().FN_EDITION_BY_CODE)); Collections.sort(excludedSets); - + // get a number of sets between an excluded and any included set - List> excludedWithDistances = new ArrayList>(); - for(CardEdition ex : excludedSets) { + List> excludedWithDistances = new ArrayList>(); + for (CardEdition ex : excludedSets) { int distance = Integer.MAX_VALUE; - for(CardEdition in : allowedSets) { + for (CardEdition in : allowedSets) { int d = Math.abs(ex.getIndex() - in.getIndex()); - if ( d < distance ) + if (d < distance) { distance = d; + } } excludedWithDistances.add(ImmutablePair.of(ex, distance)); }