Merge branch 'tokenset' into 'master'

Some improvements to token image fetching (especially emblems)

See merge request core-developers/forge!5105
This commit is contained in:
Michael Kamensky
2021-07-25 04:27:44 +00:00
3 changed files with 36 additions and 1 deletions

View File

@@ -9,6 +9,7 @@ import com.google.common.collect.Lists;
import forge.GameCommand;
import forge.ImageKeys;
import forge.card.CardRarity;
import forge.game.Game;
import forge.game.GameObject;
import forge.game.ability.AbilityFactory;
@@ -123,6 +124,8 @@ public class EffectEffect extends SpellAbilityEffect {
}
String image;
String set = hostCard.getSetCode().toLowerCase();
StringBuilder imageSet = new StringBuilder();
if (sa.hasParam("Image")) {
image = ImageKeys.getTokenKey(sa.getParam("Image"));
} else if (name.startsWith("Emblem")) { // try to get the image from name
@@ -135,11 +138,17 @@ public class EffectEffect extends SpellAbilityEffect {
} else { // use host image
image = hostCard.getImageKey();
}
imageSet.append(image).append("_").append(set);
image = imageSet.toString();
for (Player controller : effectOwner) {
final Card eff = createEffect(sa, controller, name, image);
eff.setSetCode(sa.getHostCard().getSetCode());
eff.setRarity(sa.getHostCard().getRarity());
if (name.startsWith("Emblem")) {
eff.setRarity(CardRarity.Common);
} else {
eff.setRarity(sa.getHostCard().getRarity());
}
// Abilities and triggers work the same as they do for Token
// Grant abilities

View File

@@ -88,6 +88,19 @@ public class SwingImageFetcher extends ImageFetcher {
break;
} catch (IOException e) {
System.err.println("Failed to download card [" + destPath + "] image: " + e.getMessage());
if (urlToDownload.contains("tokens")) {
int setIndex = urlToDownload.lastIndexOf('_');
int typeIndex = urlToDownload.lastIndexOf('.');
String setlessFilename = urlToDownload.substring(0, setIndex);
String extension = urlToDownload.substring(typeIndex);
urlToDownload = setlessFilename+extension;
try {
doFetch(tofullBorder(urlToDownload));
break;
} catch (IOException t) {
System.err.println("Failed to download setless token [" + destPath + "]: " + e.getMessage());
}
}
}
}
}

View File

@@ -76,6 +76,19 @@ public class LibGDXImageFetcher extends ImageFetcher {
break;
} catch (IOException e) {
System.out.println("Failed to download card [" + destPath + "] image: " + e.getMessage());
if (urlToDownload.contains("tokens")) {
int setIndex = urlToDownload.lastIndexOf('_');
int typeIndex = urlToDownload.lastIndexOf('.');
String setlessFilename = urlToDownload.substring(0, setIndex);
String extension = urlToDownload.substring(typeIndex);
urlToDownload = setlessFilename+extension;
try {
doFetch(tofullBorder(urlToDownload));
break;
} catch (IOException t) {
System.out.println("Failed to download setless token [" + destPath + "]: " + e.getMessage());
}
}
}
}
}