package editor.database.attributes;

/**
 * This enum represents a legality in a format.  If a card is banned, it cannot
 * be played in any deck.  If it is restricted, exactly one copy may appear in a deck
 * and its sideboard.  If it is legal, up to four copies (with the exception of basic
 * lands and cards that say otherwise) may appear in a deck and its sideboard.
 *
 * @author Alec Roelke
 */
public enum Legality
{
    /**
     * Card is not legal in the format.
     */
    BANNED("Banned"),
    /**
     * A normal number of cards is legal to have in a deck.
     */
    LEGAL("Legal"),
    /**
     * Only one copy of the card is legal in a deck.
     */
    RESTRICTED("Restricted");

    /**
     * Parse a String for a Legality.
     *
     * @param s String to parse
     * @return the Legality corresponding to the contents of the specified String.
     * @throws IllegalArgumentException if there is no corresponding Legality
     */
    public static Legality parseLegality(String s)
    {
        for (Legality l : Legality.values())
            if (s.equalsIgnoreCase(l.toString()))
                return l;
        throw new IllegalArgumentException("Illegal legality string " + s);
    }

    /**
     * Type of legality a card might have in a format.
     */
    private final String legality;

    /**
     * Create a new Legality.
     *
     * @param legality Type of legality a card might have.
     */
    Legality(final String legality)
    {
        this.legality = legality;
    }

    @Override
    public String toString()
    {
        return legality;
    }
}

@@ -493,16 +493,23 @@
 %22Banned%22
+, false
 ),%0A    /
@@ -596,16 +596,22 @@
 (%22Legal%22
+, true
 ),%0A    /
@@ -701,16 +701,215 @@
 tricted%22
+, true),%0A    /**%0A     * Catch-all for cards that aren't banned, but aren't legal either (e.g.%0A     * because they've rotated or weren't legal in the first place).%0A     */%0A    ILLEGAL(%22Illegal%22, false
 );%0A%0A    
@@ -1524,16 +1524,130 @@
 egality;
+%0A    /**%0A     * Whether or not this represents a legal card in a format.%0A     */%0A    public final boolean isLegal;
 %0A%0A    /*
@@ -1786,16 +1786,37 @@
 legality
+, final boolean legal
 )%0A    %7B%0A
@@ -1845,24 +1845,49 @@
 = legality;%0A
+        isLegal = legal;%0A
     %7D%0A%0A    @

Add catch-all illegal Legality