- Initial implementation for the RemoveDeck:NonCommander hint.

This commit is contained in:
Agetian
2020-07-09 09:22:47 +03:00
parent 6567aa1b88
commit 448de9b4a2
8 changed files with 33 additions and 7 deletions

View File

@@ -9,15 +9,17 @@ public class CardAiHints {
private final boolean isRemovedFromAIDecks;
private final boolean isRemovedFromRandomDecks;
private final boolean isRemovedFromNonCommanderDecks;
private final DeckHints deckHints;
private final DeckHints deckNeeds;
private final DeckHints deckHas;
public CardAiHints(boolean remAi, boolean remRandom, DeckHints dh, DeckHints dn, DeckHints has) {
public CardAiHints(boolean remAi, boolean remRandom, boolean remUnlessCommander, DeckHints dh, DeckHints dn, DeckHints has) {
isRemovedFromAIDecks = remAi;
isRemovedFromRandomDecks = remRandom;
isRemovedFromNonCommanderDecks = remUnlessCommander;
deckHints = dh;
deckNeeds = dn;
deckHas = has;
@@ -42,8 +44,17 @@ public class CardAiHints {
}
/**
* @return the deckHints
* Gets the rem random decks.
*
* @return the rem random decks
*/
public boolean getRemNonCommanderDecks() {
return this.isRemovedFromNonCommanderDecks;
}
/**
* @return the deckHints
*/
public DeckHints getDeckHints() {
return deckHints;
}

View File

@@ -291,6 +291,7 @@ public final class CardRules implements ICardCharacteristics {
// fields to build CardAiHints
private boolean removedFromAIDecks = false;
private boolean removedFromRandomDecks = false;
private boolean removedFromNonCommanderDecks = false;
private DeckHints hints = null;
private DeckHints needs = null;
private DeckHints has = null;
@@ -310,6 +311,7 @@ public final class CardRules implements ICardCharacteristics {
this.removedFromAIDecks = false;
this.removedFromRandomDecks = false;
this.removedFromNonCommanderDecks = false;
this.needs = null;
this.hints = null;
this.has = null;
@@ -324,7 +326,7 @@ public final class CardRules implements ICardCharacteristics {
* @return the card
*/
public final CardRules getCard() {
CardAiHints cah = new CardAiHints(removedFromAIDecks, removedFromRandomDecks, hints, needs, has);
CardAiHints cah = new CardAiHints(removedFromAIDecks, removedFromRandomDecks, removedFromNonCommanderDecks, hints, needs, has);
faces[0].assignMissingFields();
if (null != faces[1]) faces[1].assignMissingFields();
final CardRules result = new CardRules(faces, altMode, cah);
@@ -377,6 +379,7 @@ public final class CardRules implements ICardCharacteristics {
if ( "RemoveDeck".equals(variable) ) {
this.removedFromAIDecks = "All".equalsIgnoreCase(value);
this.removedFromRandomDecks = "Random".equalsIgnoreCase(value);
this.removedFromNonCommanderDecks = "NonCommander".equalsIgnoreCase(value);
}
} else if ("AlternateMode".equals(key)) {
//System.out.println(faces[curFace].getName());
@@ -551,7 +554,7 @@ public final class CardRules implements ICardCharacteristics {
}
public static CardRules getUnsupportedCardNamed(String name) {
CardAiHints cah = new CardAiHints(true, true, null, null, null);
CardAiHints cah = new CardAiHints(true, true, true,null, null, null);
CardFace[] faces = { new CardFace(name), null};
faces[0].setColor(ColorSet.fromMask(0));
faces[0].setType(CardType.parse(""));

View File

@@ -290,10 +290,17 @@ public abstract class DeckGeneratorBase {
// remove cards that generated decks don't like
Predicate<CardRules> canPlay = forAi ? AI_CAN_PLAY : HUMAN_CAN_PLAY;
Predicate<CardRules> hasColor = new MatchColorIdentity(colors);
Predicate<CardRules> canUseInFormat = new Predicate<CardRules>() {
@Override
public boolean apply(CardRules c) {
return !c.getAiHints().getRemNonCommanderDecks() || format.hasCommander();
}
};
if (useArtifacts) {
hasColor = Predicates.or(hasColor, COLORLESS_CARDS);
}
return Iterables.filter(pool.getAllCards(),Predicates.compose(Predicates.and(canPlay, hasColor), PaperCard.FN_GET_RULES));
return Iterables.filter(pool.getAllCards(),Predicates.compose(Predicates.and(canPlay, hasColor, canUseInFormat), PaperCard.FN_GET_RULES));
}
protected static Map<String, Integer> countLands(ItemPool<PaperCard> outList) {