} $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)); } } else { writeCsvRow($fontSizesFile, array((string) $title)); } $writer->reset(); } fclose($fontSizesFile); echo "Import complete.\n";
while (!feof($schemesFile)) { fwrite($cardsFile, fgets($schemesFile)); } fclose($schemesFile); // Copy planes. echo "Copying Sorcerer's Apprentice Cards...\n"; $sorcFile = fopen_utf8('misc/import/sorcerersApprentice.csv', 'rb'); if (!$sorcFile) { error('Unable to read Sorcerer\'s Apprentice Cards CSV file.'); } while (!feof($sorcFile)) { fwrite($cardsFile, fgets($sorcFile)); } fclose($sorcFile); // Write masterbase. $masterBase = new MasterBase($files[0]); $cards = $masterBase->cards; foreach ($cards as $card) { writeCsvRow($cardsFile, CardDB::cardToRow($card)); } fclose($cardsFile); echo "\n" . count($cards) . " cards processed.\n"; echo "Temporary file complete.\n"; if (file_exists('data/cards.csv')) { echo "Backing up file \"data/cards.csv\" to \"data/cards.csv.bak\"...\n"; @unlink('data/cards.csv.bak'); @rename('data/cards.csv', 'data/cards.csv.bak'); } echo "Moving temporary file to \"data/cards.csv\"...\n"; rename('data/cards.csv.temp', 'data/cards.csv'); echo "Import complete.\n";
array_slice($argv, 1), 'Drag and drop an MWS masterbase CSV file here and press enter...' ); echo 'Enter the name of the language: '; $language = strtolower(trim(fgets(STDIN))); echo "Creating temporary file: data/cards-$language.csv.temp\n"; $cardsFile = fopen_utf8("data/cards-$language.csv.temp", 'w+'); if (!$cardsFile) error("Unable to write CSV file: data/cards-$language.csv.temp"); // Write masterbase. $masterBase = new MasterBase($files[0]); $cards = $masterBase->cards; foreach ($cards as $card) writeCsvRow($cardsFile, CardDB::cardToLanguageRow($card)); fclose($cardsFile); echo "\n" . count($cards) . " cards processed.\n"; echo "Temporary file complete.\n"; if (file_exists("data/cards-$language.csv")) { echo "Backing up file \"data/cards-$language.csv\" to \"data/cards-$language.csv.bak\"...\n"; @unlink("data/cards-$language.csv.bak"); @rename("data/cards-$language.csv", "data/cards-$language.csv.bak"); } echo "Moving temporary file to \"data/cards-$language.csv\"...\n"; rename("data/cards-$language.csv.temp", "data/cards-$language.csv");