Fix issue that preventing starting quest mode if there was a flaw in the price list

This commit is contained in:
drdev
2014-07-16 23:23:18 +00:00
parent 0bd3aa87da
commit b7ea7675a4
2 changed files with 12 additions and 6 deletions

View File

@@ -33,8 +33,7 @@ import forge.util.ItemPool;
import forge.util.gui.SOptionPane;
public class QuestSpellShop {
private static final ReadPriceList r = new ReadPriceList();
private static final Map<String, Integer> mapPrices = r.getPriceList();
private static Map<String, Integer> mapPrices;
private static double multiplier;
private static ItemPool<InventoryItem> decksUsingMyCards;
@@ -47,13 +46,18 @@ public class QuestSpellShop {
if (card instanceof PaperCard) {
ns = card.getName() + "|" + ((PaperCard) card).getEdition();
foil = ((PaperCard) card).isFoil();
} else {
}
else {
ns = card.getName();
}
if (mapPrices == null) { //initialize price map if not already done
mapPrices = new ReadPriceList().getPriceList();
}
if (mapPrices.containsKey(ns)) {
value = mapPrices.get(ns);
} else if (card instanceof PaperCard) {
}
else if (card instanceof PaperCard) {
switch (((IPaperCard) card).getRarity()) {
case BasicLand:
value = 4;

View File

@@ -60,7 +60,6 @@ public class ReadPriceList {
private void setup() {
this.priceMap = this.readFile(ForgeConstants.QUEST_CARD_PRICE_FILE);
this.priceMap.putAll(this.readFile(ForgeConstants.PRICES_BOOSTER_FILE));
} // setup()
/**
@@ -87,6 +86,8 @@ public class ReadPriceList {
}
final String[] s = line.split("=");
if (s.length < 2) { continue; } //skip line if not in correct format
final String name = s[0].trim();
final String price = s[1].trim();
@@ -97,7 +98,8 @@ public class ReadPriceList {
float ff = 0;
if (r.nextInt(100) < 90) {
ff = r.nextInt(10) * (float) .01;
} else {
}
else {
// +/- 50%
ff = r.nextInt(50) * (float) .01;
}