Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Huge cleanup of gui and desktop code
Index: forge-gui/src/main/java/forge/interfaces/IComponent.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>ISO-8859-1
===================================================================
--- forge-gui/src/main/java/forge/interfaces/IComponent.java (revision 29317)
+++ forge-gui/src/main/java/forge/interfaces/IComponent.java (revision 29317)
@@ -0,0 +1,8 @@
+package forge.interfaces;
+
+public interface IComponent {
+ boolean isEnabled();
+ void setEnabled(boolean b0);
+ boolean isVisible();
+ void setVisible(boolean b0);
+}
Index: forge-gui/src/main/java/forge/interfaces/ITextComponent.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>ISO-8859-1
===================================================================
--- forge-gui/src/main/java/forge/interfaces/ITextComponent.java (revision 29317)
+++ forge-gui/src/main/java/forge/interfaces/ITextComponent.java (revision 29317)
@@ -0,0 +1,6 @@
+package forge.interfaces;
+
+public interface ITextComponent extends IComponent {
+ String getText();
+ void setText(String text0);
+}
Index: forge-gui/src/main/java/forge/interfaces/ILobby.java
===================================================================
--- forge-gui/src/main/java/forge/interfaces/ILobby.java (revision 29316)
+++ forge-gui/src/main/java/forge/interfaces/ILobby.java (revision 29316)
@@ -1,10 +0,0 @@
-package forge.interfaces;
-
-import forge.match.GameLobby;
-import forge.net.server.RemoteClient;
-
-public interface ILobby {
- GameLobby getState();
- int login(RemoteClient client);
- void logout(RemoteClient client);
-}
Index: forge-gui-desktop/src/main/java/forge/gui/ForgeAction.java
===================================================================
--- forge-gui-desktop/src/main/java/forge/gui/ForgeAction.java (revision 29316)
+++ forge-gui-desktop/src/main/java/forge/gui/ForgeAction.java (revision 29316)
@@ -1,37 +0,0 @@
-/*
- * Forge: Play Magic: the Gathering.
- * Copyright (C) 2011 Forge Team
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-package forge.gui;
-
-import javax.swing.*;
-
-import forge.match.MatchConstants;
-
-@SuppressWarnings("serial")
-public abstract class ForgeAction extends AbstractAction {
- public ForgeAction(MatchConstants property) {
- super(property.button);
- this.putValue("buttonText", property.button);
- this.putValue("menuText", property.menu);
- }
-
- public <T extends AbstractButton> T setupButton(final T button) {
- button.setAction(this);
- button.setText((String) this.getValue(button instanceof JMenuItem ? "menuText" : "buttonText"));
- return button;
- }
-}
Index: forge-gui-desktop/src/main/java/forge/itemmanager/filters/DeckStatTypeFilter.java
===================================================================
--- forge-gui-desktop/src/main/java/forge/itemmanager/filters/DeckStatTypeFilter.java (revision 29316)
+++ forge-gui-desktop/src/main/java/forge/itemmanager/filters/DeckStatTypeFilter.java (revision 29316)
@@ -1,37 +0,0 @@
-package forge.itemmanager.filters;
-
-import com.google.common.base.Predicates;
-
-import forge.deck.DeckProxy;
-import forge.item.InventoryItem;
-import forge.item.PaperCard;
-import forge.itemmanager.ItemManager;
-import forge.itemmanager.SItemManagerUtil.StatTypes;
-import forge.toolbox.FLabel;
-import forge.util.ItemPool;
-
-import java.util.Map;
-
-public abstract class DeckStatTypeFilter extends StatTypeFilter<DeckProxy> {
- public DeckStatTypeFilter(ItemManager<? super DeckProxy> itemManager0) {
- super(itemManager0);
- }
-
- @Override
- protected <U extends InventoryItem> boolean showUnsupportedItem(U item) {
- return false;
- }
-
- @Override
- public void afterFiltersApplied() {
- final ItemPool<? super DeckProxy> items = itemManager.getFilteredItems();
-
- for (Map.Entry<StatTypes, FLabel> btn : buttonMap.entrySet()) {
- if (btn.getKey().predicate != null) {
- int count = items.countAll(DeckProxy.createPredicate(Predicates.compose(btn.getKey().predicate, PaperCard.FN_GET_RULES)), DeckProxy.class);
- btn.getValue().setText(String.valueOf(count));
- }
- }
- getWidget().revalidate();
- }
-}
Index: forge-gui-desktop/src/main/java/forge/view/arcane/ViewPanel.java
===================================================================
--- forge-gui-desktop/src/main/java/forge/view/arcane/ViewPanel.java (revision 29316)
+++ forge-gui-desktop/src/main/java/forge/view/arcane/ViewPanel.java (revision 29316)
@@ -1,88 +0,0 @@
-/*
- * Forge: Play Magic: the Gathering.
- * Copyright (C) 2011 Nate
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-package forge.view.arcane;
-
-import javax.swing.*;
-import java.awt.*;
-
-/**
- * <p>
- * ViewPanel class.
- * </p>
- *
- * @author Forge
- * @version $Id: ViewPanel.java 24769 2014-02-09 13:56:04Z Hellfish $
- */
-public class ViewPanel extends JPanel {
-
- /**
- * Instantiates a new view panel.
- */
- public ViewPanel() {
- }
-
- /** Constant <code>serialVersionUID=7016597023142963068L</code>. */
- private static final long serialVersionUID = 7016597023142963068L;
-
- /**
- * <p>
- * doLayout.
- * </p>
- *
- * @since 1.0.15
- */
- @Override
- public final void doLayout() {
- if (this.getComponentCount() == 0) {
- return;
- }
- final CardPanel panel = (CardPanel) this.getComponent(0);
- final int viewWidth = this.getWidth();
- final int viewHeight = this.getHeight();
- final int srcWidth = viewWidth;
- final int srcHeight = Math.round(viewWidth * CardPanel.ASPECT_RATIO);
- int targetWidth = Math.round(viewHeight * (srcWidth / (float) srcHeight));
- int targetHeight;
- if (targetWidth > viewWidth) {
- targetHeight = Math.round(viewWidth * (srcHeight / (float) srcWidth));
- targetWidth = viewWidth;
- } else {
- targetHeight = viewHeight;
- }
- final int x = (viewWidth / 2) - (targetWidth / 2);
- final int y = (viewHeight / 2) - (targetHeight / 2);
- panel.setCardBounds(x, y, targetWidth, targetHeight);
- }
-
- /**
- * <p>
- * setCardPanel.
- * </p>
- *
- * @param panel
- * a {@link forge.view.arcane.CardPanel} object.
- */
- public final void setCardPanel(final CardPanel panel) {
- // CardPanel newPanel = new CardPanel(panel.gameCard);
- // newPanel.setImage(panel);
- this.removeAll();
- this.add(panel, BorderLayout.CENTER);
- panel.revalidate();
- panel.repaint();
- }
-}
Index: forge-gui/src/main/java/forge/model/MultipleForgeJarsFoundError.java
===================================================================
--- forge-gui/src/main/java/forge/model/MultipleForgeJarsFoundError.java (revision 29316)
+++ forge-gui/src/main/java/forge/model/MultipleForgeJarsFoundError.java (revision 29316)
@@ -1,40 +0,0 @@
-/*
- * Forge: Play Magic: the Gathering.
- * Copyright (C) 2011 Forge Team
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-package forge.model;
-
-//import java.io.IOException;
-
-/**
- * Exception thrown by model when it is trying to find a single forge jar, but
- * it finds more than one.
- */
-public class MultipleForgeJarsFoundError extends RuntimeException {
- /** Automatically generated. */
- private static final long serialVersionUID = 8899307272033517172L;
-
- /**
- * Create an exception with a message.
- *
- * @param message
- * the message, which could be the System's class path.
- */
- public MultipleForgeJarsFoundError(final String message) {
- super(message);
- }
-
-}
Index: forge-gui-desktop/src/main/java/forge/toolbox/special/CardViewer.java
===================================================================
--- forge-gui-desktop/src/main/java/forge/toolbox/special/CardViewer.java (revision 29316)
+++ forge-gui-desktop/src/main/java/forge/toolbox/special/CardViewer.java (revision 29316)
@@ -1,93 +0,0 @@
-/*
- * Forge: Play Magic: the Gathering.
- * Copyright (C) 2011 Forge Team
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-package forge.toolbox.special;
-
-import java.util.Collections;
-import java.util.List;
-
-import javax.swing.AbstractListModel;
-import javax.swing.JList;
-import javax.swing.JPanel;
-import javax.swing.event.ListSelectionEvent;
-import javax.swing.event.ListSelectionListener;
-
-import forge.game.card.CardView;
-import forge.gui.CardDetailPanel;
-import forge.gui.CardPicturePanel;
-import forge.item.PaperCard;
-import forge.toolbox.FScrollPane;
-
-/**
- * A simple JPanel that shows three columns: card list, pic, and description..
- *
- * @author Forge
- * @version $Id: ListChooser.java 9708 2011-08-09 19:34:12Z jendave $
- */
-@SuppressWarnings("serial")
-public class CardViewer extends JPanel {
- // Data and number of choices for the list
- private final List<PaperCard> list;
-
- // initialized before; listeners may be added to it
- private JList<PaperCard> jList = null;
- private final CardDetailPanel detail;
- private final CardPicturePanel picture;
-
- public CardViewer(final List<PaperCard> list) {
- this.list = Collections.unmodifiableList(list);
- this.jList = new JList<PaperCard>(new ChooserListModel());
- this.detail = new CardDetailPanel();
- this.picture = new CardPicturePanel();
-
- this.add(new FScrollPane(this.jList, true));
- this.add(this.picture);
- this.add(this.detail);
- this.setLayout(new java.awt.GridLayout(1, 3, 6, 0));
-
- // selection is here
- this.jList.getSelectionModel().addListSelectionListener(new SelListener());
- this.jList.setSelectedIndex(0);
- }
-
- private class ChooserListModel extends AbstractListModel<PaperCard> {
- private static final long serialVersionUID = 3871965346333840556L;
-
- @Override
- public int getSize() {
- return CardViewer.this.list.size();
- }
-
- @Override
- public PaperCard getElementAt(final int index) {
- return CardViewer.this.list.get(index);
- }
- }
-
- private class SelListener implements ListSelectionListener {
- @Override
- public void valueChanged(final ListSelectionEvent e) {
- final int row = CardViewer.this.jList.getSelectedIndex();
- // (String) jList.getSelectedValue();
- if ((row >= 0) && (row < CardViewer.this.list.size())) {
- final PaperCard cp = CardViewer.this.list.get(row);
- CardViewer.this.detail.setCard(CardView.getCardForUi(cp));
- CardViewer.this.picture.setCard(cp);
- }
- }
- }
-}
Index: forge-gui/src/main/java/forge/properties/SavePreferencesListener.java
===================================================================
--- forge-gui/src/main/java/forge/properties/SavePreferencesListener.java (revision 29316)
+++ forge-gui/src/main/java/forge/properties/SavePreferencesListener.java (revision 29316)
@@ -1,35 +0,0 @@
-/*
- * Forge: Play Magic: the Gathering.
- * Copyright (C) 2011 Forge Team
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-package forge.properties;
-
-/**
- * <p>
- * SavePreferencesListener interface.
- * </p>
- *
- * @author Forge
- * @version $Id: SavePreferencesListener.java 12297 2011-11-28 19:56:47Z jendave $
- */
-public interface SavePreferencesListener {
- /**
- * <p>
- * savePreferences.
- * </p>
- */
- void savePreferences();
-}
Index: forge-gui/src/main/java/forge/net/GameProtocol.java
===================================================================
--- forge-gui/src/main/java/forge/net/GameProtocol.java (revision 29316)
+++ forge-gui/src/main/java/forge/net/GameProtocol.java (revision 29316)
@@ -1,181 +0,0 @@
-package forge.net;
-
-import java.lang.reflect.Array;
-import java.lang.reflect.Method;
-import java.util.Collection;
-import java.util.List;
-import java.util.Map;
-
-import com.google.common.base.Function;
-
-import forge.assets.FSkinProp;
-import forge.deck.CardPool;
-import forge.game.GameEntityView;
-import forge.game.GameView;
-import forge.game.card.CardView;
-import forge.game.phase.PhaseType;
-import forge.game.player.DelayedReveal;
-import forge.game.player.PlayerView;
-import forge.game.spellability.SpellAbilityView;
-import forge.interfaces.IGameController;
-import forge.interfaces.IGuiGame;
-import forge.match.NextGameDecision;
-import forge.trackable.TrackableCollection;
-import forge.util.ITriggerEvent;
-import forge.util.ReflectionUtil;
-
-public final class GameProtocol {
-
- /**
- * Private constructor to prevent instantiation.
- */
- private GameProtocol() {
- }
-
- public static ProtocolMethod getProtocolMethod(final String name) {
- return ProtocolMethod.valueOf(name);
- }
-
- private enum Mode {
- SERVER(IGuiGame.class),
- CLIENT(IGameController.class);
-
- private final Class<?> toInvoke;
- private Mode(final Class<?> toInvoke) {
- this.toInvoke = toInvoke;
- }
- };
-
- /**
- * The methods that can be sent through this protocol.
- */
- public enum ProtocolMethod {
- // Server -> Client
- setGameView (Mode.SERVER, Void.TYPE, GameView.class),
- openView (Mode.SERVER, Void.TYPE, TrackableCollection/*PlayerView*/.class),
- afterGameEnd (Mode.SERVER),
- showCombat (Mode.SERVER),
- showPromptMessage (Mode.SERVER, Void.TYPE, PlayerView.class, String.class),
- updateButtons (Mode.SERVER, Void.TYPE, PlayerView.class, String.class, String.class, Boolean.TYPE, Boolean.TYPE, Boolean.TYPE),
- flashIncorrectAction(Mode.SERVER),
- updatePhase (Mode.SERVER),
- updateTurn (Mode.SERVER, Void.TYPE, PlayerView.class),
- updatePlayerControl (Mode.SERVER),
- enableOverlay (Mode.SERVER),
- disableOverlay (Mode.SERVER),
- finishGame (Mode.SERVER),
- showManaPool (Mode.SERVER, Object.class, PlayerView.class),
- hideManaPool (Mode.SERVER, Void.TYPE, PlayerView.class),
- updateStack (Mode.SERVER),
- updateZones (Mode.SERVER, Void.TYPE, Iterable/*PlayerZoneUpdate*/.class),
- updateCards (Mode.SERVER, Void.TYPE, Iterable/*CardView*/.class),
- updateManaPool (Mode.SERVER, Void.TYPE, Iterable/*PlayerView*/.class),
- updateLives (Mode.SERVER, Void.TYPE, Iterable/*PlayerView*/.class),
- setPanelSelection (Mode.SERVER, Void.TYPE, CardView.class),
- getAbilityToPlay (Mode.SERVER, SpellAbilityView.class, CardView.class, List/*SpellAbilityView*/.class, ITriggerEvent.class),
- assignDamage (Mode.SERVER, Map.class, CardView.class, List/*CardView*/.class, Integer.TYPE, GameEntityView.class, Boolean.TYPE),
- message (Mode.SERVER, Void.TYPE, String.class, String.class),
- showErrorDialog (Mode.SERVER, Void.TYPE, String.class, String.class),
- showConfirmDialog (Mode.SERVER, Boolean.TYPE, String.class, String.class, String.class, String.class, Boolean.TYPE),
- showOptionDialog (Mode.SERVER, Integer.TYPE, String.class, String.class, FSkinProp.class, Array/*String*/.class, Integer.TYPE),
- showCardOptionDialog(Mode.SERVER, Integer.TYPE, CardView.class, String.class, String.class, FSkinProp.class, String.class, Array/*String*/.class),
- showInputDialog (Mode.SERVER, String.class, String.class, String.class, FSkinProp.class, String.class, Array/*String*/.class),
- confirm (Mode.SERVER, Boolean.TYPE, CardView.class, String.class, Boolean.TYPE, Array/*String*/.class),
- getChoices (Mode.SERVER, List.class, String.class, Integer.TYPE, Integer.TYPE, Collection.class, Object.class, Function.class),
- order (Mode.SERVER, List.class, String.class, String.class, Integer.TYPE, Integer.TYPE, List.class, List.class, CardView.class, Boolean.TYPE),
- sideboard (Mode.SERVER, List.class, CardPool.class, CardPool.class),
- chooseSingleEntityForEffect(Mode.SERVER, GameEntityView.class, String.class, TrackableCollection.class, DelayedReveal.class, Boolean.TYPE),
- setCard (Mode.SERVER, Void.TYPE, CardView.class),
- // TODO case "setPlayerAvatar":
- openZones (Mode.SERVER, Boolean.TYPE, Collection/*ZoneType*/.class, Map/*PlayerView,Object*/.class),
- restoreOldZones (Mode.SERVER, Void.TYPE, Map/*PlayerView,Object*/.class),
- isUiSetToSkipPhase (Mode.SERVER, Boolean.TYPE, PlayerView.class, PhaseType.class),
-
- // Client -> Server
- // Note: these should all return void, to avoid awkward situations in
- // which client and server wait for one another's response and block
- // the threads that're supposed to give that response
- useMana (Mode.CLIENT, Void.TYPE, Byte.TYPE),
- undoLastAction (Mode.CLIENT, Void.TYPE, Boolean.TYPE),
- selectPlayer (Mode.CLIENT, Void.TYPE, PlayerView.class, ITriggerEvent.class),
- selectCard (Mode.CLIENT, Void.TYPE, CardView.class, List.class, ITriggerEvent.class),
- selectButtonOk (Mode.CLIENT),
- selectButtonCancel (Mode.CLIENT),
- selectAbility (Mode.CLIENT, Void.TYPE, SpellAbilityView.class),
- passPriorityUntilEndOfTurn(Mode.CLIENT),
- passPriority (Mode.CLIENT),
- nextGameDecision (Mode.CLIENT, Void.TYPE, NextGameDecision.class),
- getActivateDescription (Mode.CLIENT, Void.TYPE, String.class, CardView.class),
- concede (Mode.CLIENT),
- alphaStrike (Mode.CLIENT),
- reorderHand (Mode.CLIENT, Void.TYPE, CardView.class, Integer.TYPE);
-
- private final Mode mode;
- private final Class<?> returnType;
- private final Class<?>[] args;
-
- private ProtocolMethod(final Mode mode) {
- this(mode, Void.TYPE);
- }
- private ProtocolMethod(final Mode mode, final Class<?> returnType) {
- this(mode, returnType, (Class<?>[]) null);
- }
- @SafeVarargs
- private ProtocolMethod(final Mode mode, final Class<?> returnType, final Class<?> ... args) {
- this.mode = mode;
- this.returnType = returnType;
- this.args = args == null ? new Class<?>[] {} : args;
- }
-
- public Method getMethod() {
- try {
- final Class<?> toCall = mode.toInvoke;
- final Method candidate = toCall.getMethod(name(), args);
- // Don't check Client return values for now as some use void
- // and a default return value, to improve performance
- if (mode == Mode.SERVER && !candidate.getReturnType().equals(returnType)) {
- throw new NoSuchMethodException(String.format("Wrong return type for method %s", name()));
- }
- return candidate;
- } catch (final NoSuchMethodException | SecurityException e) {
- System.err.println(String.format("Warning: class contains no accessible method named %s", name()));
- return getMethodNoArgs();
- }
- }
-
- private Method getMethodNoArgs() {
- try {
- return mode.toInvoke.getMethod(name(), (Class<?>[]) null);
- } catch (final NoSuchMethodException | SecurityException e) {
- System.err.println(String.format("Warning: class contains no accessible arg-less method named %s", name()));
- return null;
- }
- }
- public Class<?> getReturnType() {
- return returnType;
- }
- public Class<?>[] getArgTypes() {
- return args;
- }
-
- public void checkArgs(final Object[] args) {
- for (int iArg = 0; iArg < args.length; iArg++) {
- final Object arg = args[iArg];
- final Class<?> type = this.args[iArg];
- if (!ReflectionUtil.isInstance(arg, type)) {
- throw new InternalError(String.format("Protocol method %s: illegal argument (%d) of type %s, %s expected", name(), iArg, arg.getClass().getName(), type.getName()));
- }
- }
- }
-
- public void checkReturnValue(final Object value) {
- if (returnType.equals(Void.TYPE)) {
- // If void is expected, any return value is fine
- return;
- }
- if (!ReflectionUtil.isInstance(value, returnType)) {
- throw new IllegalStateException(String.format("Protocol method %s: illegal return object type %s returned by client, expected %s", name(), value.getClass().getName(), getReturnType().getName()));
- }
- }
- }
-}
Index: forge-gui/src/main/java/forge/match/MatchButtonType.java
===================================================================
--- forge-gui/src/main/java/forge/match/MatchButtonType.java (revision 29316)
+++ forge-gui/src/main/java/forge/match/MatchButtonType.java (revision 29316)
@@ -1,6 +0,0 @@
-package forge.match;
-
-public enum MatchButtonType {
- OK,
- CANCEL;
-}
Index: forge-gui-desktop/src/main/java/forge/screens/home/EMenuItem.java
===================================================================
--- forge-gui-desktop/src/main/java/forge/screens/home/EMenuItem.java (revision 29316)
+++ forge-gui-desktop/src/main/java/forge/screens/home/EMenuItem.java (revision 29316)
@@ -1,27 +0,0 @@
-package forge.screens.home;
-
-/**
- * These are the identifiers for topics found in home screen submenus.
- *
- * <br><br><i>(E at beginning of class name denotes an enum.)</i>
- *
- */
-public enum EMenuItem { /** */
- CONSTRUCTED, /** */
- LIMITED_DRAFT, /** */
- LIMITED_SEALED, /** */
- LIMITED_WINSTON,
-
- QUEST_CHALLENGES, /** */
- QUEST_DUELS, /** */
- QUEST_DATA, /** */
- QUEST_DECKS, /** */
- QUEST_PREFS, /** */
-
- SETTINGS_PREFS, /** */
- SETTINGS_AVATARS, /** */
-
- UTILITIES_EDITOR, /** */
- UTILITIES_DOWNLOADS, /** */
- UTILITIES_EXIT
-}
Index: forge-gui-desktop/src/main/java/forge/gui/framework/IDocIdList.java
===================================================================
--- forge-gui-desktop/src/main/java/forge/gui/framework/IDocIdList.java (revision 29316)
+++ forge-gui-desktop/src/main/java/forge/gui/framework/IDocIdList.java (revision 29316)
@@ -1,12 +0,0 @@
-/**
- *
- */
-package forge.gui.framework;
-
-/**
- * This interface provides a unifying type to all enums
- * used as tab identifiers in XML and card layouts.
- *
- * <br><br><i>(I at beginning of class name denotes an interface.)</i>
- */
-public interface IDocIdList { }
Index: forge-gui-desktop/src/main/java/forge/screens/home/quest/QuestPreferencesHandler.java
===================================================================
--- forge-gui-desktop/src/main/java/forge/screens/home/quest/QuestPreferencesHandler.java (revision 29316)
+++ forge-gui-desktop/src/main/java/forge/screens/home/quest/QuestPreferencesHandler.java (revision 29316)
@@ -1,394 +0,0 @@
-package forge.screens.home.quest;
-
-import forge.assets.FSkinProp;
-import forge.model.FModel;
-import forge.quest.data.QuestPreferences;
-import forge.quest.data.QuestPreferences.QPref;
-import forge.toolbox.FLabel;
-import forge.toolbox.FSkin;
-import forge.toolbox.FSkin.SkinnedPanel;
-import forge.toolbox.FSkin.SkinnedTextField;
-import net.miginfocom.swing.MigLayout;
-
-import javax.swing.*;
-import javax.swing.border.Border;
-
-import java.awt.*;
-import java.awt.event.FocusAdapter;
-import java.awt.event.FocusEvent;
-import java.awt.event.MouseAdapter;
-import java.awt.event.MouseEvent;
-
-
-@SuppressWarnings("serial")
-public class QuestPreferencesHandler extends SkinnedPanel {
- private final QuestPreferences prefs;
- private final JPanel pnlDifficulty, pnlBooster, pnlRewards, pnlShop;
- private final FLabel lblErrRewards, lblErrBooster, lblErrDifficulty, lblErrShop;
- private String constraints1, constraints2;
-
- private enum ErrType {
- REWARDS,
- DIFFICULTY,
- BOOSTER,
- SHOP
- }
-
- /** */
- public QuestPreferencesHandler() {
- this.setOpaque(false);
- this.setLayout(new MigLayout("insets 0, gap 0, wrap"));
- this.prefs = FModel.getQuestPreferences();
-
- pnlRewards = new JPanel();
- pnlDifficulty = new JPanel();
- pnlBooster = new JPanel();
- pnlShop = new JPanel();
-
- lblErrRewards = new FLabel.Builder().text("Rewards Error").fontStyle(Font.BOLD).build();
- lblErrDifficulty = new FLabel.Builder().text("Difficulty Error").fontStyle(Font.BOLD).build();
- lblErrBooster = new FLabel.Builder().text("Booster Error").fontStyle(Font.BOLD).build();
- lblErrShop = new FLabel.Builder().text("Shop Error").fontStyle(Font.BOLD).build();
-
- lblErrRewards.setForeground(Color.red);
- lblErrDifficulty.setForeground(Color.red);
- lblErrBooster.setForeground(Color.red);
- lblErrShop.setForeground(Color.red);
-
- // Rewards panel
- pnlRewards.setOpaque(false);
- pnlRewards.setLayout(new MigLayout("insets 0, gap 0, wrap 2"));
-
- pnlRewards.add(new FLabel.Builder().text("Rewards")
- .icon(FSkin.getImage(FSkinProp.ICO_QUEST_COIN)).build(),
- "w 100%!, h 30px!, span 2 1");
- pnlRewards.add(lblErrRewards, "w 100%!, h 30px!, span 2 1");
-
- constraints1 = "w 60px, h 26px!";
- constraints2 = "w 150px!, h 26px!";
-
- pnlRewards.add(new FLabel.Builder().text("Base winnings").build(), constraints2);
- pnlRewards.add(new PrefInput(QPref.REWARDS_BASE, ErrType.REWARDS), constraints1);
-
- pnlRewards.add(new FLabel.Builder().text("No losses").build(), constraints2);
- pnlRewards.add(new PrefInput(QPref.REWARDS_UNDEFEATED, ErrType.REWARDS), constraints1);
-
- pnlRewards.add(new FLabel.Builder().text("Poison win").build(), constraints2);
- pnlRewards.add(new PrefInput(QPref.REWARDS_POISON, ErrType.REWARDS), constraints1);
-
- pnlRewards.add(new FLabel.Builder().text("Milling win").build(), constraints2);
- pnlRewards.add(new PrefInput(QPref.REWARDS_MILLED, ErrType.REWARDS), constraints1);
-
- pnlRewards.add(new FLabel.Builder().text("Mulligan 0 win").build(), constraints2);
- pnlRewards.add(new PrefInput(QPref.REWARDS_MULLIGAN0, ErrType.REWARDS), constraints1);
-
- pnlRewards.add(new FLabel.Builder().text("Alternative win").build(), constraints2);
- pnlRewards.add(new PrefInput(QPref.REWARDS_ALTERNATIVE, ErrType.REWARDS), constraints1);
-
- pnlRewards.add(new FLabel.Builder().text("Win by turn 15").build(), constraints2);
- pnlRewards.add(new PrefInput(QPref.REWARDS_TURN15, ErrType.REWARDS), constraints1);
-
- pnlRewards.add(new FLabel.Builder().text("Win by turn 10").build(), constraints2);
- pnlRewards.add(new PrefInput(QPref.REWARDS_TURN10, ErrType.REWARDS), constraints1);
-
- pnlRewards.add(new FLabel.Builder().text("Win by turn 5").build(), constraints2);
- pnlRewards.add(new PrefInput(QPref.REWARDS_TURN5, ErrType.REWARDS), constraints1);
-
- pnlRewards.add(new FLabel.Builder().text("First turn win").build(), constraints2);
- pnlRewards.add(new PrefInput(QPref.REWARDS_TURN1, ErrType.REWARDS), constraints1);
-
- // Difficulty table panel
- pnlDifficulty.setOpaque(false);
- pnlDifficulty.setLayout(new MigLayout("insets 0, gap 0, wrap 5"));
-
- pnlDifficulty.add(new FLabel.Builder().text("Difficulty Adjustments").icon(FSkin.getImage(FSkinProp.ICO_QUEST_NOTES)).build(), "w 100%!, h 30px!, span 5 1");
- pnlDifficulty.add(lblErrDifficulty, "w 100%!, h 30px!, span 5 1");
-
- constraints1 = "w 60px!, h 26px!";
- constraints2 = "w 150px!, h 26px!";
-
- pnlDifficulty.add(new FLabel.Builder().text("").build(), constraints2);
- pnlDifficulty.add(new FLabel.Builder().text("Easy").build(), constraints1);
- pnlDifficulty.add(new FLabel.Builder().text("Medium").build(), constraints1);
- pnlDifficulty.add(new FLabel.Builder().text("Hard").build(), constraints1);
- pnlDifficulty.add(new FLabel.Builder().text("Expert").build(), constraints1);
-
- pnlDifficulty.add(new FLabel.Builder().text("Wins For Booster").build(), constraints2);
- pnlDifficulty.add(new PrefInput(QPref.WINS_BOOSTER_EASY, ErrType.DIFFICULTY), constraints1);
- pnlDifficulty.add(new PrefInput(QPref.WINS_BOOSTER_MEDIUM, ErrType.DIFFICULTY), constraints1);
- pnlDifficulty.add(new PrefInput(QPref.WINS_BOOSTER_HARD, ErrType.DIFFICULTY), constraints1);
- pnlDifficulty.add(new PrefInput(QPref.WINS_BOOSTER_EXPERT, ErrType.DIFFICULTY), constraints1);
-
- pnlDifficulty.add(new FLabel.Builder().text("Wins For Rank Increase").build(), constraints2);
- pnlDifficulty.add(new PrefInput(QPref.WINS_RANKUP_EASY, ErrType.DIFFICULTY), constraints1);
- pnlDifficulty.add(new PrefInput(QPref.WINS_RANKUP_MEDIUM, ErrType.DIFFICULTY), constraints1);
- pnlDifficulty.add(new PrefInput(QPref.WINS_RANKUP_HARD, ErrType.DIFFICULTY), constraints1);
- pnlDifficulty.add(new PrefInput(QPref.WINS_RANKUP_EXPERT, ErrType.DIFFICULTY), constraints1);
-
- pnlDifficulty.add(new FLabel.Builder().text("Wins For Medium AI").build(), constraints2);
- pnlDifficulty.add(new PrefInput(QPref.WINS_MEDIUMAI_EASY, ErrType.DIFFICULTY), constraints1);
- pnlDifficulty.add(new PrefInput(QPref.WINS_MEDIUMAI_MEDIUM, ErrType.DIFFICULTY), constraints1);
- pnlDifficulty.add(new PrefInput(QPref.WINS_MEDIUMAI_HARD, ErrType.DIFFICULTY), constraints1);
- pnlDifficulty.add(new PrefInput(QPref.WINS_MEDIUMAI_EXPERT, ErrType.DIFFICULTY), constraints1);
-
- pnlDifficulty.add(new FLabel.Builder().text("Wins For Hard AI").build(), constraints2);
- pnlDifficulty.add(new PrefInput(QPref.WINS_HARDAI_EASY, ErrType.DIFFICULTY), constraints1);
- pnlDifficulty.add(new PrefInput(QPref.WINS_HARDAI_MEDIUM, ErrType.DIFFICULTY), constraints1);
- pnlDifficulty.add(new PrefInput(QPref.WINS_HARDAI_HARD, ErrType.DIFFICULTY), constraints1);
- pnlDifficulty.add(new PrefInput(QPref.WINS_HARDAI_EXPERT, ErrType.DIFFICULTY), constraints1);
-
- pnlDifficulty.add(new FLabel.Builder().text("Wins For Expert AI").build(), constraints2);
- pnlDifficulty.add(new PrefInput(QPref.WINS_EXPERTAI_EASY, ErrType.DIFFICULTY), constraints1);
- pnlDifficulty.add(new PrefInput(QPref.WINS_EXPERTAI_MEDIUM, ErrType.DIFFICULTY), constraints1);
- pnlDifficulty.add(new PrefInput(QPref.WINS_EXPERTAI_HARD, ErrType.DIFFICULTY), constraints1);
- pnlDifficulty.add(new PrefInput(QPref.WINS_EXPERTAI_EXPERT, ErrType.DIFFICULTY), constraints1);
-
- pnlDifficulty.add(new FLabel.Builder().text("Starting commons").build(), constraints2);
- pnlDifficulty.add(new PrefInput(QPref.STARTING_COMMONS_EASY, ErrType.DIFFICULTY), constraints1);
- pnlDifficulty.add(new PrefInput(QPref.STARTING_COMMONS_MEDIUM, ErrType.DIFFICULTY), constraints1);
- pnlDifficulty.add(new PrefInput(QPref.STARTING_COMMONS_HARD, ErrType.DIFFICULTY), constraints1);
- pnlDifficulty.add(new PrefInput(QPref.STARTING_COMMONS_EXPERT, ErrType.DIFFICULTY), constraints1);
-
- pnlDifficulty.add(new FLabel.Builder().text("Starting uncommons").build(), constraints2);
- pnlDifficulty.add(new PrefInput(QPref.STARTING_UNCOMMONS_EASY, ErrType.DIFFICULTY), constraints1);
- pnlDifficulty.add(new PrefInput(QPref.STARTING_UNCOMMONS_MEDIUM, ErrType.DIFFICULTY), constraints1);
- pnlDifficulty.add(new PrefInput(QPref.STARTING_UNCOMMONS_HARD, ErrType.DIFFICULTY), constraints1);
- pnlDifficulty.add(new PrefInput(QPref.STARTING_UNCOMMONS_EXPERT, ErrType.DIFFICULTY), constraints1);
-
- pnlDifficulty.add(new FLabel.Builder().text("Starting rares").build(), constraints2);
- pnlDifficulty.add(new PrefInput(QPref.STARTING_RARES_EASY, ErrType.DIFFICULTY), constraints1);
- pnlDifficulty.add(new PrefInput(QPref.STARTING_RARES_MEDIUM, ErrType.DIFFICULTY), constraints1);
- pnlDifficulty.add(new PrefInput(QPref.STARTING_RARES_HARD, ErrType.DIFFICULTY), constraints1);
- pnlDifficulty.add(new PrefInput(QPref.STARTING_RARES_EXPERT, ErrType.DIFFICULTY), constraints1);
-
- pnlDifficulty.add(new FLabel.Builder().text("Starting credits").build(), constraints2);
- pnlDifficulty.add(new PrefInput(QPref.STARTING_CREDITS_EASY, ErrType.DIFFICULTY), constraints1);
- pnlDifficulty.add(new PrefInput(QPref.STARTING_CREDITS_MEDIUM, ErrType.DIFFICULTY), constraints1);
- pnlDifficulty.add(new PrefInput(QPref.STARTING_CREDITS_HARD, ErrType.DIFFICULTY), constraints1);
- pnlDifficulty.add(new PrefInput(QPref.STARTING_CREDITS_EXPERT, ErrType.DIFFICULTY), constraints1);
-
- pnlDifficulty.add(new FLabel.Builder().text("Starting basic lands").build(), constraints2);
- pnlDifficulty.add(new PrefInput(QPref.STARTING_BASIC_LANDS, ErrType.DIFFICULTY), constraints1 + ", wrap");
-
- pnlDifficulty.add(new FLabel.Builder().text("Starting snow lands").build(), constraints2);
- pnlDifficulty.add(new PrefInput(QPref.STARTING_SNOW_LANDS, ErrType.DIFFICULTY), constraints1 + ", wrap");
-
- pnlDifficulty.add(new FLabel.Builder().text("Color bias (1-10)").build(), constraints2);
- pnlDifficulty.add(new PrefInput(QPref.STARTING_POOL_COLOR_BIAS, ErrType.DIFFICULTY), constraints1 + ", wrap");
-
- pnlDifficulty.add(new FLabel.Builder().text("Penalty for loss").build(), constraints2);
- pnlDifficulty.add(new PrefInput(QPref.PENALTY_LOSS, ErrType.DIFFICULTY), constraints1 + ", wrap");
-
- // Booster breakdown panel
- pnlBooster.setOpaque(false);
- pnlBooster.setLayout(new MigLayout("insets 0, gap 0, wrap 2"));
-
- pnlBooster.add(new FLabel.Builder().text("Booster Pack Ratios")
- .icon(FSkin.getImage(FSkinProp.ICO_QUEST_BOOK)).build(),
- "w 100%!, h 30px!, span 2 1");
- pnlBooster.add(lblErrBooster, "w 100%!, h 30px!, span 2 1");
-
- constraints1 = "w 60px!, h 26px!";
- constraints2 = "w 150px!, h 26px!";
- pnlBooster.add(new FLabel.Builder().text("Common").build(), constraints2);
- pnlBooster.add(new PrefInput(QPref.BOOSTER_COMMONS, ErrType.BOOSTER), constraints1);
-
- pnlBooster.add(new FLabel.Builder().text("Uncommon").build(), constraints2);
- pnlBooster.add(new PrefInput(QPref.BOOSTER_UNCOMMONS, ErrType.BOOSTER), constraints1);
-
- pnlBooster.add(new FLabel.Builder().text("Rare").build(), constraints2);
- pnlBooster.add(new PrefInput(QPref.BOOSTER_RARES, ErrType.BOOSTER), constraints1);
-
- // Shop panel
- pnlShop.setOpaque(false);
- pnlShop.setLayout(new MigLayout("insets 0, gap 0, wrap 2"));
-
- pnlShop.add(new FLabel.Builder().text("Shop Preferences")
- .icon(FSkin.getImage(FSkinProp.ICO_QUEST_COIN)).build(), "w 100%!, h 30px!, span 2 1");
- pnlShop.add(lblErrShop, "w 100%!, h 30px!, span 2 1");
-
- constraints1 = "w 60px, h 26px!";
- constraints2 = "w 150px!, h 26px!";
-
- pnlShop.add(new FLabel.Builder().text("Maximum Packs").build(), constraints2);
- pnlShop.add(new PrefInput(QPref.SHOP_MAX_PACKS, ErrType.SHOP), constraints1);
-
- pnlShop.add(new FLabel.Builder().text("Minimum Packs").build(), constraints2);
- pnlShop.add(new PrefInput(QPref.SHOP_MIN_PACKS, ErrType.SHOP), constraints1);
-
- pnlShop.add(new FLabel.Builder().text("Starting Packs").build(), constraints2);
- pnlShop.add(new PrefInput(QPref.SHOP_STARTING_PACKS, ErrType.SHOP), constraints1);
-
- pnlShop.add(new FLabel.Builder().text("Wins for Pack").build(), constraints2);
- pnlShop.add(new PrefInput(QPref.SHOP_WINS_FOR_ADDITIONAL_PACK, ErrType.SHOP), constraints1);
-
- pnlShop.add(new FLabel.Builder().text("Wins per Set Unlock").build(), constraints2);
- pnlShop.add(new PrefInput(QPref.WINS_UNLOCK_SET, ErrType.SHOP), constraints1);
-
- pnlShop.add(new FLabel.Builder().text("Common Singles").build(), constraints2);
- pnlShop.add(new PrefInput(QPref.SHOP_SINGLES_COMMON, ErrType.SHOP), constraints1);
-
- pnlShop.add(new FLabel.Builder().text("Uncommon Singles").build(), constraints2);
- pnlShop.add(new PrefInput(QPref.SHOP_SINGLES_UNCOMMON, ErrType.SHOP), constraints1);
-
- pnlShop.add(new FLabel.Builder().text("Rare Singles").build(), constraints2);
- pnlShop.add(new PrefInput(QPref.SHOP_SINGLES_RARE, ErrType.SHOP), constraints1);
-
- pnlShop.add(new FLabel.Builder().text("Card Sale Price Cap").build(), constraints2);
- pnlShop.add(new PrefInput(QPref.SHOP_MAX_SELLING_PRICE, ErrType.SHOP), constraints1);
-
- pnlShop.add(new FLabel.Builder().text("Wins to Uncap Sale Price").build(), constraints2);
- pnlShop.add(new PrefInput(QPref.SHOP_WINS_FOR_NO_SELL_LIMIT, ErrType.SHOP), constraints1);
-
- pnlShop.add(new FLabel.Builder().text("Item Level Restriction").build(), constraints2);
- pnlShop.add(new PrefInput(QPref.ITEM_LEVEL_RESTRICTION, ErrType.SHOP), constraints1);
-
- constraints1 = "w 100%!, gap 0 0 20px 0";
- this.add(pnlRewards, constraints1);
- this.add(pnlDifficulty, constraints1);
- this.add(pnlBooster, constraints1);
- this.add(pnlShop, constraints1);
-
- resetErrors();
- }
-
- private class PrefInput extends SkinnedTextField {
- private final QPref qpref;
- private final ErrType err;
- private final FSkin.SkinColor clrHover, clrActive, clrText;
- private boolean isFocus = false;
- private String previousText = "";
-
- /**
- * @param qp1 &emsp; {@link forge.quest.data.QuestPreferences.QPref}
- * preferences ident enum
- * @param e0 &emsp; {@link forge.view.home.ViewQuestPreference.ErrType}
- * where error should display to
- */
- public PrefInput(QPref qp0, ErrType e0) {
- super();
-
- this.qpref = qp0;
- this.err = e0;
- this.clrHover = FSkin.getColor(FSkin.Colors.CLR_HOVER);
- this.clrActive = FSkin.getColor(FSkin.Colors.CLR_ACTIVE);
- this.clrText = FSkin.getColor(FSkin.Colors.CLR_TEXT);
-
- this.setOpaque(false);
- this.setBorder((Border)null);
- this.setFont(FSkin.getFont(13));
- this.setForeground(clrText);
- this.setCaretColor(clrText);
- this.setBackground(clrHover);
- this.setHorizontalAlignment(SwingConstants.CENTER);
- this.setText(prefs.getPref(qpref));
- this.setPreviousText(prefs.getPref(qpref));
-
- this.addMouseListener(new MouseAdapter() {
- @Override
- public void mouseEntered(MouseEvent e) {
- if (isFocus) { return; }
- setOpaque(true);
- repaint();
- }
-
- @Override
- public void mouseExited(MouseEvent e) {
- if (isFocus) { return; }
- setOpaque(false);
- repaint();
- }
- });
-
- this.addFocusListener(new FocusAdapter() {
- @Override
- public void focusGained(FocusEvent e) {
- isFocus = true;
- setOpaque(true);
- setBackground(clrActive);
- }
-
- @Override
- public void focusLost(FocusEvent e) {
- isFocus = false;
- setOpaque(false);
- setBackground(clrHover);
-
- // TODO for slight performance improvement
- // check if value has changed before validating
- validateAndSave(PrefInput.this);
- }
- });
- }
-
- public QPref getQPref() {
- return this.qpref;
- }
-
- public ErrType getErrType() {
- return this.err;
- }
-
- public String getPreviousText() {
- return this.previousText;
- }
-
- public void setPreviousText(String s0) {
- this.previousText = s0;
- }
- }
-
-
- /**
- * Checks validity of values entered into prefInputs.
- * @param i0 &emsp; a PrefInput object
- */
- private void validateAndSave(PrefInput i0) {
- if (i0.getText().equals(i0.getPreviousText())) { return; }
-
- int val = Integer.parseInt(i0.getText());
- resetErrors();
-
- String validationError = prefs.validatePreference(i0.getQPref(), val);
- if (validationError != null) {
- showError(i0, validationError);
- return;
- }
-
- prefs.setPref(i0.getQPref(), i0.getText());
- prefs.save();
- i0.setPreviousText(i0.getText());
- }
-
- private void showError(PrefInput i0, String s0) {
- String s = "Save failed: " + s0;
- switch(i0.getErrType()) {
- case BOOSTER:
- lblErrBooster.setVisible(true);
- lblErrBooster.setText(s);
- break;
- case DIFFICULTY:
- lblErrDifficulty.setVisible(true);
- lblErrDifficulty.setText(s);
- break;
- case REWARDS:
- lblErrRewards.setVisible(true);
- lblErrRewards.setText(s);
- break;
- case SHOP:
- lblErrShop.setVisible(true);
- lblErrShop.setText(s);
- break;
- default:
- }
-
- i0.setText(i0.getPreviousText());
- }
-
- private void resetErrors() {
- lblErrBooster.setVisible(false);
- lblErrDifficulty.setVisible(false);
- lblErrRewards.setVisible(false);
- lblErrShop.setVisible(false);
- }
-}
Index: forge-gui/src/main/java/forge/deck/io/OldDeckParser.java
===================================================================
--- forge-gui/src/main/java/forge/deck/io/OldDeckParser.java (revision 29316)
+++ forge-gui/src/main/java/forge/deck/io/OldDeckParser.java (revision 29316)
@@ -1,263 +0,0 @@
-/*
- * Forge: Play Magic: the Gathering.
- * Copyright (C) 2011 Forge Team
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-package forge.deck.io;
-
-import forge.deck.Deck;
-import forge.deck.DeckGroup;
-import forge.properties.ForgeConstants;
-import forge.util.FileSection;
-import forge.util.FileUtil;
-import forge.util.gui.SOptionPane;
-import forge.util.storage.IStorage;
-
-import org.apache.commons.lang3.tuple.ImmutablePair;
-import org.apache.commons.lang3.tuple.MutablePair;
-import org.apache.commons.lang3.tuple.Pair;
-
-import java.io.File;
-import java.io.FilenameFilter;
-import java.util.List;
-import java.util.Map;
-import java.util.NoSuchElementException;
-import java.util.TreeMap;
-
-
-public class OldDeckParser {
-
- /** Constant <code>BDKFileFilter</code>. */
- public static final FilenameFilter BDK_FILE_FILTER = new FilenameFilter() {
- @Override
- public boolean accept(final File dir, final String name) {
- return name.endsWith(".bdk");
- }
- };
-
- public OldDeckParser(final IStorage<Deck> constructed2, final IStorage<DeckGroup> draft2,
- final IStorage<DeckGroup> sealed2, final IStorage<Deck> cube2) {
- this.deckDir = new File(ForgeConstants.DECK_BASE_DIR);
- this.sealed = sealed2;
- this.constructed = constructed2;
- this.cube = cube2;
- this.draft = draft2;
- }
-
- /**
- * Gets the sealed.
- *
- * @return the sealed
- */
- protected final IStorage<DeckGroup> getSealed() {
- return this.sealed;
- }
-
- /**
- * Gets the constructed.
- *
- * @return the constructed
- */
- protected final IStorage<Deck> getConstructed() {
- return this.constructed;
- }
-
- /**
- * Gets the draft.
- *
- * @return the draft
- */
- protected final IStorage<DeckGroup> getDraft() {
- return this.draft;
- }
-
- /**
- * Gets the cube.
- *
- * @return the cube
- */
- protected final IStorage<Deck> getCube() {
- return this.cube;
- }
-
- /**
- * Gets the deck dir.
- *
- * @return the deck dir
- */
- protected final File getDeckDir() {
- return this.deckDir;
- }
-
- private final IStorage<DeckGroup> sealed;
- private final IStorage<Deck> constructed;
- private final IStorage<DeckGroup> draft;
- private final IStorage<Deck> cube;
- private final File deckDir;
-
- /**
- * TODO: Write javadoc for this method.
- */
- public void tryParse() {
- this.convertConstructedAndSealed();
- this.convertDrafts();
- }
-
- private void convertDrafts() {
- for (final File f : this.deckDir.listFiles(OldDeckParser.BDK_FILE_FILTER)) {
- boolean gotError = false;
- final Deck human = DeckSerializer.fromFile(new File(f, "0.dck"));
- final DeckGroup d = new DeckGroup(human.getName());
- d.setHumanDeck(human);
-
- for (int i = 1; i < DeckGroupSerializer.MAX_DRAFT_PLAYERS; i++) {
- final Deck nextAi = DeckSerializer.fromFile(new File(f, i + ".dck"));
- if (nextAi == null) {
- gotError = true;
- break;
- }
- d.addAiDeck(nextAi);
- }
-
- boolean mayDelete = !gotError;
- if (!gotError) {
- this.draft.add(d);
- } else {
- final String msg = String.format("Draft '%s' lacked some decks.%n%nShould it be deleted?");
- mayDelete = SOptionPane.showConfirmDialog(msg, "Draft loading error");
- }
-
- if (mayDelete) {
- for (final File f1 : f.listFiles()) {
- f1.delete();
- }
- f.delete();
- }
-
- }
- }
-
- private void convertConstructedAndSealed() {
- boolean allowDeleteUnsupportedConstructed = false;
- final Map<String, Pair<DeckGroup, MutablePair<File, File>>> sealedDecks = new TreeMap<String, Pair<DeckGroup, MutablePair<File, File>>>(
- String.CASE_INSENSITIVE_ORDER);
-
- for (final File f : this.deckDir.listFiles(DeckStorage.DCK_FILE_FILTER)) {
- boolean importedOk = false;
-
- final List<String> fileLines = FileUtil.readFile(f);
- final Map<String, List<String>> sections = FileSection.parseSections(fileLines);
- final DeckFileHeader dh = DeckSerializer.readDeckMetadata(sections);
- String name = dh.getName();
-
- if (dh.isCustomPool()) {
- try {
- this.cube.add(DeckSerializer.fromSections(sections));
- importedOk = true;
- }
- catch (final NoSuchElementException ex) {
- if (!allowDeleteUnsupportedConstructed) {
- final String msg = String
- .format("Can not convert deck '%s' for some unsupported cards it contains. %n%s%n%nMay Forge delete all such decks?",
- name, ex.getMessage());
- allowDeleteUnsupportedConstructed = SOptionPane.showConfirmDialog(msg, "Problem converting decks");
- }
- }
- if (importedOk || allowDeleteUnsupportedConstructed) {
- f.delete();
- }
- continue;
- }
-
- switch (dh.getDeckType()) {
- case Constructed:
- try {
- this.constructed.add(DeckSerializer.fromSections(sections));
- importedOk = true;
- } catch (final NoSuchElementException ex) {
- if (!allowDeleteUnsupportedConstructed) {
- final String msg = String
- .format("Can not convert deck '%s' for some unsupported cards it contains. %n%s%n%nMay Forge delete all such decks?",
- name, ex.getMessage());
- allowDeleteUnsupportedConstructed = SOptionPane.showConfirmDialog(msg, "Problem converting decks");
- }
- }
- if (importedOk || allowDeleteUnsupportedConstructed) {
- f.delete();
- }
- break;
-
- case Limited:
- name = name.startsWith("AI_") ? name.replace("AI_", "") : name;
-
- Pair<DeckGroup, MutablePair<File, File>> stored = sealedDecks.get(name);
- if (null == stored) {
- stored = ImmutablePair.of(new DeckGroup(name), MutablePair.of((File) null, (File) null));
- }
-
- final Deck deck = DeckSerializer.fromSections(sections);
- if (dh.isIntendedForAi()) {
- stored.getLeft().addAiDeck(deck);
- stored.getRight().setRight(f);
- } else {
- stored.getLeft().setHumanDeck(deck);
- stored.getRight().setLeft(f);
- }
-
- if ((stored.getLeft().getHumanDeck() != null) && !stored.getLeft().getAiDecks().isEmpty()) {
- // have both parts of sealed deck, may convert
- this.sealed.add(stored.getLeft());
- stored.getRight().getLeft().delete();
- stored.getRight().getRight().delete();
-
- // there stay only orphans
- sealedDecks.remove(name);
- } else {
- sealedDecks.put(name, stored);
- }
- break;
- default:
- break;
- }
- }
-
- // advise to kill orphaned decks
- if (!sealedDecks.isEmpty()) {
- final StringBuilder sb = new StringBuilder();
- for (final Pair<DeckGroup, MutablePair<File, File>> s : sealedDecks.values()) {
- final String missingPart = s.getRight().getLeft() == null ? "human" : "computer";
- sb.append(String.format("Sealed deck '%s' has no matching '%s' deck.%n", s.getKey().getName(),
- missingPart));
- }
- sb.append(System.getProperty("line.separator"));
- sb.append("May Forge delete these decks?");
- if (SOptionPane.showConfirmDialog(sb.toString(), "Some of your sealed decks are orphaned")) {
- for (final Pair<DeckGroup, MutablePair<File, File>> s : sealedDecks.values()) {
- if (s.getRight().getLeft() != null) {
- s.getRight().getLeft().delete();
- }
- if (s.getRight().getRight() != null) {
- s.getRight().getRight().delete();
- }
- }
- }
- }
- }
-
- /**
- * @return the deckDir
- */
-
-}
Index: forge-gui/src/main/java/forge/properties/Preferences.java
===================================================================
--- forge-gui/src/main/java/forge/properties/Preferences.java (revision 29316)
+++ forge-gui/src/main/java/forge/properties/Preferences.java (revision 29316)
@@ -1,196 +0,0 @@
-/*
- * Forge: Play Magic: the Gathering.
- * Copyright (C) 2011 Forge Team
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-package forge.properties;
-
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.util.*;
-
-/**
- * A collection of name/value pairs with sorted keys and utility methods.
- *
- * @author Forge
- * @version $Id: Preferences.java 24769 2014-02-09 13:56:04Z Hellfish $
- */
-public class Preferences {
-
- /** The props. */
- private final Properties props;
-
- /**
- * <p>
- * Constructor for Preferences.
- * </p>
- */
- public Preferences() {
- this.props = new Properties();
- }
-
- /**
- * <p>
- * Constructor for Preferences.
- * </p>
- *
- * @param prefs
- * a {@link forge.properties.Preferences} object.
- */
- public Preferences(final Preferences prefs) {
- this.props = prefs.props;
- }
-
- /**
- * <p>
- * keys.
- * </p>
- *
- * @return a {@link java.util.Enumeration} object.
- */
- public final synchronized Enumeration<String> keys() {
- @SuppressWarnings({ "unchecked", "rawtypes" })
- final Set<String> keysEnum = (Set) this.props.keySet();
- final Vector<String> keyList = new Vector<String>();
- keyList.addAll(keysEnum);
- Collections.sort(keyList);
- return keyList.elements();
- }
-
- /**
- * <p>
- * getInt.
- * </p>
- *
- * @param name
- * a {@link java.lang.String} object.
- * @param defaultValue
- * a int.
- * @return a int.
- */
- public final int getInt(final String name, final int defaultValue) {
- final String value = this.props.getProperty(name);
- if (value == null) {
- return defaultValue;
- }
- try {
- return Integer.parseInt(value);
- } catch (final NumberFormatException ex) {
- return defaultValue;
- }
- }
-
- /**
- * <p>
- * getBoolean.
- * </p>
- *
- * @param name
- * a {@link java.lang.String} object.
- * @param defaultValue
- * a boolean.
- * @return a boolean.
- */
- public final boolean getBoolean(final String name, final boolean defaultValue) {
- final String value = this.props.getProperty(name);
- if (value == null) {
- return defaultValue;
- }
- return Boolean.parseBoolean(value);
- }
-
- /**
- * <p>
- * getLong.
- * </p>
- *
- * @param name
- * a {@link java.lang.String} object.
- * @param defaultValue
- * a long.
- * @return a long.
- */
- public final long getLong(final String name, final long defaultValue) {
- final String value = this.props.getProperty(name);
- if (value == null) {
- return defaultValue;
- }
- return Long.parseLong(value);
- }
-
- /**
- * <p>
- * set.
- * </p>
- *
- * @param key
- * a {@link java.lang.String} object.
- * @param value
- * a {@link java.lang.Object} object.
- */
- public final void set(final String key, final Object value) {
- this.props.setProperty(key, String.valueOf(value));
- }
-
- /**
- * <p>
- * get.
- * </p>
- *
- * @param key
- * a {@link java.lang.String} object.
- * @param value
- * a {@link java.lang.Object} object.
- * @return a {@link java.lang.String} object.
- */
- public final String get(final String key, final Object value) {
- String string = null;
- if (value != null) {
- string = String.valueOf(value);
- }
- return this.props.getProperty(key, string);
- }
-
- /**
- * <p>
- * load.
- * </p>
- *
- * @param stream
- * a {@link java.io.FileInputStream} object.
- * @throws IOException
- * Signals that an I/O exception has occurred.
- */
- public final void load(final FileInputStream stream) throws IOException {
- this.props.load(stream);
- }
-
- /**
- * <p>
- * store.
- * </p>
- *
- * @param stream
- * a {@link java.io.FileOutputStream} object.
- * @param comments
- * a {@link java.lang.String} object.
- * @throws IOException
- * Signals that an I/O exception has occurred.
- */
- public final void store(final FileOutputStream stream, final String comments) throws IOException {
- this.props.store(stream, comments);
- }
-}
Index: forge-gui-desktop/src/main/java/forge/control/GuiTimer.java
===================================================================
--- forge-gui-desktop/src/main/java/forge/control/GuiTimer.java (revision 29316)
+++ forge-gui-desktop/src/main/java/forge/control/GuiTimer.java (revision 29316)
@@ -1,25 +0,0 @@
-package forge.control;
-
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-
-import javax.swing.Timer;
-
-import forge.interfaces.IGuiTimer;
-
-@SuppressWarnings("serial")
-public class GuiTimer extends Timer implements IGuiTimer {
- public GuiTimer(final Runnable proc0, int interval0) {
- super(interval0, new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- proc0.run();
- }
- });
- }
-
- @Override
- public void setInterval(int interval0) {
- setDelay(interval0);
- }
-}
Index: forge-gui-mobile/src/forge/animation/GuiTimer.java
===================================================================
--- forge-gui-mobile/src/forge/animation/GuiTimer.java (revision 29316)
+++ forge-gui-mobile/src/forge/animation/GuiTimer.java (revision 29316)
@@ -1,35 +0,0 @@
-package forge.animation;
-
-import com.badlogic.gdx.utils.Timer;
-
-import forge.interfaces.IGuiTimer;
-
-public class GuiTimer implements IGuiTimer {
- private float interval;
- private Timer.Task task;
-
- public GuiTimer(final Runnable proc0, int interval0) {
- interval = (float)interval0 / 1000f; //convert to seconds
- task = new Timer.Task() {
- @Override
- public void run() {
- proc0.run();
- }
- };
- }
-
- @Override
- public void start() {
- Timer.schedule(task, interval, interval);
- }
-
- @Override
- public void stop() {
- task.cancel();
- }
-
- @Override
- public void setInterval(int interval0) {
- //ignore this function since there's not a reliable way to change the interval on the fly
- }
-}
Index: forge-gui/src/main/java/forge/interfaces/IGuiTimer.java
===================================================================
--- forge-gui/src/main/java/forge/interfaces/IGuiTimer.java (revision 29316)
+++ forge-gui/src/main/java/forge/interfaces/IGuiTimer.java (revision 29316)
@@ -1,7 +0,0 @@
-package forge.interfaces;
-
-public interface IGuiTimer {
- void setInterval(int interval0);
- void start();
- void stop();
-}
Index: forge-gui/src/main/java/forge/match/MatchConstants.java
===================================================================
--- forge-gui/src/main/java/forge/match/MatchConstants.java (revision 29316)
+++ forge-gui/src/main/java/forge/match/MatchConstants.java (revision 29316)
@@ -1,28 +0,0 @@
-package forge.match;
-
-public enum MatchConstants {
- ALWAYSACCEPT ("Always accept this trigger"),
- ALWAYSDECLINE ("Always decline this trigger"),
- ALWAYSASK ("Always ask"),
- HUMANCOMMAND ("Player's Command zone", "Command: ", "Player - View Command"),
- HUMANEXILED ("Player's Exile", "Exile:", "Player - View Exile"),
- HUMANFLASHBACK("Play card with Flashback", "Flashback:", "Player - View Cards with Flashback"),
- HUMANGRAVEYARD("Player's Graveyard", "Graveyard:", "Player - View Graveyard"),
- HUMANHAND ("Player's Hand", "Hand:", "Player - View Hand"),
- HUMANLIBRARY ("Player's Library", "Library:", "Player - View Library");
-
- public final String title;
- public final String button;
- public final String menu;
-
- private MatchConstants(String title0) {
- title = title0;
- button = title0;
- menu = title0;
- }
- private MatchConstants(String title0, String button0, String menu0) {
- title = title0;
- button = button0;
- menu = menu0;
- }
-}
Index: forge-gui/src/main/java/forge/achievement/StreakAchievement.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>ISO-8859-1
===================================================================
--- forge-gui/src/main/java/forge/achievement/StreakAchievement.java (revision 29316)
+++ forge-gui/src/main/java/forge/achievement/StreakAchievement.java (revision 29317)
@@ -8,15 +8,12 @@
public abstract class StreakAchievement extends Achievement {
private int current;
- protected StreakAchievement(String key0, String displayName0, String description0, String flavorText0) {
- super(key0, displayName0, description0, flavorText0, 0);
- }
//use this constructor for regular tiered achievements
- protected StreakAchievement(String key0, String displayName0, String sharedDesc0,
- String commonDesc0, int commonThreshold0,
- String uncommonDesc0, int uncommonThreshold0,
- String rareDesc0, int rareThreshold0,
- String mythicDesc0, int mythicThreshold0) {
+ protected StreakAchievement(final String key0, final String displayName0, final String sharedDesc0,
+ final String commonDesc0, final int commonThreshold0,
+ final String uncommonDesc0, final int uncommonThreshold0,
+ final String rareDesc0, final int rareThreshold0,
+ final String mythicDesc0, final int mythicThreshold0) {
super(key0, displayName0, sharedDesc0, 0, commonDesc0, commonThreshold0,
uncommonDesc0, uncommonThreshold0, rareDesc0, rareThreshold0,
mythicDesc0, mythicThreshold0);
@@ -25,8 +22,8 @@
protected abstract Boolean eval(Player player, Game game);
@Override
- protected final int evaluate(Player player, Game game) {
- Boolean val = eval(player, game);
+ protected final int evaluate(final Player player, final Game game) {
+ final Boolean val = eval(player, game);
if (val != null) { //null means don't increment or reset
if (val) {
current++;
@@ -48,13 +45,13 @@
}
@Override
- public void saveToXml(Element el) {
+ public void saveToXml(final Element el) {
super.saveToXml(el);
el.setAttribute("current", String.valueOf(current));
}
@Override
- public void loadFromXml(Element el) {
+ public void loadFromXml(final Element el) {
super.loadFromXml(el);
current = getIntAttribute(el, "current");
}
Index: forge-gui-desktop/src/main/java/forge/screens/match/ViewWinLose.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>ISO-8859-1
===================================================================
--- forge-gui-desktop/src/main/java/forge/screens/match/ViewWinLose.java (revision 29316)
+++ forge-gui-desktop/src/main/java/forge/screens/match/ViewWinLose.java (revision 29317)
@@ -41,6 +41,7 @@
public class ViewWinLose implements IWinLoseView<FButton> {
private final ControlWinLose control;
+ private final FScrollPane scrLog;
private final FButton btnContinue, btnRestart, btnQuit;
private final SkinnedPanel pnlCustom;
@@ -86,7 +87,7 @@
if (!FModel.getGauntletMini().isGauntletDraft()) {
break;
}
- //$FALL-THROUGH$
+ //$FALL-THROUGH$
case Sealed:
control = new LimitedWinLose(this, game0, matchUI);
break;
@@ -128,14 +129,14 @@
txtLog.setFont(FSkin.getFont(14));
txtLog.setFocusable(true); // allow highlighting and copying of log
- FLabel btnCopyLog = new FLabel.ButtonBuilder().text("Copy to clipboard").build();
+ final FLabel btnCopyLog = new FLabel.ButtonBuilder().text("Copy to clipboard").build();
btnCopyLog.setCommand(new UiCommand() {
@Override
public void run() {
- StringSelection ss = new StringSelection(txtLog.getText());
+ final StringSelection ss = new StringSelection(txtLog.getText());
try {
Toolkit.getDefaultToolkit().getSystemClipboard().setContents(ss, null);
- } catch (IllegalStateException ex) {
+ } catch (final IllegalStateException ex) {
// ignore; may be unavailable on some platforms
}
}
@@ -172,7 +173,7 @@
pnlLeft.add(pnlButtons, "w 100%!");
final JPanel pnlLog = new JPanel(new MigLayout("insets 0, wrap, ax center"));
- final FScrollPane scrLog = new FScrollPane(txtLog, false);
+ scrLog = new FScrollPane(txtLog, false);
pnlLog.setOpaque(false);
pnlLog.add(
@@ -184,7 +185,9 @@
pnlLeft.add(pnlLog, "w 100%!");
lblTitle.setText(composeTitle(game0));
+ }
+ public final void show() {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
@@ -207,7 +210,7 @@
return control;
}
- private String composeTitle(final GameView game) {
+ private static String composeTitle(final GameView game) {
final String winner = game.getWinningPlayerName();
final int winningTeam = game.getWinningTeam();
if (winner == null) {
@@ -220,16 +223,19 @@
}
/** @return {@link forge.toolbox.FButton} */
+ @Override
public FButton getBtnContinue() {
return this.btnContinue;
}
/** @return {@link forge.toolbox.FButton} */
+ @Override
public FButton getBtnRestart() {
return this.btnRestart;
}
/** @return {@link forge.toolbox.FButton} */
+ @Override
public FButton getBtnQuit() {
return this.btnQuit;
}
@@ -251,7 +257,7 @@
}
}
- private String removePlayerTypeFromLogMessage(String message) {
+ private static String removePlayerTypeFromLogMessage(final String message) {
return message.replaceAll("\\[[^\\]]*\\]", "");
}
@@ -261,12 +267,12 @@
}
@Override
- public void showRewards(Runnable runnable) {
+ public void showRewards(final Runnable runnable) {
runnable.run(); //just run on GUI thread
}
@Override
- public void showCards(String title, List<PaperCard> cards) {
+ public void showCards(final String title, final List<PaperCard> cards) {
final QuestWinLoseCardViewer cv = new QuestWinLoseCardViewer(cards);
getPnlCustom().add(new TitleLabel(title), CONSTRAINTS_TITLE);
if (FModel.getPreferences().getPrefBoolean(FPref.UI_LARGE_CARD_VIEWERS)) {
@@ -278,13 +284,13 @@
}
@Override
- public void showMessage(String message, String title, FSkinProp icon) {
- SkinIcon icoTemp = FSkin.getIcon(icon).scale(0.5);
+ public void showMessage(String message, final String title, final FSkinProp icon) {
+ final SkinIcon icoTemp = FSkin.getIcon(icon).scale(0.5);
if (message.contains("\n")) { //ensure new line characters are encoded
message = "<html>" + message.replace("\n", "<br>") + "</html>";
}
- SkinnedLabel lblMessage = new SkinnedLabel(message);
+ final SkinnedLabel lblMessage = new SkinnedLabel(message);
lblMessage.setFont(FSkin.getFont(14));
lblMessage.setForeground(FORE_COLOR);
lblMessage.setHorizontalAlignment(SwingConstants.CENTER);
@@ -297,7 +303,6 @@
/**
* JLabel header between reward sections.
- *
*/
@SuppressWarnings("serial")
private class TitleLabel extends SkinnedLabel {
Index: forge-gui-desktop/src/main/java/forge/screens/home/gauntlet/CSubmenuGauntletLoad.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>ISO-8859-1
===================================================================
--- forge-gui-desktop/src/main/java/forge/screens/home/gauntlet/CSubmenuGauntletLoad.java (revision 29316)
+++ forge-gui-desktop/src/main/java/forge/screens/home/gauntlet/CSubmenuGauntletLoad.java (revision 29317)
@@ -1,5 +1,14 @@
package forge.screens.home.gauntlet;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.swing.JButton;
+import javax.swing.SwingUtilities;
+
import forge.GuiBase;
import forge.UiCommand;
import forge.deck.Deck;
@@ -15,25 +24,20 @@
import forge.model.FModel;
import forge.player.GamePlayerUtil;
-import javax.swing.*;
-
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-import java.io.File;
-import java.util.ArrayList;
-import java.util.List;
-
-/**
+/**
* Controls the "quick gauntlet" submenu in the home UI.
- *
+ *
* <br><br><i>(C at beginning of class name denotes a control class.)</i>
*
*/
public enum CSubmenuGauntletLoad implements ICDoc {
SINGLETON_INSTANCE;
- private final ActionListener actStartGame = new ActionListener() { @Override
- public void actionPerformed(ActionEvent arg0) { startGame(); } };
+ private final ActionListener actStartGame = new ActionListener() {
+ @Override public final void actionPerformed(final ActionEvent arg0) {
+ startGame();
+ }
+ };
private final VSubmenuGauntletLoad view = VSubmenuGauntletLoad.SINGLETON_INSTANCE;
@@ -49,7 +53,7 @@
SwingUtilities.invokeLater(new Runnable() {
@Override public void run() {
- JButton btnStart = view.getBtnStart();
+ final JButton btnStart = view.getBtnStart();
if (btnStart.isEnabled()) {
view.getBtnStart().requestFocusInWindow();
}
@@ -94,7 +98,7 @@
final List<GauntletData> data = new ArrayList<GauntletData>();
for (final File f : files) {
- GauntletData gd = GauntletIO.loadGauntlet(f);
+ final GauntletData gd = GauntletIO.loadGauntlet(f);
if (gd != null) {
data.add(gd);
}
@@ -153,17 +157,4 @@
});
}
- /* (non-Javadoc)
- * @see forge.gui.framework.ICDoc#getCommandOnSelect()
- */
- @Override
- @SuppressWarnings("serial")
- public UiCommand getCommandOnSelect() {
- return new UiCommand() {
- @Override
- public void run() {
- updateData();
- }
- };
- }
}
Index: forge-gui-desktop/src/main/java/forge/sound/AltSoundSystem.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>ISO-8859-1
===================================================================
--- forge-gui-desktop/src/main/java/forge/sound/AltSoundSystem.java (revision 29316)
+++ forge-gui-desktop/src/main/java/forge/sound/AltSoundSystem.java (revision 29317)
@@ -53,6 +53,7 @@
isSync = synced;
}
+ @Override
public void run() {
if (isSync && AsyncSoundRegistry.getNumIterations(filename) >= 1) {
return;
Index: forge-gui-desktop/src/main/java/forge/screens/deckeditor/controllers/CEditorQuestLimited.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>ISO-8859-1
===================================================================
--- forge-gui-desktop/src/main/java/forge/screens/deckeditor/controllers/CEditorQuestLimited.java (revision 29316)
+++ forge-gui-desktop/src/main/java/forge/screens/deckeditor/controllers/CEditorQuestLimited.java (revision 29317)
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
@@ -48,15 +48,13 @@
import forge.screens.home.quest.CSubmenuQuestDecks;
import forge.screens.match.controllers.CDetailPicture;
-//import forge.quest.data.QuestBoosterPack;
-
/**
* Child controller for quest deck editor UI.
* <br><br>
* Card catalog and decks are drawn from a QuestController object.
- *
+ *
* <br><br><i>(C at beginning of class name denotes a control class.)</i>
- *
+ *
* @author Forge
* @version $Id: CEditorQuest.java 24868 2014-02-17 05:08:05Z drdev $
*/
@@ -89,7 +87,7 @@
* Child controller for quest deck editor UI.
* <br><br>
* Card catalog and decks are drawn from a QuestController object.
- *
+ *
* @param questData0 &emsp; {@link forge.quest.QuestController}
*/
public CEditorQuestLimited(final QuestController questData0, final CDetailPicture cDetailPicture) {
@@ -107,7 +105,7 @@
catalogManager.setAlwaysNonUnique(true);
deckManager.setAlwaysNonUnique(true);
-
+
this.setCatalogManager(catalogManager);
this.setDeckManager(deckManager);
@@ -117,23 +115,13 @@
return new DeckGroup("");
}
};
-
+
this.controller = new DeckController<DeckGroup>(questData0.getDraftDecks(), this, newCreator);
controller.getView().getDeckManager().setup(ItemManagerConfig.DRAFT_POOL);
controller.setModel(questData0.getDraftDecks().get(QuestEventDraft.DECK_NAME));
-
+
}
- /**
- * Adds any card to the catalog and data pool.
- *
- * @param card {@link forge.item.PaperCard}
- */
- public void addCheatCard(final PaperCard card, int qty) {
- this.getCatalogManager().addItem(card, qty);
- this.questData.getCards().getCardpool().add(card, qty);
- }
-
// fills number of decks using each card
private Map<PaperCard, Integer> countDecksForEachCard() {
final Map<PaperCard, Integer> result = new HashMap<PaperCard, Integer>();
@@ -161,8 +149,10 @@
* @see forge.gui.deckeditor.ACEditorBase#onAddItems()
*/
@Override
- protected void onAddItems(Iterable<Entry<PaperCard, Integer>> items, boolean toAlternate) {
- if (toAlternate) { return; }
+ protected void onAddItems(final Iterable<Entry<PaperCard, Integer>> items, final boolean toAlternate) {
+ if (toAlternate) {
+ return;
+ }
// update view
this.getDeckManager().addItems(items);
@@ -174,8 +164,10 @@
* @see forge.gui.deckeditor.ACEditorBase#onRemoveItems()
*/
@Override
- protected void onRemoveItems(Iterable<Entry<PaperCard, Integer>> items, boolean toAlternate) {
- if (toAlternate) { return; }
+ protected void onRemoveItems(final Iterable<Entry<PaperCard, Integer>> items, final boolean toAlternate) {
+ if (toAlternate) {
+ return;
+ }
// update view
this.getCatalogManager().addItems(items);
@@ -187,7 +179,7 @@
* @see forge.gui.deckeditor.ACEditorBase#buildAddContextMenu()
*/
@Override
- protected void buildAddContextMenu(EditorContextMenuBuilder cmb) {
+ protected void buildAddContextMenu(final EditorContextMenuBuilder cmb) {
cmb.addMoveItems("Move", "to deck");
}
@@ -195,17 +187,17 @@
* @see forge.gui.deckeditor.ACEditorBase#buildRemoveContextMenu()
*/
@Override
- protected void buildRemoveContextMenu(EditorContextMenuBuilder cmb) {
+ protected void buildRemoveContextMenu(final EditorContextMenuBuilder cmb) {
cmb.addMoveItems("Move", "to sideboard");
}
-
+
private Deck getSelectedDeck(final DeckGroup model) {
return model.getHumanDeck();
}
/*
* (non-Javadoc)
- *
+ *
* @see forge.gui.deckeditor.ACEditorBase#updateView()
*/
@Override
@@ -219,7 +211,7 @@
/*
* (non-Javadoc)
- *
+ *
* @see forge.gui.deckeditor.ACEditorBase#getController()
*/
@Override
@@ -229,10 +221,10 @@
@Override
public void update() {
-
+
this.getCatalogManager().setup(getScreen() == FScreen.DECK_EDITOR_DRAFT ? ItemManagerConfig.DRAFT_POOL : ItemManagerConfig.SEALED_POOL);
this.getDeckManager().setup(ItemManagerConfig.DECK_EDITOR);
-
+
this.decksUsingMyCards = this.countDecksForEachCard();
final Map<ColumnDef, ItemTableColumn> colOverridesCatalog = new HashMap<ColumnDef, ItemTableColumn>();
@@ -253,7 +245,7 @@
deckGenParent = removeTab(VDeckgen.SINGLETON_INSTANCE);
allDecksParent = removeTab(VAllDecks.SINGLETON_INSTANCE);
-
+
if (this.controller.getModel() == null) {
throw new RuntimeException("Expected deck group but found none!");
}
@@ -266,7 +258,7 @@
* @see forge.gui.deckeditor.controllers.ACEditorBase#canSwitchAway()
*/
@Override
- public boolean canSwitchAway(boolean isClosing) {
+ public boolean canSwitchAway(final boolean isClosing) {
if (SEditorIO.confirmSaveChanges(FScreen.DECK_EDITOR_QUEST_TOURNAMENT, isClosing)) {
FModel.getQuest().save();
return true;
@@ -290,11 +282,4 @@
}
}
- /**
- * TODO: Write javadoc for this method.
- * @param d0
- */
- /*public void load(Deck deck) {
- controller.setModel(deck);
- }*/
}
Index: forge-gui/src/main/java/forge/interfaces/IComboBox.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>ISO-8859-1
===================================================================
--- forge-gui/src/main/java/forge/interfaces/IComboBox.java (revision 29316)
+++ forge-gui/src/main/java/forge/interfaces/IComboBox.java (revision 29317)
@@ -1,10 +1,6 @@
package forge.interfaces;
-public interface IComboBox<E> {
- boolean isEnabled();
- void setEnabled(boolean b0);
- boolean isVisible();
- void setVisible(boolean b0);
+public interface IComboBox<E> extends IComponent {
void setSelectedItem(E item);
void setSelectedIndex(int index);
void addItem(E item);
Index: forge-gui-desktop/src/main/java/forge/itemmanager/filters/CardQuestWorldFilter.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>ISO-8859-1
===================================================================
--- forge-gui-desktop/src/main/java/forge/itemmanager/filters/CardQuestWorldFilter.java (revision 29316)
+++ forge-gui-desktop/src/main/java/forge/itemmanager/filters/CardQuestWorldFilter.java (revision 29317)
@@ -1,22 +1,22 @@
package forge.itemmanager.filters;
+import java.util.HashSet;
+import java.util.Set;
+
import forge.game.GameFormat;
import forge.item.PaperCard;
import forge.itemmanager.ItemManager;
import forge.model.FModel;
import forge.quest.QuestWorld;
-import java.util.HashSet;
-import java.util.Set;
-
public class CardQuestWorldFilter extends CardFormatFilter {
private final Set<QuestWorld> questWorlds = new HashSet<QuestWorld>();
- public CardQuestWorldFilter(ItemManager<? super PaperCard> itemManager0) {
+ public CardQuestWorldFilter(final ItemManager<? super PaperCard> itemManager0) {
super(itemManager0);
}
- public CardQuestWorldFilter(ItemManager<? super PaperCard> itemManager0, QuestWorld questWorld0) {
+ public CardQuestWorldFilter(final ItemManager<? super PaperCard> itemManager0, final QuestWorld questWorld0) {
super(itemManager0);
this.questWorlds.add(questWorld0);
this.formats.add(getQuestWorldFormat(questWorld0));
@@ -24,9 +24,9 @@
@Override
public ItemFilter<PaperCard> createCopy() {
- CardQuestWorldFilter copy = new CardQuestWorldFilter(itemManager);
+ final CardQuestWorldFilter copy = new CardQuestWorldFilter(itemManager);
copy.questWorlds.addAll(this.questWorlds);
- for (QuestWorld w : this.questWorlds) {
+ for (final QuestWorld w : this.questWorlds) {
copy.formats.add(getQuestWorldFormat(w));
}
return copy;
@@ -38,7 +38,7 @@
super.reset();
}
- public static boolean canAddQuestWorld(QuestWorld questWorld, ItemFilter<PaperCard> existingFilter) {
+ public static boolean canAddQuestWorld(final QuestWorld questWorld, final ItemFilter<PaperCard> existingFilter) {
if (questWorld.getFormat() == null && FModel.getQuest().getMainFormat() == null) {
return false; //must have format
}
@@ -51,10 +51,10 @@
* @return true if filter merged in or to suppress adding a new filter, false to allow adding new filter
*/
@Override
- public boolean merge(ItemFilter<?> filter) {
- CardQuestWorldFilter cardQuestWorldFilter = (CardQuestWorldFilter)filter;
+ public boolean merge(final ItemFilter<?> filter) {
+ final CardQuestWorldFilter cardQuestWorldFilter = (CardQuestWorldFilter)filter;
this.questWorlds.addAll(cardQuestWorldFilter.questWorlds);
- for (QuestWorld w : cardQuestWorldFilter.questWorlds) {
+ for (final QuestWorld w : cardQuestWorldFilter.questWorlds) {
this.formats.add(getQuestWorldFormat(w));
}
return true;
@@ -72,14 +72,14 @@
@Override
protected Iterable<String> getList() {
- Set<String> strings = new HashSet<String>();
- for (QuestWorld w : this.questWorlds) {
+ final Set<String> strings = new HashSet<String>();
+ for (final QuestWorld w : this.questWorlds) {
strings.add(w.getName());
}
return strings;
}
- private GameFormat getQuestWorldFormat(QuestWorld w) {
+ private static GameFormat getQuestWorldFormat(final QuestWorld w) {
GameFormat format = w.getFormat();
if (format == null) {
//assumes that no world other than the main world will have a null format
Index: forge-gui/src/main/java/forge/quest/QuestEventDraft.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>ISO-8859-1
===================================================================
--- forge-gui/src/main/java/forge/quest/QuestEventDraft.java (revision 29316)
+++ forge-gui/src/main/java/forge/quest/QuestEventDraft.java (revision 29317)
@@ -6,22 +6,31 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package forge.quest;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Date;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
import forge.GuiBase;
import forge.card.CardEdition;
import forge.card.CardEdition.CardInSet;
import forge.card.CardRarity;
-import forge.deck.CardPool;
import forge.deck.Deck;
import forge.deck.DeckGroup;
import forge.deck.DeckSection;
@@ -38,79 +47,76 @@
import forge.util.TextUtil;
import forge.util.storage.IStorage;
-import java.text.SimpleDateFormat;
-import java.util.*;
-
/**
* <p>
* QuestEvent.
* </p>
- *
+ *
* MODEL - A basic event instance in Quest mode. Can be extended for use in
* unique event types: battles, quests, and others.
*/
public class QuestEventDraft {
-
- public static class QuestDraftPrizes {
-
- public int credits;
- public List<BoosterPack> boosterPacks;
- public List<PaperCard> individualCards;
+
+ public static class QuestDraftPrizes {
+
+ public int credits;
+ public List<BoosterPack> boosterPacks;
+ public List<PaperCard> individualCards;
public List<PaperCard> selectRareCards;
-
- public boolean hasCredits() {
- return credits > 0;
- }
-
- public boolean hasBoosterPacks() {
- return boosterPacks != null && boosterPacks.size() > 0;
- }
-
- public boolean hasIndividualCards() {
- return individualCards != null && individualCards.size() > 0;
- }
-
+
+ public boolean hasCredits() {
+ return credits > 0;
+ }
+
+ public boolean hasBoosterPacks() {
+ return boosterPacks != null && boosterPacks.size() > 0;
+ }
+
+ public boolean hasIndividualCards() {
+ return individualCards != null && individualCards.size() > 0;
+ }
+
public boolean selectRareFromSets() { return selectRareCards != null && selectRareCards.size() > 0; }
-
+
public void addSelectedCard(final PaperCard card) {
FModel.getQuest().getCards().addSingleCard(card, 1);
}
-
- }
-
+
+ }
+
public static final String UNDETERMINED = "quest_draft_undetermined_place";
public static final String HUMAN = "quest_draft_human_place";
public static final String DECK_NAME = "Tournament Deck";
private static transient final ReadPriceList PRICE_LIST_READER = new ReadPriceList();
private static transient final Map<String, Integer> MAP_PRICES = PRICE_LIST_READER.getPriceList();
-
+
private String title = "Mystery Draft";
private String boosterConfiguration = "";
private String block = "";
-
+
private int entryFee = 0;
-
+
private String[] standings = new String[15];
private String[] aiNames = new String[7];
-
+
private int[] aiIcons = new int[7];
-
+
private boolean started = false;
private int age = FModel.getQuestPreferences().getPrefInt(QPref.WINS_NEW_DRAFT);
-
+
public QuestEventDraft(final String title) {
this.title = title;
}
-
+
public final String getTitle() {
return this.title;
}
-
+
public final String[] getBoosterConfiguration() {
return boosterConfiguration.split("/");
}
-
+
public final void setBoosterConfiguration(final String boosterConfiguration) {
this.boosterConfiguration = boosterConfiguration;
}
@@ -118,122 +124,108 @@
public final void setEntryFee(final int entryFee) {
this.entryFee = entryFee;
}
-
+
public final int getEntryFee() {
return entryFee;
}
-
+
public final void setBlock(final String block) {
this.block = block;
}
-
+
public final String getBlock() {
return block;
}
-
+
public void setTitle(final String title0) {
this.title = title0;
}
-
+
- public void setStandings(String[] standings) {
+ public void setStandings(final String[] standings) {
this.standings = standings;
}
-
+
public String[] getStandings() {
return standings;
}
-
+
public String[] getAINames() {
return aiNames;
}
-
+
public void setAINames(final String[] names) {
aiNames = names;
}
-
+
public int[] getAIIcons() {
return aiIcons;
}
-
+
public void setAIIcons(final int[] icons) {
aiIcons = icons;
}
-
+
public int getAge() {
return age;
}
-
+
public void setAge(final int age) {
this.age = age;
}
-
+
public void addWin() {
age--;
}
-
- public void saveToRegularDraft() {
+
+ public void saveToRegularDraft() {
- String tournamentName = FModel.getQuest().getName() + " Tournament Deck " + new SimpleDateFormat("EEE d MMM yyyy HH-mm-ss").format(new Date());
- DeckGroup original = FModel.getQuest().getDraftDecks().get(QuestEventDraft.DECK_NAME);
- DeckGroup output = new DeckGroup(tournamentName);
- for (Deck aiDeck : original.getAiDecks()) {
+ final String tournamentName = FModel.getQuest().getName() + " Tournament Deck " + new SimpleDateFormat("EEE d MMM yyyy HH-mm-ss").format(new Date());
+ final DeckGroup original = FModel.getQuest().getDraftDecks().get(QuestEventDraft.DECK_NAME);
+ final DeckGroup output = new DeckGroup(tournamentName);
+ for (final Deck aiDeck : original.getAiDecks()) {
- output.addAiDeck(copyDeck(aiDeck));
- }
- output.setHumanDeck(copyDeck(original.getHumanDeck(), tournamentName));
- FModel.getDecks().getDraft().add(output);
- }
-
- public void addToQuestDecks() {
+ output.addAiDeck(copyDeck(aiDeck));
+ }
+ output.setHumanDeck(copyDeck(original.getHumanDeck(), tournamentName));
+ FModel.getDecks().getDraft().add(output);
+ }
+
+ public void addToQuestDecks() {
- String deckName = "Tournament Deck " + new SimpleDateFormat("EEE d MMM yyyy HH-mm-ss").format(new Date());
+ final String deckName = "Tournament Deck " + new SimpleDateFormat("EEE d MMM yyyy HH-mm-ss").format(new Date());
- Deck tournamentDeck = FModel.getQuest().getDraftDecks().get(QuestEventDraft.DECK_NAME).getHumanDeck();
- Deck deck = new Deck(deckName);
+ final Deck tournamentDeck = FModel.getQuest().getDraftDecks().get(QuestEventDraft.DECK_NAME).getHumanDeck();
+ final Deck deck = new Deck(deckName);
- FModel.getQuest().getCards().addAllCards(tournamentDeck.getAllCardsInASinglePool().toFlatList());
+ FModel.getQuest().getCards().addAllCards(tournamentDeck.getAllCardsInASinglePool().toFlatList());
- if (tournamentDeck.get(DeckSection.Main).countAll() > 0) {
- deck.getOrCreate(DeckSection.Main).addAll(tournamentDeck.get(DeckSection.Main));
- FModel.getQuest().getMyDecks().add(deck);
- }
+ if (tournamentDeck.get(DeckSection.Main).countAll() > 0) {
+ deck.getOrCreate(DeckSection.Main).addAll(tournamentDeck.get(DeckSection.Main));
+ FModel.getQuest().getMyDecks().add(deck);
+ }
- FModel.getQuest().getDraftDecks().delete(QuestEventDraft.DECK_NAME);
- FModel.getQuest().getAchievements().endCurrentTournament(FModel.getQuest().getAchievements().getCurrentDraft().getPlayerPlacement());
- FModel.getQuest().save();
- }
+ FModel.getQuest().getDraftDecks().delete(QuestEventDraft.DECK_NAME);
+ FModel.getQuest().getAchievements().endCurrentTournament(FModel.getQuest().getAchievements().getCurrentDraft().getPlayerPlacement());
+ FModel.getQuest().save();
+ }
- private Deck copyDeck(final Deck deck) {
-
- Deck outputDeck = new Deck(deck.getName());
-
- outputDeck.putSection(DeckSection.Main, new CardPool(deck.get(DeckSection.Main)));
- outputDeck.putSection(DeckSection.Sideboard, new CardPool(deck.get(DeckSection.Sideboard)));
-
- return outputDeck;
-
+ private static Deck copyDeck(final Deck deck) {
+ return new Deck(deck);
- }
+ }
- private Deck copyDeck(final Deck deck, final String deckName) {
-
- Deck outputDeck = new Deck(deckName);
-
- outputDeck.putSection(DeckSection.Main, new CardPool(deck.get(DeckSection.Main)));
- outputDeck.putSection(DeckSection.Sideboard, new CardPool(deck.get(DeckSection.Sideboard)));
-
- return outputDeck;
-
+ private static Deck copyDeck(final Deck deck, final String deckName) {
+ return new Deck(deck, deckName);
- }
-
+ }
+
- public void setWinner(String playerName) {
+ public void setWinner(final String playerName) {
-
+
boolean isHumanPlayer = true;
-
+
- for (String name : aiNames) {
+ for (final String name : aiNames) {
if (playerName.equals(name)) {
isHumanPlayer = false;
}
}
-
+
int playerIndex = -1;
-
+
if (isHumanPlayer) {
for (int i = standings.length - 1; i >= 0; i--) {
if (standings[i].equals(HUMAN)) {
@@ -242,7 +234,7 @@
}
}
} else {
-
+
String aiIndex = "";
for (int i = aiNames.length - 1; i >= 0; i--) {
@@ -251,308 +243,307 @@
break;
}
}
-
+
for (int i = standings.length - 1; i >= 0; i--) {
if (standings[i].equals(aiIndex)) {
playerIndex = i;
break;
}
}
-
+
}
-
+
switch (playerIndex) {
- case 0:
- case 1:
- standings[8] = standings[playerIndex];
- break;
- case 2:
- case 3:
- standings[9] = standings[playerIndex];
- break;
- case 4:
- case 5:
- standings[10] = standings[playerIndex];
- break;
- case 6:
- case 7:
- standings[11] = standings[playerIndex];
- break;
- case 8:
- case 9:
- standings[12] = standings[playerIndex];
- break;
- case 10:
- case 11:
- standings[13] = standings[playerIndex];
- break;
- case 12:
- case 13:
- standings[14] = standings[playerIndex];
- break;
+ case 0:
+ case 1:
+ standings[8] = standings[playerIndex];
+ break;
+ case 2:
+ case 3:
+ standings[9] = standings[playerIndex];
+ break;
+ case 4:
+ case 5:
+ standings[10] = standings[playerIndex];
+ break;
+ case 6:
+ case 7:
+ standings[11] = standings[playerIndex];
+ break;
+ case 8:
+ case 9:
+ standings[12] = standings[playerIndex];
+ break;
+ case 10:
+ case 11:
+ standings[13] = standings[playerIndex];
+ break;
+ case 12:
+ case 13:
+ standings[14] = standings[playerIndex];
+ break;
}
-
+
}
-
+
/**
* Generates the prizes for the player and saves them to the current quest.
*/
public QuestDraftPrizes collectPrizes() {
-
+
- int place = getPlayerPlacement();
+ final int place = getPlayerPlacement();
int prizePool = entryFee * 9;
-
+
int boosterPrices = 0;
-
+
- for (String boosterSet : boosterConfiguration.split("/")) {
+ for (final String boosterSet : boosterConfiguration.split("/")) {
-
+
int value;
- String boosterName = FModel.getMagicDb().getEditions().get(boosterSet).getName() + " Booster Pack";
+ final String boosterName = FModel.getMagicDb().getEditions().get(boosterSet).getName() + " Booster Pack";
if (MAP_PRICES.containsKey(boosterName)) {
value = MAP_PRICES.get(boosterName);
} else {
value = 395;
}
-
+
boosterPrices += value;
-
+
}
prizePool -= boosterPrices * 8;
- QuestDraftPrizes prizes = null;
-
+ QuestDraftPrizes prizes = null;
+
switch (place) {
- case 1:
- prizes = generateFirstPlacePrizes(prizePool);
- break;
- case 2:
- prizes = generateSecondPlacePrizes(prizePool);
- break;
- case 3:
- prizes = generateThirdPlacePrizes();
- break;
- case 4:
- prizes = generateFourthPlacePrizes();
- break;
+ case 1:
+ prizes = generateFirstPlacePrizes(prizePool);
+ break;
+ case 2:
+ prizes = generateSecondPlacePrizes(prizePool);
+ break;
+ case 3:
+ prizes = generateThirdPlacePrizes();
+ break;
+ case 4:
+ prizes = generateFourthPlacePrizes();
+ break;
}
-
- if (prizes != null) {
+
+ if (prizes != null) {
- if (prizes.hasCredits()) {
- FModel.getQuest().getAssets().addCredits(prizes.credits);
- }
-
- if (prizes.hasBoosterPacks()) {
+ if (prizes.hasCredits()) {
+ FModel.getQuest().getAssets().addCredits(prizes.credits);
+ }
+
+ if (prizes.hasBoosterPacks()) {
- for (BoosterPack boosterPack : prizes.boosterPacks) {
+ for (final BoosterPack boosterPack : prizes.boosterPacks) {
- FModel.getQuest().getCards().addAllCards(boosterPack.getCards());
- }
- }
-
- if (prizes.hasIndividualCards()) {
- FModel.getQuest().getCards().addAllCards(prizes.individualCards);
- }
-
- return prizes;
-
- }
-
+ FModel.getQuest().getCards().addAllCards(boosterPack.getCards());
+ }
+ }
+
+ if (prizes.hasIndividualCards()) {
+ FModel.getQuest().getCards().addAllCards(prizes.individualCards);
+ }
+
+ return prizes;
+
+ }
+
return null;
-
+
}
-
+
private QuestDraftPrizes generateFirstPlacePrizes(final int prizePool) {
-
+
int credits = 2 * (prizePool / 3); //First place gets 2/3 the total prize pool
- List<PaperCard> cards = new ArrayList<>();
- List<BoosterPack> boosters = new ArrayList<>();
+ final List<PaperCard> cards = new ArrayList<>();
+ final List<BoosterPack> boosters = new ArrayList<>();
-
+
cards.add(getPromoCard());
int creditsForPacks = (credits / 2); //Spend 50% of the credits on packs
-
+
while (true) {
- BoosterPack pack = getBoosterPack();
- int price = getBoosterPrice(pack);
+ final BoosterPack pack = getBoosterPack();
+ final int price = getBoosterPrice(pack);
if (price > creditsForPacks + creditsForPacks * 0.1f) { //Add a little room for near-same price packs.
break;
}
creditsForPacks -= price;
boosters.add(pack);
}
-
+
credits = (credits / 2) + creditsForPacks; //Add the leftover credits + 50%
- QuestDraftPrizes prizes = new QuestDraftPrizes();
+ final QuestDraftPrizes prizes = new QuestDraftPrizes();
- prizes.credits = credits;
- prizes.boosterPacks = boosters;
- prizes.individualCards = cards;
+ prizes.credits = credits;
+ prizes.boosterPacks = boosters;
+ prizes.individualCards = cards;
awardSelectedRare(prizes);
-
+
return prizes;
-
+
}
-
+
private QuestDraftPrizes generateSecondPlacePrizes(final int prizePool) {
-
+
int credits = prizePool / 3; //Second place gets 1/3 the total prize pool
- List<PaperCard> cards = new ArrayList<>();
- List<BoosterPack> boosters = new ArrayList<>();
+ final List<PaperCard> cards = new ArrayList<>();
+ final List<BoosterPack> boosters = new ArrayList<>();
-
+
cards.add(getPromoCard());
int creditsForPacks = (credits / 4) * 3; //Spend 75% of the credits on packs
-
+
while (true) {
- BoosterPack pack = getBoosterPack();
- int price = getBoosterPrice(pack);
+ final BoosterPack pack = getBoosterPack();
+ final int price = getBoosterPrice(pack);
if (price > creditsForPacks + creditsForPacks * 0.1f) { //Add a little room for near-same price packs.
break;
}
creditsForPacks -= price;
boosters.add(pack);
}
-
+
credits = (credits / 4) + creditsForPacks; //Add the leftover credits + 25%
- QuestDraftPrizes prizes = new QuestDraftPrizes();
+ final QuestDraftPrizes prizes = new QuestDraftPrizes();
- prizes.credits = credits;
- prizes.boosterPacks = boosters;
- prizes.individualCards = cards;
+ prizes.credits = credits;
+ prizes.boosterPacks = boosters;
+ prizes.individualCards = cards;
awardSelectedRare(prizes);
- return prizes;
-
+ return prizes;
+
}
-
+
private QuestDraftPrizes generateThirdPlacePrizes() {
-
+
- int credits = 0;
- List<PaperCard> cards = new ArrayList<>();
+ final int credits = 0;
+ final List<PaperCard> cards = new ArrayList<>();
-
+
cards.add(getPromoCard());
-
+
- List<BoosterPack> boosters = new ArrayList<>();
+ final List<BoosterPack> boosters = new ArrayList<>();
boosters.add(getBoosterPack());
- QuestDraftPrizes prizes = new QuestDraftPrizes();
+ final QuestDraftPrizes prizes = new QuestDraftPrizes();
- prizes.credits = credits;
- prizes.boosterPacks = boosters;
- prizes.individualCards = cards;
+ prizes.credits = credits;
+ prizes.boosterPacks = boosters;
+ prizes.individualCards = cards;
- return prizes;
-
+ return prizes;
+
}
-
+
private QuestDraftPrizes generateFourthPlacePrizes() {
-
+
- int credits = 0;
- List<PaperCard> cards = new ArrayList<>();
+ final int credits = 0;
+ final List<PaperCard> cards = new ArrayList<>();
-
+
cards.add(getPromoCard());
- QuestDraftPrizes prizes = new QuestDraftPrizes();
+ final QuestDraftPrizes prizes = new QuestDraftPrizes();
- prizes.credits = credits;
- prizes.individualCards = cards;
+ prizes.credits = credits;
+ prizes.individualCards = cards;
- return prizes;
-
+ return prizes;
+
}
private void awardSelectedRare(final QuestDraftPrizes prizes) {
-
+
- List<PaperCard> possibleCards = new ArrayList<>();
+ final List<PaperCard> possibleCards = new ArrayList<>();
-
+
- for (CardEdition edition : getAllEditions()) {
- for (CardInSet card : edition.getCards()) {
+ for (final CardEdition edition : getAllEditions()) {
+ for (final CardInSet card : edition.getCards()) {
if (card.rarity == CardRarity.Rare || card.rarity == CardRarity.MythicRare) {
- PaperCard cardToAdd = FModel.getMagicDb().getCommonCards().getCard(card.name, edition.getCode());
+ final PaperCard cardToAdd = FModel.getMagicDb().getCommonCards().getCard(card.name, edition.getCode());
if (cardToAdd != null) {
possibleCards.add(cardToAdd);
}
}
}
}
-
+
prizes.selectRareCards = possibleCards;
-
+
}
-
+
private BoosterPack getBoosterPack() {
return BoosterPack.FN_FROM_SET.apply(getRandomEdition());
}
-
+
private PaperCard getPromoCard() {
-
+
- CardEdition randomEdition = getRandomEdition();
- List<CardInSet> cardsInEdition = new ArrayList<>();
+ final CardEdition randomEdition = getRandomEdition();
+ final List<CardInSet> cardsInEdition = new ArrayList<>();
-
+
- for (CardInSet card : randomEdition.getCards()) {
+ for (final CardInSet card : randomEdition.getCards()) {
if (card.rarity == CardRarity.Rare || card.rarity == CardRarity.MythicRare) {
cardsInEdition.add(card);
}
}
-
+
CardInSet randomCard;
PaperCard promo = null;
-
+
int attempts = 25;
-
+
while (promo == null && attempts-- > 0) {
randomCard = cardsInEdition.get((int) (Math.random() * cardsInEdition.size()));
promo = FModel.getMagicDb().getCommonCards().getCard(randomCard.name, randomEdition.getCode());
}
-
+
if (promo == null) {
return FModel.getQuest().getCards().addRandomRare();
}
-
+
return promo;
-
+
}
-
+
private CardEdition getRandomEdition() {
-
+
- List<CardEdition> editions = new ArrayList<>();
- for (String booster : boosterConfiguration.split("/")) {
+ final List<CardEdition> editions = new ArrayList<>();
+ for (final String booster : boosterConfiguration.split("/")) {
editions.add(FModel.getMagicDb().getEditions().get(booster));
}
-
+
return editions.get((int) (Math.random() * editions.size()));
-
+
}
private Set<CardEdition> getAllEditions() {
-
+
- Set<CardEdition> editions = new HashSet<>();
- for (String booster : boosterConfiguration.split("/")) {
+ final Set<CardEdition> editions = new HashSet<>();
+ for (final String booster : boosterConfiguration.split("/")) {
editions.add(FModel.getMagicDb().getEditions().get(booster));
}
return editions;
}
-
+
- private int getBoosterPrice(final BoosterPack booster) {
-
+ private static int getBoosterPrice(final BoosterPack booster) {
int value;
-
+
- String boosterName = booster.getName();
+ final String boosterName = booster.getName();
if (MAP_PRICES.containsKey(boosterName)) {
value = MAP_PRICES.get(boosterName);
} else {
value = 395;
}
-
+
return value;
-
+
}
-
+
public boolean playerHasMatchesLeft() {
-
+
int playerIndex = -1;
for (int i = standings.length - 1; i >= 0; i--) {
if (standings[i].equals(HUMAN)) {
@@ -560,52 +551,52 @@
break;
}
}
-
+
int nextMatchIndex;
-
+
switch (playerIndex) {
-
- case 0:
- case 1:
- nextMatchIndex = 8;
- break;
- case 2:
- case 3:
- nextMatchIndex = 9;
- break;
- case 4:
- case 5:
- nextMatchIndex = 10;
- break;
- case 6:
- case 7:
- nextMatchIndex = 11;
- break;
- case 8:
- case 9:
- nextMatchIndex = 12;
- break;
- case 10:
- case 11:
- nextMatchIndex = 13;
- break;
- case 12:
- case 13:
- nextMatchIndex = 14;
- break;
- case 14:
- default:
- nextMatchIndex = -1;
- break;
-
+
+ case 0:
+ case 1:
+ nextMatchIndex = 8;
+ break;
+ case 2:
+ case 3:
+ nextMatchIndex = 9;
+ break;
+ case 4:
+ case 5:
+ nextMatchIndex = 10;
+ break;
+ case 6:
+ case 7:
+ nextMatchIndex = 11;
+ break;
+ case 8:
+ case 9:
+ nextMatchIndex = 12;
+ break;
+ case 10:
+ case 11:
+ nextMatchIndex = 13;
+ break;
+ case 12:
+ case 13:
+ nextMatchIndex = 14;
+ break;
+ case 14:
+ default:
+ nextMatchIndex = -1;
+ break;
+
}
return nextMatchIndex != -1 && standings[nextMatchIndex].equals(UNDETERMINED);
}
-
+
public int getPlayerPlacement() {
-
+
int playerIndex = -1;
for (int i = standings.length - 1; i >= 0; i--) {
if (standings[i].equals(HUMAN)) {
@@ -613,49 +604,49 @@
break;
}
}
-
+
if (playerIndex <= 7) {
return 4;
}
-
+
if (playerIndex <= 11) {
return 3;
}
-
+
if (playerIndex <= 13) {
return 2;
}
-
+
if (playerIndex == 14) {
return 1;
}
-
+
return -1;
-
+
}
public String getPlacementString() {
-
+
- int place = getPlayerPlacement();
+ final int place = getPlayerPlacement();
String output;
switch (place) {
- case 1:
- output = "first";
- break;
- case 2:
- output = "second";
- break;
- case 3:
- output = "third";
- break;
- case 4:
- output = "fourth";
- break;
- default:
- output = "ERROR";
- break;
+ case 1:
+ output = "first";
+ break;
+ case 2:
+ output = "second";
+ break;
+ case 3:
+ output = "third";
+ break;
+ case 4:
+ output = "fourth";
+ break;
+ default:
+ output = "ERROR";
+ break;
}
return output;
@@ -663,7 +654,7 @@
}
public boolean canEnter() {
- long creditsAvailable = FModel.getQuest().getAssets().getCredits();
+ final long creditsAvailable = FModel.getQuest().getAssets().getCredits();
return creditsAvailable < getEntryFee();
}
@@ -676,12 +667,12 @@
public boolean isStarted() {
return started;
}
-
+
public void start() {
started = true;
FModel.getQuest().save();
}
-
+
public void setStarted(final boolean started) {
this.started = started;
}
@@ -690,40 +681,40 @@
public String toString() {
return title;
}
-
+
public static List<CardBlock> getAvailableBlocks(final QuestController quest) {
- List<CardBlock> possibleBlocks = new ArrayList<>();
- List<CardEdition> allowedQuestSets = new ArrayList<>();
+ final List<CardBlock> possibleBlocks = new ArrayList<>();
+ final List<CardEdition> allowedQuestSets = new ArrayList<>();
- boolean questUsesLimitedCardPool = quest.getFormat() != null;
+ final boolean questUsesLimitedCardPool = quest.getFormat() != null;
if (questUsesLimitedCardPool) {
- List<String> allowedSetCodes = quest.getFormat().getAllowedSetCodes();
+ final List<String> allowedSetCodes = quest.getFormat().getAllowedSetCodes();
- for (String setCode : allowedSetCodes) {
+ for (final String setCode : allowedSetCodes) {
allowedQuestSets.add(FModel.getMagicDb().getEditions().get(setCode));
}
}
- List<CardBlock> blocks = new ArrayList<>();
- IStorage<CardBlock> storage = FModel.getBlocks();
+ final List<CardBlock> blocks = new ArrayList<>();
+ final IStorage<CardBlock> storage = FModel.getBlocks();
- for (CardBlock b : storage) {
+ for (final CardBlock b : storage) {
if (b.getCntBoostersDraft() > 0) {
blocks.add(b);
}
}
if (questUsesLimitedCardPool) {
- for (CardBlock block : blocks) {
+ for (final CardBlock block : blocks) {
boolean blockAllowed = true;
- boolean allBlocksSanctioned = quest.getFormat().getAllowedSetCodes().isEmpty();
+ final boolean allBlocksSanctioned = quest.getFormat().getAllowedSetCodes().isEmpty();
- for (CardEdition set : block.getSets()) {
+ for (final CardEdition set : block.getSets()) {
if (!allowedQuestSets.contains(set) && !allBlocksSanctioned) {
blockAllowed = false;
break;
@@ -740,25 +731,25 @@
}
return possibleBlocks.isEmpty() ? null : possibleBlocks;
-
+
}
-
+
/**
* Generates a random draft event based on the provided quest's limitations.
* @param quest The quest used to determine set availability.
* @return The created draft or null in the event no draft could be created.
*/
public static QuestEventDraft getRandomDraftOrNull(final QuestController quest) {
-
+
- List<CardBlock> possibleBlocks = getAvailableBlocks(quest);
+ final List<CardBlock> possibleBlocks = getAvailableBlocks(quest);
-
+
if (possibleBlocks == null) {
return null;
}
-
+
Collections.shuffle(possibleBlocks);
return getDraftOrNull(quest, possibleBlocks.get(0));
-
+
}
/**
@@ -766,9 +757,9 @@
* @return The created draft or null in the event no draft could be created.
*/
public static QuestEventDraft getDraftOrNull(final QuestController quest, final CardBlock block) {
-
+
- QuestEventDraft event = new QuestEventDraft(block.getName());
+ final QuestEventDraft event = new QuestEventDraft(block.getName());
-
+
if (block.getNumberSets() == 1) {
String boosterConfiguration = "";
for (int i = 0; i < block.getCntBoostersDraft(); i++) {
@@ -779,15 +770,15 @@
event.boosterConfiguration = boosterConfiguration;
}
} else {
- List<String> possibleSetCombinations = getSetCombos(block);
+ final List<String> possibleSetCombinations = getSetCombos(block);
Collections.shuffle(possibleSetCombinations);
event.boosterConfiguration = possibleSetCombinations.get(0);
}
-
+
event.block = block.getName();
event.entryFee = calculateEntryFee(event.boosterConfiguration.split("/"));
-
+
- List<String> players = new ArrayList<>();
+ final List<String> players = new ArrayList<>();
players.add(HUMAN);
players.add("1");
players.add("2");
@@ -796,74 +787,73 @@
players.add("5");
players.add("6");
players.add("7");
-
+
Collections.shuffle(players);
-
+
for (int i = 0; i < players.size(); i++) {
event.standings[i] = players.get(i);
}
-
+
for (int i = 8; i < event.standings.length; i++) {
event.standings[i] = UNDETERMINED;
}
-
+
- List<String> usedNames = new ArrayList<>();
+ final List<String> usedNames = new ArrayList<>();
usedNames.add(GamePlayerUtil.getGuiPlayer().getName());
-
+
for (int i = 0; i < 7; i++) {
event.aiNames[i] = NameGenerator.getRandomName("Any", "Any", usedNames);
usedNames.add(event.aiNames[i]);
}
-
+
- int numberOfIcons = GuiBase.getInterface().getAvatarCount();
- List<Integer> usedIcons = new ArrayList<>();
+ final int numberOfIcons = GuiBase.getInterface().getAvatarCount();
+ final List<Integer> usedIcons = new ArrayList<>();
-
+
for (int i = 0; i < 7; i++) {
-
+
int icon;
int attempts = 50;
-
+
do {
icon = (int) Math.floor(Math.random() * numberOfIcons);
} while ((icon < 0 || usedIcons.contains(icon)) && attempts-- > 0);
-
+
event.aiIcons[i] = icon;
usedNames.add(event.aiNames[i]);
usedIcons.add(icon);
-
+
}
-
+
return event;
-
+
}
-
+
- private static int calculateEntryFee(String[] boosters) {
-
+ private static int calculateEntryFee(final String[] boosters) {
int entryFee = 0;
-
+
- for (String boosterSet : boosters) {
+ for (final String boosterSet : boosters) {
-
+
int value;
- String boosterName = FModel.getMagicDb().getEditions().get(boosterSet).getName() + " Booster Pack";
+ final String boosterName = FModel.getMagicDb().getEditions().get(boosterSet).getName() + " Booster Pack";
-
+
if (MAP_PRICES.containsKey(boosterName)) {
value = MAP_PRICES.get(boosterName);
} else {
value = 395;
}
-
+
entryFee += value;
-
+
}
-
+
return (int) (entryFee * 1.5);
-
+
}
-
+
private static List<String> getSetCombos(final CardBlock block) {
- List<String> result = new ArrayList<>();
+ final List<String> result = new ArrayList<>();
- List<CardEdition> sets = block.getSets();
+ final List<CardEdition> sets = block.getSets();
final String s0c = sets.get(0).getCode();
if (sets.size() == 1) {
result.add(String.format("%s/%s/%s", s0c, s0c, s0c));
@@ -871,13 +861,13 @@
}
final String s1c = sets.get(1).getCode();
- final String s2c = sets.size() > 2 ? sets.get(2).getCode() : null;
+ final String s2c = sets.size() > 2 ? sets.get(2).getCode() : null;
- boolean s0isLarge = sets.get(0).getCards().length > 200;
- boolean s1isLarge = sets.get(1).getCards().length > 200;
+ final boolean s0isLarge = sets.get(0).getCards().length > 200;
+ final boolean s1isLarge = sets.get(1).getCards().length > 200;
-
+
final String largerSet = s0isLarge == s1isLarge ? null : s0isLarge ? s0c : s1c;
-
+
if (s2c == null) {
if (largerSet != null ) {
result.add(String.format("%s/%s/%s", s0c, largerSet, s1c));
@@ -892,24 +882,25 @@
result.add(String.format("%s/%s/%s", s0c, s1c, s2c));
// allow separate drafts with 3rd large set (ex: ROE, AVR)
- if( sets.get(2).getCards().length > 200)
+ if( sets.get(2).getCards().length > 200) {