- Added the Multi+Changed mode for displaying color identity (displays color identity of all multicolor cards and of all cards with changed identity).

- Refactored and optimized the color identity display code.
This commit is contained in:
Agetian
2015-06-03 07:02:10 +00:00
parent d58e48e90d
commit dc5535c5ca
5 changed files with 27 additions and 18 deletions

View File

@@ -239,14 +239,22 @@ public class CardDetailUtil {
public static String formatCardColorIdentity(final CardStateView state) {
final String colorIdentMode = FModel.getPreferences().getPref(ForgePreferences.FPref.UI_DISPLAY_COLOR_IDENTITY);
final CardView card = state.getCard();
boolean showIdentity = false;
String colorIdent = "";
// do not show identity for temp effect cards, emblems and the like
if (state.getType().hasSubtype("Effect")) {
return "";
}
if (!colorIdentMode.equals(ForgeConstants.DISP_COLOR_IDENT_NEVER)) {
final CardView card = state.getCard();
boolean isMulticolor = state.getColors().countColors() > 1;
boolean isChanged = false;
colorIdent = getColorIdentity(state);
if (colorIdentMode.equals(ForgeConstants.DISP_COLOR_IDENT_CHANGED)) {
// do not waste CPU cycles on this if the mode does not involve checking for changed color identity
if (colorIdentMode.equals(ForgeConstants.DISP_COLOR_IDENT_CHANGED) || colorIdentMode.equals(ForgeConstants.DISP_COLOR_IDENT_MULTI_OR_CHANGED)) {
String origIdent = "";
PaperCard origPaperCard = null;
Card origCard = null;
@@ -267,17 +275,14 @@ public class CardDetailUtil {
} catch(Exception ex) {
System.err.println("Unexpected behavior: card " + card.getName() + "[" + card.getId() + "] tripped an exception when trying to process color identity.");
}
showIdentity = !colorIdent.equals(origIdent);
} else if (colorIdentMode.equals(ForgeConstants.DISP_COLOR_IDENT_MULTICOLOR)) {
final int numColors = state.getColors().countColors();
showIdentity = numColors > 1;
} else if (colorIdentMode.equals(ForgeConstants.DISP_COLOR_IDENT_ALWAYS)) {
showIdentity = true;
isChanged = !colorIdent.equals(origIdent);
}
// do not show identity for temp effect cards, emblems and the like
if (state.getType().hasSubtype("Effect")) {
showIdentity = false;
if ((colorIdentMode.equals(ForgeConstants.DISP_COLOR_IDENT_MULTICOLOR) && isMulticolor) ||
(colorIdentMode.equals(ForgeConstants.DISP_COLOR_IDENT_CHANGED) && isChanged) ||
(colorIdentMode.equals(ForgeConstants.DISP_COLOR_IDENT_MULTI_OR_CHANGED) && (isChanged || isMulticolor)) ||
(colorIdentMode.equals(ForgeConstants.DISP_COLOR_IDENT_ALWAYS))) {
showIdentity = true;
}
}

View File

@@ -182,6 +182,7 @@ public final class ForgeConstants {
public static final String DISP_COLOR_IDENT_ALWAYS = "Always";
public static final String DISP_COLOR_IDENT_CHANGED = "Changed";
public static final String DISP_COLOR_IDENT_MULTICOLOR = "Multicolor";
public static final String DISP_COLOR_IDENT_MULTI_OR_CHANGED = "Multi+Changed";
public static final String DISP_COLOR_IDENT_NEVER = "Never";
}