add the correct number of packs/decks when multiple are purchased at once

This commit is contained in:
myk
2013-02-14 22:55:08 +00:00
parent b794f636fe
commit 268ad031a9
2 changed files with 23 additions and 21 deletions

View File

@@ -317,32 +317,37 @@ public final class CEditorQuestCardShop extends ACEditorBase<InventoryItem, Deck
} else if (item instanceof OpenablePack) { } else if (item instanceof OpenablePack) {
this.getTableCatalog().removeCard(item, qty); this.getTableCatalog().removeCard(item, qty);
for (int i = 0; qty > i; ++i) {
OpenablePack booster = null; OpenablePack booster = null;
if (item instanceof BoosterPack) { if (item instanceof BoosterPack) {
booster = (BoosterPack) ((BoosterPack) item).clone(); booster = (BoosterPack) ((BoosterPack) item).clone();
} else if (item instanceof TournamentPack) { } else if (item instanceof TournamentPack) {
booster = (TournamentPack) ((TournamentPack) item).clone(); booster = (TournamentPack) ((TournamentPack) item).clone();
} else if (item instanceof FatPack) { } else if (item instanceof FatPack) {
booster = (FatPack) ((FatPack) item).clone(); booster = (FatPack) ((FatPack) item).clone();
}
this.questData.getCards().buyPack(booster, value);
final List<CardPrinted> newCards = booster.getCards();
final List<InventoryItem> newInventory = new LinkedList<InventoryItem>(newCards);
getTableDeck().addCards(newInventory);
final CardListViewer c = new CardListViewer(booster.getName(),
"You have found the following cards inside:", newCards);
c.show();
} }
this.questData.getCards().buyPack(booster, value);
final List<CardPrinted> newCards = booster.getCards();
final List<InventoryItem> newInventory = new LinkedList<InventoryItem>(newCards);
getTableDeck().addCards(newInventory);
final CardListViewer c = new CardListViewer(booster.getName(),
"You have found the following cards inside:", newCards);
c.show();
} else if (item instanceof PreconDeck) { } else if (item instanceof PreconDeck) {
this.getTableCatalog().removeCard(item, qty); this.getTableCatalog().removeCard(item, qty);
final PreconDeck deck = (PreconDeck) item; final PreconDeck deck = (PreconDeck) item;
this.questData.getCards().buyPreconDeck(deck, value); this.questData.getCards().buyPreconDeck(deck, value);
final ItemPool<InventoryItem> newInventory = final ItemPool<InventoryItem> newInventory =
ItemPool.createFrom(deck.getDeck().getMain(), InventoryItem.class); ItemPool.createFrom(deck.getDeck().getMain(), InventoryItem.class);
getTableDeck().addCards(newInventory); for (int i = 0; qty > i; ++i) {
getTableDeck().addCards(newInventory);
}
JOptionPane.showMessageDialog(null, String.format( JOptionPane.showMessageDialog(null, String.format(
"Deck '%s' was added to your decklist.%n%nCards from it were also added to your pool.", "%s '%s' %s added to your decklist.%n%nCards from it were also added to your pool.",
deck.getName()), "Thanks for purchasing!", JOptionPane.INFORMATION_MESSAGE); 1 == qty ? "Deck" : String.format("%d copies of deck", qty),
deck.getName(), 1 == qty ? "was" : "were"),
"Thanks for purchasing!", JOptionPane.INFORMATION_MESSAGE);
} }
this.creditsLabel.setText("Credits: " + this.questData.getAssets().getCredits()); this.creditsLabel.setText("Credits: " + this.questData.getAssets().getCredits());

View File

@@ -92,9 +92,6 @@ public class ReadPriceList {
final String name = s[0].trim(); final String name = s[0].trim();
final String price = s[1].trim(); final String price = s[1].trim();
// System.out.println("Name: " + name + ", Price: " +
// price);
try { try {
int val = Integer.parseInt(price.trim()); int val = Integer.parseInt(price.trim());