Skip to content

Commit

Permalink
Normalize card names for image files
Browse files Browse the repository at this point in the history
  • Loading branch information
tehdiplomat committed Dec 29, 2023
1 parent bacb72d commit 7e20fb3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 3 additions & 1 deletion forge-core/src/main/java/forge/item/PaperCard.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import forge.util.ImageUtil;
import forge.util.Localizer;
import forge.util.TextUtil;
import org.apache.commons.lang3.StringUtils;

import java.io.IOException;
import java.io.ObjectInputStream;
Expand Down Expand Up @@ -311,7 +312,8 @@ private void readObject(ObjectInputStream ois) throws ClassNotFoundException, IO

@Override
public String getImageKey(boolean altState) {
String imageKey = ImageKeys.CARD_PREFIX + name + CardDb.NameSetSeparator
String noramlizedName = StringUtils.stripAccents(name);
String imageKey = ImageKeys.CARD_PREFIX + noramlizedName + CardDb.NameSetSeparator
+ edition + CardDb.NameSetSeparator + artIndex;
if (altState) {
imageKey += ImageKeys.BACKFACE_POSTFIX;
Expand Down
2 changes: 2 additions & 0 deletions forge-core/src/main/java/forge/util/ImageUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import forge.card.CardRules;
import forge.card.CardSplitType;
import forge.item.PaperCard;
import org.apache.commons.lang3.StringUtils;

public class ImageUtil {
public static float getNearestHQSize(float baseSize, float actualSize) {
Expand Down Expand Up @@ -200,6 +201,7 @@ public static String getScryfallDownloadUrl(PaperCard cp, String face, String se
}

public static String toMWSFilename(String in) {
in = StringUtils.stripAccents(in);
final StringBuilder out = new StringBuilder();
char c;
for (int i = 0; i < in.length(); i++) {
Expand Down

0 comments on commit 7e20fb3

Please sign in to comment.