mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-17 03:08:02 +00:00
Moved some methods from QuestData to helper classes, the whole class rearranged
Moved shop-related things to QuestUtilCards.java (eg. number of shop boosters calculation) CardShop now shows how many decks use the given card Quest deck editor: press space to add card to your deck - that simple CardPool no longer allows incorrect remove numbers removed lots of senseless javadocs
This commit is contained in:
4
.gitattributes
vendored
4
.gitattributes
vendored
@@ -9562,7 +9562,6 @@ src/main/java/forge/Gui_MigrateLocalMWSSetPictures_HQ.java svneol=native#text/pl
|
||||
src/main/java/forge/Gui_MultipleBlockers4.java svneol=native#text/plain
|
||||
src/main/java/forge/Gui_NewGame.java svneol=native#text/plain
|
||||
src/main/java/forge/Gui_ProgressBarWindow.java svneol=native#text/plain
|
||||
src/main/java/forge/Gui_QuestOptions.java svneol=native#text/plain
|
||||
src/main/java/forge/Gui_WinLose.java svneol=native#text/plain
|
||||
src/main/java/forge/HandSizeOp.java svneol=native#text/plain
|
||||
src/main/java/forge/HttpUtil.java svneol=native#text/plain
|
||||
@@ -9824,6 +9823,8 @@ src/main/java/forge/quest/data/QuestDataIO.java svneol=native#text/plain
|
||||
src/main/java/forge/quest/data/QuestMatchState.java svneol=native#text/plain
|
||||
src/main/java/forge/quest/data/QuestPreferences.java svneol=native#text/plain
|
||||
src/main/java/forge/quest/data/QuestUtil.java svneol=native#text/plain
|
||||
src/main/java/forge/quest/data/QuestUtilCards.java -text
|
||||
src/main/java/forge/quest/data/QuestUtilRewards.java -text
|
||||
src/main/java/forge/quest/data/bazaar/QuestStallDefinition.java svneol=native#text/plain
|
||||
src/main/java/forge/quest/data/bazaar/QuestStallManager.java svneol=native#text/plain
|
||||
src/main/java/forge/quest/data/bazaar/QuestStallPurchasable.java svneol=native#text/plain
|
||||
@@ -9848,6 +9849,7 @@ src/main/java/forge/quest/data/pet/QuestPetWolf.java svneol=native#text/plain
|
||||
src/main/java/forge/quest/data/pet/package-info.java svneol=native#text/plain
|
||||
src/main/java/forge/quest/gui/QuestAbstractPanel.java svneol=native#text/plain
|
||||
src/main/java/forge/quest/gui/QuestFrame.java svneol=native#text/plain
|
||||
src/main/java/forge/quest/gui/QuestOptions.java svneol=native#text/plain
|
||||
src/main/java/forge/quest/gui/bazaar/QuestBazaarItem.java svneol=native#text/plain
|
||||
src/main/java/forge/quest/gui/bazaar/QuestBazaarPanel.java svneol=native#text/plain
|
||||
src/main/java/forge/quest/gui/bazaar/QuestBazaarStall.java svneol=native#text/plain
|
||||
|
||||
@@ -245,7 +245,7 @@ public class Gui_WinLose extends JFrame implements NewConstants {
|
||||
GamePlayerRating humanRating = game.getPlayerRating(PlayerIndex.HUMAN);
|
||||
GameLossReason whyAiLost = aiRating.getLossReason();
|
||||
|
||||
int rewardAltWinCondition = q.getCreditsRewardForAltWin(whyAiLost);
|
||||
int rewardAltWinCondition = q.getRewards().getCreditsRewardForAltWin(whyAiLost);
|
||||
if (rewardAltWinCondition > 0) {
|
||||
String winConditionName = "Unknown (bug)";
|
||||
if (game.getWinCondition() == GameEndReason.WinsGameSpellEffect) {
|
||||
@@ -264,7 +264,7 @@ public class Gui_WinLose extends JFrame implements NewConstants {
|
||||
}
|
||||
|
||||
int winTurn = game.getTurnGameEnded();
|
||||
int turnCredits = q.getCreditsRewardForWinByTurn(winTurn);
|
||||
int turnCredits = q.getRewards().getCreditsRewardForWinByTurn(winTurn);
|
||||
|
||||
if (winTurn == 0) { // this case should never happen - anyway, no reward if we got here
|
||||
} else if (winTurn == 1) { sb.append("Won in one turn!");
|
||||
@@ -340,7 +340,7 @@ public class Gui_WinLose extends JFrame implements NewConstants {
|
||||
}
|
||||
|
||||
//System.out.println("QuestData cardpoolsize:" + AllZone.getQuestData().getCardpool().size());
|
||||
model.quest.clearShopList();
|
||||
model.quest.getCards().clearShopList();
|
||||
|
||||
|
||||
if (model.quest.getAvailableQuests() != null) {
|
||||
@@ -388,7 +388,7 @@ public class Gui_WinLose extends JFrame implements NewConstants {
|
||||
setsToGive.addAll(Arrays.asList(new String[]{"M12","NPH","MBS","M11","ROE","WWK","ZEN","M10","ARB","CFX","ALA","MOR","SHM","EVE","LRW"}));
|
||||
}
|
||||
|
||||
ArrayList<CardPrinted> cardsWon = model.quest.addCards(setsToGive);
|
||||
ArrayList<CardPrinted> cardsWon = model.quest.getCards().addCards(setsToGive);
|
||||
ImageIcon icon = getIcon("BookIcon.png");
|
||||
CardListViewer c = new CardListViewer("Booster", "You have won the following new cards", cardsWon, icon);
|
||||
c.show();
|
||||
@@ -397,13 +397,13 @@ public class Gui_WinLose extends JFrame implements NewConstants {
|
||||
|
||||
protected void giveQuestRewards(final boolean wonMatch) {
|
||||
// Award a random booster, as frequent as set in difficulty setup
|
||||
if (model.quest.shouldAddCards(wonMatch)) {
|
||||
if (model.quest.getRewards().willGiveBooster(wonMatch)) {
|
||||
giveBooster();
|
||||
}
|
||||
|
||||
// Award credits
|
||||
if (wonMatch) {
|
||||
long creds = model.quest.getCreditsToAdd(model.match);
|
||||
long creds = model.quest.getRewards().getCreditsToAdd(model.match);
|
||||
model.quest.addCredits(creds);
|
||||
|
||||
String s = getCreditsAwardedText(creds, model.match, model.quest);
|
||||
@@ -418,7 +418,7 @@ public class Gui_WinLose extends JFrame implements NewConstants {
|
||||
int wins = model.quest.getWin();
|
||||
if (wins > 0 && wins % 80 == 0) // at every 80 wins, give 10 random rares
|
||||
{
|
||||
ArrayList<CardPrinted> randomRares = model.quest.addRandomRare(10);
|
||||
List<CardPrinted> randomRares = model.quest.getCards().addRandomRare(10);
|
||||
|
||||
ImageIcon icon = getIcon("BoxIcon.png");
|
||||
String title = "You just won 10 random rares!";
|
||||
@@ -443,7 +443,7 @@ public class Gui_WinLose extends JFrame implements NewConstants {
|
||||
sb.append(cardName.getName());
|
||||
sb.append("\r\n");
|
||||
}
|
||||
model.quest.addAllCards(questRewardCards);
|
||||
model.quest.getCards().addAllCards(questRewardCards);
|
||||
sb.append("\r\n");
|
||||
}
|
||||
sb.append("Quest Bounty: ");
|
||||
@@ -476,9 +476,8 @@ public class Gui_WinLose extends JFrame implements NewConstants {
|
||||
}
|
||||
|
||||
// Random rare given at 50% chance (65% with luck upgrade)
|
||||
if (model.quest.shouldAddAdditionalCards(wonMatch)) {
|
||||
|
||||
CardPrinted card = model.quest.addRandomRare();
|
||||
if (wonMatch && model.quest.getRewards().getLuckyCoinResult()) {
|
||||
CardPrinted card = model.quest.getCards().addRandomRare();
|
||||
ArrayList<CardPrinted> rares = new ArrayList<CardPrinted>();
|
||||
rares.add(card);
|
||||
|
||||
|
||||
@@ -125,14 +125,11 @@ public class ReadBoosterPack implements NewConstants {
|
||||
* @param questLevel a int.
|
||||
* @return a {@link forge.CardList} object.
|
||||
*/
|
||||
public CardPoolView getShopCards(int numberWins, int questLevel) {
|
||||
public CardPoolView getShopCards(int totalPacks) {
|
||||
CardPool list = new CardPool();
|
||||
|
||||
// Number of Packs granted
|
||||
int levelPacks = questLevel > 0 ? 8 / questLevel / 2 : 4;
|
||||
int winPacks = numberWins / 10;
|
||||
|
||||
int totalPacks = Math.min(levelPacks + winPacks, 6);
|
||||
|
||||
for (int i = 0; i < totalPacks; i++) {
|
||||
// TODO: Balance CardPool Availability
|
||||
@@ -153,57 +150,28 @@ public class ReadBoosterPack implements NewConstants {
|
||||
}
|
||||
|
||||
//return CardList of 5 or 6 cards, one for each color and maybe an artifact
|
||||
/**
|
||||
* <p>getVariety.</p>
|
||||
*
|
||||
* @param in a {@link forge.CardList} object.
|
||||
* @return a {@link forge.CardList} object.
|
||||
*/
|
||||
private List<CardPrinted> getVariety(List<CardPrinted> in) {
|
||||
List<CardPrinted> out = new ArrayList<CardPrinted>();
|
||||
Collections.shuffle(in, MyRandom.random);
|
||||
|
||||
for (int i = 0; i < Constant.Color.Colors.length; i++) {
|
||||
CardPrinted check = findColor(in, i);
|
||||
CardPrinted check = findCardOfColor(in, i);
|
||||
if (check != null) { out.add(check); }
|
||||
}
|
||||
|
||||
return out;
|
||||
}//getVariety()
|
||||
|
||||
/**
|
||||
* <p>findColor.</p>
|
||||
*
|
||||
* @param in a {@link forge.CardList} object.
|
||||
* @param color a {@link java.lang.String} object.
|
||||
* @return a {@link forge.Card} object.
|
||||
*/
|
||||
private CardPrinted findColor(final List<CardPrinted> in, final int color) {
|
||||
Predicate<CardRules> filter = null;
|
||||
switch (color) {
|
||||
case 0: filter = CardRules.Predicates.Presets.isWhite; break;
|
||||
case 1: filter = CardRules.Predicates.Presets.isBlue; break;
|
||||
case 2: filter = CardRules.Predicates.Presets.isBlack; break;
|
||||
case 3: filter = CardRules.Predicates.Presets.isRed; break;
|
||||
case 4: filter = CardRules.Predicates.Presets.isGreen; break;
|
||||
case 5: filter = CardRules.Predicates.Presets.isColorless; break;
|
||||
default: break;
|
||||
}
|
||||
private CardPrinted findCardOfColor(final List<CardPrinted> in, final int color) {
|
||||
Predicate<CardRules> filter = CardRules.Predicates.Presets.colors.get(color);
|
||||
if (null == filter) { return null; }
|
||||
return filter.first(in, CardPrinted.fnGetRules);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* <p>getRandomCard.</p>
|
||||
*
|
||||
* @param list a {@link forge.CardList} object.
|
||||
* @return a {@link forge.Card} object.
|
||||
*/
|
||||
private CardPrinted getRandomCard(List<CardPrinted> list) {
|
||||
for (int i = 0; i < 10; i++)
|
||||
Collections.shuffle(list, MyRandom.random);
|
||||
private CardPrinted getRandomCard(final List<CardPrinted> list) {
|
||||
Collections.shuffle(list, MyRandom.random);
|
||||
int index = MyRandom.random.nextInt(list.size());
|
||||
Collections.shuffle(list, MyRandom.random);
|
||||
return list.get(index);
|
||||
}//getRandomCard()
|
||||
|
||||
|
||||
@@ -154,10 +154,7 @@ public class ReadQuest_Assignment implements Runnable, NewConstants {
|
||||
qa.setComputerLife(100);
|
||||
|
||||
s = readLine();
|
||||
if (s.equals("Repeatable"))
|
||||
qa.setRepeatable(true);
|
||||
else
|
||||
qa.setRepeatable(false);
|
||||
qa.setRepeatable(s.equals("Repeatable"));
|
||||
|
||||
s = readLine();
|
||||
int wins = Integer.valueOf(s);
|
||||
|
||||
@@ -43,15 +43,11 @@ public final class CardPool extends CardPoolView {
|
||||
for (Entry<CardPrinted, Integer> e : map) { add(e.getKey(), e.getValue()); }
|
||||
isListInSync = false;
|
||||
}
|
||||
public void addAll(final Entry<CardPrinted, Integer>[] map) {
|
||||
for (Entry<CardPrinted, Integer> e : map) { add(e.getKey(), e.getValue()); }
|
||||
isListInSync = false;
|
||||
}
|
||||
|
||||
public void remove(final CardPrinted card) { remove(card, 1); }
|
||||
public void remove(final CardPrinted card, final int amount) {
|
||||
int count = count(card);
|
||||
if (count == 0) { return; }
|
||||
if (count == 0 || amount <= 0) { return; }
|
||||
if (count <= amount) { cards.remove(card); }
|
||||
else { cards.put(card, count - amount); }
|
||||
isListInSync = false;
|
||||
|
||||
@@ -15,7 +15,7 @@ import java.util.*;
|
||||
* @author Forge
|
||||
* @version $Id$
|
||||
*/
|
||||
public class Deck implements Comparable<Deck>, Serializable {
|
||||
public final class Deck implements Comparable<Deck>, Serializable {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@@ -70,7 +70,7 @@ public class Deck implements Comparable<Deck>, Serializable {
|
||||
*
|
||||
* @param type a {@link java.lang.String} object.
|
||||
*/
|
||||
public Deck(String type) {
|
||||
public Deck(final String type) {
|
||||
this();
|
||||
setDeckType(type);
|
||||
}
|
||||
@@ -164,28 +164,12 @@ public class Deck implements Comparable<Deck>, Serializable {
|
||||
*
|
||||
* @param cardName a {@link java.lang.String} object.
|
||||
*/
|
||||
public void addMain(String cardName) { addMain( CardDb.instance().getCard(cardName) ); }
|
||||
public void addMain(CardPrinted card) { main.add(card); }
|
||||
public void addMain(CardPoolView list) { main.addAll(list); }
|
||||
|
||||
|
||||
/**
|
||||
* <p>countMain.</p>
|
||||
*
|
||||
* @return a int.
|
||||
*/
|
||||
public int countMain() {
|
||||
return main.countAll();
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>removeMain.</p>
|
||||
*
|
||||
* @param c a {@link forge.Card} object.
|
||||
*/
|
||||
public void removeMain(CardPrinted card) {
|
||||
main.remove(card);
|
||||
}
|
||||
public void addMain(final String cardName) { addMain(CardDb.instance().getCard(cardName)); }
|
||||
public void addMain(final CardPrinted card) { main.add(card); }
|
||||
public void addMain(final CardPoolView list) { main.addAll(list); }
|
||||
public void removeMain(final CardPrinted card) { main.remove(card); }
|
||||
public void removeMain(final CardPrinted card, final int amount) { main.remove(card, amount); }
|
||||
public int countMain() { return main.countAll(); }
|
||||
|
||||
/**
|
||||
* <p>addSideboard.</p>
|
||||
@@ -197,7 +181,6 @@ public class Deck implements Comparable<Deck>, Serializable {
|
||||
public final void addSideboard(final CardPrinted card, final int amount) { sideboard.add(card, amount); }
|
||||
public final void addSideboard(final CardPoolView cards) { sideboard.addAll(cards); }
|
||||
|
||||
|
||||
/**
|
||||
* <p>countSideboard.</p>
|
||||
*
|
||||
|
||||
@@ -57,9 +57,6 @@ public final class DeckEditor extends DeckEditorBase implements NewConstants {
|
||||
private JButton removeButton = new JButton();
|
||||
private JButton addButton = new JButton();
|
||||
private JButton analysisButton = new JButton();
|
||||
private JScrollPane jScrollPane3 = new JScrollPane();
|
||||
private JPanel jPanel3 = new JPanel();
|
||||
private GridLayout gridLayout1 = new GridLayout();
|
||||
|
||||
private JLabel labelFilterName = new JLabel();
|
||||
private JLabel labelFilterType = new JLabel();
|
||||
@@ -227,10 +224,6 @@ public final class DeckEditor extends DeckEditorBase implements NewConstants {
|
||||
// Do not lower statsLabel any lower, we want this to be visible at 1024
|
||||
// x 768 screen size
|
||||
this.setTitle("Deck Editor");
|
||||
jScrollPane3.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
|
||||
jPanel3.setLayout(gridLayout1);
|
||||
gridLayout1.setColumns(1);
|
||||
gridLayout1.setRows(0);
|
||||
|
||||
Container pane = this.getContentPane();
|
||||
MigLayout layout = new MigLayout("fill");
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package forge.gui.deckeditor;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Rectangle;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ItemEvent;
|
||||
import java.awt.event.ItemListener;
|
||||
@@ -85,5 +87,4 @@ public abstract class DeckEditorBase extends JFrame implements DeckDisplay {
|
||||
top.setFilter(buildFilter());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@ import forge.card.CardPrinted;
|
||||
import forge.deck.Deck;
|
||||
import forge.deck.DeckManager;
|
||||
import forge.error.ErrorViewer;
|
||||
import forge.gui.GuiUtils;
|
||||
import forge.properties.ForgeProps;
|
||||
import forge.properties.NewConstants;
|
||||
import forge.view.swing.OldGuiNewGame;
|
||||
@@ -98,10 +99,11 @@ public class DeckEditorDraft extends DeckEditorBase implements NewConstants, New
|
||||
|
||||
top.setup(columns, cardView);
|
||||
bottom.setup(columns, cardView);
|
||||
|
||||
this.setSize(1024, 740);
|
||||
GuiUtils.centerFrame(this);
|
||||
this.setResizable(false);
|
||||
|
||||
//Use both so that when "un"maximizing, the frame isn't tiny
|
||||
setSize(1024, 740);
|
||||
//setExtendedState(Frame.MAXIMIZED_BOTH);
|
||||
}
|
||||
|
||||
public DeckEditorDraft() {
|
||||
|
||||
@@ -9,6 +9,7 @@ import forge.card.CardPoolView;
|
||||
import forge.card.CardPrinted;
|
||||
import forge.deck.Deck;
|
||||
import forge.error.ErrorViewer;
|
||||
import forge.gui.GuiUtils;
|
||||
import forge.properties.NewConstants;
|
||||
import forge.view.swing.OldGuiNewGame;
|
||||
|
||||
@@ -42,24 +43,9 @@ public final class DeckEditorQuest extends DeckEditorBase implements NewConstant
|
||||
private JButton removeButton = new JButton();
|
||||
private JButton analysisButton = new JButton();
|
||||
|
||||
private GridLayout gridLayout1 = new GridLayout();
|
||||
private JLabel labelSortHint = new JLabel();
|
||||
|
||||
private JLabel jLabel1 = new JLabel();
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public void setTitle(String message) {
|
||||
super.setTitle(message);
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* show.
|
||||
* </p>
|
||||
*
|
||||
* @param exitCommand
|
||||
* a {@link forge.Command} object.
|
||||
*/
|
||||
public void show(final Command exitCommand) {
|
||||
final Command exit = new Command() {
|
||||
private static final long serialVersionUID = -7428793574300520612L;
|
||||
@@ -100,7 +86,7 @@ public final class DeckEditorQuest extends DeckEditorBase implements NewConstant
|
||||
|
||||
CardPoolView bottomPool = deck.getMain();
|
||||
CardPool cardpool = new CardPool();
|
||||
cardpool.addAll(AllZone.getQuestData().getCardpool());
|
||||
cardpool.addAll(AllZone.getQuestData().getCards().getCardpool());
|
||||
|
||||
// remove bottom cards that are in the deck from the card pool
|
||||
cardpool.removeAll(bottomPool);
|
||||
@@ -136,21 +122,15 @@ public final class DeckEditorQuest extends DeckEditorBase implements NewConstant
|
||||
top.setup(columns, cardView);
|
||||
bottom.setup(columns, cardView);
|
||||
|
||||
setSize(1024, 768);
|
||||
this.setSize(1024, 768);
|
||||
GuiUtils.centerFrame(this);
|
||||
this.setResizable(false);
|
||||
Dimension screen = getToolkit().getScreenSize();
|
||||
Rectangle bounds = getBounds();
|
||||
bounds.width = 1024;
|
||||
bounds.height = 768;
|
||||
bounds.x = (screen.width - bounds.width) / 2;
|
||||
bounds.y = (screen.height - bounds.height) / 2;
|
||||
setBounds(bounds);
|
||||
|
||||
// TODO use this as soon the deck editor has resizable GUI
|
||||
// //Use both so that when "un"maximizing, the frame isn't tiny
|
||||
// setSize(1024, 740);
|
||||
// setExtendedState(Frame.MAXIMIZED_BOTH);
|
||||
}// setupAndDisplay()
|
||||
} // setupAndDisplay()
|
||||
|
||||
public DeckEditorQuest() {
|
||||
try {
|
||||
@@ -167,7 +147,7 @@ public final class DeckEditorQuest extends DeckEditorBase implements NewConstant
|
||||
|
||||
private void jbInit() throws Exception {
|
||||
this.setLayout(null);
|
||||
|
||||
|
||||
top.getTableDecorated().setBounds(new Rectangle(19, 20, 726, 346));
|
||||
bottom.getTableDecorated().setBounds(new Rectangle(19, 458, 726, 218));
|
||||
|
||||
@@ -205,7 +185,6 @@ public final class DeckEditorQuest extends DeckEditorBase implements NewConstant
|
||||
/**
|
||||
* Type filtering
|
||||
*/
|
||||
|
||||
filterBoxes.land.setBounds(340, 400, 48, 20);
|
||||
filterBoxes.creature.setBounds(385, 400, 65, 20);
|
||||
filterBoxes.sorcery.setBounds(447, 400, 62, 20);
|
||||
@@ -245,11 +224,9 @@ public final class DeckEditorQuest extends DeckEditorBase implements NewConstant
|
||||
// Do not lower statsLabel any lower, we want this to be visible at 1024
|
||||
// x 768 screen size
|
||||
this.setTitle("Deck Editor");
|
||||
gridLayout1.setColumns(1);
|
||||
gridLayout1.setRows(0);
|
||||
|
||||
jLabel1.setText("Click on the column name (like name or color) to sort the cards");
|
||||
jLabel1.setBounds(new Rectangle(20, 1, 400, 19));
|
||||
labelSortHint.setText("Click on the column name (like name or color) to sort the cards");
|
||||
labelSortHint.setBounds(new Rectangle(20, 1, 400, 19));
|
||||
|
||||
this.getContentPane().add(top.getTableDecorated(), null);
|
||||
this.getContentPane().add(bottom.getTableDecorated(), null);
|
||||
@@ -258,7 +235,7 @@ public final class DeckEditorQuest extends DeckEditorBase implements NewConstant
|
||||
this.getContentPane().add(analysisButton, null);
|
||||
this.getContentPane().add(bottom.getLabel(), null);
|
||||
this.getContentPane().add(top.getLabel(), null);
|
||||
this.getContentPane().add(jLabel1, null);
|
||||
this.getContentPane().add(labelSortHint, null);
|
||||
this.getContentPane().add(cardView, null);
|
||||
|
||||
for (JCheckBox box : filterBoxes.allTypes) {
|
||||
@@ -268,6 +245,13 @@ public final class DeckEditorQuest extends DeckEditorBase implements NewConstant
|
||||
for (JCheckBox box : filterBoxes.allColors) {
|
||||
this.getContentPane().add(box, null);
|
||||
}
|
||||
|
||||
top.getTable().addKeyListener(new KeyAdapter() {
|
||||
@Override
|
||||
public void keyPressed(final KeyEvent e) {
|
||||
if (e.getKeyChar() == ' ') { addButtonActionPerformed(null); }
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -295,7 +279,7 @@ public final class DeckEditorQuest extends DeckEditorBase implements NewConstant
|
||||
|
||||
public void addCheatCard(CardPrinted card) {
|
||||
top.addCard(card);
|
||||
AllZone.getQuestData().getCardpool().add(card);
|
||||
AllZone.getQuestData().getCards().getCardpool().add(card);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -280,13 +280,13 @@ public class DeckEditorQuestMenu extends JMenuBar {
|
||||
Deck newDeck = DeckManager.readDeck(file);
|
||||
questData.addDeck(newDeck);
|
||||
|
||||
CardPool cardpool = new CardPool(questData.getCardpool());
|
||||
CardPool cardpool = new CardPool(questData.getCards().getCardpool());
|
||||
CardPool decklist = new CardPool();
|
||||
for (Entry<CardPrinted, Integer> s : newDeck.getMain()) {
|
||||
CardPrinted cp = s.getKey();
|
||||
decklist.add(cp, s.getValue());
|
||||
cardpool.add(cp, s.getValue());
|
||||
questData.getCardpool().add(cp, s.getValue());
|
||||
questData.getCards().getCardpool().add(cp, s.getValue());
|
||||
}
|
||||
deckDisplay.setDecks(cardpool, decklist);
|
||||
|
||||
@@ -347,7 +347,7 @@ public class DeckEditorQuestMenu extends JMenuBar {
|
||||
if (StringUtils.isBlank(deckName)) { return; }
|
||||
|
||||
setPlayerDeckName(deckName);
|
||||
CardPool cards = new CardPool(questData.getCardpool().getView());
|
||||
CardPool cards = new CardPool(questData.getCards().getCardpool().getView());
|
||||
CardPoolView deck = questData.getDeck(deckName).getMain();
|
||||
|
||||
// show in pool all cards except ones used in deck
|
||||
@@ -358,7 +358,7 @@ public class DeckEditorQuestMenu extends JMenuBar {
|
||||
|
||||
private final ActionListener newDeckActionListener = new ActionListener() {
|
||||
public void actionPerformed(final ActionEvent a) {
|
||||
deckDisplay.setDecks(questData.getCardpool().getView(), new CardPool());
|
||||
deckDisplay.setDecks(questData.getCards().getCardpool().getView(), new CardPool());
|
||||
setPlayerDeckName("");
|
||||
}
|
||||
};
|
||||
@@ -441,7 +441,7 @@ public class DeckEditorQuestMenu extends JMenuBar {
|
||||
questData.removeDeck(currentDeck.getName());
|
||||
|
||||
//show card pool
|
||||
deckDisplay.setDecks(questData.getCardpool().getView(), new CardPool());
|
||||
deckDisplay.setDecks(questData.getCards().getCardpool().getView(), new CardPool());
|
||||
|
||||
setPlayerDeckName("");
|
||||
}
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
package forge.gui.deckeditor;
|
||||
|
||||
import java.awt.Dimension;
|
||||
import java.awt.GridLayout;
|
||||
import java.awt.Rectangle;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.WindowAdapter;
|
||||
@@ -9,15 +7,15 @@ import java.awt.event.WindowEvent;
|
||||
import java.text.DecimalFormat;
|
||||
import java.text.NumberFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.TreeMap;
|
||||
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JOptionPane;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JScrollPane;
|
||||
|
||||
import net.slightlymagic.braids.util.lambda.Lambda1;
|
||||
|
||||
@@ -27,6 +25,7 @@ import forge.card.CardPoolView;
|
||||
import forge.card.CardPrinted;
|
||||
import forge.deck.Deck;
|
||||
import forge.error.ErrorViewer;
|
||||
import forge.gui.GuiUtils;
|
||||
import forge.quest.data.QuestData;
|
||||
import forge.view.swing.OldGuiNewGame;
|
||||
|
||||
@@ -38,7 +37,7 @@ import forge.view.swing.OldGuiNewGame;
|
||||
* @author Forge
|
||||
* @version $Id$
|
||||
*/
|
||||
public class DeckEditorShop extends DeckEditorBase {
|
||||
public final class DeckEditorShop extends DeckEditorBase {
|
||||
|
||||
/** Constant <code>serialVersionUID=3988857075791576483L</code> */
|
||||
private static final long serialVersionUID = 3988857075791576483L;
|
||||
@@ -46,9 +45,6 @@ public class DeckEditorShop extends DeckEditorBase {
|
||||
private JButton buyButton = new JButton();
|
||||
private JButton sellButton = new JButton();
|
||||
|
||||
private JScrollPane jScrollPane3 = new JScrollPane();
|
||||
private JPanel jPanel3 = new JPanel();
|
||||
private GridLayout gridLayout1 = new GridLayout();
|
||||
private JLabel creditsLabel = new JLabel();
|
||||
private JLabel jLabel1 = new JLabel();
|
||||
private JLabel sellPercentageLabel = new JLabel();
|
||||
@@ -60,18 +56,9 @@ public class DeckEditorShop extends DeckEditorBase {
|
||||
// get pricelist:
|
||||
private ReadPriceList r = new ReadPriceList();
|
||||
private Map<String, Integer> mapPrices = r.getPriceList();
|
||||
private Map<CardPrinted, Integer> decksUsingMyCards;
|
||||
|
||||
|
||||
/** {@inheritDoc} */
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* show.
|
||||
* </p>
|
||||
*
|
||||
* @param exitCommand
|
||||
* a {@link forge.Command} object.
|
||||
*/
|
||||
public void show(final Command exitCommand) {
|
||||
final Command exit = new Command() {
|
||||
private static final long serialVersionUID = -7428793574300520612L;
|
||||
@@ -92,29 +79,46 @@ public class DeckEditorShop extends DeckEditorBase {
|
||||
|
||||
setup();
|
||||
|
||||
multiplier = questData.getSellMutliplier();
|
||||
decksUsingMyCards = countDecksForEachCard();
|
||||
|
||||
CardPoolView forSale = questData.getShopList();
|
||||
multiplier = questData.getCards().getSellMutliplier();
|
||||
|
||||
CardPoolView forSale = questData.getCards().getShopList();
|
||||
if (forSale.isEmpty()) {
|
||||
questData.generateCardsInShop();
|
||||
forSale = questData.getShopList();
|
||||
questData.getCards().generateCardsInShop();
|
||||
forSale = questData.getCards().getShopList();
|
||||
}
|
||||
CardPoolView owned = questData.getCardpool().getView();
|
||||
CardPoolView owned = questData.getCards().getCardpool().getView();
|
||||
|
||||
setDecks(forSale, owned);
|
||||
|
||||
double multiPercent = multiplier * 100;
|
||||
NumberFormat formatter = new DecimalFormat("#0.00");
|
||||
String maxSellingPrice = "";
|
||||
int maxSellPrice = questData.getSellPriceLimit();
|
||||
int maxSellPrice = questData.getCards().getSellPriceLimit();
|
||||
|
||||
if (maxSellPrice < Integer.MAX_VALUE) { maxSellingPrice = String.format(" Max selling price: %d", maxSellPrice); }
|
||||
sellPercentageLabel.setText("(Sell percentage: " + formatter.format(multiPercent) + "% of value)" + maxSellingPrice);
|
||||
|
||||
top.sort(1, true);
|
||||
bottom.sort(1, true);
|
||||
}// show(Command)
|
||||
} // show(Command)
|
||||
|
||||
// fills number of decks using each card
|
||||
private Map<CardPrinted, Integer> countDecksForEachCard() {
|
||||
Map<CardPrinted, Integer> result = new HashMap<CardPrinted, Integer>();
|
||||
for (String deckName : questData.getDeckNames()) {
|
||||
Deck deck = questData.getDeck(deckName);
|
||||
for (Entry<CardPrinted, Integer> e : deck.getMain()) {
|
||||
CardPrinted card = e.getKey();
|
||||
Integer iValue = result.get(card);
|
||||
int cntDecks = iValue == null ? 1 : 1 + iValue.intValue();
|
||||
result.put(card, Integer.valueOf(cntDecks));
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* setup.
|
||||
@@ -128,27 +132,21 @@ public class DeckEditorShop extends DeckEditorBase {
|
||||
columns.add(new TableColumnInfo<CardPrinted>("Color", 50, PresetColumns.fnColorCompare, PresetColumns.fnColorGet));
|
||||
columns.add(new TableColumnInfo<CardPrinted>("Type", 100, PresetColumns.fnTypeCompare, PresetColumns.fnTypeGet));
|
||||
columns.add(new TableColumnInfo<CardPrinted>("Stats", 40, PresetColumns.fnStatsCompare, PresetColumns.fnStatsGet));
|
||||
columns.add(new TableColumnInfo<CardPrinted>("R", 35, PresetColumns.fnRarityCompare, PresetColumns.fnRarityGet));
|
||||
columns.add(new TableColumnInfo<CardPrinted>("Set", 40, PresetColumns.fnSetCompare, PresetColumns.fnSetGet));
|
||||
columns.add(new TableColumnInfo<CardPrinted>("R", 30, PresetColumns.fnRarityCompare, PresetColumns.fnRarityGet));
|
||||
columns.add(new TableColumnInfo<CardPrinted>("Set", 35, PresetColumns.fnSetCompare, PresetColumns.fnSetGet));
|
||||
|
||||
List<TableColumnInfo<CardPrinted>> columnsBelow = new ArrayList<TableColumnInfo<CardPrinted>>(columns);
|
||||
columns.add(new TableColumnInfo<CardPrinted>("Price", 40, fnPriceCompare, fnPriceGet));
|
||||
|
||||
top.setup(columns, cardView);
|
||||
bottom.setup(columns, cardView);
|
||||
|
||||
setSize(1024, 768);
|
||||
columnsBelow.add(new TableColumnInfo<CardPrinted>("#Dk", 30, fnDeckCompare, fnDeckGet));
|
||||
columnsBelow.add(new TableColumnInfo<CardPrinted>("Price", 40, fnPriceCompare, fnPriceGet));
|
||||
bottom.setup(columnsBelow, cardView);
|
||||
|
||||
this.setSize(1024, 768);
|
||||
GuiUtils.centerFrame(this);
|
||||
this.setResizable(false);
|
||||
Dimension screen = getToolkit().getScreenSize();
|
||||
Rectangle bounds = getBounds();
|
||||
bounds.width = 1024;
|
||||
bounds.height = 768;
|
||||
bounds.x = (screen.width - bounds.width) / 2;
|
||||
bounds.y = (screen.height - bounds.height) / 2;
|
||||
setBounds(bounds);
|
||||
// TODO use this as soon the deck editor has resizable GUI
|
||||
// //Use both so that when "un"maximizing, the frame isn't tiny
|
||||
// setSize(1024, 740);
|
||||
// setExtendedState(Frame.MAXIMIZED_BOTH);
|
||||
}// setupAndDisplay()
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@@ -211,12 +209,7 @@ public class DeckEditorShop extends DeckEditorBase {
|
||||
// Do not lower statsLabel any lower, we want this to be visible at 1024
|
||||
// x 768 screen size
|
||||
this.setTitle("Card Shop");
|
||||
jScrollPane3.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
|
||||
jScrollPane3.setBounds(new Rectangle(6, 168, 225, 143));
|
||||
jPanel3.setBounds(new Rectangle(7, 21, 224, 141));
|
||||
jPanel3.setLayout(gridLayout1);
|
||||
gridLayout1.setColumns(1);
|
||||
gridLayout1.setRows(0);
|
||||
|
||||
creditsLabel.setBounds(new Rectangle(19, 365, 720, 31));
|
||||
creditsLabel.setText("Total credits: " + questData.getCredits());
|
||||
if (!OldGuiNewGame.useLAFFonts.isSelected())
|
||||
@@ -227,6 +220,7 @@ public class DeckEditorShop extends DeckEditorBase {
|
||||
sellPercentageLabel.setFont(new java.awt.Font("Dialog", 0, 14));
|
||||
jLabel1.setText("Click on the column name (like name or color) to sort the cards");
|
||||
jLabel1.setBounds(new Rectangle(20, 1, 400, 19));
|
||||
|
||||
this.getContentPane().add(cardView, null);
|
||||
this.getContentPane().add(top.getTableDecorated(), null);
|
||||
this.getContentPane().add(bottom.getTableDecorated(), null);
|
||||
@@ -263,7 +257,7 @@ public class DeckEditorShop extends DeckEditorBase {
|
||||
bottom.addCard(c);
|
||||
top.removeCard(c);
|
||||
|
||||
questData.buyCard(c, value);
|
||||
questData.getCards().buyCard(c, value);
|
||||
|
||||
creditsLabel.setText("Total credits: " + questData.getCredits());
|
||||
} else {
|
||||
@@ -271,14 +265,7 @@ public class DeckEditorShop extends DeckEditorBase {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* sellButton_actionPerformed.
|
||||
* </p>
|
||||
*
|
||||
* @param e
|
||||
* a {@link java.awt.event.ActionEvent} object.
|
||||
*/
|
||||
|
||||
void sellButton_actionPerformed(ActionEvent e) {
|
||||
CardPrinted c = bottom.getSelectedCard();
|
||||
if (c == null) { return; }
|
||||
@@ -286,20 +273,10 @@ public class DeckEditorShop extends DeckEditorBase {
|
||||
bottom.removeCard(c);
|
||||
top.addCard(c);
|
||||
|
||||
int price = Math.min((int) (multiplier * getCardValue(c)), questData.getSellPriceLimit());
|
||||
questData.sellCard(c, price);
|
||||
questData.addCardToShopList(c);
|
||||
int price = Math.min((int) (multiplier * getCardValue(c)), questData.getCards().getSellPriceLimit());
|
||||
questData.getCards().sellCard(c, price);
|
||||
|
||||
creditsLabel.setText("Total credits: " + questData.getCredits());
|
||||
|
||||
int leftInPool = questData.getCardpool().count(c);
|
||||
// remove sold cards from all decks:
|
||||
for (String deckName : questData.getDeckNames()) {
|
||||
Deck deck = questData.getDeck(deckName);
|
||||
for (int cntInDeck = deck.getMain().count(c); cntInDeck > leftInPool; cntInDeck--) {
|
||||
deck.removeMain(c);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
@@ -310,4 +287,17 @@ public class DeckEditorShop extends DeckEditorBase {
|
||||
new Lambda1<Object, Entry<CardPrinted, Integer>>() { @Override
|
||||
public Object apply(final Entry<CardPrinted, Integer> from) { return getCardValue(from.getKey()); } };
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
private final Lambda1<Comparable, Entry<CardPrinted, Integer>> fnDeckCompare =
|
||||
new Lambda1<Comparable, Entry<CardPrinted, Integer>>() { @Override
|
||||
public Comparable apply(final Entry<CardPrinted, Integer> from) {
|
||||
Integer iValue = decksUsingMyCards.get(from.getKey());
|
||||
return iValue == null ? Integer.valueOf(0) : iValue;
|
||||
} };
|
||||
private final Lambda1<Object, Entry<CardPrinted, Integer>> fnDeckGet =
|
||||
new Lambda1<Object, Entry<CardPrinted, Integer>>() { @Override
|
||||
public Object apply(final Entry<CardPrinted, Integer> from) {
|
||||
Integer iValue = decksUsingMyCards.get(from.getKey());
|
||||
return iValue == null ? "" : iValue.toString();
|
||||
} };
|
||||
}
|
||||
|
||||
@@ -1,12 +1,9 @@
|
||||
package forge.quest.data;
|
||||
|
||||
import forge.Constant;
|
||||
import forge.card.CardDb;
|
||||
import forge.card.CardPrinted;
|
||||
import forge.card.CardRarity;
|
||||
import forge.card.CardRules;
|
||||
import forge.properties.NewConstants;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
@@ -22,49 +19,12 @@ import net.slightlymagic.maxmtg.Predicate;
|
||||
* @author Forge
|
||||
* @version $Id$
|
||||
*/
|
||||
public class QuestBoosterPack implements NewConstants {
|
||||
ArrayList<String> choices;
|
||||
public final class QuestBoosterPack {
|
||||
|
||||
/**
|
||||
* <p>Constructor for QuestBoosterPack.</p>
|
||||
*/
|
||||
public QuestBoosterPack() {
|
||||
choices = new ArrayList<String>();
|
||||
choices.add("Multicolor");
|
||||
|
||||
for (String s : Constant.Color.Colors) {
|
||||
choices.add(s);
|
||||
choices.add(s);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* getQuestStarterDeck.
|
||||
* </p>
|
||||
*
|
||||
* @param allCards
|
||||
* the card pool from which we can generate the deck
|
||||
*
|
||||
* @param numCommon
|
||||
* a int.
|
||||
*
|
||||
* @param numUncommon
|
||||
* a int.
|
||||
*
|
||||
* @param numRare
|
||||
* a int.
|
||||
*
|
||||
* @param standardPool
|
||||
* whether to restrict the card pool to what is currently
|
||||
* considered the Standard block. To update the sets that are
|
||||
* considered standard, modify this method.
|
||||
*
|
||||
* @return a {@link java.util.ArrayList} object.
|
||||
*/
|
||||
public List<CardPrinted> getQuestStarterDeck( final Predicate<CardPrinted> filter,
|
||||
int numCommon, int numUncommon, int numRare ) {
|
||||
ArrayList<CardPrinted> names = new ArrayList<CardPrinted>();
|
||||
public static List<CardPrinted> getQuestStarterDeck(final Predicate<CardPrinted> filter,
|
||||
final int numCommon, final int numUncommon, final int numRare)
|
||||
{
|
||||
ArrayList<CardPrinted> cards = new ArrayList<CardPrinted>();
|
||||
|
||||
// Each color should have around the same amount of monocolored cards
|
||||
// There should be 3 Colorless cards for every 4 cards in a single color
|
||||
@@ -85,14 +45,13 @@ public class QuestBoosterPack implements NewConstants {
|
||||
|
||||
Iterable<CardPrinted> cardpool = CardDb.instance().getAllUniqueCards();
|
||||
|
||||
names.addAll(generateDefinetlyColouredCards(cardpool,
|
||||
cards.addAll(generateDefinetlyColouredCards(cardpool,
|
||||
Predicate.and(filter, CardPrinted.Predicates.Presets.isCommon), numCommon, colorFilters));
|
||||
names.addAll(generateDefinetlyColouredCards(cardpool,
|
||||
cards.addAll(generateDefinetlyColouredCards(cardpool,
|
||||
Predicate.and(filter, CardPrinted.Predicates.Presets.isUncommon), numUncommon, colorFilters));
|
||||
names.addAll(generateDefinetlyColouredCards(cardpool,
|
||||
cards.addAll(generateDefinetlyColouredCards(cardpool,
|
||||
Predicate.and(filter, CardPrinted.Predicates.Presets.isRareOrMythic), numRare, colorFilters));
|
||||
|
||||
return names;
|
||||
return cards;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -104,7 +63,7 @@ public class QuestBoosterPack implements NewConstants {
|
||||
* @param allowedColors a List<Predicate<CardRules>>
|
||||
* @return a list of card names
|
||||
*/
|
||||
public final ArrayList<CardPrinted> generateDefinetlyColouredCards(
|
||||
private static ArrayList<CardPrinted> generateDefinetlyColouredCards(
|
||||
final Iterable<CardPrinted> source,
|
||||
final Predicate<CardPrinted> filter,
|
||||
final int cntNeeded,
|
||||
@@ -148,13 +107,13 @@ public class QuestBoosterPack implements NewConstants {
|
||||
}
|
||||
|
||||
|
||||
public ArrayList<CardPrinted> generateDistinctCards(
|
||||
private static ArrayList<CardPrinted> generateDistinctCards(
|
||||
final Iterable<CardPrinted> source,
|
||||
final Predicate<CardPrinted> filter,
|
||||
final int cntNeeded)
|
||||
{
|
||||
ArrayList<CardPrinted> result = new ArrayList<CardPrinted>();
|
||||
int cntMade = 0, iAttempt = 0;
|
||||
int cntMade = 0;
|
||||
|
||||
// This will prevent endless loop @ wh
|
||||
int allowedMisses = (2 + 2) * cntNeeded; // lol, 2+2 is not magic constant!
|
||||
@@ -167,7 +126,6 @@ public class QuestBoosterPack implements NewConstants {
|
||||
cntMade++;
|
||||
}
|
||||
else { allowedMisses--; }
|
||||
iAttempt++;
|
||||
}
|
||||
|
||||
return result;
|
||||
@@ -175,17 +133,17 @@ public class QuestBoosterPack implements NewConstants {
|
||||
|
||||
|
||||
// Left if only for backwards compatibility
|
||||
public ArrayList<CardPrinted> generateCards(int num, CardRarity rarity, String color) {
|
||||
public ArrayList<CardPrinted> generateCards(final int num, final CardRarity rarity, final String color) {
|
||||
Predicate<CardPrinted> whatYouWant = getPredicateForConditions(rarity, color);
|
||||
return generateDistinctCards(CardDb.instance().getAllUniqueCards(), whatYouWant, num);
|
||||
}
|
||||
|
||||
public ArrayList<CardPrinted> generateCards(Predicate<CardPrinted> filter, int num, CardRarity rarity, String color) {
|
||||
public static ArrayList<CardPrinted> generateCards(final Predicate<CardPrinted> filter, int num, CardRarity rarity, String color) {
|
||||
Predicate<CardPrinted> whatYouWant = Predicate.and(filter, getPredicateForConditions(rarity, color));
|
||||
return generateDistinctCards(CardDb.instance().getAllUniqueCards(), whatYouWant, num);
|
||||
}
|
||||
|
||||
protected Predicate<CardPrinted> getPredicateForConditions(CardRarity rarity, String color)
|
||||
private static Predicate<CardPrinted> getPredicateForConditions(final CardRarity rarity, final String color)
|
||||
{
|
||||
Predicate<CardPrinted> rFilter;
|
||||
switch (rarity) {
|
||||
|
||||
@@ -1,17 +1,10 @@
|
||||
package forge.quest.data;
|
||||
|
||||
import forge.*;
|
||||
import forge.card.CardDb;
|
||||
import forge.MyRandom;
|
||||
import forge.card.CardPool;
|
||||
import forge.card.CardPoolView;
|
||||
import forge.card.CardPrinted;
|
||||
import forge.card.CardRarity;
|
||||
import forge.deck.Deck;
|
||||
import forge.error.ErrorViewer;
|
||||
import forge.game.GameLossReason;
|
||||
import forge.game.GamePlayerRating;
|
||||
import forge.game.GameSummary;
|
||||
import forge.game.PlayerIndex;
|
||||
import forge.properties.ForgeProps;
|
||||
import forge.properties.NewConstants;
|
||||
import forge.quest.data.item.QuestInventory;
|
||||
@@ -24,12 +17,10 @@ import java.util.Map;
|
||||
|
||||
import net.slightlymagic.maxmtg.Predicate;
|
||||
|
||||
|
||||
//when you create QuestDataOld and AFTER you copy the AI decks over
|
||||
//you have to call one of these two methods below
|
||||
//see Gui_QuestOptions for more details
|
||||
|
||||
//
|
||||
//static readAIQuestDeckFiles(QuestDataOld data, ArrayList aiDeckNames)
|
||||
//OR non-static readAIQuestDeckFiles()
|
||||
//which reads the files "questDecks-easy", "questDecks-medium","questDecks-hard",
|
||||
@@ -42,42 +33,6 @@ import net.slightlymagic.maxmtg.Predicate;
|
||||
*/
|
||||
public final class QuestData {
|
||||
|
||||
int rankIndex;
|
||||
int win;
|
||||
int lost;
|
||||
|
||||
int life;
|
||||
|
||||
int questsPlayed;
|
||||
|
||||
long credits;
|
||||
int diffIndex;
|
||||
String difficulty;
|
||||
|
||||
String mode = "";
|
||||
|
||||
Map<String, Deck> myDecks = new HashMap<String, Deck>();
|
||||
|
||||
CardPool cardPool = new CardPool();
|
||||
CardPool shopList = new CardPool();
|
||||
List<Integer> availableQuests = new ArrayList<Integer>();
|
||||
|
||||
List<Integer> completedQuests = new ArrayList<Integer>();
|
||||
|
||||
private transient QuestBoosterPack boosterPack;
|
||||
|
||||
//used by shouldAddAdditionalCards()
|
||||
private long randomSeed = 0;
|
||||
|
||||
private transient String[] rankArray;
|
||||
|
||||
/** Constant <code>FANTASY="Fantasy"</code> */
|
||||
public static final String FANTASY = "Fantasy";
|
||||
/** Constant <code>REALISTIC="Realistic"</code> */
|
||||
public static final String REALISTIC = "Realistic";
|
||||
|
||||
QuestInventory inventory = new QuestInventory();
|
||||
|
||||
//This field holds the version of the Quest Data
|
||||
/** Constant <code>CURRENT_VERSION_NUMBER=2</code> */
|
||||
public static final int CURRENT_VERSION_NUMBER = 2;
|
||||
@@ -87,589 +42,141 @@ public final class QuestData {
|
||||
//DO NOT RENAME THIS FIELD
|
||||
int versionNumber = CURRENT_VERSION_NUMBER;
|
||||
|
||||
QuestPetManager petManager = new QuestPetManager();
|
||||
int rankIndex; // level
|
||||
int win; // number of wins
|
||||
int lost;
|
||||
|
||||
long credits; // this money is good for all modes
|
||||
|
||||
int life; // for fantasy mode, how much life bought at shop to start game with
|
||||
QuestInventory inventory = new QuestInventory(); // different gadgets
|
||||
QuestPetManager petManager = new QuestPetManager(); // pets that start match with you
|
||||
|
||||
|
||||
// Diffuculty - they store both index and title
|
||||
int diffIndex;
|
||||
String difficulty;
|
||||
|
||||
// Quest mode - there should be an enum :(
|
||||
String mode = "";
|
||||
public static final String FANTASY = "Fantasy";
|
||||
public static final String REALISTIC = "Realistic";
|
||||
|
||||
// Decks collected by player
|
||||
Map<String, Deck> myDecks = new HashMap<String, Deck>();
|
||||
|
||||
// Cards associated with quest
|
||||
CardPool cardPool = new CardPool(); // player's belonging
|
||||
CardPool shopList = new CardPool(); // the current shop list
|
||||
CardPool newCardList = new CardPool(); // cards acquired since last game-win/loss
|
||||
|
||||
// Quests history
|
||||
int questsPlayed;
|
||||
List<Integer> availableQuests = new ArrayList<Integer>();
|
||||
List<Integer> completedQuests = new ArrayList<Integer>();
|
||||
|
||||
// own randomizer seed
|
||||
private long randomSeed = 0;
|
||||
|
||||
// Utility class to access cards, has access to private fields
|
||||
// Moved some methods there that otherwise would make this class even more complex
|
||||
private transient QuestUtilCards myCards;
|
||||
private transient QuestUtilRewards myRewards;
|
||||
|
||||
|
||||
public static final String[] RANK_TITLES = new String[]{
|
||||
"Level 0 - Confused Wizard",
|
||||
"Level 1 - Mana Mage",
|
||||
"Level 2 - Death by Megrim",
|
||||
"Level 3 - Shattered the Competition",
|
||||
"Level 4 - Black Knighted",
|
||||
"Level 5 - Shockingly Good",
|
||||
"Level 6 - Regressed into Timmy",
|
||||
"Level 7 - Loves Blue Control",
|
||||
"Level 8 - Immobilized by Fear",
|
||||
"Level 9 - Lands = Friends",
|
||||
"Saltblasted for your talent",
|
||||
"Serra Angel is your girlfriend",
|
||||
};
|
||||
|
||||
/**
|
||||
* <p>Constructor for QuestData.</p>
|
||||
*/
|
||||
public QuestData() {
|
||||
|
||||
cardPool.add(CardDb.instance().getCard("Forest", "M10"), QuestPreferences.getStartingBasic());
|
||||
cardPool.add(CardDb.instance().getCard("Mountain", "M10"), QuestPreferences.getStartingBasic());
|
||||
cardPool.add(CardDb.instance().getCard("Swamp", "M10"), QuestPreferences.getStartingBasic());
|
||||
cardPool.add(CardDb.instance().getCard("Island", "M10"), QuestPreferences.getStartingBasic());
|
||||
cardPool.add(CardDb.instance().getCard("Plains", "M10"), QuestPreferences.getStartingBasic());
|
||||
|
||||
cardPool.add(CardDb.instance().getCard("Snow-Covered Forest", "ICE"), QuestPreferences.getStartingSnowBasic());
|
||||
cardPool.add(CardDb.instance().getCard("Snow-Covered Mountain", "ICE"), QuestPreferences.getStartingSnowBasic());
|
||||
cardPool.add(CardDb.instance().getCard("Snow-Covered Swamp", "ICE"), QuestPreferences.getStartingSnowBasic());
|
||||
cardPool.add(CardDb.instance().getCard("Snow-Covered Island", "ICE"), QuestPreferences.getStartingSnowBasic());
|
||||
cardPool.add(CardDb.instance().getCard("Snow-Covered Plains", "ICE"), QuestPreferences.getStartingSnowBasic());
|
||||
|
||||
initTransients();
|
||||
myCards.generateBasicLands(QuestPreferences.getStartingBasic(), QuestPreferences.getStartingSnowBasic());
|
||||
randomizeOpponents();
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>initTransients.</p>
|
||||
*/
|
||||
private void initTransients() {
|
||||
rankArray = new String[]{
|
||||
"Level 0 - Confused Wizard",
|
||||
"Level 1 - Mana Mage",
|
||||
"Level 2 - Death by Megrim",
|
||||
"Level 3 - Shattered the Competition",
|
||||
"Level 4 - Black Knighted",
|
||||
"Level 5 - Shockingly Good",
|
||||
"Level 6 - Regressed into Timmy",
|
||||
"Level 7 - Loves Blue Control",
|
||||
"Level 8 - Immobilized by Fear",
|
||||
"Level 9 - Lands = Friends",
|
||||
"Saltblasted for your talent",
|
||||
"Serra Angel is your girlfriend",};
|
||||
|
||||
boosterPack = new QuestBoosterPack();
|
||||
myCards = new QuestUtilCards(this);
|
||||
myRewards = new QuestUtilRewards(this);
|
||||
}
|
||||
|
||||
public void newGame(final int diff, final String m0de, final boolean standardStart) {
|
||||
setDifficulty(diff);
|
||||
|
||||
//adds cards to card pool and sets difficulty
|
||||
Predicate<CardPrinted> filter = standardStart
|
||||
? CardPrinted.Predicates.Presets.isStandard
|
||||
: Predicate.getTrue(CardPrinted.class);
|
||||
|
||||
/**
|
||||
* <p>newGame.</p>
|
||||
*
|
||||
* @param difficulty a int.
|
||||
* @param m a {@link java.lang.String} object.
|
||||
* @param standardStart a boolean.
|
||||
*/
|
||||
public void newGame(int difficulty, String m, boolean standardStart) {
|
||||
setDifficulty(difficulty);
|
||||
|
||||
Predicate<CardPrinted> filter = standardStart
|
||||
? CardPrinted.Predicates.Presets.isStandard
|
||||
: Predicate.getTrue(CardPrinted.class);
|
||||
|
||||
List<CardPrinted> list = boosterPack.getQuestStarterDeck(
|
||||
filter,
|
||||
QuestPreferences.getStartingCommons(difficulty),
|
||||
QuestPreferences.getStartingUncommons(difficulty),
|
||||
QuestPreferences.getStartingRares(difficulty));
|
||||
|
||||
//because cardPool already has basic land added to it
|
||||
addAllCards(list);
|
||||
myCards.setupNewGameCardPool(filter, diff);
|
||||
credits = QuestPreferences.getStartingCredits();
|
||||
|
||||
mode = m;
|
||||
if (mode.equals(FANTASY)) {
|
||||
life = 15;
|
||||
} else {
|
||||
life = 20;
|
||||
}
|
||||
mode = m0de;
|
||||
life = mode.equals(FANTASY) ? 15 : 20;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method should be called whenever the opponents should change.
|
||||
*/
|
||||
public void randomizeOpponents() {
|
||||
randomSeed = MyRandom.random.nextLong();
|
||||
}
|
||||
// All belongins
|
||||
public QuestInventory getInventory() { return inventory; }
|
||||
public QuestPetManager getPetManager() { return petManager; }
|
||||
// Cards - class uses data from here
|
||||
public QuestUtilCards getCards() { return myCards; }
|
||||
public QuestUtilRewards getRewards() { return myRewards; }
|
||||
|
||||
// Quests performance
|
||||
public int getQuestsPlayed() { return questsPlayed; }
|
||||
public void addQuestsPlayed() { questsPlayed++; }
|
||||
|
||||
/**
|
||||
* <p>saveData.</p>
|
||||
*/
|
||||
public void saveData() {
|
||||
QuestDataIO.saveData(this);
|
||||
}
|
||||
public List<Integer> getAvailableQuests() { return availableQuests != null ? new ArrayList<Integer>(availableQuests) : null; }
|
||||
public void setAvailableQuests(final List<Integer> list) { availableQuests = list; }
|
||||
public void clearAvailableQuests() { availableQuests.clear(); }
|
||||
public List<Integer> getCompletedQuests() { return completedQuests != null ? new ArrayList<Integer>(completedQuests) : null; }
|
||||
|
||||
|
||||
public CardPool getCardpool() {
|
||||
return cardPool;
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>Getter for the field <code>shopList</code>.</p>
|
||||
*
|
||||
* @return a {@link java.util.List} object.
|
||||
*/
|
||||
public CardPoolView getShopList() {
|
||||
if (shopList.isEmpty()) {
|
||||
generateCardsInShop();
|
||||
}
|
||||
return shopList;
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>Setter for the field <code>shopList</code>.</p>
|
||||
*
|
||||
* @param list a {@link java.util.List} object.
|
||||
*/
|
||||
public void generateCardsInShop() {
|
||||
ReadBoosterPack pack = new ReadBoosterPack();
|
||||
CardPoolView fromBoosters = pack.getShopCards(getWin(), getLevel());
|
||||
shopList.clear();
|
||||
shopList.addAll(fromBoosters);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* <p>Getter for the field <code>availableQuests</code>.</p>
|
||||
*
|
||||
* @return a {@link java.util.List} object.
|
||||
*/
|
||||
public List<Integer> getAvailableQuests() {
|
||||
if (availableQuests != null) {
|
||||
return new ArrayList<Integer>(availableQuests);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>Setter for the field <code>availableQuests</code>.</p>
|
||||
*
|
||||
* @param list a {@link java.util.List} object.
|
||||
*/
|
||||
public void setAvailableQuests(List<Integer> list) {
|
||||
availableQuests = list;
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>clearAvailableQuests.</p>
|
||||
*/
|
||||
public void clearAvailableQuests() {
|
||||
availableQuests.clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>Getter for the field <code>completedQuests</code>.</p>
|
||||
*
|
||||
* @return a {@link java.util.List} object.
|
||||
*/
|
||||
public List<Integer> getCompletedQuests() {
|
||||
if (completedQuests != null) {
|
||||
return new ArrayList<Integer>(completedQuests);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>Setter for the field <code>completedQuests</code>.</p>
|
||||
*
|
||||
* @param list a {@link java.util.List} object.
|
||||
*/
|
||||
public void setCompletedQuests(List<Integer> list) {
|
||||
completedQuests = list;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* <p>clearShopList.</p>
|
||||
*/
|
||||
public void clearShopList() {
|
||||
if (null != shopList) { shopList.clear(); }
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* <p>removeDeck.</p>
|
||||
*
|
||||
* @param deckName a {@link java.lang.String} object.
|
||||
*/
|
||||
public void removeDeck(String deckName) {
|
||||
myDecks.remove(deckName);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* <p>addDeck.</p>
|
||||
*
|
||||
* @param d a {@link forge.deck.Deck} object.
|
||||
*/
|
||||
public void addDeck(Deck d) {
|
||||
myDecks.put(d.getName(), d);
|
||||
}
|
||||
|
||||
//this Deck object is a Constructed deck
|
||||
//deck.getDeckType() is Constant.GameType.Sealed
|
||||
//sealed since the card pool is the Deck sideboard
|
||||
|
||||
/**
|
||||
* <p>getDeck.</p>
|
||||
*
|
||||
* @param deckName a {@link java.lang.String} object.
|
||||
* @return a {@link forge.deck.Deck} object.
|
||||
*/
|
||||
public Deck getDeck(String deckName) {
|
||||
//have to always set the card pool aka the Deck sideboard
|
||||
//because new cards may have been added to the card pool by addCards()
|
||||
|
||||
if (!myDecks.containsKey(deckName)) {
|
||||
ErrorViewer.showError(new Exception(),
|
||||
"QuestData : getDeckFromMap(String deckName) error, deck name not found - %s", deckName);
|
||||
}
|
||||
|
||||
Deck d = myDecks.get(deckName);
|
||||
|
||||
d.clearSideboard();
|
||||
|
||||
return d;
|
||||
}
|
||||
|
||||
|
||||
//returns human player decks
|
||||
//returns ArrayList of String deck names
|
||||
|
||||
/**
|
||||
* <p>getDeckNames.</p>
|
||||
*
|
||||
* @return a {@link java.util.List} object.
|
||||
*/
|
||||
public List<String> getDeckNames() {
|
||||
return new ArrayList<String>(myDecks.keySet());
|
||||
}
|
||||
|
||||
|
||||
//adds 11 cards, to the current card pool
|
||||
//(I chose 11 cards instead of 15 in order to make things more challenging)
|
||||
|
||||
/**
|
||||
* <p>addCards.</p>
|
||||
*/
|
||||
public ArrayList<CardPrinted> addCards( List<String> setsFilter ) {
|
||||
int nCommon = QuestPreferences.getNumCommon();
|
||||
int nUncommon = QuestPreferences.getNumUncommon();
|
||||
int nRare = QuestPreferences.getNumRare();
|
||||
Predicate<CardPrinted> fSets = CardPrinted.Predicates.printedInSets(setsFilter, true);
|
||||
|
||||
ArrayList<CardPrinted> newCards = new ArrayList<CardPrinted>();
|
||||
newCards.addAll(boosterPack.generateCards(fSets, nCommon, CardRarity.Common, null));
|
||||
newCards.addAll(boosterPack.generateCards(fSets, nUncommon, CardRarity.Uncommon, null));
|
||||
newCards.addAll(boosterPack.generateCards(fSets, nRare, CardRarity.Rare, null));
|
||||
|
||||
addAllCards(newCards);
|
||||
return newCards;
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>addRandomRare.</p>
|
||||
*
|
||||
* @param n a int.
|
||||
* @return a {@link java.util.ArrayList} object.
|
||||
*/
|
||||
public ArrayList<CardPrinted> addRandomRare(int n) {
|
||||
ArrayList<CardPrinted> newCards = new ArrayList<CardPrinted>();
|
||||
newCards.addAll(boosterPack.generateCards(n, CardRarity.Rare, null));
|
||||
|
||||
addAllCards(newCards);
|
||||
|
||||
return newCards;
|
||||
}
|
||||
|
||||
public void addAllCards(Iterable<CardPrinted> newCards) {
|
||||
for (CardPrinted card : newCards) {
|
||||
cardPool.add( card );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>addRandomRare.</p>
|
||||
*
|
||||
* @return a {@link java.lang.String} object.
|
||||
*/
|
||||
public CardPrinted addRandomRare() {
|
||||
return addRandomRare(1).get(0);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* <p>addCardToShopList.</p>
|
||||
*
|
||||
* @param c a {@link forge.Card} object.
|
||||
*/
|
||||
public void addCardToShopList(CardPrinted c) {
|
||||
shopList.add(c);
|
||||
}
|
||||
|
||||
public final int getCreditsRewardForAltWin(final GameLossReason whyAiLost) {
|
||||
int rewardAltWinCondition = 0;
|
||||
switch (whyAiLost) {
|
||||
case LifeReachedZero:
|
||||
break; // nothing special here, ordinary kill
|
||||
case Milled:
|
||||
rewardAltWinCondition = QuestPreferences.getMatchRewardMilledWinBonus();
|
||||
break;
|
||||
case Poisoned:
|
||||
rewardAltWinCondition = QuestPreferences.getMatchRewardPoisonWinBonus();
|
||||
break;
|
||||
case DidNotLoseYet: // must be player's alternate win condition: felidar, helix pinnacle and like this
|
||||
rewardAltWinCondition = QuestPreferences.getMatchRewardAltWinBonus();
|
||||
break;
|
||||
case SpellEffect: // Door to Nothingness or something like this
|
||||
rewardAltWinCondition = QuestPreferences.getMatchRewardAltWinBonus();
|
||||
break;
|
||||
default: // this .checkstyle forces us to write some idiotic code
|
||||
rewardAltWinCondition = 0;
|
||||
}
|
||||
return rewardAltWinCondition;
|
||||
}
|
||||
|
||||
public final int getCreditsRewardForWinByTurn(final int iTurn) {
|
||||
if (iTurn == 1) {
|
||||
return QuestPreferences.getMatchRewardWinFirst();
|
||||
} else if (iTurn <= 5) {
|
||||
return QuestPreferences.getMatchRewardWinByFifth();
|
||||
} else if (iTurn <= 10) {
|
||||
return QuestPreferences.getMatchRewardWinByTen();
|
||||
} else if (iTurn <= 15) {
|
||||
return QuestPreferences.getMatchRewardWinByFifteen();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>getCreditsToAdd.</p>
|
||||
*
|
||||
* @param matchState a {@link forge.quest.data.QuestMatchState} object.
|
||||
* @return a long.
|
||||
*/
|
||||
public final long getCreditsToAdd(final QuestMatchState matchState) {
|
||||
long creds = (long) (QuestPreferences.getMatchRewardBase()
|
||||
+ (QuestPreferences.getMatchRewardTotalWins() * win));
|
||||
|
||||
boolean hasNeverLost = true;
|
||||
for (GameSummary game : matchState.getGamesPlayed()) {
|
||||
if (game.isAIWinner()) {
|
||||
hasNeverLost = true;
|
||||
continue; // no rewards for losing a game
|
||||
}
|
||||
|
||||
GamePlayerRating aiRating = game.getPlayerRating(PlayerIndex.AI);
|
||||
GamePlayerRating humanRating = game.getPlayerRating(PlayerIndex.HUMAN);
|
||||
GameLossReason whyAiLost = aiRating.getLossReason();
|
||||
|
||||
creds += getCreditsRewardForAltWin(whyAiLost);
|
||||
creds += getCreditsRewardForWinByTurn(game.getTurnGameEnded());
|
||||
|
||||
int cntCardsHumanStartedWith = humanRating.getOpeningHandSize();
|
||||
if (0 == cntCardsHumanStartedWith) {
|
||||
creds += QuestPreferences.getMatchMullToZero();
|
||||
}
|
||||
}
|
||||
|
||||
if (hasNeverLost) {
|
||||
creds += QuestPreferences.getMatchRewardNoLosses();
|
||||
}
|
||||
|
||||
switch(inventory.getItemLevel("Estates")) {
|
||||
case 1: creds *= 1.1; break;
|
||||
case 2: creds *= 1.15; break;
|
||||
case 3: creds *= 1.2; break;
|
||||
default: break;
|
||||
}
|
||||
|
||||
return creds;
|
||||
}
|
||||
|
||||
//gets all of the cards that are in the cardpool
|
||||
|
||||
/**
|
||||
* <p>getTotalNumberOfGames.</p>
|
||||
*
|
||||
* @param difficulty a int.
|
||||
* @return a int.
|
||||
*/
|
||||
public int getTotalNumberOfGames(int difficulty) {
|
||||
//-2 because you start a level 1, and the last level is secret
|
||||
int numberLevels = rankArray.length - 2;
|
||||
int nMatches = QuestPreferences.getWinsForRankIncrease(difficulty);
|
||||
|
||||
return numberLevels * nMatches;
|
||||
}
|
||||
|
||||
//this changes getRank()
|
||||
|
||||
/**
|
||||
* <p>addWin.</p>
|
||||
*/
|
||||
public void addWin() {
|
||||
// Wins & Losses
|
||||
public int getLost() { return lost; }
|
||||
public void addLost() { lost++; }
|
||||
public int getWin() { return win; }
|
||||
public void addWin() { //changes getRank()
|
||||
win++;
|
||||
|
||||
if (win % QuestPreferences.getWinsForRankIncrease(diffIndex) == 0) {
|
||||
rankIndex++;
|
||||
}
|
||||
int winsToLvlUp = QuestPreferences.getWinsForRankIncrease(diffIndex);
|
||||
if (win % winsToLvlUp == 0) { rankIndex++; }
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>addLost.</p>
|
||||
*/
|
||||
public void addLost() {
|
||||
lost++;
|
||||
}
|
||||
// Life (only fantasy)
|
||||
public int getLife() { return isFantasy() ? life : 20; }
|
||||
public void addLife(final int n) { life += n; }
|
||||
|
||||
/**
|
||||
* <p>Getter for the field <code>win</code>.</p>
|
||||
*
|
||||
* @return a int.
|
||||
*/
|
||||
public int getWin() {
|
||||
return win;
|
||||
}
|
||||
// Credits
|
||||
public void addCredits(final long c) { credits += c; }
|
||||
public void subtractCredits(final long c) { credits = credits > c ? credits - c : 0; }
|
||||
public long getCredits() { return credits; }
|
||||
|
||||
/**
|
||||
* <p>Getter for the field <code>lost</code>.</p>
|
||||
*
|
||||
* @return a int.
|
||||
*/
|
||||
public int getLost() {
|
||||
return lost;
|
||||
}
|
||||
// Quest mode
|
||||
public boolean isFantasy() { return mode.equals(FANTASY); }
|
||||
public String getMode() { return mode == null ? "" : mode; }
|
||||
|
||||
//********************FANTASY STUFF START***********************
|
||||
// Difficulty
|
||||
public String getDifficulty() { return difficulty; }
|
||||
public int getDifficultyIndex() { return diffIndex; }
|
||||
|
||||
/**
|
||||
* <p>Setter for the field <code>life</code>.</p>
|
||||
*
|
||||
* @param n a int.
|
||||
*/
|
||||
public void setLife(int n) {
|
||||
life = n;
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>Getter for the field <code>life</code>.</p>
|
||||
*
|
||||
* @return a int.
|
||||
*/
|
||||
public int getLife() {
|
||||
return life;
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>addLife.</p>
|
||||
*
|
||||
* @param n a int.
|
||||
*/
|
||||
public void addLife(int n) {
|
||||
life += n;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* <p>Getter for the field <code>questsPlayed</code>.</p>
|
||||
*
|
||||
* @return a int.
|
||||
*/
|
||||
public int getQuestsPlayed() {
|
||||
return questsPlayed;
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>addQuestsPlayed.</p>
|
||||
*/
|
||||
public void addQuestsPlayed() {
|
||||
questsPlayed++;
|
||||
}
|
||||
|
||||
//********************FANTASY STUFF END***********************
|
||||
|
||||
/**
|
||||
* <p>addCredits.</p>
|
||||
*
|
||||
* @param c a long.
|
||||
*/
|
||||
public void addCredits(long c) {
|
||||
credits += c;
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>subtractCredits.</p>
|
||||
*
|
||||
* @param c a long.
|
||||
*/
|
||||
public void subtractCredits(long c) {
|
||||
credits -= c;
|
||||
if (credits < 0) {
|
||||
credits = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>Getter for the field <code>credits</code>.</p>
|
||||
*
|
||||
* @return a long.
|
||||
*/
|
||||
public long getCredits() {
|
||||
return credits;
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>Getter for the field <code>mode</code>.</p>
|
||||
*
|
||||
* @return a {@link java.lang.String} object.
|
||||
*/
|
||||
public String getMode() {
|
||||
if (mode == null) {
|
||||
return "";
|
||||
}
|
||||
return mode;
|
||||
}
|
||||
|
||||
public double getSellMutliplier() {
|
||||
double multi = 0.20 + (0.001 * getWin());
|
||||
if (multi > 0.6)
|
||||
multi = 0.6;
|
||||
|
||||
if (getMode().equals(forge.quest.data.QuestData.FANTASY)) {
|
||||
if (getInventory().getItemLevel("Estates") == 1)
|
||||
multi += 0.01;
|
||||
else if (getInventory().getItemLevel("Estates") == 2)
|
||||
multi += 0.0175;
|
||||
else if (getInventory().getItemLevel("Estates") >= 3)
|
||||
multi += 0.025;
|
||||
}
|
||||
return multi;
|
||||
}
|
||||
|
||||
public int getSellPriceLimit() {
|
||||
return getWin() <= 50 ? 1000 : Integer.MAX_VALUE;
|
||||
}
|
||||
|
||||
|
||||
//should be called first, because the difficultly won't change
|
||||
|
||||
/**
|
||||
* <p>Getter for the field <code>difficulty</code>.</p>
|
||||
*
|
||||
* @return a {@link java.lang.String} object.
|
||||
*/
|
||||
public String getDifficulty() {
|
||||
return difficulty;
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>getDifficultyIndex.</p>
|
||||
*
|
||||
* @return a int.
|
||||
*/
|
||||
public int getDifficultyIndex() {
|
||||
return diffIndex;
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>Setter for the field <code>difficulty</code>.</p>
|
||||
*
|
||||
* @param i a int.
|
||||
*/
|
||||
public void setDifficulty(int i) {
|
||||
public void setDifficulty(final int i) {
|
||||
diffIndex = i;
|
||||
difficulty = QuestPreferences.getDifficulty(i);
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>setDifficultyIndex.</p>
|
||||
*/
|
||||
public void setDifficultyIndex() {
|
||||
public void guessDifficultyIndex() {
|
||||
String[] diffStr = QuestPreferences.getDifficulty();
|
||||
for (int i = 0; i < diffStr.length; i++) {
|
||||
if (difficulty.equals(diffStr[i])) {
|
||||
@@ -678,139 +185,56 @@ public final class QuestData {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>getDifficultyChoices.</p>
|
||||
*
|
||||
* @return an array of {@link java.lang.String} objects.
|
||||
*/
|
||||
public String[] getDifficultyChoices() {
|
||||
return QuestPreferences.getDifficulty();
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>getRank.</p>
|
||||
*
|
||||
* @return a {@link java.lang.String} object.
|
||||
*/
|
||||
// Level, read-only ( note: it increments in addWin() )
|
||||
public int getLevel() { return rankIndex; }
|
||||
public String getRank() {
|
||||
//is rankIndex too big?
|
||||
if (rankIndex >= rankArray.length) {
|
||||
rankIndex = rankArray.length - 1;
|
||||
if (rankIndex >= RANK_TITLES.length) { rankIndex = RANK_TITLES.length - 1; }
|
||||
return RANK_TITLES[rankIndex];
|
||||
}
|
||||
|
||||
// decks management
|
||||
public List<String> getDeckNames() { return new ArrayList<String>(myDecks.keySet()); }
|
||||
public void removeDeck(final String deckName) { myDecks.remove(deckName); }
|
||||
public void addDeck(final Deck d) { myDecks.put(d.getName(), d); }
|
||||
|
||||
/**
|
||||
* <p>getDeck.</p>
|
||||
*
|
||||
* @param deckName a {@link java.lang.String} object.
|
||||
* @return a {@link forge.deck.Deck} object.
|
||||
*/
|
||||
public Deck getDeck(final String deckName) {
|
||||
if (!myDecks.containsKey(deckName)) {
|
||||
ErrorViewer.showError(new Exception(),
|
||||
"QuestData : getDeckFromMap(String deckName) error, deck name not found - %s", deckName);
|
||||
}
|
||||
|
||||
return rankArray[rankIndex];
|
||||
Deck d = myDecks.get(deckName);
|
||||
d.clearSideboard();
|
||||
return d;
|
||||
}
|
||||
|
||||
// randomizer - related
|
||||
public long getRandomSeed() { return randomSeed; }
|
||||
|
||||
/**
|
||||
* <p>getLevel.</p>
|
||||
*
|
||||
* @return a int.
|
||||
* @since 1.0.15
|
||||
* This method should be called whenever the opponents should change.
|
||||
*/
|
||||
public int getLevel() {
|
||||
return rankIndex;
|
||||
public void randomizeOpponents() {
|
||||
randomSeed = MyRandom.random.nextLong();
|
||||
}
|
||||
|
||||
//add cards after a certain number of wins or losses
|
||||
// SERIALIZATION - relared things
|
||||
|
||||
/**
|
||||
* <p>shouldAddCards.</p>
|
||||
*
|
||||
* @param didWin a boolean.
|
||||
* @return a boolean.
|
||||
*/
|
||||
public boolean shouldAddCards(boolean didWin) {
|
||||
int n = QuestPreferences.getWinsForBooster(diffIndex);
|
||||
|
||||
if (didWin) {
|
||||
return getWin() % n == 0;
|
||||
} else {
|
||||
return getLost() % n == 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>shouldAddAdditionalCards.</p>
|
||||
*
|
||||
* @param didWin a boolean.
|
||||
* @return a boolean.
|
||||
*/
|
||||
public boolean shouldAddAdditionalCards(boolean didWin) {
|
||||
float chance = 0.5f;
|
||||
if (inventory.getItemLevel("Lucky Coin") == 1) {
|
||||
chance = 0.65f;
|
||||
}
|
||||
|
||||
float r = MyRandom.random.nextFloat();
|
||||
|
||||
if (didWin) {
|
||||
return r <= chance;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>hasSaveFile.</p>
|
||||
*
|
||||
* @return a boolean.
|
||||
*/
|
||||
public boolean hasSaveFile() {
|
||||
return ForgeProps.getFile(NewConstants.QUEST.DATA).exists() ||
|
||||
ForgeProps.getFile(NewConstants.QUEST.XMLDATA).exists();
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>Getter for the field <code>petManager</code>.</p>
|
||||
*
|
||||
* @return a {@link forge.quest.data.pet.QuestPetManager} object.
|
||||
*/
|
||||
public QuestPetManager getPetManager() {
|
||||
return petManager;
|
||||
}
|
||||
|
||||
//get new cards that were added to your card pool by addCards()
|
||||
|
||||
|
||||
/**
|
||||
* <p>readResolve.</p>
|
||||
*
|
||||
* @return a {@link java.lang.Object} object.
|
||||
*/
|
||||
// This must be called by XML-serializer via reflection
|
||||
public Object readResolve() {
|
||||
initTransients();
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>Getter for the field <code>inventory</code>.</p>
|
||||
*
|
||||
* @return a {@link forge.quest.data.item.QuestInventory} object.
|
||||
*/
|
||||
public QuestInventory getInventory() {
|
||||
return inventory;
|
||||
public boolean hasSaveFile() {
|
||||
return ForgeProps.getFile(NewConstants.QUEST.DATA).exists() ||
|
||||
ForgeProps.getFile(NewConstants.QUEST.XMLDATA).exists();
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>Getter for the field <code>randomSeed</code>.</p>
|
||||
*
|
||||
* @return a long.
|
||||
*/
|
||||
public long getRandomSeed() {
|
||||
return randomSeed;
|
||||
}
|
||||
|
||||
public void buyCard(final CardPrinted card, final int value) {
|
||||
if (credits >= value) {
|
||||
credits -= value;
|
||||
getCardpool().add(card);
|
||||
shopList.remove(card);
|
||||
}
|
||||
}
|
||||
|
||||
public void sellCard(final CardPrinted card, final int price) {
|
||||
if (price > 0) { credits += price; }
|
||||
getCardpool().remove(card);
|
||||
// remove from decks right here
|
||||
}
|
||||
public void saveData() { QuestDataIO.saveData(this); }
|
||||
}
|
||||
|
||||
152
src/main/java/forge/quest/data/QuestUtilCards.java
Normal file
152
src/main/java/forge/quest/data/QuestUtilCards.java
Normal file
@@ -0,0 +1,152 @@
|
||||
package forge.quest.data;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.slightlymagic.maxmtg.Predicate;
|
||||
|
||||
import forge.ReadBoosterPack;
|
||||
import forge.card.CardDb;
|
||||
import forge.card.CardPool;
|
||||
import forge.card.CardPoolView;
|
||||
import forge.card.CardPrinted;
|
||||
import forge.card.CardRarity;
|
||||
import forge.deck.Deck;
|
||||
|
||||
/**
|
||||
* This is a helper class to execute operations on QuestData.
|
||||
* It has been created to decrease complexity of questData class
|
||||
*/
|
||||
public final class QuestUtilCards {
|
||||
private QuestData q;
|
||||
public QuestUtilCards(final QuestData qd) { q = qd; }
|
||||
|
||||
public void generateBasicLands(int nBasic, int nSnow)
|
||||
{
|
||||
CardDb db = CardDb.instance();
|
||||
q.cardPool.add(db.getCard("Forest", "M10"), nBasic);
|
||||
q.cardPool.add(db.getCard("Mountain", "M10"), nBasic);
|
||||
q.cardPool.add(db.getCard("Swamp", "M10"), nBasic);
|
||||
q.cardPool.add(db.getCard("Island", "M10"), nBasic);
|
||||
q.cardPool.add(db.getCard("Plains", "M10"), nBasic);
|
||||
|
||||
q.cardPool.add(db.getCard("Snow-Covered Forest", "ICE"), nSnow);
|
||||
q.cardPool.add(db.getCard("Snow-Covered Mountain", "ICE"), nSnow);
|
||||
q.cardPool.add(db.getCard("Snow-Covered Swamp", "ICE"), nSnow);
|
||||
q.cardPool.add(db.getCard("Snow-Covered Island", "ICE"), nSnow);
|
||||
q.cardPool.add(db.getCard("Snow-Covered Plains", "ICE"), nSnow);
|
||||
}
|
||||
|
||||
|
||||
//adds 11 cards, to the current card pool
|
||||
//(I chose 11 cards instead of 15 in order to make things more challenging)
|
||||
|
||||
/**
|
||||
* <p>addCards.</p>
|
||||
*/
|
||||
public ArrayList<CardPrinted> addCards(final List<String> setsFilter) {
|
||||
int nCommon = QuestPreferences.getNumCommon();
|
||||
int nUncommon = QuestPreferences.getNumUncommon();
|
||||
int nRare = QuestPreferences.getNumRare();
|
||||
|
||||
Predicate<CardPrinted> fSets = CardPrinted.Predicates.printedInSets(setsFilter, true);
|
||||
|
||||
ArrayList<CardPrinted> newCards = new ArrayList<CardPrinted>();
|
||||
newCards.addAll(QuestBoosterPack.generateCards(fSets, nCommon, CardRarity.Common, null));
|
||||
newCards.addAll(QuestBoosterPack.generateCards(fSets, nUncommon, CardRarity.Uncommon, null));
|
||||
newCards.addAll(QuestBoosterPack.generateCards(fSets, nRare, CardRarity.Rare, null));
|
||||
|
||||
addAllCards(newCards);
|
||||
return newCards;
|
||||
}
|
||||
|
||||
public void addAllCards(final Iterable<CardPrinted> newCards) {
|
||||
for (CardPrinted card : newCards) {
|
||||
q.cardPool.add(card);
|
||||
}
|
||||
}
|
||||
|
||||
public CardPrinted addRandomRare() { return addRandomRare(1).get(0); }
|
||||
public List<CardPrinted> addRandomRare(final int n) {
|
||||
List<CardPrinted> newCards = CardPrinted.Predicates.Presets.isRareOrMythic.random(CardDb.instance().getAllCards(), n);
|
||||
addAllCards(newCards);
|
||||
return newCards;
|
||||
}
|
||||
|
||||
public void setupNewGameCardPool(Predicate<CardPrinted> filter, int idxDifficulty)
|
||||
{
|
||||
int nC = QuestPreferences.getStartingCommons(idxDifficulty);
|
||||
int nU = QuestPreferences.getStartingUncommons(idxDifficulty);
|
||||
int nR = QuestPreferences.getStartingRares(idxDifficulty);
|
||||
|
||||
addAllCards(QuestBoosterPack.getQuestStarterDeck(filter, nC, nU, nR));
|
||||
}
|
||||
|
||||
public void buyCard(final CardPrinted card, final int value) {
|
||||
if (q.credits >= value) {
|
||||
q.credits -= value;
|
||||
q.cardPool.add(card);
|
||||
q.shopList.remove(card);
|
||||
}
|
||||
}
|
||||
|
||||
public void sellCard(final CardPrinted card, final int price) {
|
||||
if (price > 0) { q.credits += price; }
|
||||
q.cardPool.remove(card);
|
||||
q.shopList.add(card);
|
||||
|
||||
// remove card being sold from all decks
|
||||
int leftInPool = q.cardPool.count(card);
|
||||
// remove sold cards from all decks:
|
||||
for (Deck deck : q.myDecks.values()) {
|
||||
deck.removeMain(card, deck.getMain().count(card) - leftInPool);
|
||||
}
|
||||
}
|
||||
|
||||
public void clearShopList() {
|
||||
if (null != q.shopList) { q.shopList.clear(); }
|
||||
}
|
||||
|
||||
public double getSellMutliplier() {
|
||||
double multi = 0.20 + (0.001 * q.getWin());
|
||||
if (multi > 0.6)
|
||||
multi = 0.6;
|
||||
|
||||
int lvlEstates = q.isFantasy() ? q.inventory.getItemLevel("Estates") : 0;
|
||||
switch (lvlEstates) {
|
||||
case 1: multi += 0.01; break;
|
||||
case 2: multi += 0.0175; break;
|
||||
case 3: multi += 0.025; break;
|
||||
}
|
||||
|
||||
return multi;
|
||||
}
|
||||
|
||||
public int getSellPriceLimit() {
|
||||
return q.getWin() <= 50 ? 1000 : Integer.MAX_VALUE;
|
||||
}
|
||||
|
||||
public void generateCardsInShop() {
|
||||
ReadBoosterPack pack = new ReadBoosterPack();
|
||||
|
||||
int levelPacks = q.getLevel() > 0 ? 4 / q.getLevel() : 4;
|
||||
int winPacks = q.getWin() / 10;
|
||||
int totalPacks = Math.min(levelPacks + winPacks, 6);
|
||||
|
||||
CardPoolView fromBoosters = pack.getShopCards(totalPacks);
|
||||
q.shopList.clear();
|
||||
q.shopList.addAll(fromBoosters);
|
||||
}
|
||||
|
||||
public CardPool getCardpool() {
|
||||
return q.cardPool;
|
||||
}
|
||||
|
||||
public CardPoolView getShopList() {
|
||||
if (q.shopList.isEmpty()) {
|
||||
generateCardsInShop();
|
||||
}
|
||||
return q.shopList;
|
||||
}
|
||||
|
||||
}
|
||||
96
src/main/java/forge/quest/data/QuestUtilRewards.java
Normal file
96
src/main/java/forge/quest/data/QuestUtilRewards.java
Normal file
@@ -0,0 +1,96 @@
|
||||
package forge.quest.data;
|
||||
|
||||
import forge.MyRandom;
|
||||
import forge.game.GameLossReason;
|
||||
import forge.game.GamePlayerRating;
|
||||
import forge.game.GameSummary;
|
||||
import forge.game.PlayerIndex;
|
||||
|
||||
/**
|
||||
* Helper class to deal with rewards given in quest.
|
||||
*/
|
||||
public class QuestUtilRewards {
|
||||
private QuestData q;
|
||||
public QuestUtilRewards(final QuestData qd) { q = qd; }
|
||||
|
||||
public int getCreditsRewardForAltWin(final GameLossReason whyAiLost) {
|
||||
int rewardAltWinCondition = 0;
|
||||
switch (whyAiLost) {
|
||||
case LifeReachedZero: return 0; // nothing special here, ordinary kill
|
||||
case Milled: return QuestPreferences.getMatchRewardMilledWinBonus();
|
||||
case Poisoned: return QuestPreferences.getMatchRewardPoisonWinBonus();
|
||||
case DidNotLoseYet: return QuestPreferences.getMatchRewardAltWinBonus(); // felidar, helix pinnacle and like this
|
||||
case SpellEffect: return QuestPreferences.getMatchRewardAltWinBonus(); // Door to Nothingness or something like this
|
||||
default: // this .checkstyle forces us to write some idiotic code
|
||||
rewardAltWinCondition = 0;
|
||||
}
|
||||
return rewardAltWinCondition;
|
||||
}
|
||||
|
||||
public int getCreditsRewardForWinByTurn(final int iTurn) {
|
||||
if (iTurn == 1) { return QuestPreferences.getMatchRewardWinFirst();
|
||||
} else if (iTurn <= 5) { return QuestPreferences.getMatchRewardWinByFifth();
|
||||
} else if (iTurn <= 10) { return QuestPreferences.getMatchRewardWinByTen();
|
||||
} else if (iTurn <= 15) { return QuestPreferences.getMatchRewardWinByFifteen();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>getCreditsToAdd.</p>
|
||||
*
|
||||
* @param matchState a {@link forge.quest.data.QuestMatchState} object.
|
||||
* @return a long.
|
||||
*/
|
||||
public long getCreditsToAdd(final QuestMatchState matchState) {
|
||||
long creds = (long) (QuestPreferences.getMatchRewardBase()
|
||||
+ (QuestPreferences.getMatchRewardTotalWins() * q.getWin()));
|
||||
|
||||
boolean hasNeverLost = true;
|
||||
for (GameSummary game : matchState.getGamesPlayed()) {
|
||||
if (game.isAIWinner()) {
|
||||
hasNeverLost = true;
|
||||
continue; // no rewards for losing a game
|
||||
}
|
||||
|
||||
GamePlayerRating aiRating = game.getPlayerRating(PlayerIndex.AI);
|
||||
GamePlayerRating humanRating = game.getPlayerRating(PlayerIndex.HUMAN);
|
||||
GameLossReason whyAiLost = aiRating.getLossReason();
|
||||
|
||||
creds += getCreditsRewardForAltWin(whyAiLost);
|
||||
creds += getCreditsRewardForWinByTurn(game.getTurnGameEnded());
|
||||
|
||||
int cntCardsHumanStartedWith = humanRating.getOpeningHandSize();
|
||||
if (0 == cntCardsHumanStartedWith) {
|
||||
creds += QuestPreferences.getMatchMullToZero();
|
||||
}
|
||||
}
|
||||
|
||||
if (hasNeverLost) {
|
||||
creds += QuestPreferences.getMatchRewardNoLosses();
|
||||
}
|
||||
|
||||
switch(q.inventory.getItemLevel("Estates")) {
|
||||
case 1: creds *= 1.1; break;
|
||||
case 2: creds *= 1.15; break;
|
||||
case 3: creds *= 1.2; break;
|
||||
default: break;
|
||||
}
|
||||
|
||||
return creds;
|
||||
}
|
||||
|
||||
//add cards after a certain number of wins or losses
|
||||
public boolean willGiveBooster(final boolean didWin) {
|
||||
int cntOutcomes = didWin ? q.getWin() : q.getLost();
|
||||
return cntOutcomes % QuestPreferences.getWinsForBooster(q.getDifficultyIndex()) == 0;
|
||||
}
|
||||
|
||||
// this is a chance check, but used for random rare only by now
|
||||
public boolean getLuckyCoinResult() {
|
||||
boolean hasCoin = q.inventory.getItemLevel("Lucky Coin") >= 1;
|
||||
|
||||
return MyRandom.random.nextFloat() <= (hasCoin ? 0.65f : 0.5f);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,15 +1,16 @@
|
||||
package forge;
|
||||
package forge.quest.gui;
|
||||
|
||||
import forge.AllZone;
|
||||
import forge.error.ErrorViewer;
|
||||
import forge.gui.GuiUtils;
|
||||
import forge.quest.data.QuestData;
|
||||
import forge.quest.data.QuestDataIO;
|
||||
import forge.quest.gui.QuestFrame;
|
||||
import forge.quest.data.QuestPreferences;
|
||||
import forge.view.swing.OldGuiNewGame;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.border.Border;
|
||||
import javax.swing.border.TitledBorder;
|
||||
import java.awt.Color;
|
||||
import java.awt.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.WindowAdapter;
|
||||
@@ -21,11 +22,11 @@ import java.awt.event.WindowEvent;
|
||||
* @author Forge
|
||||
* @version $Id$
|
||||
*/
|
||||
public class Gui_QuestOptions extends JFrame {
|
||||
public class QuestOptions extends JFrame {
|
||||
/** Constant <code>serialVersionUID=2018518804206822235L</code> */
|
||||
private static final long serialVersionUID = 2018518804206822235L;
|
||||
|
||||
private forge.quest.data.QuestData questData = new forge.quest.data.QuestData();
|
||||
private QuestData questData = new QuestData();
|
||||
|
||||
private JLabel jLabel1 = new JLabel();
|
||||
private JButton continueQuestButton = new JButton();
|
||||
@@ -52,7 +53,7 @@ public class Gui_QuestOptions extends JFrame {
|
||||
/**
|
||||
* <p>Constructor for Gui_QuestOptions.</p>
|
||||
*/
|
||||
public Gui_QuestOptions() {
|
||||
public QuestOptions() {
|
||||
try {
|
||||
jbInit();
|
||||
} catch (Exception ex) {
|
||||
@@ -79,25 +80,29 @@ public class Gui_QuestOptions extends JFrame {
|
||||
this.addWindowListener(new WindowAdapter() {
|
||||
@Override
|
||||
public void windowClosing(WindowEvent ev) {
|
||||
Gui_QuestOptions.this.dispose();
|
||||
QuestOptions.this.dispose();
|
||||
new OldGuiNewGame();
|
||||
}
|
||||
});
|
||||
|
||||
//is there any saved data?
|
||||
if (!questData.hasSaveFile()) continueQuestButton.setEnabled(false);
|
||||
}//setup()
|
||||
} //setup()
|
||||
|
||||
//show total number of games for each difficulty
|
||||
/**
|
||||
* <p>setupRadioButtonText.</p>
|
||||
*/
|
||||
private void setupRadioButtonText() {
|
||||
String[] diff = questData.getDifficultyChoices();
|
||||
String[] diff = QuestPreferences.getDifficulty();
|
||||
JRadioButton[] b = {easyRadio, mediumRadio, hardRadio, veryHardRadio};
|
||||
|
||||
for (int i = 0; i < diff.length; i++) {
|
||||
b[i].setText(diff[i] + " - " + questData.getTotalNumberOfGames(i));
|
||||
//-2 because you start a level 1, and the last level is secret
|
||||
int numberLevels = QuestData.RANK_TITLES.length - 2;
|
||||
int numGames = numberLevels * QuestPreferences.getWinsForRankIncrease(i);
|
||||
|
||||
b[i].setText(String.format("%s - %d", diff[i], numGames));
|
||||
}
|
||||
|
||||
}//setupRadioButtonText()
|
||||
@@ -215,7 +220,7 @@ public class Gui_QuestOptions extends JFrame {
|
||||
void continueQuestButton_actionPerformed(ActionEvent e) {
|
||||
//set global variable
|
||||
AllZone.setQuestData(QuestDataIO.loadData());
|
||||
AllZone.getQuestData().setDifficultyIndex();
|
||||
AllZone.getQuestData().guessDifficultyIndex();
|
||||
dispose();
|
||||
|
||||
new QuestFrame();
|
||||
@@ -20,6 +20,7 @@ import forge.properties.ForgeProps;
|
||||
import forge.properties.NewConstants;
|
||||
import forge.properties.NewConstants.LANG.OldGuiNewGame.MENU_BAR.MENU;
|
||||
import forge.properties.NewConstants.LANG.OldGuiNewGame.MENU_BAR.OPTIONS;
|
||||
import forge.quest.gui.QuestOptions;
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
|
||||
import javax.swing.*;
|
||||
@@ -277,7 +278,7 @@ public class OldGuiNewGame extends JFrame implements NewConstants, NewConstants.
|
||||
// ActionListener
|
||||
OldGuiNewGame.this.dispose();
|
||||
|
||||
new Gui_QuestOptions();
|
||||
new QuestOptions();
|
||||
}
|
||||
});
|
||||
} // addListeners()
|
||||
|
||||
@@ -174,7 +174,11 @@ public abstract class Predicate<T> {
|
||||
return new Node<T>(operand1, operator, operand2);
|
||||
}
|
||||
// Predefined operators: and, or
|
||||
public static <T> Predicate<T> and(final Predicate<T> operand1, final Predicate<T> operand2) { return new NodeAnd<T>(operand1, operand2); }
|
||||
public static <T> Predicate<T> and(final Predicate<T> operand1, final Predicate<T> operand2) {
|
||||
if (operand1.is1()) { return operand2; }
|
||||
if (operand2.is1()) { return operand1; }
|
||||
return new NodeAnd<T>(operand1, operand2);
|
||||
}
|
||||
public static <T> Predicate<T> and(final Iterable<Predicate<T>> operand) { return new MultiNodeAnd<T>(operand); }
|
||||
public static <T, U> Predicate<T> and(final Predicate<T> operand1, final Predicate<U> operand2, Lambda1<U, T> bridge) { return new NodeAndBridged<T, U>(operand1, operand2, bridge); }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user