mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-19 12:18:00 +00:00
Huge cleanup: use collection interfaces (List, Set, Map) rather than
implementations (ArrayList etc.) in references to objects
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package forge.achievement;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import forge.game.Game;
|
||||
import forge.game.card.Card;
|
||||
@@ -15,7 +16,7 @@ public class Domain extends ProgressiveAchievement {
|
||||
@Override
|
||||
protected boolean eval(Player player, Game game) {
|
||||
if (player.getOutcome().hasWon()) {
|
||||
HashSet<String> basicLands = new HashSet<String>();
|
||||
Set<String> basicLands = new HashSet<String>();
|
||||
for (Card c : player.getCardsIn(ZoneType.Battlefield)) {
|
||||
if (c.isBasicLand()) {
|
||||
basicLands.add(c.getName());
|
||||
|
||||
@@ -322,7 +322,7 @@ public class FControlGameEventHandler extends IGameEventVisitor.Base<Void> {
|
||||
|
||||
@Override
|
||||
public Void visit(final GameEventBlockersDeclared event) {
|
||||
final HashSet<Card> cards = new HashSet<Card>();
|
||||
final Set<Card> cards = new HashSet<Card>();
|
||||
for (final MapOfLists<Card, Card> kv : event.blockers.values()) {
|
||||
for (final Collection<Card> blockers : kv.values()) {
|
||||
cards.addAll(blockers);
|
||||
|
||||
@@ -9,7 +9,7 @@ public class ColorDeckGenerator extends DeckProxy implements Comparable<ColorDec
|
||||
public static List<DeckProxy> getColorDecks(final IItemManager<DeckProxy> lstDecks0, final boolean isAi0) {
|
||||
final String[] colors = new String[] { "Random 1", "Random 2", "Random 3",
|
||||
"White", "Blue", "Black", "Red", "Green" };
|
||||
final ArrayList<DeckProxy> decks = new ArrayList<DeckProxy>();
|
||||
final List<DeckProxy> decks = new ArrayList<DeckProxy>();
|
||||
for (int i = 0; i < colors.length; i++) {
|
||||
decks.add(new ColorDeckGenerator(colors[i], i, lstDecks0, isAi0));
|
||||
}
|
||||
|
||||
@@ -59,8 +59,8 @@ public class DeckGeneratorTheme extends DeckGeneratorBase {
|
||||
*
|
||||
* @return a {@link java.util.ArrayList} object.
|
||||
*/
|
||||
public static final ArrayList<String> getThemeNames() {
|
||||
final ArrayList<String> ltNames = new ArrayList<String>();
|
||||
public static final List<String> getThemeNames() {
|
||||
final List<String> ltNames = new ArrayList<String>();
|
||||
|
||||
final File file = new File(ForgeConstants.THEMES_DIR);
|
||||
|
||||
@@ -170,7 +170,7 @@ public class DeckGeneratorTheme extends DeckGeneratorBase {
|
||||
|
||||
private class Grp {
|
||||
/** The Cardnames. */
|
||||
private final ArrayList<String> cardnames = new ArrayList<String>();
|
||||
private final List<String> cardnames = new ArrayList<String>();
|
||||
|
||||
/** The Max cnt. */
|
||||
private int maxCnt;
|
||||
|
||||
@@ -3,6 +3,7 @@ package forge.deck;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
@@ -140,7 +141,7 @@ public class DeckProxy implements InventoryItem {
|
||||
if (color == null && !isGeneratedDeck()) {
|
||||
byte colorProfile = MagicColor.COLORLESS;
|
||||
byte landProfile = MagicColor.COLORLESS;
|
||||
HashSet<Byte> nonReqColors = null;
|
||||
Set<Byte> nonReqColors = null;
|
||||
|
||||
for (final Entry<DeckSection, CardPool> deckEntry : getDeck()) {
|
||||
switch (deckEntry.getKey()) {
|
||||
|
||||
@@ -6,22 +6,23 @@
|
||||
* 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.download;
|
||||
|
||||
import forge.properties.ForgeConstants;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
|
||||
import forge.properties.ForgeConstants;
|
||||
|
||||
public class GuiDownloadPrices extends GuiDownloadService {
|
||||
@Override
|
||||
public String getTitle() {
|
||||
@@ -30,8 +31,6 @@ public class GuiDownloadPrices extends GuiDownloadService {
|
||||
|
||||
@Override
|
||||
protected Map<String, String> getNeededFiles() {
|
||||
Map<String, String> result = new HashMap<String, String>();
|
||||
result.put(ForgeConstants.QUEST_CARD_PRICE_FILE, ForgeConstants.URL_PRICE_DOWNLOAD);
|
||||
return result;
|
||||
return ImmutableMap.of(ForgeConstants.QUEST_CARD_PRICE_FILE, ForgeConstants.URL_PRICE_DOWNLOAD);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,12 +17,13 @@
|
||||
*/
|
||||
package forge.itemmanager;
|
||||
|
||||
import forge.itemmanager.ItemColumnConfig.SortState;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import forge.itemmanager.ItemColumnConfig.SortState;
|
||||
|
||||
/**
|
||||
* A collection of methods pertaining to columns in card catalog and
|
||||
* current deck tables, for use in the deck editor.
|
||||
@@ -55,7 +56,7 @@ public final class SColumnUtil {
|
||||
}
|
||||
private static Map<ColumnDef, ItemColumnConfig> getCardColumns(ColumnDef quantityColDef, boolean includeFavorite,
|
||||
boolean includeOwned, boolean includePrice, boolean includeNew, boolean includeDecks) {
|
||||
ArrayList<ColumnDef> colDefs = new ArrayList<ColumnDef>();
|
||||
List<ColumnDef> colDefs = new ArrayList<ColumnDef>();
|
||||
if (includeFavorite) {
|
||||
colDefs.add(ColumnDef.FAVORITE);
|
||||
}
|
||||
@@ -126,7 +127,7 @@ public final class SColumnUtil {
|
||||
}
|
||||
|
||||
public static Map<ColumnDef, ItemColumnConfig> getSpecialCardPoolDefaultColumns() {
|
||||
ArrayList<ColumnDef> colDefs = new ArrayList<ColumnDef>();
|
||||
List<ColumnDef> colDefs = new ArrayList<ColumnDef>();
|
||||
colDefs.add(ColumnDef.FAVORITE);
|
||||
colDefs.add(ColumnDef.NAME);
|
||||
colDefs.add(ColumnDef.TYPE);
|
||||
@@ -186,7 +187,7 @@ public final class SColumnUtil {
|
||||
}
|
||||
|
||||
public static Map<ColumnDef, ItemColumnConfig> getDecksDefaultColumns(boolean allowEdit, boolean includeFolder) {
|
||||
ArrayList<ColumnDef> colDefs = new ArrayList<ColumnDef>();
|
||||
List<ColumnDef> colDefs = new ArrayList<ColumnDef>();
|
||||
colDefs.add(ColumnDef.DECK_FAVORITE);
|
||||
if (allowEdit) {
|
||||
colDefs.add(ColumnDef.DECK_ACTIONS);
|
||||
|
||||
@@ -215,7 +215,7 @@ public class BoosterDraft implements IBoosterDraft {
|
||||
/** Looks for draft files, reads them, returns a list. */
|
||||
private static List<CustomLimited> loadCustomDrafts() {
|
||||
String[] dList;
|
||||
final ArrayList<CustomLimited> customs = new ArrayList<CustomLimited>();
|
||||
final List<CustomLimited> customs = new ArrayList<CustomLimited>();
|
||||
|
||||
// get list of custom draft files
|
||||
final File dFolder = new File(ForgeConstants.DRAFT_DIR);
|
||||
|
||||
@@ -50,7 +50,7 @@ public class BoosterDraftAI {
|
||||
|
||||
// holds all the cards for each of the computer's decks
|
||||
protected final List<List<PaperCard>> deck = new ArrayList<List<PaperCard>>();
|
||||
protected final ArrayList<DeckColors> playerColors = new ArrayList<DeckColors>();
|
||||
protected final List<DeckColors> playerColors = new ArrayList<DeckColors>();
|
||||
|
||||
// roughly equivalent to 25 ranks in a core set, or 15 ranks in a small set
|
||||
private static final double TAKE_BEST_THRESHOLD = 0.1;
|
||||
|
||||
@@ -61,7 +61,7 @@ import java.util.Map.Entry;
|
||||
public class SealedCardPoolGenerator {
|
||||
public static final String FILE_EXT = ".sealed";
|
||||
|
||||
private final ArrayList<IUnOpenedProduct> product = new ArrayList<IUnOpenedProduct>();
|
||||
private final List<IUnOpenedProduct> product = new ArrayList<IUnOpenedProduct>();
|
||||
|
||||
/** The Land set code. */
|
||||
private String landSetCode = null;
|
||||
@@ -216,7 +216,7 @@ public class SealedCardPoolGenerator {
|
||||
|
||||
case Custom:
|
||||
String[] dList;
|
||||
final ArrayList<CustomLimited> customs = new ArrayList<CustomLimited>();
|
||||
final List<CustomLimited> customs = new ArrayList<CustomLimited>();
|
||||
|
||||
// get list of custom draft files
|
||||
final File dFolder = new File(ForgeConstants.SEALED_DIR);
|
||||
@@ -278,9 +278,9 @@ public class SealedCardPoolGenerator {
|
||||
*
|
||||
* @return an ArrayList of the set choices.
|
||||
*/
|
||||
private static ArrayList<String> getSetCombos(final List<String> setz, final int nPacks) {
|
||||
private static List<String> getSetCombos(final List<String> setz, final int nPacks) {
|
||||
String[] sets = setz.toArray(ArrayUtils.EMPTY_STRING_ARRAY);
|
||||
ArrayList<String> setCombos = new ArrayList<String>();
|
||||
List<String> setCombos = new ArrayList<String>();
|
||||
|
||||
if (nPacks == 3) {
|
||||
if (sets.length >= 2) {
|
||||
|
||||
@@ -1,16 +1,17 @@
|
||||
package forge.limited;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import forge.deck.CardPool;
|
||||
import forge.item.PaperCard;
|
||||
import forge.util.MyRandom;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class WinstonDraftAI extends BoosterDraftAI{
|
||||
|
||||
private WinstonDraft draft = null;
|
||||
private static final int N_DECKS = 1;
|
||||
private ArrayList<Byte> colorPreference = new ArrayList<>();
|
||||
private List<Byte> colorPreference = new ArrayList<>();
|
||||
|
||||
public WinstonDraft getDraft() {
|
||||
return draft;
|
||||
|
||||
@@ -31,24 +31,33 @@ import forge.util.FCollection;
|
||||
import forge.util.FCollectionView;
|
||||
|
||||
public abstract class AbstractGuiGame implements IGuiGame, IMayViewCards {
|
||||
private FCollectionView<PlayerView> localPlayers = new FCollection<PlayerView>();
|
||||
private FCollection<PlayerView> localPlayers = new FCollection<PlayerView>();
|
||||
private PlayerView currentPlayer = null;
|
||||
|
||||
protected final void setLocalPlayers(final Iterable<PlayerView> myPlayers) {
|
||||
protected final void setLocalPlayers(final Collection<PlayerView> myPlayers) {
|
||||
this.localPlayers = myPlayers == null ? new FCollection<PlayerView>() : new FCollection<PlayerView>(myPlayers);
|
||||
this.currentPlayer = Iterables.getFirst(this.localPlayers, null);
|
||||
this.autoPassUntilEndOfTurn.retainAll(myPlayers);
|
||||
}
|
||||
private void addLocalPlayer(final PlayerView player) {
|
||||
this.localPlayers.add(player);
|
||||
}
|
||||
private void removeLocalPlayer(final PlayerView player) {
|
||||
this.localPlayers.remove(player);
|
||||
this.autoPassUntilEndOfTurn.remove(player);
|
||||
}
|
||||
|
||||
public final boolean hasLocalPlayers() {
|
||||
return localPlayers != null && !localPlayers.isEmpty();
|
||||
return !localPlayers.isEmpty();
|
||||
}
|
||||
public final FCollectionView<PlayerView> getLocalPlayers() {
|
||||
return localPlayers;
|
||||
}
|
||||
public final int getLocalPlayerCount() {
|
||||
return localPlayers == null ? 0 : localPlayers.size();
|
||||
return localPlayers.size();
|
||||
}
|
||||
public final boolean isLocalPlayer(final PlayerView player) {
|
||||
return hasLocalPlayers() && localPlayers.contains(player);
|
||||
return localPlayers.contains(player);
|
||||
}
|
||||
|
||||
public final PlayerView getCurrentPlayer() {
|
||||
@@ -83,6 +92,11 @@ public abstract class AbstractGuiGame implements IGuiGame, IMayViewCards {
|
||||
@Override
|
||||
public void setGameController(final PlayerView player, final IGameController gameController) {
|
||||
this.gameControllers.put(player, gameController);
|
||||
if (gameController == null) {
|
||||
addLocalPlayer(player);
|
||||
} else {
|
||||
removeLocalPlayer(player);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -247,7 +247,7 @@ public abstract class InputPayMana extends InputSyncronizedBase {
|
||||
colorNeeded = MagicColor.WHITE;
|
||||
}
|
||||
else {
|
||||
final ArrayList<SpellAbility> colorMatches = new ArrayList<SpellAbility>();
|
||||
final List<SpellAbility> colorMatches = new ArrayList<SpellAbility>();
|
||||
for (SpellAbility sa : abilities) {
|
||||
if (abilityProducesManaColor(sa, sa.getManaPartRecursive(), colorNeeded)) {
|
||||
colorMatches.add(sa);
|
||||
|
||||
@@ -41,7 +41,7 @@ public class UnOpenedMeta implements IUnOpenedProduct {
|
||||
SelectAll,
|
||||
}
|
||||
|
||||
private final ArrayList<MetaSet> metaSets;
|
||||
private final List<MetaSet> metaSets;
|
||||
private final JoinOperation operation;
|
||||
private final Random generator = MyRandom.getRandom();
|
||||
|
||||
|
||||
@@ -270,7 +270,7 @@ public class HumanPlay {
|
||||
}
|
||||
|
||||
final List<CostPart> parts = cost.getCostParts();
|
||||
ArrayList<CostPart> remainingParts = new ArrayList<CostPart>(parts);
|
||||
final List<CostPart> remainingParts = new ArrayList<CostPart>(parts);
|
||||
CostPart costPart = null;
|
||||
if (!parts.isEmpty()) {
|
||||
costPart = parts.get(0);
|
||||
@@ -470,7 +470,7 @@ public class HumanPlay {
|
||||
}
|
||||
Card selected = inp.getFirstSelected();
|
||||
final Map<CounterType, Integer> tgtCounters = selected.getCounters();
|
||||
final ArrayList<CounterType> typeChoices = new ArrayList<CounterType>();
|
||||
final List<CounterType> typeChoices = new ArrayList<CounterType>();
|
||||
for (CounterType key : tgtCounters.keySet()) {
|
||||
if (tgtCounters.get(key) > 0) {
|
||||
typeChoices.add(key);
|
||||
|
||||
@@ -13,6 +13,7 @@ import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import org.apache.commons.lang3.Range;
|
||||
@@ -23,9 +24,9 @@ import org.apache.commons.lang3.tuple.Pair;
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.base.Predicate;
|
||||
import com.google.common.base.Predicates;
|
||||
import com.google.common.collect.ArrayListMultimap;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.collect.ListMultimap;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.common.collect.Multimap;
|
||||
@@ -120,8 +121,8 @@ import forge.util.gui.SOptionPane;
|
||||
* Handles phase skips for now.
|
||||
*/
|
||||
public class PlayerControllerHuman
|
||||
extends PlayerController
|
||||
implements IGameController {
|
||||
extends PlayerController
|
||||
implements IGameController {
|
||||
/**
|
||||
* Cards this player may look at right now, for example when searching a
|
||||
* library.
|
||||
@@ -176,7 +177,7 @@ implements IGameController {
|
||||
return mayLookAtAllCards;
|
||||
}
|
||||
|
||||
private final HashSet<Card> tempShownCards = new HashSet<Card>();
|
||||
private final Set<Card> tempShownCards = new HashSet<Card>();
|
||||
public <T> void tempShow(final Iterable<T> objects) {
|
||||
for (final T t : objects) {
|
||||
if (t instanceof Card) {
|
||||
@@ -796,7 +797,7 @@ implements IGameController {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object vote(final SpellAbility sa, final String prompt, final List<Object> options, final ArrayListMultimap<Object, Player> votes) {
|
||||
public Object vote(final SpellAbility sa, final String prompt, final List<Object> options, final ListMultimap<Object, Player> votes) {
|
||||
return getGui().one(prompt, options);
|
||||
}
|
||||
|
||||
@@ -1120,7 +1121,7 @@ implements IGameController {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ReplacementEffect chooseSingleReplacementEffect(final String prompt, final List<ReplacementEffect> possibleReplacers, final HashMap<String, Object> runParams) {
|
||||
public ReplacementEffect chooseSingleReplacementEffect(final String prompt, final List<ReplacementEffect> possibleReplacers, final Map<String, Object> runParams) {
|
||||
final ReplacementEffect first = possibleReplacers.get(0);
|
||||
if (possibleReplacers.size() == 1) {
|
||||
return first;
|
||||
|
||||
@@ -276,12 +276,12 @@ public final class BoosterUtils {
|
||||
* If true, multiple copies of the same card will be allowed to be generated.
|
||||
* @return a list of card names
|
||||
*/
|
||||
private static ArrayList<PaperCard> generateCards(
|
||||
private static List<PaperCard> generateCards(
|
||||
final Iterable<PaperCard> source, final Predicate<PaperCard> filter, final int cntNeeded,
|
||||
final List<Predicate<CardRules>> allowedColors, final boolean allowDuplicates) {
|
||||
|
||||
//If color is null, use colorOrder progression to grab cards
|
||||
final ArrayList<PaperCard> result = new ArrayList<>();
|
||||
final List<PaperCard> result = new ArrayList<>();
|
||||
|
||||
final int size = allowedColors == null ? 0 : allowedColors.size();
|
||||
if (allowedColors != null) {
|
||||
|
||||
@@ -6,17 +6,39 @@
|
||||
* 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.bazaar;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.SortedSet;
|
||||
import java.util.TreeMap;
|
||||
import java.util.TreeSet;
|
||||
|
||||
import javax.xml.parsers.DocumentBuilder;
|
||||
import javax.xml.parsers.DocumentBuilderFactory;
|
||||
import javax.xml.parsers.ParserConfigurationException;
|
||||
|
||||
import org.w3c.dom.Attr;
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.NamedNodeMap;
|
||||
import org.w3c.dom.Node;
|
||||
import org.w3c.dom.NodeList;
|
||||
import org.xml.sax.SAXException;
|
||||
|
||||
import com.thoughtworks.xstream.XStream;
|
||||
|
||||
import forge.model.FModel;
|
||||
@@ -25,29 +47,18 @@ import forge.quest.data.QuestAssets;
|
||||
import forge.util.IgnoringXStream;
|
||||
import forge.util.XmlUtil;
|
||||
|
||||
import org.w3c.dom.*;
|
||||
import org.xml.sax.SAXException;
|
||||
|
||||
import javax.xml.parsers.DocumentBuilder;
|
||||
import javax.xml.parsers.DocumentBuilderFactory;
|
||||
import javax.xml.parsers.ParserConfigurationException;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* QuestStallManager class.
|
||||
* </p>
|
||||
*
|
||||
*
|
||||
* @author Forge
|
||||
* @version $Id$
|
||||
*/
|
||||
public class QuestBazaarManager {
|
||||
private final File xmlFile;
|
||||
|
||||
public QuestBazaarManager(File xmlFile0) {
|
||||
public QuestBazaarManager(final File xmlFile0) {
|
||||
xmlFile = xmlFile0;
|
||||
}
|
||||
|
||||
@@ -57,42 +68,42 @@ public class QuestBazaarManager {
|
||||
builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
|
||||
final Document document = builder.parse(xmlFile);
|
||||
|
||||
XStream xs = new IgnoringXStream();
|
||||
final XStream xs = new IgnoringXStream();
|
||||
xs.autodetectAnnotations(true);
|
||||
|
||||
NodeList xmlStalls = document.getElementsByTagName("stalls").item(0).getChildNodes();
|
||||
final NodeList xmlStalls = document.getElementsByTagName("stalls").item(0).getChildNodes();
|
||||
for (int iN = 0; iN < xmlStalls.getLength(); iN++) {
|
||||
Node n = xmlStalls.item(iN);
|
||||
final Node n = xmlStalls.item(iN);
|
||||
if (n.getNodeType() != Node.ELEMENT_NODE) { continue; }
|
||||
|
||||
Attr att = document.createAttribute("resolves-to");
|
||||
final Attr att = document.createAttribute("resolves-to");
|
||||
att.setValue(QuestStallDefinition.class.getCanonicalName());
|
||||
n.getAttributes().setNamedItem(att);
|
||||
QuestStallDefinition stall = (QuestStallDefinition) xs.fromXML(XmlUtil.nodeToString(n));
|
||||
final QuestStallDefinition stall = (QuestStallDefinition) xs.fromXML(XmlUtil.nodeToString(n));
|
||||
stalls.put(stall.getName(), stall);
|
||||
}
|
||||
|
||||
NodeList xmlQuestItems = document.getElementsByTagName("questItems").item(0).getChildNodes();
|
||||
final NodeList xmlQuestItems = document.getElementsByTagName("questItems").item(0).getChildNodes();
|
||||
for (int iN = 0; iN < xmlQuestItems.getLength(); iN++) {
|
||||
Node n = xmlQuestItems.item(iN);
|
||||
final Node n = xmlQuestItems.item(iN);
|
||||
if (n.getNodeType() != Node.ELEMENT_NODE) { continue; }
|
||||
|
||||
NamedNodeMap attrs = n.getAttributes();
|
||||
String sType = attrs.getNamedItem("itemType").getTextContent();
|
||||
String name = attrs.getNamedItem("name").getTextContent();
|
||||
QuestItemType qType = QuestItemType.smartValueOf(sType);
|
||||
Attr att = document.createAttribute("resolves-to");
|
||||
final NamedNodeMap attrs = n.getAttributes();
|
||||
final String sType = attrs.getNamedItem("itemType").getTextContent();
|
||||
final String name = attrs.getNamedItem("name").getTextContent();
|
||||
final QuestItemType qType = QuestItemType.smartValueOf(sType);
|
||||
final Attr att = document.createAttribute("resolves-to");
|
||||
att.setValue(qType.getBazaarControllerClass().getCanonicalName());
|
||||
attrs.setNamedItem(att);
|
||||
QuestItemBasic ctrl = (QuestItemBasic) xs.fromXML(XmlUtil.nodeToString(n));
|
||||
final QuestItemBasic ctrl = (QuestItemBasic) xs.fromXML(XmlUtil.nodeToString(n));
|
||||
items.put(name, ctrl);
|
||||
}
|
||||
|
||||
} catch (SAXException e) {
|
||||
} catch (final SAXException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IOException e) {
|
||||
} catch (final IOException e) {
|
||||
e.printStackTrace();
|
||||
} catch (ParserConfigurationException e) {
|
||||
} catch (final ParserConfigurationException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
@@ -107,7 +118,7 @@ public class QuestBazaarManager {
|
||||
* <p>
|
||||
* getStall.
|
||||
* </p>
|
||||
*
|
||||
*
|
||||
* @param stallName
|
||||
* a {@link java.lang.String} object.
|
||||
* @return a {@link forge.quest.bazaar.QuestStallDefinition} object.
|
||||
@@ -129,7 +140,7 @@ public class QuestBazaarManager {
|
||||
|
||||
for (int iSlot = 0; iSlot < QuestController.MAX_PET_SLOTS; iSlot++) {
|
||||
|
||||
for (QuestPetController pet : qCtrl.getPetsStorage().getAllPets(iSlot)) {
|
||||
for (final QuestPetController pet : qCtrl.getPetsStorage().getAllPets(iSlot)) {
|
||||
//System.out.println("Pet: " + pet.getName());
|
||||
itemSet.put(pet.getName(), pet);
|
||||
}
|
||||
@@ -139,11 +150,11 @@ public class QuestBazaarManager {
|
||||
|
||||
itemsOnStalls.clear();
|
||||
|
||||
for (QuestStallDefinition thisStall : stalls.values()) {
|
||||
TreeSet<IQuestBazaarItem> set = new TreeSet<IQuestBazaarItem>();
|
||||
for (final QuestStallDefinition thisStall : stalls.values()) {
|
||||
final SortedSet<IQuestBazaarItem> set = new TreeSet<IQuestBazaarItem>();
|
||||
|
||||
for (String itemName : thisStall.getItems()) {
|
||||
IQuestBazaarItem item = itemSet.get(itemName);
|
||||
for (final String itemName : thisStall.getItems()) {
|
||||
final IQuestBazaarItem item = itemSet.get(itemName);
|
||||
//System.out.println(itemName);
|
||||
set.add(item);
|
||||
}
|
||||
@@ -153,7 +164,7 @@ public class QuestBazaarManager {
|
||||
|
||||
/**
|
||||
* Returns <i>purchasable</i> items available for a particular stall.
|
||||
*
|
||||
*
|
||||
* @param stallName   {@link java.lang.String}
|
||||
* @return {@link java.util.List}.
|
||||
*/
|
||||
@@ -162,7 +173,7 @@ public class QuestBazaarManager {
|
||||
|
||||
final List<IQuestBazaarItem> ret = new ArrayList<IQuestBazaarItem>();
|
||||
|
||||
QuestAssets qA = FModel.getQuest().getAssets();
|
||||
final QuestAssets qA = FModel.getQuest().getAssets();
|
||||
for (final IQuestBazaarItem purchasable : itemsOnStalls.get(stallName)) {
|
||||
if (purchasable.isAvailableForPurchase(qA, qCtrl)) {
|
||||
ret.add(purchasable);
|
||||
|
||||
@@ -238,7 +238,7 @@ public class QuestDataIO {
|
||||
|
||||
QuestDataIO.setFinalField(QuestAchievements.class, "challengesPlayed", qA, Integer.parseInt(document.getElementsByTagName("challengesPlayed").item(0).getTextContent()));
|
||||
|
||||
final ArrayList<Integer> completedChallenges = new ArrayList<>();
|
||||
final List<Integer> completedChallenges = new ArrayList<>();
|
||||
QuestDataIO.setFinalField(QuestAchievements.class, "completedChallenges", qA, completedChallenges);
|
||||
|
||||
if ((nw = document.getElementsByTagName("completedChallenges").item(0)) != null) {
|
||||
|
||||
Reference in New Issue
Block a user