mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-17 19:28:01 +00:00
removed ReadDraftBoosterPack class - it was used by tests only.
removed BoosterDraftAITest - it didn't succeed anyway (needs to have CardDb initialized to succeed)
This commit is contained in:
2
.gitattributes
vendored
2
.gitattributes
vendored
@@ -9669,7 +9669,6 @@ src/main/java/forge/card/CardType.java -text
|
||||
src/main/java/forge/card/MtgDataParser.java -text
|
||||
src/main/java/forge/card/QuestBoosterPack.java svneol=native#text/plain
|
||||
src/main/java/forge/card/ReadBoosterPack.java svneol=native#text/plain
|
||||
src/main/java/forge/card/ReadDraftBoosterPack.java svneol=native#text/plain
|
||||
src/main/java/forge/card/abilityFactory/AbilityFactory.java svneol=native#text/plain
|
||||
src/main/java/forge/card/abilityFactory/AbilityFactory_AlterLife.java svneol=native#text/plain
|
||||
src/main/java/forge/card/abilityFactory/AbilityFactory_Animate.java svneol=native#text/plain
|
||||
@@ -9979,7 +9978,6 @@ src/main/java/tree/properties/package-info.java svneol=native#text/plain
|
||||
src/main/java/tree/properties/types/FileType.java svneol=native#text/plain
|
||||
src/main/java/tree/properties/types/package-info.java svneol=native#text/plain
|
||||
src/site/apt/index.apt -text
|
||||
src/test/java/forge/BoosterDraftAITest.java svneol=native#text/plain
|
||||
src/test/java/forge/BoosterDraftTest.java svneol=native#text/plain
|
||||
src/test/java/forge/BoosterDraft_1Test.java svneol=native#text/plain
|
||||
src/test/java/forge/CardColorTest.java svneol=native#text/plain
|
||||
|
||||
@@ -1,162 +0,0 @@
|
||||
package forge.card;
|
||||
|
||||
|
||||
import forge.Constant;
|
||||
import forge.MyRandom;
|
||||
import forge.error.ErrorViewer;
|
||||
import forge.item.CardDb;
|
||||
import forge.item.CardPrinted;
|
||||
import forge.item.ItemPool;
|
||||
import forge.item.ItemPoolView;
|
||||
import forge.properties.ForgeProps;
|
||||
import forge.properties.NewConstants;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import net.slightlymagic.maxmtg.Predicate;
|
||||
|
||||
|
||||
/**
|
||||
* <p>ReadDraftBoosterPack class.</p>
|
||||
*
|
||||
* @author Forge
|
||||
* @version $Id$
|
||||
*/
|
||||
public class ReadDraftBoosterPack implements NewConstants {
|
||||
|
||||
/** Constant <code>comment="//"</code>. */
|
||||
private static final String comment = "//";
|
||||
|
||||
private List<CardPrinted> commonCreatureList = new ArrayList<CardPrinted>();
|
||||
private List<CardPrinted> commonNonCreatureList = new ArrayList<CardPrinted>();
|
||||
|
||||
private List<CardPrinted> commonList = new ArrayList<CardPrinted>();
|
||||
private List<CardPrinted> uncommonList = new ArrayList<CardPrinted>();
|
||||
private List<CardPrinted> rareList = new ArrayList<CardPrinted>();
|
||||
|
||||
/**
|
||||
* <p>Constructor for ReadDraftBoosterPack.</p>
|
||||
*/
|
||||
public ReadDraftBoosterPack() {
|
||||
setup();
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>getBoosterPack.</p>
|
||||
*
|
||||
* @return a {@link forge.CardList} object.
|
||||
*/
|
||||
public final ItemPoolView<CardPrinted> getBoosterPack() {
|
||||
ItemPool<CardPrinted> pack = new ItemPool<CardPrinted>(CardPrinted.class);
|
||||
|
||||
pack.add(getRandomCard(rareList));
|
||||
|
||||
for (int i = 0; i < 3; i++)
|
||||
pack.add(getRandomCard(uncommonList));
|
||||
|
||||
//11 commons, 7 creature 4 noncreature
|
||||
List<CardPrinted> variety;
|
||||
for (int i = 0; i < 7; i++) {
|
||||
variety = getVariety(commonCreatureList);
|
||||
pack.add(getRandomCard(variety));
|
||||
}
|
||||
|
||||
for (int i = 0; i < 4; i++) {
|
||||
variety = getVariety(commonNonCreatureList);
|
||||
pack.add(getRandomCard(variety));
|
||||
}
|
||||
|
||||
if (pack.countAll() != 15)
|
||||
throw new RuntimeException("ReadDraftBoosterPack : getBoosterPack() error, pack is not 15 cards - "
|
||||
+ pack.countAll());
|
||||
|
||||
return pack;
|
||||
}
|
||||
|
||||
//return CardList of 5 or 6 cards, one for each color and maybe an artifact
|
||||
private List<CardPrinted> getVariety(final List<CardPrinted> in) {
|
||||
List<CardPrinted> out = new ArrayList<CardPrinted>();
|
||||
Collections.shuffle(in, MyRandom.random);
|
||||
|
||||
for (int i = 0; i < Constant.Color.Colors.length; i++) {
|
||||
CardPrinted check = findColor(in, i);
|
||||
if (check != null) { out.add(check); }
|
||||
}
|
||||
|
||||
return out;
|
||||
} //getVariety()
|
||||
|
||||
private static CardPrinted findColor(final List<CardPrinted> in, final int color) {
|
||||
Predicate<CardRules> filter = null;
|
||||
switch (color) {
|
||||
case 0: filter = CardRules.Predicates.Presets.isWhite; break;
|
||||
case 1: filter = CardRules.Predicates.Presets.isBlue; break;
|
||||
case 2: filter = CardRules.Predicates.Presets.isBlack; break;
|
||||
case 3: filter = CardRules.Predicates.Presets.isRed; break;
|
||||
case 4: filter = CardRules.Predicates.Presets.isGreen; break;
|
||||
case 5: filter = CardRules.Predicates.Presets.isColorless; break;
|
||||
default: break;
|
||||
}
|
||||
if (null == filter) { return null; }
|
||||
return filter.first(in, CardPrinted.fnGetRules);
|
||||
}
|
||||
|
||||
|
||||
|
||||
private static CardPrinted getRandomCard(final List<CardPrinted> list) {
|
||||
for (int i = 0; i < 10; i++) {
|
||||
Collections.shuffle(list, MyRandom.random);
|
||||
}
|
||||
int index = MyRandom.random.nextInt(list.size());
|
||||
return list.get(index);
|
||||
} //getRandomCard()
|
||||
|
||||
|
||||
/**
|
||||
* <p>setup.</p>
|
||||
*/
|
||||
private void setup() {
|
||||
CardDb db = CardDb.instance();
|
||||
commonList = db.getCards(readFile(ForgeProps.getFile(DRAFT.COMMON)));
|
||||
uncommonList = db.getCards(readFile(ForgeProps.getFile(DRAFT.UNCOMMON)));
|
||||
rareList = db.getCards(readFile(ForgeProps.getFile(DRAFT.RARE)));
|
||||
|
||||
System.out.println("commonList size:" + commonList.size());
|
||||
System.out.println("ucommonList size:" + uncommonList.size());
|
||||
System.out.println("rareList size:" + rareList.size());
|
||||
|
||||
CardRules.Predicates.Presets.isCreature.split(commonList, CardPrinted.fnGetRules,
|
||||
commonCreatureList, commonNonCreatureList);
|
||||
|
||||
} //setup()
|
||||
|
||||
private List<String> readFile(final File file) {
|
||||
List<String> cardList = new ArrayList<String>();
|
||||
|
||||
BufferedReader in;
|
||||
try {
|
||||
in = new BufferedReader(new FileReader(file));
|
||||
String line = in.readLine();
|
||||
|
||||
//stop reading if end of file or blank line is read
|
||||
while (line != null && (line.trim().length() != 0)) {
|
||||
if (!line.startsWith(comment)) {
|
||||
cardList.add(line.trim());
|
||||
}
|
||||
|
||||
line = in.readLine();
|
||||
}
|
||||
|
||||
} catch (Exception ex) {
|
||||
ErrorViewer.showError(ex);
|
||||
throw new RuntimeException("ReadDraftBoosterPack : readFile error, " + ex);
|
||||
}
|
||||
|
||||
return cardList;
|
||||
} //readFile()
|
||||
}
|
||||
@@ -1,59 +0,0 @@
|
||||
package forge;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import forge.card.ReadDraftBoosterPack;
|
||||
import forge.deck.Deck;
|
||||
import forge.game.limited.BoosterDraftAI;
|
||||
import forge.item.CardPrinted;
|
||||
import forge.item.ItemPool;
|
||||
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
@Test(groups = {"UnitTest"}, timeOut = 5000, enabled = false)
|
||||
public class BoosterDraftAITest {
|
||||
|
||||
/**
|
||||
* <p>runTestPrint.</p>
|
||||
*/
|
||||
@Test(timeOut = 5000)
|
||||
public void runTestPrint() {
|
||||
BoosterDraftAI ai = new BoosterDraftAI();
|
||||
runTest(ai);
|
||||
|
||||
Deck[] deck = ai.getDecks();
|
||||
|
||||
for (int outer = 0; outer < 7; outer++) {
|
||||
Deck thisDeck = deck[outer];
|
||||
System.out.print(thisDeck.countMain() + " - ");
|
||||
|
||||
List<CardPrinted> cards = thisDeck.getMain().toFlatList();
|
||||
for (int i = 0; i < 16; i++)
|
||||
System.out.print(cards.get(i) + ", ");
|
||||
|
||||
System.out.println("");
|
||||
|
||||
for (int i = 16; i < 22; i++)
|
||||
System.out.print(cards.get(i) + ", ");
|
||||
|
||||
System.out.println("\n");
|
||||
}//for outer
|
||||
}//runTestPrint()
|
||||
|
||||
@Test(timeOut = 5000)
|
||||
public void runTest(BoosterDraftAI ai) {
|
||||
ReadDraftBoosterPack booster = new ReadDraftBoosterPack();
|
||||
for (int outer = 0; outer < 1; outer++) {
|
||||
ItemPool<CardPrinted> allBooster = new ItemPool<CardPrinted>(CardPrinted.class);
|
||||
for (int i = 0; i < 21; i++)
|
||||
allBooster.addAll(booster.getBoosterPack());
|
||||
|
||||
CardList forgeCardlist = allBooster.toForgeCardList();
|
||||
int stop = forgeCardlist.size();
|
||||
for (int i = 0; i < stop; i++) {
|
||||
forgeCardlist.remove(ai.choose(forgeCardlist, i));
|
||||
}
|
||||
//ai.checkDeckList(ai.deck);
|
||||
}
|
||||
}//runTest()
|
||||
}
|
||||
@@ -1,10 +1,11 @@
|
||||
package forge;
|
||||
|
||||
import forge.card.ReadDraftBoosterPack;
|
||||
import forge.card.BoosterGenerator;
|
||||
import forge.deck.Deck;
|
||||
|
||||
import forge.game.limited.BoosterDraft;
|
||||
import forge.item.CardPrinted;
|
||||
import forge.item.ItemPool;
|
||||
import forge.item.ItemPoolView;
|
||||
|
||||
import org.testng.annotations.Test;
|
||||
@@ -36,8 +37,8 @@ public class BoosterDraftTest implements BoosterDraft {
|
||||
*/
|
||||
public ItemPoolView<CardPrinted> nextChoice() {
|
||||
n--;
|
||||
ReadDraftBoosterPack pack = new ReadDraftBoosterPack();
|
||||
return pack.getBoosterPack();
|
||||
BoosterGenerator pack = new BoosterGenerator("M11");
|
||||
return ItemPool.createFrom(pack.getBoosterPack(), CardPrinted.class);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
|
||||
Reference in New Issue
Block a user