mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-17 19:28:01 +00:00
- Fix DeckHints and put back in to LimitedDeck generation.
This commit is contained in:
4
.gitattributes
vendored
4
.gitattributes
vendored
@@ -11863,7 +11863,7 @@ src/main/java/forge/card/CardRules.java -text
|
||||
src/main/java/forge/card/CardRulesReader.java svneol=native#text/plain
|
||||
src/main/java/forge/card/CardSuperType.java -text
|
||||
src/main/java/forge/card/CardType.java -text
|
||||
src/main/java/forge/card/DeckWants.java -text
|
||||
src/main/java/forge/card/DeckHints.java -text
|
||||
src/main/java/forge/card/EditionCollection.java svneol=native#text/plain
|
||||
src/main/java/forge/card/EditionInfo.java svneol=native#text/plain
|
||||
src/main/java/forge/card/FatPackData.java -text
|
||||
@@ -12442,7 +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/gui/ListChooserTest.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/item/DeckHintsTest.java -text
|
||||
src/test/java/forge/model/BuildInfoTest.java -text
|
||||
src/test/java/forge/model/FModelTest.java -text
|
||||
src/test/java/net/slightlymagic/braids/util/testng/BraidsAssertFunctions.java svneol=native#text/plain
|
||||
|
||||
@@ -5,7 +5,7 @@ Text:no text
|
||||
T:Mode$ SpellCast | ValidCard$ Card.White | TriggerZones$ Battlefield | OptionalDecider$ You | Execute$ TrigGainLife | TriggerDescription$ Whenever a player casts a white spell, you may gain 1 life.
|
||||
SVar:TrigGainLife:AB$GainLife | Cost$ 0 | LifeAmount$ 1
|
||||
SVar:RemRandomDeck:True
|
||||
SVar:DeckWants:Color$white
|
||||
DeckHints:Color$white
|
||||
SVar:Rarity:Uncommon
|
||||
SVar:Picture:http://www.wizards.com/global/images/magic/general/angels_feather.jpg
|
||||
SetInfo:DST|Uncommon|http://magiccards.info/scans/en/ds/92.jpg
|
||||
|
||||
@@ -7,7 +7,7 @@ SVar:TrigSac:AB$Sacrifice | Cost$ 0 | SacValid$ Creature.nonZombie | Defined$ Tr
|
||||
T:Mode$ Phase | Phase$ End of Turn | TriggerZones$ Battlefield | IsPresent$ Creature | PresentCompare$ EQ0 | Execute$ TrigSacSelf | TriggerDescription$ At the beginning of the end step, if no creatures are on the battlefield, sacrifice CARDNAME.
|
||||
SVar:TrigSacSelf:AB$Sacrifice | Cost$ 0 | Defined$ Self
|
||||
SVar:RemRandomDeck:True
|
||||
SVar:DeckWants:Type$Zombie
|
||||
DeckHints:Type$Zombie
|
||||
SVar:Rarity:Rare
|
||||
SVar:Picture:http://www.wizards.com/global/images/magic/general/call_to_the_grave.jpg
|
||||
SetInfo:SCG|Rare|http://magiccards.info/scans/en/sc/58.jpg
|
||||
|
||||
@@ -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.
|
||||
SVar:DBControl:DB$ GainControl | Defined$ Targeted | ConditionAllM12Empires$ True
|
||||
SVar:RemRandomDeck:True
|
||||
SVar:DeckWants:Name$Scepter of Empires|Throne of Empires
|
||||
DeckHints:Name$Scepter of Empires|Throne of Empires
|
||||
SVar:Rarity:Uncommon
|
||||
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
|
||||
|
||||
@@ -5,7 +5,7 @@ Text:no text
|
||||
T:Mode$ SpellCast | ValidCard$ Card.Black | TriggerZones$ Battlefield | OptionalDecider$ You | Execute$ TrigGainLife | TriggerDescription$ Whenever a player casts a black spell, you may gain 1 life.
|
||||
SVar:TrigGainLife:AB$GainLife | Cost$ 0 | Defined$ You | LifeAmount$ 1
|
||||
SVar:RemRandomDeck:True
|
||||
SVar:DeckWants:Color$Black
|
||||
DeckHints:Color$Black
|
||||
SVar:Rarity:Uncommon
|
||||
SVar:Picture:http://www.wizards.com/global/images/magic/general/demons_horn.jpg
|
||||
SetInfo:DST|Uncommon|http://magiccards.info/scans/en/ds/116.jpg
|
||||
|
||||
@@ -5,7 +5,6 @@ Text:no text
|
||||
K:CARDNAME enters the battlefield tapped.
|
||||
A:AB$ LosesGame | Cost$ W W U U B B R R G G T Sac<1/CARDNAME> | ValidTgts$ Player | TgtPrompt$ Select target player | SpellDescription$ Target player loses the game.
|
||||
SVar:RemRandomDeck:True
|
||||
SVar:DeckWants:ColorAll$white|blue|black|red|green
|
||||
SVar:Rarity:Rare
|
||||
SVar:Picture:http://www.wizards.com/global/images/magic/general/door_to_nothingness.jpg
|
||||
SetInfo:M13|Rare|http://magiccards.info/scans/en/m13/203.jpg
|
||||
|
||||
@@ -5,7 +5,7 @@ Text:no text
|
||||
T:Mode$ SpellCast | ValidCard$ Card.Red | TriggerZones$ Battlefield | OptionalDecider$ You | Execute$ TrigGainLife | TriggerDescription$ Whenever a player casts a red spell, you may gain 1 life.
|
||||
SVar:TrigGainLife:AB$GainLife | Cost$ 0 | Defined$ You | LifeAmount$ 1
|
||||
SVar:RemRandomDeck:True
|
||||
SVar:DeckWants:Color$Red
|
||||
DeckHints:Color$Red
|
||||
SVar:Rarity:Uncommon
|
||||
SVar:Picture:http://www.wizards.com/global/images/magic/general/dragons_claw.jpg
|
||||
SetInfo:DST|Uncommon|http://magiccards.info/scans/en/ds/117.jpg
|
||||
|
||||
@@ -6,7 +6,7 @@ PT:2/2
|
||||
S:Mode$ Continuous | Affected$ Creature.Elf+Other+YouCtrl | AddPower$ 1 | AddToughness$ 1 | Description$ Other Elf creatures you control get +1/+1.
|
||||
A:AB$ Mana | Cost$ T | Produced$ G | Amount$ X | References$ X | SpellDescription$ Add G to your mana pool for each Elf you control.
|
||||
SVar:X:Count$Valid Elf.YouCtrl
|
||||
SVar:DeckWants:Type$Elf
|
||||
DeckHints:Type$Elf
|
||||
SVar:PlayMain1:TRUE
|
||||
SVar:Rarity:Rare
|
||||
SVar:Picture:http://www.wizards.com/global/images/magic/general/elvish_archdruid.jpg
|
||||
|
||||
@@ -7,7 +7,7 @@ S:Mode$ Continuous | Affected$ Card.Self | AddPower$ 3 | AddToughness$ 3 | AddKe
|
||||
SVar:X:Count$Valid Griffin.YouCtrl
|
||||
SVar:BuffedBy:Griffin
|
||||
SVar:RemRandomDeck:True
|
||||
SVar:DeckWants:Type$Griffin
|
||||
DeckHints:Type$Griffin
|
||||
SVar:Rarity:Common
|
||||
SVar:Picture:http://www.wizards.com/global/images/magic/general/griffin_rider.jpg
|
||||
SetInfo:M12|Common|http://magiccards.info/scans/en/m12/20.jpg
|
||||
|
||||
@@ -5,7 +5,7 @@ Text:no text
|
||||
T:Mode$ SpellCast | ValidCard$ Card.Blue | TriggerZones$ Battlefield | OptionalDecider$ You | Execute$ TrigGainLife | TriggerDescription$ Whenever a player casts a blue spell, you may gain 1 life.
|
||||
SVar:TrigGainLife:AB$GainLife | Cost$ 0 | Defined$ You | LifeAmount$ 1
|
||||
SVar:RemRandomDeck:True
|
||||
SVar:DeckWants:Color$Blue
|
||||
DeckHints:Color$Blue
|
||||
SVar:Rarity:Uncommon
|
||||
SVar:Picture:http://www.wizards.com/global/images/magic/general/krakens_eye.jpg
|
||||
SetInfo:DST|Uncommon|http://magiccards.info/scans/en/ds/126.jpg
|
||||
|
||||
@@ -6,7 +6,7 @@ PT:0/2
|
||||
T:Mode$ SpellCast | ValidCard$ Enchantment | ValidActivatingPlayer$ You | Execute$ TrigDraw | TriggerZones$ Battlefield | OptionalDecider$ You | TriggerDescription$ Whenever you cast an enchantment spell, draw a card.
|
||||
SVar:TrigDraw:AB$Draw | Cost$ 0 | Defined$ You | NumCards$ 1
|
||||
SVar:RemRandomDeck:True
|
||||
SVar:DeckWants:Type$Enchantment
|
||||
DeckHints:Type$Enchantment
|
||||
SVar:Rarity:Rare
|
||||
SVar:Picture:http://www.wizards.com/global/images/magic/general/mesa_enchantress.jpg
|
||||
SetInfo:M10|Rare|http://magiccards.info/scans/en/m10/20.jpg
|
||||
|
||||
@@ -6,7 +6,7 @@ PT:2/1
|
||||
T:Mode$ ChangesZone | Origin$ Any | Destination$ Battlefield | ValidCard$ Card.Self | Execute$ ScoutSearch | TriggerDescription$ When CARDNAME enters the battlefield, search your library for a creature card with deathtouch, hexproof, reach or trample and reveal it. Shuffle your library, then put that card on top of it.
|
||||
SVar:ScoutSearch:DB$ ChangeZone | Origin$ Library | Destination$ Library | LibraryPosition$ 0 | ChangeNum$ 1 | ChangeType$ Creature.withDeathtouch+YouCtrl,Creature.withHexproof+YouCtrl,Creature.withReach+YouCtrl,Creature.withTrample+YouCtrl
|
||||
SVar:RemRandomDeck:True
|
||||
SVar:DeckWants:KeywordAny$Deathtouch|Hexproof|Reach|Trample
|
||||
DeckHints:Keyword$Deathtouch|Hexproof|Reach|Trample
|
||||
SVar:Rarity:Uncommon
|
||||
SVar:Picture:http://www.wizards.com/global/images/magic/general/mwonvuli_beast_tracker.jpg
|
||||
SetInfo:M13|Uncommon|http://magiccards.info/scans/en/m13/177.jpg
|
||||
|
||||
@@ -7,7 +7,7 @@ K:Indestructible
|
||||
T:Mode$ Always | TriggerZones$ Battlefield | IsPresent$ Permanent.counters_GE1_PHYLACTERY+YouCtrl | PresentCompare$ EQ0 | Execute$ TrigSac | TriggerDescription$ When you control no permanents with phylactery counters on them, sacrifice CARDNAME.
|
||||
SVar:TrigSac:AB$Sacrifice | Cost$ 0 | Defined$ Self
|
||||
SVar:RemRandomDeck:True
|
||||
SVar:DeckWants:Type$Artifact
|
||||
DeckHints:Type$Artifact
|
||||
SVar:Rarity:Rare
|
||||
SVar:Picture:http://www.wizards.com/global/images/magic/general/phylactery_lich.jpg
|
||||
SetInfo:M11|Rare|http://magiccards.info/scans/en/m11/110.jpg
|
||||
|
||||
@@ -7,7 +7,7 @@ T:Mode$ SpellCast | ValidCard$ Card.White,Card.Blue,Card.Black,Card.Red | ValidA
|
||||
SVar:TrigPutCounter:AB$PutCounter | Cost$ 0 | Defined$ Self | CounterType$ P1P1 | CounterNum$ 1
|
||||
SVar:BuffedBy:Card.White,Card.Blue,Card.Black,Card.Red
|
||||
SVar:RemRandomDeck:True
|
||||
SVar:DeckWants:ColorAny$white|blue|black|red
|
||||
DeckHints:Color$white|blue|black|red
|
||||
SVar:Rarity:Rare
|
||||
SVar:Picture:http://www.wizards.com/global/images/magic/general/quirion_dryad.jpg
|
||||
SetInfo:M13|Rare|http://magiccards.info/scans/en/m13/184.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.
|
||||
SVar:X:Count$AllM12Empires.3.1
|
||||
SVar:RemRandomDeck:True
|
||||
SVar:DeckWants:Name$Throne of Empires|Crown of Empires
|
||||
DeckHints:Name$Throne of Empires|Crown of Empires
|
||||
SVar:Rarity:Uncommon
|
||||
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
|
||||
|
||||
@@ -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.
|
||||
SVar:X:Count$AllM12Empires.5.1
|
||||
SVar:RemRandomDeck:True
|
||||
SVar:DeckWants:Name$Scepter of Empires|Crown of Empires
|
||||
DeckHints:Name$Scepter of Empires|Crown of Empires
|
||||
SVar:Rarity:Rare
|
||||
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
|
||||
|
||||
@@ -7,7 +7,7 @@ K:Flying
|
||||
S:Mode$ Continuous | Affected$ Card.Self | AddHiddenKeyword$ HIDDEN CARDNAME can't attack. | CheckSVar$ X | SVarCompare$ EQ0 | Description$ CARDNAME can't attack unless you control a Knight or Soldier.
|
||||
SVar:X:Count$Valid Knight.YouCtrl,Soldier.YouCtrl
|
||||
SVar:RemRandomDeck:True
|
||||
SVar:DeckWants:TypeAny$Knight|Soldier
|
||||
DeckHints:Type$Knight|Soldier
|
||||
SVar:Rarity:Common
|
||||
SVar:Picture:http://www.wizards.com/global/images/magic/general/war_falcon.jpg
|
||||
SetInfo:M13|Common|http://magiccards.info/scans/en/m13/38.jpg
|
||||
|
||||
@@ -5,7 +5,7 @@ Text:no text
|
||||
T:Mode$ SpellCast | ValidCard$ Card.Green | TriggerZones$ Battlefield | OptionalDecider$ You | Execute$ TrigGainLife | TriggerDescription$ Whenever a player casts a green spell, you may gain 1 life.
|
||||
SVar:TrigGainLife:AB$GainLife | Cost$ 0 | Defined$ You | LifeAmount$ 1
|
||||
SVar:RemRandomDeck:True
|
||||
SVar:DeckWants:Color$Green
|
||||
DeckHints:Color$Green
|
||||
SVar:Rarity:Uncommon
|
||||
SVar:Picture:http://www.wizards.com/global/images/magic/general/wurms_tooth.jpg
|
||||
SetInfo:DST|Uncommon|http://magiccards.info/scans/en/ds/162.jpg
|
||||
|
||||
@@ -17,6 +17,8 @@
|
||||
*/
|
||||
package forge.card;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.TreeMap;
|
||||
|
||||
@@ -33,7 +35,8 @@ public class CardRuleCharacteristics {
|
||||
private String[] cardRules = null;
|
||||
private Map<String, CardInSet> setsData = new TreeMap<String, CardInSet>();
|
||||
private String dlUrl;
|
||||
private DeckWants deckHints;
|
||||
private DeckHints deckHints;
|
||||
private List<String> keywords = new ArrayList<String>();
|
||||
|
||||
/**
|
||||
* Gets the card name.
|
||||
@@ -178,14 +181,40 @@ public class CardRuleCharacteristics {
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO: Write javadoc for this method.
|
||||
* Set the deck hints.
|
||||
*
|
||||
* @param valueAfterKey
|
||||
*/
|
||||
public void setDeckHints(String valueAfterKey) {
|
||||
deckHints = new DeckWants(valueAfterKey);
|
||||
deckHints = new DeckHints(valueAfterKey);
|
||||
}
|
||||
|
||||
public DeckWants getDeckHints() {
|
||||
public DeckHints getDeckHints() {
|
||||
return deckHints;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the keywords
|
||||
*/
|
||||
public List<String> getKeywords() {
|
||||
return keywords;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param keywords0
|
||||
* the keywords to set
|
||||
*/
|
||||
public void setKeywords(List<String> keywords) {
|
||||
this.keywords = keywords;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add keyword.
|
||||
*
|
||||
* @param keyword
|
||||
*/
|
||||
public void addKeyword(String keyword) {
|
||||
this.keywords.add(keyword);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -371,12 +371,19 @@ public final class CardRules {
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the deckWants
|
||||
* @return the deckHints
|
||||
*/
|
||||
public DeckWants getDeckWants() {
|
||||
public DeckHints getDeckHints() {
|
||||
return characteristics.getDeckHints();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the keywords
|
||||
*/
|
||||
public List<String> getKeywords() {
|
||||
return characteristics.getKeywords();
|
||||
}
|
||||
|
||||
/**
|
||||
* Filtering conditions specific for CardRules class, defined here along
|
||||
* with some presets.
|
||||
@@ -502,6 +509,22 @@ public final class CardRules {
|
||||
return new LeafString(LeafString.CardField.JOINED_TYPE, op, what);
|
||||
}
|
||||
|
||||
/**
|
||||
* Has Keyword.
|
||||
*
|
||||
* @param keyword
|
||||
* the keyword
|
||||
* @return the predicate
|
||||
*/
|
||||
public static Predicate<CardRules> hasKeyword(final String keyword) {
|
||||
return new Predicate<CardRules>() {
|
||||
@Override
|
||||
public boolean isTrue(final CardRules card) {
|
||||
return card.getKeywords().contains(keyword);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Was printed in sets.
|
||||
*
|
||||
@@ -640,18 +663,18 @@ public final class CardRules {
|
||||
|
||||
@Override
|
||||
public boolean isTrue(final CardRules card) {
|
||||
boolean shouldConatin;
|
||||
boolean shouldContain;
|
||||
switch (this.field) {
|
||||
case NAME:
|
||||
return this.op(card.getName(), this.operand);
|
||||
case SUBTYPE:
|
||||
shouldConatin = (this.getOperator() == StringOp.CONTAINS)
|
||||
shouldContain = (this.getOperator() == StringOp.CONTAINS)
|
||||
|| (this.getOperator() == StringOp.EQUALS);
|
||||
return shouldConatin == card.getType().subTypeContains(this.operand);
|
||||
return shouldContain == card.getType().subTypeContains(this.operand);
|
||||
case RULES:
|
||||
shouldConatin = (this.getOperator() == StringOp.CONTAINS)
|
||||
shouldContain = (this.getOperator() == StringOp.CONTAINS)
|
||||
|| (this.getOperator() == StringOp.EQUALS);
|
||||
return shouldConatin == card.rulesContain(this.operand);
|
||||
return shouldContain == card.rulesContain(this.operand);
|
||||
case JOINED_TYPE:
|
||||
return this.op(card.getType().toString(), this.operand);
|
||||
default:
|
||||
|
||||
@@ -105,6 +105,19 @@ public class CardRulesReader {
|
||||
}
|
||||
break;
|
||||
|
||||
case 'D':
|
||||
if (line.startsWith("DeckHints:")) {
|
||||
this.characteristics[this.curCharacteristics].setDeckHints(CardRulesReader.getValueAfterKey(line, "DeckHints:"));
|
||||
}
|
||||
break;
|
||||
|
||||
case 'K':
|
||||
if (line.startsWith("K:")) {
|
||||
final String value = line.substring(2);
|
||||
this.characteristics[this.curCharacteristics].addKeyword(value);
|
||||
}
|
||||
break;
|
||||
|
||||
case 'L':
|
||||
if (line.startsWith("Loyalty:")) {
|
||||
this.characteristics[this.curCharacteristics].setPtLine(CardRulesReader.getValueAfterKey(line, "Loyalty:"));
|
||||
@@ -150,9 +163,6 @@ public class CardRulesReader {
|
||||
this.removedFromRandomDecks = "True".equalsIgnoreCase(CardRulesReader.getValueAfterKey(line, "SVar:RemRandomDeck:"));
|
||||
} else if (line.startsWith("SVar:Picture:")) {
|
||||
this.characteristics[this.curCharacteristics].setDlUrl(CardRulesReader.getValueAfterKey(line, "SVar:Picture:"));
|
||||
} else if (line.startsWith("SVar:DeckWants:")) {
|
||||
this.characteristics[this.curCharacteristics].setDeckHints(CardRulesReader.getValueAfterKey(line, "SVar:DeckWants:"));
|
||||
|
||||
} else if (line.startsWith("SetInfo:")) {
|
||||
CardRulesReader.parseSetInfoLine(line, this.characteristics[this.curCharacteristics].getSetsData());
|
||||
}
|
||||
|
||||
105
src/main/java/forge/card/DeckHints.java
Normal file
105
src/main/java/forge/card/DeckHints.java
Normal file
@@ -0,0 +1,105 @@
|
||||
package forge.card;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import forge.item.CardPrinted;
|
||||
import forge.util.closures.PredicateString.StringOp;
|
||||
|
||||
/**
|
||||
* DeckHints provides the ability for a Card to "want" another Card or type of
|
||||
* Cards in its random deck.
|
||||
*
|
||||
*/
|
||||
public class DeckHints {
|
||||
|
||||
/**
|
||||
* Enum of types of DeckHints.
|
||||
*/
|
||||
public enum Type {
|
||||
COLOR, KEYWORD, NAME, TYPE, NONE
|
||||
}
|
||||
|
||||
private Type type = Type.NONE;
|
||||
private String filterParam = null;
|
||||
|
||||
/**
|
||||
* Construct a DeckHints from the SVar string.
|
||||
*
|
||||
* @param wants
|
||||
* SVar for DeckHints
|
||||
*/
|
||||
public DeckHints(String wants) {
|
||||
String[] pieces = wants.split("\\$");
|
||||
if (pieces.length == 2) {
|
||||
try {
|
||||
Type typeValue = Type.valueOf(pieces[0].toUpperCase());
|
||||
for (Type t : Type.values()) {
|
||||
if (typeValue == t) {
|
||||
type = t;
|
||||
break;
|
||||
}
|
||||
}
|
||||
} catch (IllegalArgumentException e) {
|
||||
// type will remain NONE
|
||||
}
|
||||
|
||||
filterParam = pieces[1];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the type
|
||||
*/
|
||||
public Type getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of Cards from the given CardList that match this
|
||||
* DeckHints. I.e., other cards that this Card needs in its deck.
|
||||
*
|
||||
* @param cardList
|
||||
* list of cards to be filtered
|
||||
* @return CardList of Cards that match this DeckHints.
|
||||
*/
|
||||
public List<CardPrinted> filter(List<CardPrinted> cardList) {
|
||||
List<CardPrinted> ret;
|
||||
switch (type) {
|
||||
case TYPE:
|
||||
ret = new ArrayList<CardPrinted>();
|
||||
String[] types = filterParam.split("\\|");
|
||||
for (String type : types) {
|
||||
ret.addAll(CardRules.Predicates.subType(type).select(cardList, CardPrinted.FN_GET_RULES));
|
||||
}
|
||||
break;
|
||||
case COLOR:
|
||||
ret = new ArrayList<CardPrinted>();
|
||||
String[] colors = filterParam.split("\\|");
|
||||
for (String color : colors) {
|
||||
CardColor cc = CardColor.fromNames(color);
|
||||
ret.addAll(CardRules.Predicates.isColor(cc.getColor()).select(cardList, CardPrinted.FN_GET_RULES));
|
||||
}
|
||||
break;
|
||||
case KEYWORD:
|
||||
ret = new ArrayList<CardPrinted>();
|
||||
String[] keywords = filterParam.split("\\|");
|
||||
for (String keyword : keywords) {
|
||||
ret.addAll(CardRules.Predicates.hasKeyword(keyword).select(cardList, CardPrinted.FN_GET_RULES));
|
||||
}
|
||||
break;
|
||||
case NAME:
|
||||
ret = new ArrayList<CardPrinted>();
|
||||
String[] names = filterParam.split("\\|");
|
||||
for (String name : names) {
|
||||
ret.addAll(CardRules.Predicates.name(StringOp.EQUALS, name).select(cardList, CardPrinted.FN_GET_RULES));
|
||||
}
|
||||
break;
|
||||
default:
|
||||
ret = cardList;
|
||||
break;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,133 +0,0 @@
|
||||
package forge.card;
|
||||
|
||||
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
|
||||
* Cards in its random deck.
|
||||
*
|
||||
*/
|
||||
public class DeckWants {
|
||||
|
||||
/**
|
||||
* Enum of types of DeckWants.
|
||||
*/
|
||||
public enum Type { CARD, COLOR, COLORANY, COLORALL, KEYWORDANY, NAME, TYPE, TYPEANY, NONE }
|
||||
|
||||
private Type type = Type.NONE;
|
||||
private String filterParam = null;
|
||||
|
||||
/**
|
||||
* Construct a DeckWants from the SVar string.
|
||||
*
|
||||
* @param wants
|
||||
* SVar for DeckWants
|
||||
*/
|
||||
public DeckWants(String wants) {
|
||||
String[] pieces = wants.split("\\$");
|
||||
if (pieces.length == 2) {
|
||||
try {
|
||||
Type typeValue = Type.valueOf(pieces[0].toUpperCase());
|
||||
for (Type t : Type.values()) {
|
||||
if (typeValue == t) {
|
||||
type = t;
|
||||
break;
|
||||
}
|
||||
}
|
||||
} catch (IllegalArgumentException e) {
|
||||
// type will remain NONE
|
||||
}
|
||||
|
||||
filterParam = pieces[1];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the type
|
||||
*/
|
||||
public Type getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of Cards from the given CardList that match this
|
||||
* DeckWants. I.e., other cards that this Card needs in its deck.
|
||||
*
|
||||
* @param cardList
|
||||
* list of cards to be filtered
|
||||
* @return CardList of Cards that match this DeckWants.
|
||||
*/
|
||||
public List<CardPrinted> filter(List<CardPrinted> cardList) {
|
||||
List<CardPrinted> ret;
|
||||
switch (type) {
|
||||
case TYPE:
|
||||
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;
|
||||
case COLOR:
|
||||
CardColor color = CardColor.fromNames(filterParam);
|
||||
ret = CardRules.Predicates.isColor(color.getColor()).select(cardList, CardPrinted.FN_GET_RULES);
|
||||
break;
|
||||
// case COLORANY:
|
||||
// ret = new CardList();
|
||||
// String[] colors = filterParam.split("\\|");
|
||||
// for (String color : colors) {
|
||||
// CardList found = cardList.getColorByManaCost(color.trim().toLowerCase());
|
||||
// if (found.size() > 0) {
|
||||
// ret.addAll(found);
|
||||
// }
|
||||
// }
|
||||
// break;
|
||||
// case COLORALL:
|
||||
// ret = new CardList();
|
||||
// int numFound = 0;
|
||||
// colors = filterParam.split("\\|");
|
||||
// for (String color : colors) {
|
||||
// CardList found = cardList.getColorByManaCost(color.trim().toLowerCase());
|
||||
// if (found.size() > 0) {
|
||||
// ret.addAll(found);
|
||||
// numFound++;
|
||||
// }
|
||||
// }
|
||||
// if (numFound < colors.length) {
|
||||
// ret.clear();
|
||||
// }
|
||||
// break;
|
||||
// case KEYWORDANY:
|
||||
// ret = new ArrayList<CardPrinted>();
|
||||
// String[] keywords = filterParam.split("\\|");
|
||||
// for (String keyword : keywords) {
|
||||
// ret.addAll(CardRules.Predicates..select(cardList, CardPrinted.FN_GET_RULES));
|
||||
// }
|
||||
// break;
|
||||
case NAME:
|
||||
ret = new ArrayList<CardPrinted>();
|
||||
String[] names = filterParam.split("\\|");
|
||||
for (String name : names) {
|
||||
ret.addAll(CardRules.Predicates.name(StringOp.EQUALS, name).select(cardList, CardPrinted.FN_GET_RULES));
|
||||
}
|
||||
break;
|
||||
default:
|
||||
ret = cardList;
|
||||
break;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -4,13 +4,16 @@ import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import forge.Constant;
|
||||
import forge.card.CardColor;
|
||||
import forge.card.CardManaCost;
|
||||
import forge.card.CardRules;
|
||||
import forge.card.DeckHints;
|
||||
import forge.card.mana.ManaCostShard;
|
||||
import forge.deck.Deck;
|
||||
import forge.deck.generate.GenerateDeckUtil;
|
||||
@@ -32,6 +35,7 @@ public class LimitedDeck extends Deck {
|
||||
private List<CardPrinted> availableList;
|
||||
private List<CardPrinted> aiPlayables;
|
||||
private List<CardPrinted> deckList = new ArrayList<CardPrinted>();
|
||||
private List<String> setsWithBasicLands = new ArrayList<String>();
|
||||
private static ReadDraftRankings draftRankings = new ReadDraftRankings();
|
||||
|
||||
/**
|
||||
@@ -48,6 +52,7 @@ public class LimitedDeck extends Deck {
|
||||
this.availableList = dList;
|
||||
this.colors = pClrs;
|
||||
removeUnplayables();
|
||||
findBasicLandSets();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -60,6 +65,7 @@ public class LimitedDeck extends Deck {
|
||||
super("");
|
||||
this.availableList = list;
|
||||
removeUnplayables();
|
||||
findBasicLandSets();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -103,9 +109,9 @@ public class LimitedDeck extends Deck {
|
||||
List<CardPrinted> nonLands = hasColor.select(aiPlayables, CardPrinted.FN_GET_RULES);
|
||||
if (deckList.size() == numSpellsNeeded && getAverageCMC(deckList) < 3 && !nonLands.isEmpty()) {
|
||||
List<CardRankingBean> list = rankCards(nonLands);
|
||||
CardPrinted c = list.get(0).getCard();
|
||||
CardPrinted c = list.get(0).getCardPrinted();
|
||||
deckList.add(c);
|
||||
getAiPlayables().remove(0);
|
||||
getAiPlayables().remove(c);
|
||||
landsNeeded--;
|
||||
}
|
||||
|
||||
@@ -195,8 +201,7 @@ public class LimitedDeck extends Deck {
|
||||
// if no playable cards remain fill up with basic lands
|
||||
for (int i = 0; i < 5; i++) {
|
||||
if (clrCnts[i].getCount() > 0) {
|
||||
final CardPrinted cp = CardDb.instance().getCard(clrCnts[i].getColor(),
|
||||
IBoosterDraft.LAND_SET_CODE[0]);
|
||||
final CardPrinted cp = getBasicLand(clrCnts[i].getColor());
|
||||
deckList.add(cp);
|
||||
System.out.println(" - Added " + cp.getName() + " as last resort.");
|
||||
break;
|
||||
@@ -214,6 +219,19 @@ public class LimitedDeck extends Deck {
|
||||
availableList.removeAll(getAiPlayables());
|
||||
}
|
||||
|
||||
private void findBasicLandSets() {
|
||||
Set<String> sets = new HashSet<String>();
|
||||
for (CardPrinted cp : aiPlayables) {
|
||||
if (CardDb.instance().isCardSupported("Plains", cp.getEdition())) {
|
||||
sets.add(cp.getEdition());
|
||||
}
|
||||
}
|
||||
setsWithBasicLands.addAll(sets);
|
||||
if (setsWithBasicLands.isEmpty()) {
|
||||
setsWithBasicLands.add("M13");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add lands to fulfill the given color counts.
|
||||
*
|
||||
@@ -242,8 +260,7 @@ public class LimitedDeck extends Deck {
|
||||
}
|
||||
|
||||
for (int j = 0; j < nLand; j++) {
|
||||
final CardPrinted cp = CardDb.instance().getCard(clrCnts[i].getColor(), aiPlayables.get(0).getEdition());
|
||||
deckList.add(cp);
|
||||
deckList.add(getBasicLand(clrCnts[i].getColor()));
|
||||
landsAdded++;
|
||||
}
|
||||
}
|
||||
@@ -256,7 +273,7 @@ public class LimitedDeck extends Deck {
|
||||
int n = 0;
|
||||
while (landsNeeded > 0) {
|
||||
if (clrCnts[n].getCount() > 0) {
|
||||
CardPrinted cp = CardDb.instance().getCard(clrCnts[n].getColor(), aiPlayables.get(0).getEdition());
|
||||
final CardPrinted cp = getBasicLand(clrCnts[n].getColor());
|
||||
deckList.add(cp);
|
||||
landsNeeded--;
|
||||
|
||||
@@ -270,6 +287,22 @@ public class LimitedDeck extends Deck {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get basic land.
|
||||
*
|
||||
* @param basicLand
|
||||
* @return card
|
||||
*/
|
||||
private CardPrinted getBasicLand(String basicLand) {
|
||||
String set;
|
||||
if (setsWithBasicLands.size() > 1) {
|
||||
set = setsWithBasicLands.get(MyRandom.getRandom().nextInt(setsWithBasicLands.size() - 1));
|
||||
} else {
|
||||
set = setsWithBasicLands.get(0);
|
||||
}
|
||||
return CardDb.instance().getCard(basicLand, set);
|
||||
}
|
||||
|
||||
/**
|
||||
* attempt to optimize basic land counts according to color representation.
|
||||
*
|
||||
@@ -339,12 +372,12 @@ public class LimitedDeck extends Deck {
|
||||
List<CardRankingBean> ranked = rankCards(others);
|
||||
for (CardRankingBean bean : ranked) {
|
||||
if (nCards > 0) {
|
||||
deckList.add(bean.getCard());
|
||||
aiPlayables.remove(bean.getCard());
|
||||
deckList.add(bean.getCardPrinted());
|
||||
aiPlayables.remove(bean.getCardPrinted());
|
||||
nCards--;
|
||||
if (Constant.Runtime.DEV_MODE[0]) {
|
||||
System.out.println("Random[" + nCards + "]:" + bean.getCard().getName() + "("
|
||||
+ bean.getCard().getCard().getManaCost() + ")");
|
||||
System.out.println("Random[" + nCards + "]:" + bean.getCardPrinted().getName() + "("
|
||||
+ bean.getCardPrinted().getCard().getManaCost() + ")");
|
||||
}
|
||||
} else {
|
||||
break;
|
||||
@@ -362,7 +395,7 @@ public class LimitedDeck extends Deck {
|
||||
private void addNonCreatures(List<CardRankingBean> nonCreatures, int num) {
|
||||
for (CardRankingBean bean : nonCreatures) {
|
||||
if (num > 0) {
|
||||
CardPrinted cardToAdd = bean.getCard();
|
||||
CardPrinted cardToAdd = bean.getCardPrinted();
|
||||
deckList.add(cardToAdd);
|
||||
num--;
|
||||
getAiPlayables().remove(cardToAdd);
|
||||
@@ -370,7 +403,7 @@ public class LimitedDeck extends Deck {
|
||||
System.out.println("Others[" + num + "]:" + cardToAdd.getName() + " ("
|
||||
+ cardToAdd.getCard().getManaCost() + ")");
|
||||
}
|
||||
// num = addComboCards(cardToAdd, num);
|
||||
num = addComboCards(cardToAdd, num);
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
@@ -386,32 +419,32 @@ public class LimitedDeck extends Deck {
|
||||
* number of cards
|
||||
* @return number left after adding
|
||||
*/
|
||||
// private int addComboCards(CardPrinted cardToAdd, int num) {
|
||||
// if (!cardToAdd.getCard().getSVar("DeckWants").equals("")) {
|
||||
// DeckWants wants = cardToAdd.getDeckWants();
|
||||
// CardList comboCards = wants.filter(getAiPlayables());
|
||||
// if (Constant.Runtime.DEV_MODE[0]) {
|
||||
// System.out.println("Found " + comboCards.size() + " cards for " +
|
||||
// cardToAdd.getName());
|
||||
// }
|
||||
// List<CardRankingBean> rankedComboCards = rankCards(comboCards);
|
||||
// for (CardRankingBean comboBean : rankedComboCards) {
|
||||
// if (num > 0) {
|
||||
// // TODO: This is not exactly right, because the
|
||||
// // rankedComboCards could include creatures and
|
||||
// // non-creatures. This code could add too many of one or the
|
||||
// // other.
|
||||
// Card combo = comboBean.getCard();
|
||||
// deckList.add(combo);
|
||||
// num--;
|
||||
// getAiPlayables().remove(combo);
|
||||
// } else {
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// return num;
|
||||
// }
|
||||
private int addComboCards(CardPrinted cardToAdd, int num) {
|
||||
if (cardToAdd.getCard().getDeckHints() != null
|
||||
&& cardToAdd.getCard().getDeckHints().getType() != DeckHints.Type.NONE) {
|
||||
DeckHints hints = cardToAdd.getCard().getDeckHints();
|
||||
List<CardPrinted> comboCards = hints.filter(getAiPlayables());
|
||||
if (Constant.Runtime.DEV_MODE[0]) {
|
||||
System.out.println("Found " + comboCards.size() + " cards for " + cardToAdd.getName());
|
||||
}
|
||||
List<CardRankingBean> rankedComboCards = rankCards(comboCards);
|
||||
for (CardRankingBean comboBean : rankedComboCards) {
|
||||
if (num > 0) {
|
||||
// TODO: This is not exactly right, because the
|
||||
// rankedComboCards could include creatures and
|
||||
// non-creatures. This code could add too many of one or the
|
||||
// other.
|
||||
CardPrinted combo = comboBean.getCardPrinted();
|
||||
deckList.add(combo);
|
||||
num--;
|
||||
getAiPlayables().remove(combo);
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return num;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add creatures to the deck.
|
||||
@@ -423,14 +456,14 @@ public class LimitedDeck extends Deck {
|
||||
private void addCreatures(List<CardRankingBean> creatures, int num) {
|
||||
for (CardRankingBean bean : creatures) {
|
||||
if (num > 0) {
|
||||
CardPrinted c = bean.getCard();
|
||||
CardPrinted c = bean.getCardPrinted();
|
||||
deckList.add(c);
|
||||
num--;
|
||||
getAiPlayables().remove(c);
|
||||
if (Constant.Runtime.DEV_MODE[0]) {
|
||||
System.out.println("Creature[" + num + "]:" + c.getName() + " (" + c.getCard().getManaCost() + ")");
|
||||
}
|
||||
// num = addComboCards(c, num);
|
||||
num = addComboCards(c, num);
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
@@ -464,7 +497,7 @@ public class LimitedDeck extends Deck {
|
||||
}
|
||||
|
||||
for (CardRankingBean bean : creatures) {
|
||||
CardPrinted c = bean.getCard();
|
||||
CardPrinted c = bean.getCardPrinted();
|
||||
int cmc = c.getCard().getManaCost().getCMC();
|
||||
if (cmc < 1) {
|
||||
cmc = 1;
|
||||
@@ -495,7 +528,7 @@ public class LimitedDeck extends Deck {
|
||||
if (Constant.Runtime.DEV_MODE[0]) {
|
||||
System.out.println("Creature[" + num + "]:" + c.getName() + " (" + c.getCard().getManaCost() + ")");
|
||||
}
|
||||
// num = addComboCards(c, num);
|
||||
num = addComboCards(c, num);
|
||||
} else {
|
||||
if (Constant.Runtime.DEV_MODE[0]) {
|
||||
System.out.println(c.getName() + " not added because CMC " + c.getCard().getManaCost().getCMC()
|
||||
@@ -527,6 +560,12 @@ public class LimitedDeck extends Deck {
|
||||
return ranked;
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate average CMC.
|
||||
*
|
||||
* @param cards
|
||||
* @return the average
|
||||
*/
|
||||
private double getAverageCMC(List<CardPrinted> cards) {
|
||||
double sum = 0.0;
|
||||
for (CardPrinted cardPrinted : cards) {
|
||||
@@ -584,7 +623,7 @@ public class LimitedDeck extends Deck {
|
||||
/**
|
||||
* @return the card
|
||||
*/
|
||||
public CardPrinted getCard() {
|
||||
public CardPrinted getCardPrinted() {
|
||||
return card;
|
||||
}
|
||||
|
||||
|
||||
@@ -44,9 +44,9 @@ public class SealedDeck extends LimitedDeck {
|
||||
final List<CardPrinted> colorChooserList = new ArrayList<CardPrinted>();
|
||||
double limit = rankedCards.size() * .33;
|
||||
for (int i = 0; i < limit; i++) {
|
||||
colorChooserList.add(rankedCards.get(i).getCard());
|
||||
System.out.println(rankedCards.get(i).getCard().getName() + " "
|
||||
+ rankedCards.get(i).getCard().getCard().getManaCost().toString());
|
||||
colorChooserList.add(rankedCards.get(i).getCardPrinted());
|
||||
System.out.println(rankedCards.get(i).getCardPrinted().getName() + " "
|
||||
+ rankedCards.get(i).getCardPrinted().getCard().getManaCost().toString());
|
||||
}
|
||||
|
||||
int white = CardRules.Predicates.Presets.IS_WHITE.select(colorChooserList, CardPrinted.FN_GET_RULES).size();
|
||||
|
||||
@@ -13,7 +13,7 @@ import forge.properties.NewConstants;
|
||||
import forge.util.FileUtil;
|
||||
|
||||
/**
|
||||
* Tests for DeckWants.
|
||||
* Tests for ReadDraftRankings.
|
||||
*
|
||||
*/
|
||||
@Test(enabled = true)
|
||||
|
||||
@@ -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);
|
||||
Reference in New Issue
Block a user