Skip to content

Commit

Permalink
ColorSet: use Stream to map ManaSymbol
Browse files Browse the repository at this point in the history
  • Loading branch information
Hanmac committed Nov 17, 2024
1 parent c9e733e commit 73940c5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 29 deletions.
20 changes: 5 additions & 15 deletions forge-gui-mobile/src/forge/itemmanager/views/ImageView.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import java.util.Map;
import java.util.Map.Entry;
import java.util.TreeMap;
import java.util.stream.Collectors;
import java.util.stream.IntStream;

import static forge.assets.FSkin.getDefaultSkinFile;
Expand Down Expand Up @@ -1030,7 +1031,7 @@ private class ItemInfo extends FDisplayObject implements Entry<InventoryItem, In
private boolean selected, deckSelectMode, showRanking;
private final float IMAGE_SIZE = CardRenderer.MANA_SYMBOL_SIZE;
private DeckProxy deckProxy = null;
private StringBuffer colorID = new StringBuffer();
private String colorID = null;
private FImageComplex deckCover = null;
private Texture dpImg = null;
//private TextureRegion tr;
Expand Down Expand Up @@ -1058,18 +1059,7 @@ private ItemInfo(T item0, Group group0) {
}
}
if (((PaperCard) item).getColorID() != null) {
for (String s : ((PaperCard) item).getColorID()) {
if ("white".equalsIgnoreCase(s))
colorID.append("{W}");
if ("green".equalsIgnoreCase(s))
colorID.append("{G}");
if ("red".equalsIgnoreCase(s))
colorID.append("{R}");
if ("blue".equalsIgnoreCase(s))
colorID.append("{U}");
if ("black".equalsIgnoreCase(s))
colorID.append("{B}");
}
colorID = ((PaperCard) item).getColorID().stream().map(MagicColor::toSymbol).collect(Collectors.joining());
}
}
}
Expand Down Expand Up @@ -1153,8 +1143,8 @@ public void draw(Graphics g) {
}
}
// spire colors
if (colorID.length() > 0) {
textRenderer.drawText(g, colorID.toString(), FSkinFont.forHeight(w / 5), Color.WHITE, x, y + h / 4, w, h, y, h, false, Align.center, true);
if (!colorID.isEmpty()) {
textRenderer.drawText(g, colorID, FSkinFont.forHeight(w / 5), Color.WHITE, x, y + h / 4, w, h, y, h, false, Align.center, true);
}
} else if (item instanceof ConquestCommander) {
CardRenderer.drawCard(g, ((ConquestCommander) item).getCard(), x, y, w, h, pos);
Expand Down
15 changes: 1 addition & 14 deletions forge-gui/src/main/java/forge/gui/card/CardDetailUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -129,20 +129,7 @@ else if (cardColors.isColorless()) {
}

public static String getCurrentColors(final CardStateView c) {
ColorSet curColors = c.getColors();
String strCurColors = "";

if (curColors.hasWhite()) { strCurColors += "{W}"; }
if (curColors.hasBlue()) { strCurColors += "{U}"; }
if (curColors.hasBlack()) { strCurColors += "{B}"; }
if (curColors.hasRed()) { strCurColors += "{R}"; }
if (curColors.hasGreen()) { strCurColors += "{G}"; }

if (strCurColors.isEmpty()) {
strCurColors = "{C}";
}

return strCurColors;
return c.getColors().toEnumSet().stream().map(MagicColor.Color::getSymbol).collect(Collectors.joining());
}

public static DetailColors getRarityColor(final CardRarity rarity) {
Expand Down

0 comments on commit 73940c5

Please sign in to comment.