CardType: add flag to show when its used incomplete in Animate Effects

This commit is contained in:
Hans Mackowiak
2020-10-05 08:07:18 +02:00
parent 9b87a33300
commit 011a5dddeb
8 changed files with 29 additions and 22 deletions

View File

@@ -487,7 +487,7 @@ public final class CardRules implements ICardCharacteristics {
if ("T".equals(key)) {
this.faces[this.curFace].addTrigger(value);
} else if ("Types".equals(key)) {
this.faces[this.curFace].setType(CardType.parse(value));
this.faces[this.curFace].setType(CardType.parse(value, false));
} else if ("Text".equals(key) && !"no text".equals(value) && StringUtils.isNotBlank(value)) {
this.faces[this.curFace].setNonAbilityText(value);
}
@@ -557,7 +557,7 @@ public final class CardRules implements ICardCharacteristics {
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(""));
faces[0].setType(CardType.parse("", false));
faces[0].setOracleText("This card is not supported by Forge. Whenever you start a game with this card, it will be bugged.");
faces[0].setNonAbilityText("This card is not supported by Forge.\nWhenever you start a game with this card, it will be bugged.");
faces[0].assignMissingFields();

View File

@@ -50,7 +50,7 @@ import forge.util.Settable;
public final class CardType implements Comparable<CardType>, CardTypeView {
private static final long serialVersionUID = 4629853583167022151L;
public static final CardTypeView EMPTY = new CardType();
public static final CardTypeView EMPTY = new CardType(false);
public static final String AllCreatureTypes = "AllCreatureTypes";
@@ -111,11 +111,14 @@ public final class CardType implements Comparable<CardType>, CardTypeView {
private final Set<CoreType> coreTypes = EnumSet.noneOf(CoreType.class);
private final Set<Supertype> supertypes = EnumSet.noneOf(Supertype.class);
private final Set<String> subtypes = Sets.newLinkedHashSet();
private boolean incomplete = false;
private transient String calculatedType = null;
public CardType() {
public CardType(boolean incomplete) {
this.incomplete = incomplete;
}
public CardType(final Iterable<String> from0) {
public CardType(final Iterable<String> from0, boolean incomplete) {
this.incomplete = incomplete;
addAll(from0);
}
public CardType(final CardType from0) {
@@ -516,6 +519,10 @@ public final class CardType implements Comparable<CardType>, CardTypeView {
}
public void sanisfySubtypes() {
// incomplete types are used for changing effects
if (this.incomplete) {
return;
}
if (!isCreature() && !isTribal()) {
Iterables.removeIf(subtypes, Predicates.IS_CREATURE_TYPE);
subtypes.remove(AllCreatureTypes);
@@ -637,11 +644,11 @@ public final class CardType implements Comparable<CardType>, CardTypeView {
return false;
}
public static CardType parse(final String typeText) {
public static CardType parse(final String typeText, boolean incomplete) {
// Most types and subtypes, except "Serra's Realm" and
// "Bolas's Meditation Realm" consist of only one word
final char space = ' ';
final CardType result = new CardType();
final CardType result = new CardType(incomplete);
int iTypeStart = 0;
int iSpace = typeText.indexOf(space);
@@ -661,7 +668,7 @@ public final class CardType implements Comparable<CardType>, CardTypeView {
}
public static CardType combine(final CardType a, final CardType b) {
final CardType result = new CardType();
final CardType result = new CardType(false);
result.supertypes.addAll(a.supertypes);
result.supertypes.addAll(b.supertypes);
result.coreTypes.addAll(a.coreTypes);