mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-17 19:28:01 +00:00
- work on DeckWantsTest, no longer breaking
This commit is contained in:
2
.gitattributes
vendored
2
.gitattributes
vendored
@@ -12428,7 +12428,6 @@ src/site/apt/index.apt -text
|
|||||||
src/test/java/forge/BoosterDraft1Test.java svneol=native#text/plain
|
src/test/java/forge/BoosterDraft1Test.java svneol=native#text/plain
|
||||||
src/test/java/forge/BoosterDraftTest.java svneol=native#text/plain
|
src/test/java/forge/BoosterDraftTest.java svneol=native#text/plain
|
||||||
src/test/java/forge/CardColorTest.java svneol=native#text/plain
|
src/test/java/forge/CardColorTest.java svneol=native#text/plain
|
||||||
src/test/java/forge/DeckWantsTest.java -text
|
|
||||||
src/test/java/forge/GuiDownloadPicturesLQTest.java svneol=native#text/plain
|
src/test/java/forge/GuiDownloadPicturesLQTest.java svneol=native#text/plain
|
||||||
src/test/java/forge/GuiDownloadSetPicturesLQTest.java svneol=native#text/plain
|
src/test/java/forge/GuiDownloadSetPicturesLQTest.java svneol=native#text/plain
|
||||||
src/test/java/forge/GuiMigrateLocalMWSSetPicturesHQTest.java svneol=native#text/plain
|
src/test/java/forge/GuiMigrateLocalMWSSetPicturesHQTest.java svneol=native#text/plain
|
||||||
@@ -12443,6 +12442,7 @@ src/test/java/forge/deck/generate/Generate3ColorDeckTest.java svneol=native#text
|
|||||||
src/test/java/forge/deck/generate/Generate5ColorDeckTest.java svneol=native#text/plain
|
src/test/java/forge/deck/generate/Generate5ColorDeckTest.java svneol=native#text/plain
|
||||||
src/test/java/forge/gui/ListChooserTest.java svneol=native#text/plain
|
src/test/java/forge/gui/ListChooserTest.java svneol=native#text/plain
|
||||||
src/test/java/forge/gui/game/CardDetailPanelTest.java svneol=native#text/plain
|
src/test/java/forge/gui/game/CardDetailPanelTest.java svneol=native#text/plain
|
||||||
|
src/test/java/forge/item/DeckWantsTest.java -text
|
||||||
src/test/java/forge/model/BuildInfoTest.java -text
|
src/test/java/forge/model/BuildInfoTest.java -text
|
||||||
src/test/java/forge/model/FModelTest.java -text
|
src/test/java/forge/model/FModelTest.java -text
|
||||||
src/test/java/net/slightlymagic/braids/util/testng/BraidsAssertFunctions.java svneol=native#text/plain
|
src/test/java/net/slightlymagic/braids/util/testng/BraidsAssertFunctions.java svneol=native#text/plain
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ Text:no text
|
|||||||
A:AB$ Tap | Cost$ 3 T | ValidTgts$ Creature | TgtPrompt$ Select target creature | ConditionNotAllM12Empires$ True | SubAbility$ DBControl | SpellDescription$ Tap target creature. Gain control of that creature instead if you control artifacts named Scepter of Empires and Throne of Empires.
|
A:AB$ Tap | Cost$ 3 T | ValidTgts$ Creature | TgtPrompt$ Select target creature | ConditionNotAllM12Empires$ True | SubAbility$ DBControl | SpellDescription$ Tap target creature. Gain control of that creature instead if you control artifacts named Scepter of Empires and Throne of Empires.
|
||||||
SVar:DBControl:DB$ GainControl | Defined$ Targeted | ConditionAllM12Empires$ True
|
SVar:DBControl:DB$ GainControl | Defined$ Targeted | ConditionAllM12Empires$ True
|
||||||
SVar:RemRandomDeck:True
|
SVar:RemRandomDeck:True
|
||||||
SVar:DeckWants:ListAll$Scepter of Empires|Throne of Empires
|
SVar:DeckWants:Name$Scepter of Empires|Throne of Empires
|
||||||
SVar:Rarity:Uncommon
|
SVar:Rarity:Uncommon
|
||||||
SVar:Picture:http://www.wizards.com/global/images/magic/general/crown_of_empires.jpg
|
SVar:Picture:http://www.wizards.com/global/images/magic/general/crown_of_empires.jpg
|
||||||
SetInfo:M12|Uncommon|http://magiccards.info/scans/en/m12/203.jpg
|
SetInfo:M12|Uncommon|http://magiccards.info/scans/en/m12/203.jpg
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ Text:no text
|
|||||||
A:AB$ DealDamage | Cost$ T | Tgt$ TgtP | NumDmg$ X | References$ X | SpellDescription$ CARDNAME deals 1 damage to target player. It deals 3 damage to that player instead if you control artifacts named Crown of Empires and Throne of Empires.
|
A:AB$ DealDamage | Cost$ T | Tgt$ TgtP | NumDmg$ X | References$ X | SpellDescription$ CARDNAME deals 1 damage to target player. It deals 3 damage to that player instead if you control artifacts named Crown of Empires and Throne of Empires.
|
||||||
SVar:X:Count$AllM12Empires.3.1
|
SVar:X:Count$AllM12Empires.3.1
|
||||||
SVar:RemRandomDeck:True
|
SVar:RemRandomDeck:True
|
||||||
SVar:DeckWants:ListAll$Throne of Empires|Crown of Empires
|
SVar:DeckWants:Name$Throne of Empires|Crown of Empires
|
||||||
SVar:Rarity:Uncommon
|
SVar:Rarity:Uncommon
|
||||||
SVar:Picture:http://www.wizards.com/global/images/magic/general/scepter_of_empires.jpg
|
SVar:Picture:http://www.wizards.com/global/images/magic/general/scepter_of_empires.jpg
|
||||||
SetInfo:M12|Uncommon|http://magiccards.info/scans/en/m12/216.jpg
|
SetInfo:M12|Uncommon|http://magiccards.info/scans/en/m12/216.jpg
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ Text:no text
|
|||||||
A:AB$ Token | Cost$ 1 T | TokenAmount$ X | References$ X | TokenName$ Soldier | TokenTypes$ Creature,Soldier | TokenOwner$ You | TokenColors$ White | TokenPower$ 1 | TokenToughness$ 1 | SpellDescription$ Put a 1/1 white Soldier creature token onto the battlefield. Put five of those tokens onto the battlefield instead if you control artifacts named Crown of Empires and Scepter of Empires.
|
A:AB$ Token | Cost$ 1 T | TokenAmount$ X | References$ X | TokenName$ Soldier | TokenTypes$ Creature,Soldier | TokenOwner$ You | TokenColors$ White | TokenPower$ 1 | TokenToughness$ 1 | SpellDescription$ Put a 1/1 white Soldier creature token onto the battlefield. Put five of those tokens onto the battlefield instead if you control artifacts named Crown of Empires and Scepter of Empires.
|
||||||
SVar:X:Count$AllM12Empires.5.1
|
SVar:X:Count$AllM12Empires.5.1
|
||||||
SVar:RemRandomDeck:True
|
SVar:RemRandomDeck:True
|
||||||
SVar:DeckWants:ListAll$Scepter of Empires|Crown of Empires
|
SVar:DeckWants:Name$Scepter of Empires|Crown of Empires
|
||||||
SVar:Rarity:Rare
|
SVar:Rarity:Rare
|
||||||
SVar:Picture:http://www.wizards.com/global/images/magic/general/throne_of_empires.jpg
|
SVar:Picture:http://www.wizards.com/global/images/magic/general/throne_of_empires.jpg
|
||||||
SetInfo:M12|Rare|http://magiccards.info/scans/en/m12/221.jpg
|
SetInfo:M12|Rare|http://magiccards.info/scans/en/m12/221.jpg
|
||||||
|
|||||||
@@ -292,6 +292,10 @@ public final class CardColor implements Comparable<CardColor> {
|
|||||||
return fromMask(mask);
|
return fromMask(mask);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public byte getColor() {
|
||||||
|
return myColor;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* (non-Javadoc)
|
* (non-Javadoc)
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -1,6 +1,11 @@
|
|||||||
package forge.card;
|
package forge.card;
|
||||||
|
|
||||||
import forge.CardList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import forge.item.CardPrinted;
|
||||||
|
import forge.util.closures.PredicateString;
|
||||||
|
import forge.util.closures.PredicateString.StringOp;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* DeckWants provides the ability for a Card to "want" another Card or type of
|
* DeckWants provides the ability for a Card to "want" another Card or type of
|
||||||
@@ -12,7 +17,7 @@ public class DeckWants {
|
|||||||
/**
|
/**
|
||||||
* Enum of types of DeckWants.
|
* Enum of types of DeckWants.
|
||||||
*/
|
*/
|
||||||
public enum Type { CARD, COLOR, COLORANY, COLORALL, KEYWORDANY, LISTALL, TYPE, TYPEANY, NONE }
|
public enum Type { CARD, COLOR, COLORANY, COLORALL, KEYWORDANY, NAME, TYPE, TYPEANY, NONE }
|
||||||
|
|
||||||
private Type type = Type.NONE;
|
private Type type = Type.NONE;
|
||||||
private String filterParam = null;
|
private String filterParam = null;
|
||||||
@@ -57,75 +62,65 @@ public class DeckWants {
|
|||||||
* list of cards to be filtered
|
* list of cards to be filtered
|
||||||
* @return CardList of Cards that match this DeckWants.
|
* @return CardList of Cards that match this DeckWants.
|
||||||
*/
|
*/
|
||||||
public CardList filter(CardList cardList) {
|
public List<CardPrinted> filter(List<CardPrinted> cardList) {
|
||||||
CardList ret;
|
List<CardPrinted> ret;
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case TYPE:
|
case TYPE:
|
||||||
ret = cardList.getType(filterParam);
|
ret = CardRules.Predicates.subType(filterParam).select(cardList, CardPrinted.FN_GET_RULES);
|
||||||
break;
|
|
||||||
case TYPEANY:
|
|
||||||
ret = new CardList();
|
|
||||||
String[] types = filterParam.split("\\|");
|
|
||||||
for (String type : types) {
|
|
||||||
CardList found = cardList.getType(type.trim());
|
|
||||||
if (found.size() > 0) {
|
|
||||||
ret.addAll(found);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
case CARD:
|
|
||||||
ret = cardList.getName(filterParam);
|
|
||||||
break;
|
break;
|
||||||
|
// case TYPEANY:
|
||||||
|
// ret = new CardList();
|
||||||
|
// String[] types = filterParam.split("\\|");
|
||||||
|
// for (String type : types) {
|
||||||
|
// CardList found = cardList.getType(type.trim());
|
||||||
|
// if (found.size() > 0) {
|
||||||
|
// ret.addAll(found);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// case CARD:
|
||||||
|
// ret = cardList.getName(filterParam);
|
||||||
|
// break;
|
||||||
case COLOR:
|
case COLOR:
|
||||||
ret = cardList.getColorByManaCost(filterParam.toLowerCase());
|
CardColor color = CardColor.fromNames(filterParam);
|
||||||
|
ret = CardRules.Predicates.isColor(color.getColor()).select(cardList, CardPrinted.FN_GET_RULES);
|
||||||
break;
|
break;
|
||||||
case COLORANY:
|
// case COLORANY:
|
||||||
ret = new CardList();
|
// ret = new CardList();
|
||||||
String[] colors = filterParam.split("\\|");
|
// String[] colors = filterParam.split("\\|");
|
||||||
for (String color : colors) {
|
// for (String color : colors) {
|
||||||
CardList found = cardList.getColorByManaCost(color.trim().toLowerCase());
|
// CardList found = cardList.getColorByManaCost(color.trim().toLowerCase());
|
||||||
if (found.size() > 0) {
|
// if (found.size() > 0) {
|
||||||
ret.addAll(found);
|
// ret.addAll(found);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
break;
|
// break;
|
||||||
case COLORALL:
|
// case COLORALL:
|
||||||
ret = new CardList();
|
// ret = new CardList();
|
||||||
int numFound = 0;
|
// int numFound = 0;
|
||||||
colors = filterParam.split("\\|");
|
// colors = filterParam.split("\\|");
|
||||||
for (String color : colors) {
|
// for (String color : colors) {
|
||||||
CardList found = cardList.getColorByManaCost(color.trim().toLowerCase());
|
// CardList found = cardList.getColorByManaCost(color.trim().toLowerCase());
|
||||||
if (found.size() > 0) {
|
// if (found.size() > 0) {
|
||||||
ret.addAll(found);
|
// ret.addAll(found);
|
||||||
numFound++;
|
// numFound++;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
if (numFound < colors.length) {
|
// if (numFound < colors.length) {
|
||||||
ret.clear();
|
// ret.clear();
|
||||||
}
|
// }
|
||||||
break;
|
// break;
|
||||||
case KEYWORDANY:
|
// case KEYWORDANY:
|
||||||
ret = new CardList();
|
// ret = new ArrayList<CardPrinted>();
|
||||||
String[] keywords = filterParam.split("\\|");
|
// String[] keywords = filterParam.split("\\|");
|
||||||
for (String keyword : keywords) {
|
// for (String keyword : keywords) {
|
||||||
CardList found = cardList.getKeyword(keyword.trim());
|
// ret.addAll(CardRules.Predicates..select(cardList, CardPrinted.FN_GET_RULES));
|
||||||
if (found.size() > 0) {
|
// }
|
||||||
ret.addAll(found);
|
// break;
|
||||||
}
|
case NAME:
|
||||||
}
|
ret = new ArrayList<CardPrinted>();
|
||||||
break;
|
|
||||||
case LISTALL:
|
|
||||||
ret = new CardList();
|
|
||||||
numFound = 0;
|
|
||||||
String[] names = filterParam.split("\\|");
|
String[] names = filterParam.split("\\|");
|
||||||
for (String name : names) {
|
for (String name : names) {
|
||||||
CardList found = cardList.getName(name.trim());
|
ret.addAll(CardRules.Predicates.name(StringOp.EQUALS, name).select(cardList, CardPrinted.FN_GET_RULES));
|
||||||
if (found.size() > 0) {
|
|
||||||
ret.addAll(found);
|
|
||||||
numFound++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (numFound < names.length) {
|
|
||||||
ret.clear();
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@@ -135,25 +130,4 @@ public class DeckWants {
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* Get the minimum number of "wanted" cards needed for the current card
|
|
||||||
* to be used in an AI deck.
|
|
||||||
*
|
|
||||||
* @return int
|
|
||||||
*/
|
|
||||||
public int getMinCardsNeeded() {
|
|
||||||
int ret;
|
|
||||||
switch (type) {
|
|
||||||
case LISTALL:
|
|
||||||
String[] names = filterParam.split("\\|");
|
|
||||||
ret = names.length;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
ret = 1;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,209 +0,0 @@
|
|||||||
package forge;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import org.testng.annotations.Test;
|
|
||||||
|
|
||||||
import junit.framework.Assert;
|
|
||||||
|
|
||||||
import forge.card.CardRules;
|
|
||||||
import forge.card.CardRulesReader;
|
|
||||||
import forge.card.DeckWants;
|
|
||||||
import forge.properties.ForgeProps;
|
|
||||||
import forge.properties.NewConstants;
|
|
||||||
import forge.util.FileUtil;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Tests for DeckWants.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
@Test(timeOut = 1000, enabled = true)
|
|
||||||
public class DeckWantsTest {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Card test.
|
|
||||||
*_/
|
|
||||||
@Test(timeOut = 1000, enabled = true)
|
|
||||||
void test() {
|
|
||||||
List<String> cardLines = FileUtil
|
|
||||||
.readFile(new File(ForgeProps.getFile(NewConstants.CARDSFOLDER) + "/g", "griffin_rider.txt"));
|
|
||||||
Card c = CardReader.readCard(cardLines);
|
|
||||||
Assert.assertEquals("Griffin Rider", c.getName());
|
|
||||||
Assert.assertNotNull(c.getDeckWants());
|
|
||||||
Assert.assertEquals(DeckWants.Type.TYPE, 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) + "/a", "auramancer.txt"));
|
|
||||||
Card auramancer = CardReader.readCard(cardLines);
|
|
||||||
cl.add(auramancer);
|
|
||||||
|
|
||||||
Assert.assertEquals(1, c.getDeckWants().filter(cl).size());
|
|
||||||
Assert.assertEquals("Assault Griffin", c.getDeckWants().filter(cl).get(0).getName());
|
|
||||||
Assert.assertEquals(1, c.getDeckWants().getMinCardsNeeded());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Filter for cards.
|
|
||||||
*_/
|
|
||||||
@Test(timeOut = 1000, enabled = true)
|
|
||||||
void testCards() {
|
|
||||||
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);
|
|
||||||
cardLines = FileUtil
|
|
||||||
.readFile(new File(ForgeProps.getFile(NewConstants.CARDSFOLDER) + "/c", "crown_of_empires.txt"));
|
|
||||||
Card cr = CardReader.readCard(cardLines);
|
|
||||||
cl.add(cr);
|
|
||||||
|
|
||||||
Assert.assertEquals(2, c.getDeckWants().filter(cl).size());
|
|
||||||
Assert.assertEquals(2, c.getDeckWants().getMinCardsNeeded());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Filter for keywords.
|
|
||||||
*_/
|
|
||||||
@Test(timeOut = 1000, enabled = true)
|
|
||||||
void testKeywords() {
|
|
||||||
List<String> cardLines = FileUtil
|
|
||||||
.readFile(new File(ForgeProps.getFile(NewConstants.CARDSFOLDER) + "/m", "mwonvuli_beast_tracker.txt"));
|
|
||||||
Card c = CardReader.readCard(cardLines);
|
|
||||||
Assert.assertNotNull(c.getDeckWants());
|
|
||||||
Assert.assertEquals(DeckWants.Type.KEYWORDANY, c.getDeckWants().getType());
|
|
||||||
|
|
||||||
cardLines = FileUtil
|
|
||||||
.readFile(new File(ForgeProps.getFile(NewConstants.CARDSFOLDER) + "/a", "acidic_slime.txt"));
|
|
||||||
Card card = CardReader.readCard(cardLines);
|
|
||||||
CardList cl = new CardList();
|
|
||||||
cl.add(card);
|
|
||||||
cardLines = FileUtil
|
|
||||||
.readFile(new File(ForgeProps.getFile(NewConstants.CARDSFOLDER) + "/a", "ajanis_sunstriker.txt"));
|
|
||||||
Card card2 = CardReader.readCard(cardLines);
|
|
||||||
cl.add(card2);
|
|
||||||
|
|
||||||
Assert.assertEquals(1, c.getDeckWants().filter(cl).size());
|
|
||||||
Assert.assertEquals(1, c.getDeckWants().getMinCardsNeeded());
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Filter for color.
|
|
||||||
*_/
|
|
||||||
@Test(timeOut = 1000, enabled = true)
|
|
||||||
void testColor() {
|
|
||||||
List<String> cardLines = FileUtil
|
|
||||||
.readFile(new File(ForgeProps.getFile(NewConstants.CARDSFOLDER) + "/w", "wurms_tooth.txt"));
|
|
||||||
Card c = CardReader.readCard(cardLines);
|
|
||||||
Assert.assertNotNull(c.getDeckWants());
|
|
||||||
Assert.assertEquals(DeckWants.Type.COLOR, c.getDeckWants().getType());
|
|
||||||
|
|
||||||
cardLines = FileUtil
|
|
||||||
.readFile(new File(ForgeProps.getFile(NewConstants.CARDSFOLDER) + "/l", "llanowar_elves.txt"));
|
|
||||||
Card card = CardReader.readCard(cardLines);
|
|
||||||
CardList cl = new CardList();
|
|
||||||
cl.add(card);
|
|
||||||
cardLines = FileUtil
|
|
||||||
.readFile(new File(ForgeProps.getFile(NewConstants.CARDSFOLDER) + "/u", "unsummon.txt"));
|
|
||||||
card = CardReader.readCard(cardLines);
|
|
||||||
cl.add(card);
|
|
||||||
|
|
||||||
cl.getOnly2Colors("green", "white");
|
|
||||||
Assert.assertEquals(1, c.getDeckWants().filter(cl).size());
|
|
||||||
Assert.assertEquals(1, c.getDeckWants().getMinCardsNeeded());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 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() {
|
|
||||||
|
|
||||||
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());
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
protected CardRules readCard(String filename) {
|
|
||||||
String firstLetter = filename.substring(0,1);
|
|
||||||
File dir = new File(ForgeProps.getFile(NewConstants.CARDSFOLDER), firstLetter);
|
|
||||||
File txtFile = new File(dir, filename);
|
|
||||||
|
|
||||||
CardRulesReader crr = new CardRulesReader();
|
|
||||||
for(String line: FileUtil.readFile(txtFile))
|
|
||||||
crr.parseLine(line);
|
|
||||||
return crr.getCard();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
186
src/test/java/forge/item/DeckWantsTest.java
Normal file
186
src/test/java/forge/item/DeckWantsTest.java
Normal file
@@ -0,0 +1,186 @@
|
|||||||
|
package forge.item;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import junit.framework.Assert;
|
||||||
|
|
||||||
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
|
import forge.card.CardRarity;
|
||||||
|
import forge.card.CardRulesReader;
|
||||||
|
import forge.card.DeckWants;
|
||||||
|
import forge.properties.ForgeProps;
|
||||||
|
import forge.properties.NewConstants;
|
||||||
|
import forge.util.FileUtil;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests for DeckWants.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
@Test(timeOut = 1000, enabled = true)
|
||||||
|
public class DeckWantsTest {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Card test.
|
||||||
|
*/
|
||||||
|
@Test(timeOut = 1000, enabled = true)
|
||||||
|
void test() {
|
||||||
|
CardPrinted cp = readCard("griffin_rider.txt");
|
||||||
|
Assert.assertEquals("Griffin Rider", cp.getName());
|
||||||
|
DeckWants hints = cp.getCard().getDeckWants();
|
||||||
|
Assert.assertNotNull(hints);
|
||||||
|
Assert.assertEquals(DeckWants.Type.TYPE, hints.getType());
|
||||||
|
|
||||||
|
List<CardPrinted> list = new ArrayList<CardPrinted>();
|
||||||
|
CardPrinted c0 = readCard("assault_griffin.txt");
|
||||||
|
list.add(c0);
|
||||||
|
CardPrinted c1 = readCard("auramancer.txt");
|
||||||
|
list.add(c1);
|
||||||
|
|
||||||
|
Assert.assertEquals(1, hints.filter(list).size());
|
||||||
|
Assert.assertEquals("Assault Griffin", hints.filter(list).get(0).getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Filter for cards.
|
||||||
|
*/
|
||||||
|
@Test(timeOut = 1000, enabled = true)
|
||||||
|
void testCards() {
|
||||||
|
CardPrinted cp = readCard("throne_of_empires.txt");
|
||||||
|
Assert.assertEquals("Throne of Empires", cp.getName());
|
||||||
|
DeckWants hints = cp.getCard().getDeckWants();
|
||||||
|
Assert.assertNotNull(hints);
|
||||||
|
Assert.assertEquals(DeckWants.Type.NAME, hints.getType());
|
||||||
|
|
||||||
|
List<CardPrinted> list = new ArrayList<CardPrinted>();
|
||||||
|
CardPrinted c0 = readCard("assault_griffin.txt");
|
||||||
|
list.add(c0);
|
||||||
|
CardPrinted c1 = readCard("scepter_of_empires.txt");
|
||||||
|
list.add(c1);
|
||||||
|
CardPrinted c2 = readCard("crown_of_empires.txt");
|
||||||
|
list.add(c2);
|
||||||
|
|
||||||
|
Assert.assertEquals(2, hints.filter(list).size());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Filter for keywords.
|
||||||
|
*_/
|
||||||
|
@Test(timeOut = 1000, enabled = true)
|
||||||
|
void testKeywords() {
|
||||||
|
CardPrinted cp = readCard("mwonvuli_beast_tracker.txt");
|
||||||
|
DeckWants hints = cp.getCard().getDeckWants();
|
||||||
|
Assert.assertNotNull(hints);
|
||||||
|
Assert.assertEquals(DeckWants.Type.KEYWORDANY, hints.getType());
|
||||||
|
|
||||||
|
List<CardPrinted> list = new ArrayList<CardPrinted>();
|
||||||
|
CardPrinted c0 = readCard("acidic_slime.txt");
|
||||||
|
list.add(c0);
|
||||||
|
CardPrinted c1 = readCard("ajanis_sunstriker.txt");
|
||||||
|
list.add(c1);
|
||||||
|
|
||||||
|
Assert.assertEquals(1, hints.filter(list).size());
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Filter for color.
|
||||||
|
*/
|
||||||
|
@Test(timeOut = 1000, enabled = true)
|
||||||
|
void testColor() {
|
||||||
|
CardPrinted cp = readCard("wurms_tooth.txt");
|
||||||
|
DeckWants hints = cp.getCard().getDeckWants();
|
||||||
|
Assert.assertNotNull(hints);
|
||||||
|
Assert.assertEquals(DeckWants.Type.COLOR, hints.getType());
|
||||||
|
|
||||||
|
List<CardPrinted> list = new ArrayList<CardPrinted>();
|
||||||
|
CardPrinted c0 = readCard("llanowar_elves.txt");
|
||||||
|
list.add(c0);
|
||||||
|
CardPrinted c1 = readCard("unsummon.txt");
|
||||||
|
list.add(c1);
|
||||||
|
|
||||||
|
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() {
|
||||||
|
|
||||||
|
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());
|
||||||
|
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
protected CardPrinted readCard(String filename) {
|
||||||
|
String firstLetter = filename.substring(0,1);
|
||||||
|
File dir = new File(ForgeProps.getFile(NewConstants.CARDSFOLDER), firstLetter);
|
||||||
|
File txtFile = new File(dir, filename);
|
||||||
|
|
||||||
|
CardRulesReader crr = new CardRulesReader();
|
||||||
|
for(String line: FileUtil.readFile(txtFile))
|
||||||
|
crr.parseLine(line);
|
||||||
|
// Don't care what the actual set or rarity is here.
|
||||||
|
return CardPrinted.build(crr.getCard(), "M11", CardRarity.Common, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user