- Fix DeckHints and put back in to LimitedDeck generation.

This commit is contained in:
mcrawford620
2012-08-02 23:02:24 +00:00
parent 1af53f38c2
commit 5ba0659f05
27 changed files with 311 additions and 286 deletions

View File

@@ -13,7 +13,7 @@ import forge.properties.NewConstants;
import forge.util.FileUtil;
/**
* Tests for DeckWants.
* Tests for ReadDraftRankings.
*
*/
@Test(enabled = true)

View File

@@ -10,17 +10,17 @@ import org.testng.annotations.Test;
import forge.card.CardRarity;
import forge.card.CardRulesReader;
import forge.card.DeckWants;
import forge.card.DeckHints;
import forge.properties.ForgeProps;
import forge.properties.NewConstants;
import forge.util.FileUtil;
/**
* Tests for DeckWants.
* Tests for DeckHints.
*
*/
@Test(timeOut = 1000, enabled = true)
public class DeckWantsTest {
public class DeckHintsTest {
/**
* Card test.
@@ -29,9 +29,9 @@ public class DeckWantsTest {
void test() {
CardPrinted cp = readCard("griffin_rider.txt");
Assert.assertEquals("Griffin Rider", cp.getName());
DeckWants hints = cp.getCard().getDeckWants();
DeckHints hints = cp.getCard().getDeckHints();
Assert.assertNotNull(hints);
Assert.assertEquals(DeckWants.Type.TYPE, hints.getType());
Assert.assertEquals(DeckHints.Type.TYPE, hints.getType());
List<CardPrinted> list = new ArrayList<CardPrinted>();
CardPrinted c0 = readCard("assault_griffin.txt");
@@ -50,9 +50,9 @@ public class DeckWantsTest {
void testCards() {
CardPrinted cp = readCard("throne_of_empires.txt");
Assert.assertEquals("Throne of Empires", cp.getName());
DeckWants hints = cp.getCard().getDeckWants();
DeckHints hints = cp.getCard().getDeckHints();
Assert.assertNotNull(hints);
Assert.assertEquals(DeckWants.Type.NAME, hints.getType());
Assert.assertEquals(DeckHints.Type.NAME, hints.getType());
List<CardPrinted> list = new ArrayList<CardPrinted>();
CardPrinted c0 = readCard("assault_griffin.txt");
@@ -67,13 +67,13 @@ public class DeckWantsTest {
/**
* Filter for keywords.
*_/
*/
@Test(timeOut = 1000, enabled = true)
void testKeywords() {
CardPrinted cp = readCard("mwonvuli_beast_tracker.txt");
DeckWants hints = cp.getCard().getDeckWants();
DeckHints hints = cp.getCard().getDeckHints();
Assert.assertNotNull(hints);
Assert.assertEquals(DeckWants.Type.KEYWORDANY, hints.getType());
Assert.assertEquals(DeckHints.Type.KEYWORD, hints.getType());
List<CardPrinted> list = new ArrayList<CardPrinted>();
CardPrinted c0 = readCard("acidic_slime.txt");
@@ -83,7 +83,6 @@ public class DeckWantsTest {
Assert.assertEquals(1, hints.filter(list).size());
}
*/
/**
@@ -92,9 +91,9 @@ public class DeckWantsTest {
@Test(timeOut = 1000, enabled = true)
void testColor() {
CardPrinted cp = readCard("wurms_tooth.txt");
DeckWants hints = cp.getCard().getDeckWants();
DeckHints hints = cp.getCard().getDeckHints();
Assert.assertNotNull(hints);
Assert.assertEquals(DeckWants.Type.COLOR, hints.getType());
Assert.assertEquals(DeckHints.Type.COLOR, hints.getType());
List<CardPrinted> list = new ArrayList<CardPrinted>();
CardPrinted c0 = readCard("llanowar_elves.txt");
@@ -105,71 +104,25 @@ public class DeckWantsTest {
Assert.assertEquals(1, hints.filter(list).size());
}
/**
* Failing filter for cards.
*_/
@Test(timeOut = 1000, enabled = true)
void testFailCards() {
List<String> cardLines = FileUtil
.readFile(new File(ForgeProps.getFile(NewConstants.CARDSFOLDER) + "/t", "throne_of_empires.txt"));
Card c = CardReader.readCard(cardLines);
Assert.assertEquals("Throne of Empires", c.getName());
Assert.assertNotNull(c.getDeckWants());
Assert.assertEquals(DeckWants.Type.LISTALL, c.getDeckWants().getType());
cardLines = FileUtil
.readFile(new File(ForgeProps.getFile(NewConstants.CARDSFOLDER) + "/a", "assault_griffin.txt"));
Card assaultGriffin = CardReader.readCard(cardLines);
CardList cl = new CardList();
cl.add(assaultGriffin);
cardLines = FileUtil
.readFile(new File(ForgeProps.getFile(NewConstants.CARDSFOLDER) + "/s", "scepter_of_empires.txt"));
Card sc = CardReader.readCard(cardLines);
cl.add(sc);
Assert.assertEquals(0, c.getDeckWants().filter(cl).size());
Assert.assertEquals(2, c.getDeckWants().getMinCardsNeeded());
}
/**
* Card test for junk deck wants.
*_/
@Test(timeOut = 1000, enabled = true)
void testJunk() {
List<String> cardLines = FileUtil
.readFile(new File(ForgeProps.getFile(NewConstants.CARDSFOLDER) + "/g", "griffin_rider.txt"));
Card c = CardReader.readCard(cardLines);
c.setSVar("DeckWants", "Junk$Junk");
Assert.assertNotNull(c.getDeckWants());
Assert.assertEquals(DeckWants.Type.NONE, c.getDeckWants().getType());
}
/**
*
* Test for no wants.
*_/
*/
@Test(timeOut = 1000, enabled = false)
void testNoFilter() {
CardPrinted cp = readCard("assault_griffin.txt");
DeckHints hints = cp.getCard().getDeckHints();
Assert.assertEquals("Assault Griffin", cp.getName());
Assert.assertNotNull(hints);
Assert.assertEquals(DeckHints.Type.NONE, hints.getType());
CardRules c = readCard("assault_griffin.txt");
Assert.assertEquals("Assault Griffin", c.getName());
Assert.assertNotNull(c.getDeckWants());
Assert.assertEquals(DeckWants.Type.NONE, c.getDeckWants().getType());
List<String> cardLines = FileUtil
.readFile(new File(ForgeProps.getFile(NewConstants.CARDSFOLDER) + "/a", "assault_griffin.txt"));
CardRulesReader crr = new CardRulesReader();
for(String line: cardLines)
crr.parseLine(line);
Card assaultGriffin = CardReader.readCard(cardLines);
CardList cl = new CardList();
cl.add(assaultGriffin);
Assert.assertEquals(1, c.getDeckWants().filter(cl).size());
List<CardPrinted> list = new ArrayList<CardPrinted>();
CardPrinted c0 = readCard("assault_griffin.txt");
list.add(c0);
Assert.assertEquals(1, hints.filter(list).size());
}
*/
protected CardPrinted readCard(String filename) {
String firstLetter = filename.substring(0,1);