mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-19 12:18:00 +00:00
Code cleanup
This commit is contained in:
@@ -28,15 +28,14 @@ import com.google.common.collect.Iterables;
|
|||||||
|
|
||||||
import forge.util.IItemReader;
|
import forge.util.IItemReader;
|
||||||
|
|
||||||
//reads and writeDeck Deck objects
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
* DeckManager class.
|
* StorageBase class.
|
||||||
* </p>
|
* </p>
|
||||||
*
|
*
|
||||||
* @param <T> the generic type
|
* @param <T> the generic type
|
||||||
* @author Forge
|
* @author Forge
|
||||||
* @version $Id: DeckManager.java 13590 2012-01-27 20:46:27Z Max mtg $
|
* @version $Id: StorageBase.java 13590 2012-01-27 20:46:27Z Max mtg $
|
||||||
*/
|
*/
|
||||||
public class StorageBase<T> implements IStorage<T> {
|
public class StorageBase<T> implements IStorage<T> {
|
||||||
protected final Map<String, T> map;
|
protected final Map<String, T> map;
|
||||||
@@ -59,7 +58,6 @@ public class StorageBase<T> implements IStorage<T> {
|
|||||||
return this.map.get(name);
|
return this.map.get(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public final Collection<String> getItemNames() {
|
public final Collection<String> getItemNames() {
|
||||||
return new ArrayList<String>(this.map.keySet());
|
return new ArrayList<String>(this.map.keySet());
|
||||||
@@ -85,15 +83,13 @@ public class StorageBase<T> implements IStorage<T> {
|
|||||||
return Iterables.tryFind(map.values(), condition).orNull();
|
return Iterables.tryFind(map.values(), condition).orNull();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void add(T deck) {
|
public void add(T item) {
|
||||||
throw new UnsupportedOperationException("This is a read-only storage");
|
throw new UnsupportedOperationException("This is a read-only storage");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void delete(String deckName) {
|
public void delete(String itemName) {
|
||||||
throw new UnsupportedOperationException("This is a read-only storage");
|
throw new UnsupportedOperationException("This is a read-only storage");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -34,10 +34,8 @@ import forge.util.FileUtil;
|
|||||||
* the generic type
|
* the generic type
|
||||||
*/
|
*/
|
||||||
public abstract class StorageReaderFile<T> extends StorageReaderBase<T> {
|
public abstract class StorageReaderFile<T> extends StorageReaderBase<T> {
|
||||||
|
|
||||||
private final File file;
|
private final File file;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Instantiates a new storage reader file.
|
* Instantiates a new storage reader file.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -36,7 +36,6 @@ import forge.util.FileUtil;
|
|||||||
* the generic type
|
* the generic type
|
||||||
*/
|
*/
|
||||||
public abstract class StorageReaderFileSections<T> extends StorageReaderBase<T> {
|
public abstract class StorageReaderFileSections<T> extends StorageReaderBase<T> {
|
||||||
|
|
||||||
private final File file;
|
private final File file;
|
||||||
|
|
||||||
public StorageReaderFileSections(final String pathname, final Function<? super T, String> keySelector0) {
|
public StorageReaderFileSections(final String pathname, final Function<? super T, String> keySelector0) {
|
||||||
@@ -46,7 +45,6 @@ public abstract class StorageReaderFileSections<T> extends StorageReaderBase<T>
|
|||||||
public StorageReaderFileSections(final File file0, final Function<? super T, String> keySelector0) {
|
public StorageReaderFileSections(final File file0, final Function<? super T, String> keySelector0) {
|
||||||
super(keySelector0);
|
super(keySelector0);
|
||||||
this.file = file0;
|
this.file = file0;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Map<String, T> createMap() {
|
protected Map<String, T> createMap() {
|
||||||
@@ -136,5 +134,4 @@ public abstract class StorageReaderFileSections<T> extends StorageReaderBase<T>
|
|||||||
public String getItemKey(final T item) {
|
public String getItemKey(final T item) {
|
||||||
return this.keySelector.apply(item);
|
return this.keySelector.apply(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,7 +38,6 @@ import com.google.common.base.Function;
|
|||||||
* @param <T> the generic type
|
* @param <T> the generic type
|
||||||
*/
|
*/
|
||||||
public abstract class StorageReaderFolder<T> extends StorageReaderBase<T> {
|
public abstract class StorageReaderFolder<T> extends StorageReaderBase<T> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the directory
|
* @return the directory
|
||||||
*/
|
*/
|
||||||
@@ -46,18 +45,17 @@ public abstract class StorageReaderFolder<T> extends StorageReaderBase<T> {
|
|||||||
return directory;
|
return directory;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
protected final File directory;
|
protected final File directory;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Instantiates a new storage reader folder.
|
* Instantiates a new storage reader folder.
|
||||||
*
|
*
|
||||||
* @param deckDir0 the deck dir0
|
* @param itemDir0 the item dir0
|
||||||
*/
|
*/
|
||||||
public StorageReaderFolder(final File deckDir0, Function<? super T, String> keySelector0) {
|
public StorageReaderFolder(final File itemDir0, Function<? super T, String> keySelector0) {
|
||||||
super(keySelector0);
|
super(keySelector0);
|
||||||
|
|
||||||
this.directory = deckDir0;
|
this.directory = itemDir0;
|
||||||
|
|
||||||
if (this.directory == null) {
|
if (this.directory == null) {
|
||||||
throw new IllegalArgumentException("No directory specified");
|
throw new IllegalArgumentException("No directory specified");
|
||||||
@@ -126,7 +124,6 @@ public abstract class StorageReaderFolder<T> extends StorageReaderBase<T> {
|
|||||||
return keySelector.apply(item);
|
return keySelector.apply(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// methods handling nested folders are provided. It's up to consumer whether to use these or not.
|
// methods handling nested folders are provided. It's up to consumer whether to use these or not.
|
||||||
@Override
|
@Override
|
||||||
public Iterable<File> getSubFolders() {
|
public Iterable<File> getSubFolders() {
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
package forge.gui.deckchooser;
|
package forge.gui.deckchooser;
|
||||||
|
|
||||||
import java.awt.Toolkit;
|
import java.awt.Toolkit;
|
||||||
import java.awt.datatransfer.StringSelection;
|
import java.awt.datatransfer.StringSelection;
|
||||||
@@ -58,7 +58,6 @@ public class DeckgenUtil {
|
|||||||
* @return {@link forge.deck.Deck}
|
* @return {@link forge.deck.Deck}
|
||||||
*/
|
*/
|
||||||
public static Deck buildColorDeck(List<String> selection, boolean forAi) {
|
public static Deck buildColorDeck(List<String> selection, boolean forAi) {
|
||||||
|
|
||||||
final Deck deck;
|
final Deck deck;
|
||||||
String deckName = null;
|
String deckName = null;
|
||||||
|
|
||||||
@@ -66,11 +65,14 @@ public class DeckgenUtil {
|
|||||||
CardDb cardDb = Singletons.getMagicDb().getCommonCards();
|
CardDb cardDb = Singletons.getMagicDb().getCommonCards();
|
||||||
if (selection.size() == 1) {
|
if (selection.size() == 1) {
|
||||||
gen = new DeckGeneratorMonoColor(cardDb, selection.get(0));
|
gen = new DeckGeneratorMonoColor(cardDb, selection.get(0));
|
||||||
} else if (selection.size() == 2) {
|
}
|
||||||
|
else if (selection.size() == 2) {
|
||||||
gen = new DeckGenerator2Color(cardDb, selection.get(0), selection.get(1));
|
gen = new DeckGenerator2Color(cardDb, selection.get(0), selection.get(1));
|
||||||
} else if (selection.size() == 3) {
|
}
|
||||||
|
else if (selection.size() == 3) {
|
||||||
gen = new DeckGenerator3Color(cardDb, selection.get(0), selection.get(1), selection.get(2));
|
gen = new DeckGenerator3Color(cardDb, selection.get(0), selection.get(1), selection.get(2));
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
gen = new DeckGenerator5Color(cardDb);
|
gen = new DeckGenerator5Color(cardDb);
|
||||||
deckName = "5 colors";
|
deckName = "5 colors";
|
||||||
}
|
}
|
||||||
@@ -78,8 +80,9 @@ public class DeckgenUtil {
|
|||||||
gen.setUseArtifacts(Singletons.getModel().getPreferences().getPrefBoolean(FPref.DECKGEN_ARTIFACTS));
|
gen.setUseArtifacts(Singletons.getModel().getPreferences().getPrefBoolean(FPref.DECKGEN_ARTIFACTS));
|
||||||
ItemPoolView<PaperCard> cards = gen == null ? null : gen.getDeck(60, forAi);
|
ItemPoolView<PaperCard> cards = gen == null ? null : gen.getDeck(60, forAi);
|
||||||
|
|
||||||
if(null == deckName)
|
if (null == deckName) {
|
||||||
deckName = Lang.joinHomogenous(Arrays.asList(selection));
|
deckName = Lang.joinHomogenous(Arrays.asList(selection));
|
||||||
|
}
|
||||||
|
|
||||||
// After generating card lists, build deck.
|
// After generating card lists, build deck.
|
||||||
deck = new Deck("Random deck : " + deckName);
|
deck = new Deck("Random deck : " + deckName);
|
||||||
@@ -112,14 +115,15 @@ public class DeckgenUtil {
|
|||||||
IStorage<Deck> path = Singletons.getModel().getDecks().getConstructed();
|
IStorage<Deck> path = Singletons.getModel().getDecks().getConstructed();
|
||||||
String name = selection;
|
String name = selection;
|
||||||
int idxSlash = name.indexOf('/');
|
int idxSlash = name.indexOf('/');
|
||||||
while( idxSlash > 0 && path != null) {
|
while (idxSlash > 0 && path != null) {
|
||||||
String sf = name.substring(0, idxSlash).trim();
|
String sf = name.substring(0, idxSlash).trim();
|
||||||
path = path.getFolders().get(sf);
|
path = path.getFolders().get(sf);
|
||||||
name = name.substring(idxSlash+1).trim();
|
name = name.substring(idxSlash+1).trim();
|
||||||
idxSlash = name.indexOf('/');
|
idxSlash = name.indexOf('/');
|
||||||
};
|
};
|
||||||
if ( path == null )
|
if (path == null) {
|
||||||
throw new IllegalArgumentException("Path not found - " + selection);
|
throw new IllegalArgumentException("Path not found - " + selection);
|
||||||
|
}
|
||||||
return path.get(name);
|
return path.get(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -129,9 +133,10 @@ public class DeckgenUtil {
|
|||||||
|
|
||||||
public static QuestEvent getQuestEvent(final String name) {
|
public static QuestEvent getQuestEvent(final String name) {
|
||||||
QuestController qCtrl = Singletons.getModel().getQuest();
|
QuestController qCtrl = Singletons.getModel().getQuest();
|
||||||
for(QuestEventChallenge challenge : qCtrl.getChallenges()) {
|
for (QuestEventChallenge challenge : qCtrl.getChallenges()) {
|
||||||
if( challenge.getTitle().equals(name) )
|
if (challenge.getTitle().equals(name)) {
|
||||||
return challenge;
|
return challenge;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QuestEventDuel duel = Iterables.find(qCtrl.getDuelsManager().getAllDuels(), new Predicate<QuestEventDuel>() {
|
QuestEventDuel duel = Iterables.find(qCtrl.getDuelsManager().getAllDuels(), new Predicate<QuestEventDuel>() {
|
||||||
@@ -173,7 +178,6 @@ public class DeckgenUtil {
|
|||||||
final List<Deck> allQuestDecks = new ArrayList<Deck>();
|
final List<Deck> allQuestDecks = new ArrayList<Deck>();
|
||||||
QuestController qCtrl = Singletons.getModel().getQuest();
|
QuestController qCtrl = Singletons.getModel().getQuest();
|
||||||
|
|
||||||
|
|
||||||
for (final QuestEvent e : qCtrl.getDuelsManager().getAllDuels()) {
|
for (final QuestEvent e : qCtrl.getDuelsManager().getAllDuels()) {
|
||||||
allQuestDecks.add(e.getEventDeck());
|
allQuestDecks.add(e.getEventDeck());
|
||||||
}
|
}
|
||||||
@@ -189,20 +193,22 @@ public class DeckgenUtil {
|
|||||||
public static int[] randomSelectColors(int maxColors) {
|
public static int[] randomSelectColors(int maxColors) {
|
||||||
int nColors = MyRandom.getRandom().nextInt(3) + 1;
|
int nColors = MyRandom.getRandom().nextInt(3) + 1;
|
||||||
int[] result = new int[nColors];
|
int[] result = new int[nColors];
|
||||||
for(int i = 0; i < nColors; i++) {
|
for (int i = 0; i < nColors; i++) {
|
||||||
int next = MyRandom.getRandom().nextInt(maxColors);
|
int next = MyRandom.getRandom().nextInt(maxColors);
|
||||||
|
|
||||||
boolean isUnique = true;
|
boolean isUnique = true;
|
||||||
for(int j = 0; j < i; j++) {
|
for (int j = 0; j < i; j++) {
|
||||||
if(result[j] == next) {
|
if (result[j] == next) {
|
||||||
isUnique = false;
|
isUnique = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(isUnique)
|
if (isUnique) {
|
||||||
result[i] = next;
|
result[i] = next;
|
||||||
else
|
}
|
||||||
|
else {
|
||||||
i--; // try over with this number
|
i--; // try over with this number
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@@ -224,7 +230,6 @@ public class DeckgenUtil {
|
|||||||
* @param lst0 {@link javax.swing.JList}
|
* @param lst0 {@link javax.swing.JList}
|
||||||
*/
|
*/
|
||||||
public static void showDecklist(final Deck deck) {
|
public static void showDecklist(final Deck deck) {
|
||||||
|
|
||||||
if (deck == null) { return; }
|
if (deck == null) { return; }
|
||||||
|
|
||||||
// Dump into map and display.
|
// Dump into map and display.
|
||||||
@@ -234,16 +239,17 @@ public class DeckgenUtil {
|
|||||||
deckList.append(dName == null ? "" : dName + nl + nl);
|
deckList.append(dName == null ? "" : dName + nl + nl);
|
||||||
|
|
||||||
int nLines = 0;
|
int nLines = 0;
|
||||||
for(DeckSection s : DeckSection.values()){
|
for (DeckSection s : DeckSection.values()){
|
||||||
CardPool cp = deck.get(s);
|
CardPool cp = deck.get(s);
|
||||||
if ( cp == null || cp.isEmpty() )
|
if (cp == null || cp.isEmpty()) {
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
deckList.append(s.toString()).append(": ");
|
deckList.append(s.toString()).append(": ");
|
||||||
if ( s.isSingleCard() ) {
|
if (s.isSingleCard()) {
|
||||||
deckList.append(cp.get(0).getName()).append(nl);
|
deckList.append(cp.get(0).getName()).append(nl);
|
||||||
nLines++;
|
nLines++;
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
deckList.append(nl);
|
deckList.append(nl);
|
||||||
nLines++;
|
nLines++;
|
||||||
for (final Entry<PaperCard, Integer> ev : cp) {
|
for (final Entry<PaperCard, Integer> ev : cp) {
|
||||||
@@ -255,11 +261,11 @@ public class DeckgenUtil {
|
|||||||
nLines++;
|
nLines++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
final StringBuilder msg = new StringBuilder();
|
final StringBuilder msg = new StringBuilder();
|
||||||
if (nLines <= 32) {
|
if (nLines <= 32) {
|
||||||
msg.append(deckList.toString());
|
msg.append(deckList.toString());
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
msg.append("Decklist too long for dialog." + nl + nl);
|
msg.append("Decklist too long for dialog." + nl + nl);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -315,7 +321,8 @@ public class DeckgenUtil {
|
|||||||
if (appearances < 2) {
|
if (appearances < 2) {
|
||||||
schemes.add(cp);
|
schemes.add(cp);
|
||||||
schemesToAdd--;
|
schemesToAdd--;
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
attemptsLeft--;
|
attemptsLeft--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -334,23 +341,19 @@ public class DeckgenUtil {
|
|||||||
|
|
||||||
int phenoms = 0;
|
int phenoms = 0;
|
||||||
int targetsize = MyRandom.getRandom().nextInt(allPlanars.size()-10)+10;
|
int targetsize = MyRandom.getRandom().nextInt(allPlanars.size()-10)+10;
|
||||||
while(true)
|
while (true) {
|
||||||
{
|
|
||||||
PaperCard rndPlane = Aggregates.random(allPlanars);
|
PaperCard rndPlane = Aggregates.random(allPlanars);
|
||||||
allPlanars.remove(rndPlane);
|
allPlanars.remove(rndPlane);
|
||||||
|
|
||||||
if(rndPlane.getRules().getType().isPhenomenon() && phenoms < 2)
|
if (rndPlane.getRules().getType().isPhenomenon() && phenoms < 2) {
|
||||||
{
|
|
||||||
res.add(rndPlane);
|
res.add(rndPlane);
|
||||||
phenoms++;
|
phenoms++;
|
||||||
}
|
}
|
||||||
else if (rndPlane.getRules().getType().isPlane())
|
else if (rndPlane.getRules().getType().isPlane()) {
|
||||||
{
|
|
||||||
res.add(rndPlane);
|
res.add(rndPlane);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(allPlanars.isEmpty() || res.countAll() == targetsize)
|
if (allPlanars.isEmpty() || res.countAll() == targetsize) {
|
||||||
{
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,7 +41,6 @@ import forge.util.storage.IStorage;
|
|||||||
|
|
||||||
@SuppressWarnings("serial")
|
@SuppressWarnings("serial")
|
||||||
public class FDeckChooser extends JPanel implements IDecksComboBoxListener {
|
public class FDeckChooser extends JPanel implements IDecksComboBoxListener {
|
||||||
|
|
||||||
private final Color BORDER_COLOR = FSkin.getColor(FSkin.Colors.CLR_TEXT).getColor().darker();
|
private final Color BORDER_COLOR = FSkin.getColor(FSkin.Colors.CLR_TEXT).getColor().darker();
|
||||||
|
|
||||||
private boolean isUISetup = false;
|
private boolean isUISetup = false;
|
||||||
@@ -116,7 +115,6 @@ public class FDeckChooser extends JPanel implements IDecksComboBoxListener {
|
|||||||
lst.setSelectedIndices(getSelectedDeckIndices(Arrays.asList(listData), new int[]{0, 1}));
|
lst.setSelectedIndices(getSelectedDeckIndices(Arrays.asList(listData), new int[]{0, 1}));
|
||||||
lst.ensureIndexIsVisible(lst.getSelectedIndices()[0]);
|
lst.ensureIndexIsVisible(lst.getSelectedIndices()[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateThemes() {
|
private void updateThemes() {
|
||||||
@@ -141,7 +139,6 @@ public class FDeckChooser extends JPanel implements IDecksComboBoxListener {
|
|||||||
lst.setSelectedIndices(getSelectedDeckIndices(listData, new int[]{0}));
|
lst.setSelectedIndices(getSelectedDeckIndices(listData, new int[]{0}));
|
||||||
lst.ensureIndexIsVisible(lst.getSelectedIndices()[0]);
|
lst.ensureIndexIsVisible(lst.getSelectedIndices()[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateCustom() {
|
private void updateCustom() {
|
||||||
@@ -226,7 +223,6 @@ public class FDeckChooser extends JPanel implements IDecksComboBoxListener {
|
|||||||
lst.setSelectedIndices(getSelectedDeckIndices(listData, new int[]{0}));
|
lst.setSelectedIndices(getSelectedDeckIndices(listData, new int[]{0}));
|
||||||
lst.ensureIndexIsVisible(lst.getSelectedIndices()[0]);
|
lst.ensureIndexIsVisible(lst.getSelectedIndices()[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Deck getDeck() {
|
public Deck getDeck() {
|
||||||
@@ -236,17 +232,21 @@ public class FDeckChooser extends JPanel implements IDecksComboBoxListener {
|
|||||||
if (selection.isEmpty()) { return null; }
|
if (selection.isEmpty()) { return null; }
|
||||||
|
|
||||||
// Special branch for quest events
|
// Special branch for quest events
|
||||||
if (lst0.getName().equals(DeckgenUtil.DeckTypes.QUESTEVENTS.toString()))
|
if (lst0.getName().equals(DeckgenUtil.DeckTypes.QUESTEVENTS.toString())) {
|
||||||
return DeckgenUtil.getQuestEvent(selection.get(0)).getEventDeck();
|
return DeckgenUtil.getQuestEvent(selection.get(0)).getEventDeck();
|
||||||
if (lst0.getName().equals(DeckgenUtil.DeckTypes.COLORS.toString()) && DeckgenUtil.colorCheck(selection))
|
}
|
||||||
|
if (lst0.getName().equals(DeckgenUtil.DeckTypes.COLORS.toString()) && DeckgenUtil.colorCheck(selection)) {
|
||||||
return DeckgenUtil.buildColorDeck(selection, isAi);
|
return DeckgenUtil.buildColorDeck(selection, isAi);
|
||||||
if (lst0.getName().equals(DeckgenUtil.DeckTypes.THEMES.toString()))
|
}
|
||||||
|
if (lst0.getName().equals(DeckgenUtil.DeckTypes.THEMES.toString())) {
|
||||||
return DeckgenUtil.buildThemeDeck(selection.get(0));
|
return DeckgenUtil.buildThemeDeck(selection.get(0));
|
||||||
if (lst0.getName().equals(DeckgenUtil.DeckTypes.CUSTOM.toString()))
|
}
|
||||||
|
if (lst0.getName().equals(DeckgenUtil.DeckTypes.CUSTOM.toString())) {
|
||||||
return DeckgenUtil.getConstructedDeck(selection.get(0));
|
return DeckgenUtil.getConstructedDeck(selection.get(0));
|
||||||
if (lst0.getName().equals(DeckgenUtil.DeckTypes.PRECON.toString()))
|
}
|
||||||
|
if (lst0.getName().equals(DeckgenUtil.DeckTypes.PRECON.toString())) {
|
||||||
return DeckgenUtil.getPreconDeck(selection.get(0));
|
return DeckgenUtil.getPreconDeck(selection.get(0));
|
||||||
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -268,7 +268,6 @@ public class FDeckChooser extends JPanel implements IDecksComboBoxListener {
|
|||||||
return new RegisteredPlayer(getDeck());
|
return new RegisteredPlayer(getDeck());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public final boolean isAi() {
|
public final boolean isAi() {
|
||||||
return isAi;
|
return isAi;
|
||||||
}
|
}
|
||||||
@@ -424,5 +423,4 @@ public class FDeckChooser extends JPanel implements IDecksComboBoxListener {
|
|||||||
return defaultSelection;
|
return defaultSelection;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,10 +23,9 @@ import com.google.common.base.Function;
|
|||||||
|
|
||||||
import forge.util.IItemSerializer;
|
import forge.util.IItemSerializer;
|
||||||
|
|
||||||
//reads and writeDeck Deck objects
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
* DeckManager class.
|
* StorageImmediatelySerialized class.
|
||||||
* </p>
|
* </p>
|
||||||
*
|
*
|
||||||
* @param <T> the generic type
|
* @param <T> the generic type
|
||||||
@@ -34,7 +33,6 @@ import forge.util.IItemSerializer;
|
|||||||
* @version $Id$
|
* @version $Id$
|
||||||
*/
|
*/
|
||||||
public class StorageImmediatelySerialized<T> extends StorageBase<T> {
|
public class StorageImmediatelySerialized<T> extends StorageBase<T> {
|
||||||
|
|
||||||
private final IItemSerializer<T> serializer;
|
private final IItemSerializer<T> serializer;
|
||||||
private final IStorage<IStorage<T>> subfolders;
|
private final IStorage<IStorage<T>> subfolders;
|
||||||
|
|
||||||
@@ -47,7 +45,7 @@ public class StorageImmediatelySerialized<T> extends StorageBase<T> {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
* Constructor for DeckManager.
|
* Constructor for StorageImmediatelySerialized.
|
||||||
* </p>
|
* </p>
|
||||||
*
|
*
|
||||||
* @param io the io
|
* @param io the io
|
||||||
@@ -56,7 +54,6 @@ public class StorageImmediatelySerialized<T> extends StorageBase<T> {
|
|||||||
this(name, io, false);
|
this(name, io, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public StorageImmediatelySerialized(String name, final IItemSerializer<T> io, boolean withSubFolders) {
|
public StorageImmediatelySerialized(String name, final IItemSerializer<T> io, boolean withSubFolders) {
|
||||||
super(name, io);
|
super(name, io);
|
||||||
this.serializer = io;
|
this.serializer = io;
|
||||||
@@ -66,7 +63,7 @@ public class StorageImmediatelySerialized<T> extends StorageBase<T> {
|
|||||||
/*
|
/*
|
||||||
* (non-Javadoc)
|
* (non-Javadoc)
|
||||||
*
|
*
|
||||||
* @see forge.deck.IFolderMap#add(T)
|
* @see forge.util.storage.StorageBase#add(T)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public final void add(final T deck) {
|
public final void add(final T deck) {
|
||||||
@@ -78,7 +75,7 @@ public class StorageImmediatelySerialized<T> extends StorageBase<T> {
|
|||||||
/*
|
/*
|
||||||
* (non-Javadoc)
|
* (non-Javadoc)
|
||||||
*
|
*
|
||||||
* @see forge.deck.IFolderMap#delete(java.lang.String)
|
* @see forge.util.storage.StorageBase#delete(java.lang.String)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public final void delete(final String deckName) {
|
public final void delete(final String deckName) {
|
||||||
|
|||||||
@@ -5,16 +5,13 @@ import java.util.HashMap;
|
|||||||
|
|
||||||
import com.google.common.base.Function;
|
import com.google.common.base.Function;
|
||||||
|
|
||||||
|
|
||||||
public class StorageNestedFolders<T> extends StorageBase<IStorage<T>> {
|
public class StorageNestedFolders<T> extends StorageBase<IStorage<T>> {
|
||||||
|
|
||||||
private final File thisFolder;
|
private final File thisFolder;
|
||||||
|
|
||||||
public StorageNestedFolders(File thisFolder, Iterable<File> subfolders, Function<File, IStorage<T>> factory) {
|
public StorageNestedFolders(File thisFolder, Iterable<File> subfolders, Function<File, IStorage<T>> factory) {
|
||||||
super("<Subfolders>", new HashMap<String, IStorage<T>>());
|
super("<Subfolders>", new HashMap<String, IStorage<T>>());
|
||||||
this.thisFolder = thisFolder;
|
this.thisFolder = thisFolder;
|
||||||
for(File sf : subfolders )
|
for (File sf : subfolders ) {
|
||||||
{
|
|
||||||
IStorage<T> newUnit = factory.apply(sf);
|
IStorage<T> newUnit = factory.apply(sf);
|
||||||
map.put(sf.getName(), newUnit);
|
map.put(sf.getName(), newUnit);
|
||||||
}
|
}
|
||||||
@@ -37,8 +34,8 @@ public class StorageNestedFolders<T> extends StorageBase<IStorage<T>> {
|
|||||||
IStorage<T> f = map.remove(deckName);
|
IStorage<T> f = map.remove(deckName);
|
||||||
|
|
||||||
// TODO: Clear all that files from disk
|
// TODO: Clear all that files from disk
|
||||||
if ( f != null )
|
if (f != null) {
|
||||||
subdir.delete(); // won't work if not empty;
|
subdir.delete(); // won't work if not empty;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user