From bae89a965f0e0535fbb6c42bc9086aae87285947 Mon Sep 17 00:00:00 2001 From: Kyle <41976328+ImKyle4815@users.noreply.github.com> Date: Mon, 4 Oct 2021 17:44:22 -0700 Subject: [PATCH] Update creator-23.js --- js/creator-23.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/js/creator-23.js b/js/creator-23.js index 909101a8..4cbdc404 100644 --- a/js/creator-23.js +++ b/js/creator-23.js @@ -157,11 +157,14 @@ function getElementIndex(element) { return Array.prototype.indexOf.call(element.parentElement.children, element); } function getCardName() { + if (card.text == undefined) { + return 'unnamed'; + } var imageName = card.text.title.text || 'unnamed'; if (card.text.nickname) { imageName += ' (' + card.text.nickname.text + ')'; } - return imageName.replace(/\{[^}]+\}/g, '') + '.png'; + return imageName.replace(/\{[^}]+\}/g, ''); } //UI function toggleCreatorTabs(event, target) { @@ -727,6 +730,9 @@ function writeText(textObject, targetContext) { if (params.get('copyright') != null && (textObject.name == 'wizards' || textObject.name == 'copyright') && card.margins) { rawText = params.get('copyright'); //so people using CC for custom card games without WotC's IP can customize their copyright info } + if (rawText.toLowerCase().includes('{cardname}')) { + rawText = rawText.replace(/{cardname}/ig, getCardName()); + } var splitText = rawText.replace(/\n/g, '{line}').replace(/{flavor}/g, '{lns}{bar}{lns}{fixtextalign}{i}').replace(/{/g, splitString + '{').replace(/}/g, '}' + splitString).replace(/ /g, splitString + ' ' + splitString).split(splitString); splitText = splitText.filter(item => item); if (textObject.vertical) { @@ -1582,7 +1588,7 @@ function downloadCard(alt = false) { } else { // Prep file information const imageDataURL = cardCanvas.toDataURL('image/png'); - var imageName = getCardName(); + var imageName = getCardName() + '.png'; // Download image if (alt) { const newWindow = window.open('about:blank');