ensure TokenEffect-generated tokens have correctly formed filenames

This commit is contained in:
myk
2013-03-13 14:29:10 +00:00
parent 037bb74d88
commit c54cc4dfe6
2 changed files with 5 additions and 7 deletions

View File

@@ -67,7 +67,7 @@ public class TokenEffect extends SpellAbilityEffect {
} }
if (mapParams.hasParam("TokenImage")) { if (mapParams.hasParam("TokenImage")) {
image = mapParams.getParam("TokenImage"); image = CardToken.makeTokenFileName(mapParams.getParam("TokenImage"));
} else { } else {
image = ""; image = "";
} }

View File

@@ -16,11 +16,9 @@ public class CardToken implements InventoryItemFromSet, IPaperCard {
private String imageFileName; private String imageFileName;
private CardRules card; private CardRules card;
private static String toTokenFilename(final String in) { // takes a string of the form "<colors> <power> <toughness> <name>" such as: "B 0 0 Germ"
final StringBuffer out = new StringBuffer(); public static String makeTokenFileName(String in) {
StringBuffer out = new StringBuffer(ImageCache.TOKEN_PREFIX);
out.append(ImageCache.TOKEN_PREFIX);
char c; char c;
for (int i = 0; i < in.length(); i++) { for (int i = 0; i < in.length(); i++) {
c = in.charAt(i); c = in.charAt(i);
@@ -40,7 +38,7 @@ public class CardToken implements InventoryItemFromSet, IPaperCard {
public static String makeTokenFileName(String colors, String power, String toughness, String name) { public static String makeTokenFileName(String colors, String power, String toughness, String name) {
StringBuilder fileName = new StringBuilder(); StringBuilder fileName = new StringBuilder();
fileName.append(colors).append('_').append(power).append('_').append(toughness).append('_').append(name); fileName.append(colors).append('_').append(power).append('_').append(toughness).append('_').append(name);
return toTokenFilename(fileName.toString()); return makeTokenFileName(fileName.toString());
} }
public CardToken(final CardRules c, CardEdition edition0, final String imageFileName) { public CardToken(final CardRules c, CardEdition edition0, final String imageFileName) {