deck - changed tags to Set<String>, removed getCardPool from base class, moved ai-can-play deck predicate to ComputerUtilCard

This commit is contained in:
Maxmtg
2013-02-26 18:15:13 +00:00
parent c2dd603394
commit a3f1e5efbc
5 changed files with 22 additions and 52 deletions

View File

@@ -25,6 +25,8 @@ import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import java.util.TreeSet;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -32,7 +34,6 @@ import java.util.regex.Pattern;
import org.apache.commons.lang3.StringUtils;
import com.google.common.base.Function;
import com.google.common.base.Predicate;
import forge.deck.io.DeckFileHeader;
import forge.deck.io.DeckSerializer;
@@ -65,7 +66,7 @@ public class Deck extends DeckBase implements Iterable<Entry<DeckSection, CardPo
private final Map<DeckSection, CardPool> parts = new EnumMap<DeckSection, CardPool>(DeckSection.class);
private final List<String> tags = new ArrayList<String>();
private final Set<String> tags = new TreeSet<String>(String.CASE_INSENSITIVE_ORDER);
// gameType is from Constant.GameType, like GameType.Regular
/**
@@ -123,16 +124,6 @@ public class Deck extends DeckBase implements Iterable<Entry<DeckSection, CardPo
return p;
}
/*
* (non-Javadoc)
*
* @see forge.item.CardCollectionBase#getCardPool()
*/
@Override
public ItemPoolView<CardPrinted> getCardPool() {
return this.parts.get(DeckSection.Main);
}
/* (non-Javadoc)
* @see forge.deck.DeckBase#cloneFieldsTo(forge.deck.DeckBase)
*/
@@ -292,7 +283,6 @@ public class Deck extends DeckBase implements Iterable<Entry<DeckSection, CardPo
if (!this.getTags().isEmpty()) {
out.add(String.format("%s=%s", DeckFileHeader.TAGS, StringUtils.join(getTags(), DeckFileHeader.TAGS_SEPARATOR)));
}
for(Entry<DeckSection, CardPool> s : parts.entrySet()) {
out.add(String.format("[%s]", s.getKey().toString()));
@@ -309,19 +299,6 @@ public class Deck extends DeckBase implements Iterable<Entry<DeckSection, CardPo
}
};
public static final Predicate<Deck> AI_KNOWS_HOW_TO_PLAY_ALL_CARDS = new Predicate<Deck>() {
@Override
public boolean apply(Deck d) {
for(Entry<DeckSection, CardPool> cp: d) {
for(Entry<CardPrinted, Integer> e : cp.getValue()) {
if ( e.getKey().getRules().getAiHints().getRemAIDecks() )
return false;
}
}
return true;
}
};
/* (non-Javadoc)
* @see java.lang.Iterable#iterator()
*/
@@ -331,9 +308,9 @@ public class Deck extends DeckBase implements Iterable<Entry<DeckSection, CardPo
}
/**
* @return the associated tags, a writable list
* @return the associated tags, a writable set
*/
public List<String> getTags() {
public Set<String> getTags() {
return tags;
}
}

View File

@@ -19,9 +19,6 @@ package forge.deck;
import java.io.Serializable;
import forge.item.CardPrinted;
import forge.item.ItemPoolView;
/**
* TODO: Write javadoc for this type.
*
@@ -77,13 +74,6 @@ public abstract class DeckBase implements Serializable, Comparable<DeckBase> {
return this.name;
}
/**
* Gets the card pool.
*
* @return the card pool
*/
public abstract ItemPoolView<CardPrinted> getCardPool();
/**
* Sets the comment.
*

View File

@@ -20,15 +20,10 @@ package forge.deck;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
// import java.lang.Double;
import java.util.List;
import com.google.common.base.Function;
import forge.item.CardPrinted;
import forge.item.ItemPoolView;
/**
* TODO: Write javadoc for this type.
*
@@ -112,14 +107,6 @@ public class DeckGroup extends DeckBase {
this.aiDecks.add(aiDeck);
}
/* (non-Javadoc)
* @see forge.deck.DeckBase#getCardPool()
*/
@Override
public ItemPoolView<CardPrinted> getCardPool() {
return this.getHumanDeck().getMain();
}
/**
* Adds the ai decks.
*

View File

@@ -22,8 +22,12 @@ import forge.CardUtil;
import forge.Constant;
import forge.card.CardType;
import forge.card.spellability.SpellAbility;
import forge.deck.CardPool;
import forge.deck.Deck;
import forge.deck.DeckSection;
import forge.game.player.Player;
import forge.game.zone.ZoneType;
import forge.item.CardPrinted;
import forge.util.Aggregates;
import forge.util.MyRandom;
@@ -914,4 +918,17 @@ public class ComputerUtilCard {
return worstLand;
} // end getWorstLand
public static final Predicate<Deck> AI_KNOWS_HOW_TO_PLAY_ALL_CARDS = new Predicate<Deck>() {
@Override
public boolean apply(Deck d) {
for(Entry<DeckSection, CardPool> cp: d) {
for(Entry<CardPrinted, Integer> e : cp.getValue()) {
if ( e.getKey().getRules().getAiHints().getRemAIDecks() )
return false;
}
}
return true;
}
};
}

View File

@@ -216,7 +216,6 @@ public class CustomLimited extends DeckBase {
*
* @see forge.item.CardCollectionBase#getCardPool()
*/
@Override
public ItemPoolView<CardPrinted> getCardPool() {
return this.cardPool;
}