New formula for unlock prices, minor checkstyle.

This commit is contained in:
RumbleBBU
2012-11-16 07:00:33 +00:00
parent c5f2c48fd8
commit 0e5ad8bd2d

View File

@@ -61,12 +61,13 @@ public class QuestUtilUnlockSets {
final ReadPriceList prices = new ReadPriceList(); final ReadPriceList prices = new ReadPriceList();
final Map<String, Integer> mapPrices = prices.getPriceList(); final Map<String, Integer> mapPrices = prices.getPriceList();
final List<ImmutablePair<CardEdition, Integer>> setPrices = new ArrayList<ImmutablePair<CardEdition,Integer>>(); final List<ImmutablePair<CardEdition, Integer>> setPrices = new ArrayList<ImmutablePair<CardEdition, Integer>>();
for (CardEdition ed : getUnlockableEditions(qData)) { for (CardEdition ed : getUnlockableEditions(qData)) {
int price = 7500; int price = 7500;
if (mapPrices.containsKey(ed.getName() + " Booster Pack")) { 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)); setPrices.add(ImmutablePair.of(ed, price));
} }
@@ -82,12 +83,10 @@ public class QuestUtilUnlockSets {
return null; return null;
} }
ImmutablePair<CardEdition, Integer> toBuy = setPrices.get(index); ImmutablePair<CardEdition, Integer> toBuy = setPrices.get(index);
int price = toBuy.right; int price = toBuy.right;
CardEdition choosenEdition = toBuy.left; CardEdition choosenEdition = toBuy.left;
if (qData.getAssets().getCredits() < price) { if (qData.getAssets().getCredits() < price) {
JOptionPane.showMessageDialog(null, "Unfortunately, you cannot afford that set yet.\n" JOptionPane.showMessageDialog(null, "Unfortunately, you cannot afford that set yet.\n"
@@ -129,19 +128,20 @@ public class QuestUtilUnlockSets {
// Sort current sets by index // Sort current sets by index
List<CardEdition> allowedSets = Lists.newArrayList(Iterables.transform(qData.getFormat().getAllowedSetCodes(), Singletons.getModel().getEditions().FN_EDITION_BY_CODE)); List<CardEdition> allowedSets = Lists.newArrayList(Iterables.transform(qData.getFormat().getAllowedSetCodes(), Singletons.getModel().getEditions().FN_EDITION_BY_CODE));
Collections.sort(allowedSets); Collections.sort(allowedSets);
// Sort unlockable sets by index // Sort unlockable sets by index
List<CardEdition> excludedSets = Lists.newArrayList(Iterables.transform(qData.getFormat().getLockedSets(), Singletons.getModel().getEditions().FN_EDITION_BY_CODE)); List<CardEdition> excludedSets = Lists.newArrayList(Iterables.transform(qData.getFormat().getLockedSets(), Singletons.getModel().getEditions().FN_EDITION_BY_CODE));
Collections.sort(excludedSets); Collections.sort(excludedSets);
// get a number of sets between an excluded and any included set // get a number of sets between an excluded and any included set
List<ImmutablePair<CardEdition, Integer>> excludedWithDistances = new ArrayList<ImmutablePair<CardEdition,Integer>>(); List<ImmutablePair<CardEdition, Integer>> excludedWithDistances = new ArrayList<ImmutablePair<CardEdition, Integer>>();
for(CardEdition ex : excludedSets) { for (CardEdition ex : excludedSets) {
int distance = Integer.MAX_VALUE; int distance = Integer.MAX_VALUE;
for(CardEdition in : allowedSets) { for (CardEdition in : allowedSets) {
int d = Math.abs(ex.getIndex() - in.getIndex()); int d = Math.abs(ex.getIndex() - in.getIndex());
if ( d < distance ) if (d < distance) {
distance = d; distance = d;
}
} }
excludedWithDistances.add(ImmutablePair.of(ex, distance)); excludedWithDistances.add(ImmutablePair.of(ex, distance));
} }