mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-19 20:28:00 +00:00
smallest refactoring - move classes to siutable folders
This commit is contained in:
@@ -5,6 +5,7 @@ import java.io.File;
|
||||
import forge.deck.io.CubeSerializer;
|
||||
import forge.deck.io.DeckSerializer;
|
||||
import forge.deck.io.DeckSetSerializer;
|
||||
import forge.deck.io.OldDeckParser;
|
||||
import forge.util.FolderMap;
|
||||
import forge.util.IFolderMap;
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package forge.deck;
|
||||
package forge.deck.io;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FilenameFilter;
|
||||
@@ -14,9 +14,9 @@ import org.apache.commons.lang3.tuple.MutablePair;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
import forge.PlayerType;
|
||||
import forge.deck.io.DeckFileHeader;
|
||||
import forge.deck.io.DeckSerializer;
|
||||
import forge.deck.io.DeckSetSerializer;
|
||||
import forge.deck.CustomLimited;
|
||||
import forge.deck.Deck;
|
||||
import forge.deck.DeckSet;
|
||||
import forge.util.FileUtil;
|
||||
import forge.util.IFolderMap;
|
||||
import forge.util.SectionUtil;
|
||||
@@ -79,28 +79,20 @@ public class PreconDeck implements InventoryItemFromSet {
|
||||
public PreconDeck(final File f) {
|
||||
final List<String> deckLines = FileUtil.readFile(f);
|
||||
final Map<String, List<String>> sections = SectionUtil.parseSections(deckLines);
|
||||
this.deck = Deck.fromLines(deckLines);
|
||||
this.deck = Deck.fromSections(sections);
|
||||
|
||||
String filenameProxy = null;
|
||||
String setProxy = "n/a";
|
||||
String descriptionProxy = "";
|
||||
final List<String> metadata = sections.get("metadata");
|
||||
if ((null != metadata) && !metadata.isEmpty()) {
|
||||
for (final String s : metadata) {
|
||||
final String[] kv = s.split("=");
|
||||
if ("Image".equalsIgnoreCase(kv[0])) {
|
||||
filenameProxy = kv[1];
|
||||
} else if ("set".equalsIgnoreCase(kv[0]) && (SetUtils.getSetByCode(kv[1].toUpperCase()) != null)) {
|
||||
setProxy = kv[1];
|
||||
} else if ("Description".equalsIgnoreCase(kv[0])) {
|
||||
descriptionProxy = kv[1];
|
||||
}
|
||||
}
|
||||
}
|
||||
this.imageFilename = filenameProxy;
|
||||
|
||||
Map<String,String> kv = SectionUtil.parseKvPairs(sections.get("metadata"), "=");
|
||||
|
||||
imageFilename = kv.get("Image");
|
||||
description = kv.get("Description");
|
||||
if( SetUtils.getSetByCode(kv.get("set").toUpperCase()) != null )
|
||||
{ setProxy = kv.get("set"); }
|
||||
|
||||
this.set = setProxy;
|
||||
this.recommendedDeals = new SellRules(sections.get("shop"));
|
||||
this.description = descriptionProxy;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -61,6 +61,16 @@ public class FolderMap<T extends IHasName> extends FolderMapView<T> implements I
|
||||
public final void delete(final String deckName) {
|
||||
serializer.erase(this.getMap().remove(deckName));
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see forge.deck.IFolderMapView#isUnique(java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public final boolean isUnique(final String name) {
|
||||
return !this.getMap().containsKey(name);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -47,14 +47,6 @@ public class FolderMapView<T extends IHasName> implements Iterable<T>, IFolderMa
|
||||
this.map = io.readAll();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see forge.deck.IFolderMapView#isUnique(java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public final boolean isUnique(final String name) {
|
||||
return !this.map.containsKey(name);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see forge.deck.IFolderMapView#get(java.lang.String)
|
||||
*/
|
||||
|
||||
@@ -28,4 +28,15 @@ public interface IFolderMap<T extends IHasName> extends IFolderMapView<T> {
|
||||
*/
|
||||
public abstract void delete(final String deckName);
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* isUnique.
|
||||
* </p>
|
||||
*
|
||||
* @param deckName
|
||||
* a {@link java.lang.String} object.
|
||||
* @return a boolean.
|
||||
*/
|
||||
public abstract boolean isUnique(final String name);
|
||||
|
||||
}
|
||||
@@ -10,17 +10,6 @@ import java.util.Collection;
|
||||
*/
|
||||
public interface IFolderMapView<T extends IHasName> extends Iterable<T> {
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* isUnique.
|
||||
* </p>
|
||||
*
|
||||
* @param deckName
|
||||
* a {@link java.lang.String} object.
|
||||
* @return a boolean.
|
||||
*/
|
||||
public abstract boolean isUnique(final String name);
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* getDeck.
|
||||
|
||||
@@ -86,6 +86,9 @@ public class SectionUtil {
|
||||
* @return the map
|
||||
*/
|
||||
public static Map<String, String> parseKvPairs(final List<String> lines, String separator ) {
|
||||
if ( null == lines )
|
||||
return null;
|
||||
|
||||
final Map<String, String> result = new TreeMap<String, String>(String.CASE_INSENSITIVE_ORDER);
|
||||
|
||||
for (final String dd : lines) {
|
||||
|
||||
Reference in New Issue
Block a user