mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-15 18:28:00 +00:00
*Added a map of color -> basic land type to Constant, since it might be of use elsewhere.
*Added Commander deck conformance check for basic land types.
This commit is contained in:
@@ -20,10 +20,14 @@ package forge;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
import forge.card.MagicColor;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Constant interface.
|
||||
@@ -95,6 +99,20 @@ public final class Constant {
|
||||
|
||||
/** The Basic lands. */
|
||||
public static final List<String> BASIC_LANDS = Collections.unmodifiableList(Arrays.asList("Plains", "Island", "Swamp", "Mountain", "Forest"));
|
||||
|
||||
public static final Map<String, String> COLOR_TO_BASIC_LAND_TYPE_MAP;
|
||||
|
||||
static
|
||||
{
|
||||
Map<String, String> colToType = new HashMap<String, String>();
|
||||
colToType.put(Color.WHITE, "Plains");
|
||||
colToType.put(Color.BLUE, "Island");
|
||||
colToType.put(Color.BLACK, "Swamp");
|
||||
colToType.put(Color.RED, "Mountain");
|
||||
colToType.put(Color.GREEN, "Forest");
|
||||
|
||||
COLOR_TO_BASIC_LAND_TYPE_MAP = Collections.unmodifiableMap(colToType);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -19,14 +19,18 @@ package forge.deck;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import org.apache.commons.lang.math.IntRange;
|
||||
|
||||
import forge.Constant;
|
||||
import forge.Singletons;
|
||||
import forge.card.CardCoreType;
|
||||
import forge.card.ColorSet;
|
||||
import forge.card.MagicColor;
|
||||
import forge.item.CardDb;
|
||||
import forge.item.CardPrinted;
|
||||
import forge.item.IPaperCard;
|
||||
@@ -146,18 +150,44 @@ public enum DeckFormat {
|
||||
|
||||
ColorSet cmdCI = cmd.get(0).getRules().getColorIdentity();
|
||||
List<CardPrinted> erroneousCI = new ArrayList<CardPrinted>();
|
||||
|
||||
|
||||
for(Entry<CardPrinted, Integer> cp : deck.get(DeckSection.Main)) {
|
||||
if(!cp.getKey().getRules().getColorIdentity().hasNoColorsExcept(cmdCI.getColor()))
|
||||
{
|
||||
erroneousCI.add(cp.getKey());
|
||||
}
|
||||
if(cp.getKey().getRules().getType().isLand())
|
||||
{
|
||||
for(String key : Constant.Color.COLOR_TO_BASIC_LAND_TYPE_MAP.keySet())
|
||||
{
|
||||
if(!cmdCI.hasAnyColor(MagicColor.fromName(key)))
|
||||
{
|
||||
if(cp.getKey().getRules().getType().subTypeContains(Constant.Color.COLOR_TO_BASIC_LAND_TYPE_MAP.get(key)))
|
||||
{
|
||||
erroneousCI.add(cp.getKey());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
for(Entry<CardPrinted, Integer> cp : deck.get(DeckSection.Sideboard)) {
|
||||
if(!cp.getKey().getRules().getColorIdentity().hasNoColorsExcept(cmdCI.getColor()))
|
||||
{
|
||||
erroneousCI.add(cp.getKey());
|
||||
}
|
||||
if(cp.getKey().getRules().getType().isLand())
|
||||
{
|
||||
for(String key : Constant.Color.COLOR_TO_BASIC_LAND_TYPE_MAP.keySet())
|
||||
{
|
||||
if(!cmdCI.hasAnyColor(MagicColor.fromName(key)))
|
||||
{
|
||||
if(cp.getKey().getRules().getType().subTypeContains(Constant.Color.COLOR_TO_BASIC_LAND_TYPE_MAP.get(key)))
|
||||
{
|
||||
erroneousCI.add(cp.getKey());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(erroneousCI.size() > 0)
|
||||
|
||||
Reference in New Issue
Block a user