diff --git a/.gitattributes b/.gitattributes index 850852a3c57..6b2306d60ab 100644 --- a/.gitattributes +++ b/.gitattributes @@ -11350,7 +11350,6 @@ src/main/java/forge/card/cardfactory/CardFactoryLands.java svneol=native#text/pl src/main/java/forge/card/cardfactory/CardFactoryPlaneswalkers.java svneol=native#text/plain src/main/java/forge/card/cardfactory/CardFactorySorceries.java svneol=native#text/plain src/main/java/forge/card/cardfactory/CardFactoryUtil.java svneol=native#text/plain -src/main/java/forge/card/cardfactory/LazyCardFactory.java svneol=native#text/plain src/main/java/forge/card/cardfactory/PreloadingCardFactory.java svneol=native#text/plain src/main/java/forge/card/cardfactory/package-info.java svneol=native#text/plain src/main/java/forge/card/cost/Cost.java svneol=native#text/plain @@ -11740,7 +11739,6 @@ src/main/java/forge/view/package-info.java svneol=native#text/plain src/main/java/net/slightlymagic/braids/LICENSE.txt svneol=native#text/plain src/main/java/net/slightlymagic/braids/util/ClumsyRunnable.java svneol=native#text/plain src/main/java/net/slightlymagic/braids/util/ImmutableIterableFrom.java svneol=native#text/plain -src/main/java/net/slightlymagic/braids/util/NotImplementedError.java svneol=native#text/plain src/main/java/net/slightlymagic/braids/util/UtilFunctions.java svneol=native#text/plain src/main/java/net/slightlymagic/braids/util/generator/FindNonDirectoriesSkipDotDirectoriesGenerator.java svneol=native#text/plain src/main/java/net/slightlymagic/braids/util/generator/GeneratorFromArray.java svneol=native#text/plain @@ -11779,7 +11777,6 @@ src/test/java/forge/PanelTest.java svneol=native#text/plain src/test/java/forge/PhaseHandlerTest.java -text src/test/java/forge/RunTest.java svneol=native#text/plain src/test/java/forge/TinyTest.java svneol=native#text/plain -src/test/java/forge/card/cardFactory/CardFactoryTest.java svneol=native#text/plain src/test/java/forge/card/cardFactory/CardFactoryUtilTest.java svneol=native#text/plain src/test/java/forge/card/mana/ManaPartTest.java svneol=native#text/plain src/test/java/forge/deck/generate/Generate2ColorDeckTest.java svneol=native#text/plain diff --git a/src/main/java/forge/card/cardfactory/LazyCardFactory.java b/src/main/java/forge/card/cardfactory/LazyCardFactory.java deleted file mode 100644 index c65e5cfd475..00000000000 --- a/src/main/java/forge/card/cardfactory/LazyCardFactory.java +++ /dev/null @@ -1,120 +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 . - */ -package forge.card.cardfactory; - -import java.io.File; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; -import java.util.Map; - -import net.slightlymagic.braids.util.NotImplementedError; -import forge.Card; -import forge.CardReader; -import forge.CardUtil; -import forge.Player; - -/** - * Like PreloadingCardFactory, but loads cards one at a time, instead of all at - * once; only used for unit testing at this time. - * - * Iteration has been disabled for this class. - */ -public class LazyCardFactory extends AbstractCardFactory { - - private final CardReader cardReader; - private final List cardsFailedToLoad = new ArrayList(); - - /** - * Construct an instance, pointing it to a specific cardsfolder. - * - * @param cardsfolder - * a directory containing cardsfolder.zip or subdirectories and - * txt files. - */ - public LazyCardFactory(final File cardsfolder) { - super(cardsfolder); - - this.getMap().clear(); - this.cardReader = new CardReader(cardsfolder, this.getMap()); - } - - /** - * Getter for cardReader. - * - * @return cardReader - */ - public final CardReader getCardReader() { - return this.cardReader; - } - - /** - * Not implemented; do not call. - * - * @return never - */ - @Override - public final Iterator iterator() { - throw new NotImplementedError(); - } - - /** - * Like AbstractCardFactory.getCard2, but loads the card into the map first - * if it's not there. - * - * @param cardName - * the name of the card to fetch - * @param owner - * the owner of the returned card - * - * @return a new Card instance with abilities and an owner - */ - @Override - protected final Card getCard2(final String cardName, final Player owner) { - final Map cardNamesToCards = this.getMap(); - Card result = null; - boolean wasLoaded = cardNamesToCards.containsKey(cardName); - - if (!wasLoaded) { - - if (this.cardsFailedToLoad.contains(cardName)) { - return null; // no more System.err, exceptions of other drama - - // just return null. - } - - final String canonicalASCIIName = CardUtil.canonicalizeCardName(cardName); - final Card cardRequested = this.getCardReader().findCard(canonicalASCIIName); - if (null != cardRequested) { - cardNamesToCards.put(cardName, cardRequested); - wasLoaded = true; - } else { - this.cardsFailedToLoad.add(cardName); - System.err.println(String.format("LazyCF: Tried to read from disk card '%s' but not found it!", - cardName)); - return null; - } - } - - // Factory should return us a copy, ready for changes. - if (wasLoaded) { - result = super.getCard2(cardName, owner); - } - - return result; - } -} diff --git a/src/main/java/forge/gui/download/GuiDownloadQuestImages.java b/src/main/java/forge/gui/download/GuiDownloadQuestImages.java index 95d1f056ea9..bc3ca7dad8f 100644 --- a/src/main/java/forge/gui/download/GuiDownloadQuestImages.java +++ b/src/main/java/forge/gui/download/GuiDownloadQuestImages.java @@ -17,7 +17,6 @@ */ package forge.gui.download; -import java.io.File; import java.util.ArrayList; import java.util.List; diff --git a/src/main/java/forge/properties/NewConstants.java b/src/main/java/forge/properties/NewConstants.java index 9e5132b696d..0afdc9e2f0e 100644 --- a/src/main/java/forge/properties/NewConstants.java +++ b/src/main/java/forge/properties/NewConstants.java @@ -141,8 +141,6 @@ public final class NewConstants { /** Constant IMAGE_ICON="image/icon". */ public static final String IMAGE_ICON = "image/icon"; public static final String IMAGE_SEALED_PRODUCT = "image/product"; - /** Constant PICS_BOOSTER="pics/booster". */ - public static final String PICS_BOOSTER = "pics/booster"; /** Constant PICS_BOOSTER_IMAGES="pics/booster/images". */ public static final String PICS_BOOSTER_IMAGES = "pics/booster/images"; /** Constant SOUND_BASE="sound/base". */ diff --git a/src/main/java/net/slightlymagic/braids/util/NotImplementedError.java b/src/main/java/net/slightlymagic/braids/util/NotImplementedError.java deleted file mode 100644 index 8d8a6abca31..00000000000 --- a/src/main/java/net/slightlymagic/braids/util/NotImplementedError.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * The files in the directory "net/slightlymagic/braids" and in all subdirectories of it (the "Files") are - * Copyright 2011 Braids Cabal-Conjurer. They are available under either Forge's - * main license (the GNU Public License; see LICENSE.txt in Forge's top directory) - * or under the Apache License, as explained below. - * - * The Files are additionally licensed under the Apache License, Version 2.0 (the - * "Apache License"); you may not use the files in this directory except in - * compliance with one of its two licenses. You may obtain a copy of the Apache - * License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the Apache License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the Apache License for the specific language governing permissions and - * limitations under the Apache License. - * - */ -package net.slightlymagic.braids.util; - -/** - * This exception indicates the particular method (or part of a method) being - * called has not been implemented; getting this exception is generally - * considered a programming error. - * - * Throwing this exception does not necessarily mean the method will be - * implemented at any point in the future. - */ -public class NotImplementedError extends RuntimeException { - - private static final long serialVersionUID = -6714022569997781370L; - - /** - * No-arg constructor; this usually means the entire method or block from - * which it is thrown has not been implemented. - */ - public NotImplementedError() { - super(); - } - - /** - * Indicates what has not been implemented. - * - * @param message - * indicates what exactly has not been implemented. May include - * information about future plans to implement the described - * section of code. - */ - public NotImplementedError(final String message) { - super(message); - } - - /** - * Like the no-arg constructor, but with a cause parameter. - * - * @param cause - * the exception that caused this one to be thrown - * - * @see #NotImplementedError() - */ - public NotImplementedError(final Throwable cause) { - super(cause); - } - - /** - * Like the String constructor, but with a cause parameter. - * - * @param message - * indicates what exactly has not been implemented. May include - * information about future plans to implement the described - * section of code. - * - * @param cause - * the exception that caused this one to be thrown - * - * @see #NotImplementedError(String) - */ - public NotImplementedError(final String message, final Throwable cause) { - super(message, cause); - } -} diff --git a/src/test/java/forge/card/cardFactory/CardFactoryTest.java b/src/test/java/forge/card/cardFactory/CardFactoryTest.java deleted file mode 100644 index fa70bcb1d69..00000000000 --- a/src/test/java/forge/card/cardFactory/CardFactoryTest.java +++ /dev/null @@ -1,122 +0,0 @@ -package forge.card.cardFactory; - -import java.util.Set; -import java.util.TreeSet; - -import net.slightlymagic.braids.util.ClumsyRunnable; -import net.slightlymagic.braids.util.testng.BraidsAssertFunctions; - -import org.testng.Assert; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; - -import forge.Card; -import forge.CardList; -import forge.card.cardfactory.CardFactoryInterface; -import forge.card.cardfactory.LazyCardFactory; -import forge.card.cardfactory.PreloadingCardFactory; -import forge.model.FModel; -import forge.properties.ForgeProps; -import forge.properties.NewConstants; - -//import net.slightlymagic.braids.testng.BraidsAssertFunctions; - -/** - *

- * Mana_PartTest class. - *

- * - * @author Forge - * @version $Id$ - */ -@Test(groups = { "UnitTest" }, timeOut = CardFactoryTest.DEFAULT_TEST_TIMEOUT_MS, enabled = false) -public class CardFactoryTest { - - /** The default time to allow a test to run before TestNG ignores it. */ - public static final int DEFAULT_TEST_TIMEOUT_MS = 5000; - // on 8/18/11 11:43 - // PM - - private transient CardFactoryInterface factory; - - /** - * Executed before each test method, as in JUnit. - */ - @BeforeMethod - public final void setUp() { - FModel.loadDynamicGamedata(); - this.factory = new LazyCardFactory(ForgeProps.getFile(NewConstants.CARDSFOLDER)); - } - - /** - * Just a quick test to see if Arc-Slogger is in the database, and if it has - * the correct owner. - */ - @Test(enabled = false, timeOut = CardFactoryTest.DEFAULT_TEST_TIMEOUT_MS) - public final void test_getCard_1() { - final Card card = this.factory.getCard("Arc-Slogger", null); - Assert.assertNotNull(card, "card is not null"); - Assert.assertNull(card.getOwner(), "card has correct owner"); - } - - /** - * Make sure the method throws an exception when it's supposed to. - */ - @Test(enabled = false, timeOut = CardFactoryTest.DEFAULT_TEST_TIMEOUT_MS) - public final void test_getRandomCombinationWithoutRepetition_tooLarge() { - // by - // Braids - // on - // 8/18/11 - // 11:39 - // PM - BraidsAssertFunctions.assertThrowsException(IllegalArgumentException.class, new ClumsyRunnable() { - @Override - public void run() throws Exception { - // 11:40 PM - CardFactoryTest.this.factory.getRandomCombinationWithoutRepetition(CardFactoryTest.this.factory.size()); - } - }); - - BraidsAssertFunctions.assertThrowsException(IllegalArgumentException.class, new ClumsyRunnable() { - @Override - public void run() throws Exception { - // 11:40 PM - final int largeDivisorForRandomCombo = 4; - // 8/18/11 11:41 PM - CardFactoryTest.this.factory.getRandomCombinationWithoutRepetition(CardFactoryTest.this.factory.size() - / largeDivisorForRandomCombo); - } - }); - } - - /** - * Make sure the method works. - * - * This doesn't work with LazyCardFactory, so it is too slow to enable by - * default. - */ - @Test(enabled = false, timeOut = CardFactoryTest.DEFAULT_TEST_TIMEOUT_MS) - public final void test_getRandomCombinationWithoutRepetition_oneTenth() { - // by - // Braids - // on - // 8/18/11 - // 11:39 - // PM - this.factory = new PreloadingCardFactory(ForgeProps.getFile(NewConstants.CARDSFOLDER)); - final int divisor = 10; - final CardList actual = this.factory.getRandomCombinationWithoutRepetition(this.factory.size() / divisor); - - final Set cardNames = new TreeSet(); - - for (final Card card : actual) { - Assert.assertNotNull(card); - cardNames.add(card.getName()); - } - - // Make sure we got a unique set of card names and that all are - // accounted for. - Assert.assertEquals(actual.size(), cardNames.size()); - } -}