mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-18 19:58:00 +00:00
removed some unused code
This commit is contained in:
3
.gitattributes
vendored
3
.gitattributes
vendored
@@ -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/CardFactoryPlaneswalkers.java svneol=native#text/plain
|
||||||
src/main/java/forge/card/cardfactory/CardFactorySorceries.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/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/PreloadingCardFactory.java svneol=native#text/plain
|
||||||
src/main/java/forge/card/cardfactory/package-info.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
|
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/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/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/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/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/FindNonDirectoriesSkipDotDirectoriesGenerator.java svneol=native#text/plain
|
||||||
src/main/java/net/slightlymagic/braids/util/generator/GeneratorFromArray.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/PhaseHandlerTest.java -text
|
||||||
src/test/java/forge/RunTest.java svneol=native#text/plain
|
src/test/java/forge/RunTest.java svneol=native#text/plain
|
||||||
src/test/java/forge/TinyTest.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/cardFactory/CardFactoryUtilTest.java svneol=native#text/plain
|
||||||
src/test/java/forge/card/mana/ManaPartTest.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
|
src/test/java/forge/deck/generate/Generate2ColorDeckTest.java svneol=native#text/plain
|
||||||
|
|||||||
@@ -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 <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
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<String> cardsFailedToLoad = new ArrayList<String>();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 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<Card> 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<String, Card> 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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -17,7 +17,6 @@
|
|||||||
*/
|
*/
|
||||||
package forge.gui.download;
|
package forge.gui.download;
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
|||||||
@@ -141,8 +141,6 @@ public final class NewConstants {
|
|||||||
/** Constant <code>IMAGE_ICON="image/icon"</code>. */
|
/** Constant <code>IMAGE_ICON="image/icon"</code>. */
|
||||||
public static final String IMAGE_ICON = "image/icon";
|
public static final String IMAGE_ICON = "image/icon";
|
||||||
public static final String IMAGE_SEALED_PRODUCT = "image/product";
|
public static final String IMAGE_SEALED_PRODUCT = "image/product";
|
||||||
/** Constant <code>PICS_BOOSTER="pics/booster"</code>. */
|
|
||||||
public static final String PICS_BOOSTER = "pics/booster";
|
|
||||||
/** Constant <code>PICS_BOOSTER_IMAGES="pics/booster/images"</code>. */
|
/** Constant <code>PICS_BOOSTER_IMAGES="pics/booster/images"</code>. */
|
||||||
public static final String PICS_BOOSTER_IMAGES = "pics/booster/images";
|
public static final String PICS_BOOSTER_IMAGES = "pics/booster/images";
|
||||||
/** Constant <code>SOUND_BASE="sound/base"</code>. */
|
/** Constant <code>SOUND_BASE="sound/base"</code>. */
|
||||||
|
|||||||
@@ -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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -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;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <p>
|
|
||||||
* Mana_PartTest class.
|
|
||||||
* </p>
|
|
||||||
*
|
|
||||||
* @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<String> cardNames = new TreeSet<String>();
|
|
||||||
|
|
||||||
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());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user