Exemple #1
0
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program.  If not, see <http://www.gnu.org/licenses/>.
////////////////////////////////////////////////////////////////////////
require_once 'scripts/includes/global.php';

echo "Card Generator v$version - Create Card\n\n";

configPrompt(false);
cleanOutputDir(false);

$writer = new ImageWriter();
$writer->setOutputType(false, false);

echo "Collecting card data...\n";
echo "Card type (R=Regular, L=Land, V=Vanguard, S=Split, F=Flip, FL=Flip Land):\n";
$cardType = strtolower(trim(fgets(STDIN)));
if ($cardType != 'r' && $cardType != 'l' && $cardType != 'v' && $cardType != 's' && $cardType != 'f' && $cardType != 'fl') error('Invalid card type.');
if ($cardType == 's') {
	$card = promptCardInfo($cardType, false);
	$card2 = promptCardInfo($cardType, true);
	$card->title .= '/' . $card2->title;
	$card->color .= '/' . $card2->color;
	$card->cost .= '/' . $card2->cost;
	$card->type .= '/' . $card2->type;
	$card->legal .= ' // ' . $card2->legal;
	$card->flavor .= ' // ' . $card2->flavor;
    if (strtolower(trim(fgets(STDIN))) != 'n') {
        $existingFontSizeDB = new FontSizeDB(true);
    }
    if (file_exists("data/fontSizes.csv")) {
        echo "Backing up file \"data/fontSizes.csv\" to \"data/fontSizes.csv.bak\"...\n";
        @unlink("data/fontSizes.csv.bak");
        @copy("data/fontSizes.csv", "data/fontSizes.csv.bak");
    }
}
$fontSizesFile = fopen_utf8("data/fontSizes.csv", $existingFontSizeDB ? 'a' : 'w');
if (!$fontSizesFile) {
    error("Unable to write CSV file: data/fontSizes.csv");
}
$config['output.card.set.directories'] = true;
$config['card.flavor.random'] = false;
$writer = new ImageWriter();
$writer->setOutputType(false, false);
echo "Building cache...\n";
foreach ($writer->cardDB->getAllCardTitles() as $title) {
    if ($existingFontSizeDB && $existingFontSizeDB->hasCard($title)) {
        continue;
    }
    $writer->fontSizeDB->reset();
    $writer->addCardByTitle($title);
    foreach ($writer->renderers as $renderer) {
        $renderer->render();
    }
    $fontSizes = $writer->fontSizeDB->getSizes($title);
    if ($fontSizes) {
        foreach ($fontSizes as $hash => $size) {
            writeCsvRow($fontSizesFile, array((string) $title, (string) $hash, (string) $size));
Exemple #3
0
// You should have received a copy of the GNU General Public License
// along with this program.  If not, see <http://www.gnu.org/licenses/>.
////////////////////////////////////////////////////////////////////////
require_once 'includes/global.php';
$pagedOutput = $argv[1] == 'pagedOutput=true';
$decklistOnlyOutput = $argv[2] == 'decklistOnlyOutput=true';
$fileNames = array_slice($argv, 3);
$mode = 'Generate ';
if ($decklistOnlyOutput) {
    $mode .= 'Decklist ';
}
$mode .= $pagedOutput ? 'Pages' : 'Cards';
echo "Card Generator v{$version} - {$mode}\n\n";
$files = getInputFiles($fileNames, 'Drag and drop a decklist file or directory into this window and press enter...');
configPrompt($decklistOnlyOutput);
cleanOutputDir($pagedOutput);
$writer = new ImageWriter();
$writer->setOutputType($pagedOutput, $decklistOnlyOutput);
foreach ($files as $file) {
    $writer->parseDecklist($file);
}
echo "Generating images...\n";
if ($pagedOutput) {
    $count = $writer->writePages();
    echo "Image generation complete.\n";
    echo $count . " pages written.\n";
} else {
    $count = $writer->writeCards();
    echo "Image generation complete.\n";
    echo $count . " images written.\n";
}