当前位置: 首页>>代码示例>>PHP>>正文


PHP Card::getCostColors方法代码示例

本文整理汇总了PHP中Card::getCostColors方法的典型用法代码示例。如果您正苦于以下问题:PHP Card::getCostColors方法的具体用法?PHP Card::getCostColors怎么用?PHP Card::getCostColors使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Card的用法示例。


在下文中一共展示了Card::getCostColors方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: render

	public function render () {
		global $config;

		echo $this->card . '...';
		$card = $this->card;
		$settings = $this->getSettings();
		$costColors = Card::getCostColors($card->cost);
		$white = '255,255,255';

		$canvas = imagecreatetruecolor(1050, 736);

		// Art image.
		$this->drawArt($canvas, $card->artFileName, $settings['art.top'], $settings['art.left'], $settings['art.bottom'], $settings['art.right'], !$config['art.keep.aspect.ratio']);

		echo '.';

		// Background image.
		$bgImage = @imagecreatefrompng('images/plane/plane.png');
		imagecopy($canvas, $bgImage, 0, 0, 0, 0, 1050, 736);

		echo '.';

		// Set and rarity.
		$rarityLeft = $this->drawRarity($canvas, $card->rarity, $card->set, $settings['rarity.right'], $settings['rarity.center.y'], $settings['rarity.height'], $settings['rarity.width'], false);

		// Card title.
		$this->drawText($canvas, $settings['title.x'], $settings['title.y'], null, $card->getDisplayTitle(), $this->font('title'));

		echo '.';

		// Type.
		$this->drawText($canvas, $settings['type.x'], $settings['type.y'], null, $card->type, $this->font('type'));

		//Chaos Symbol
		$this->drawSymbol($canvas, 632, 115, 50, 'C', null);

		// Legal text.
		if (!preg_match('/(.*\n)(.*?)$/s', $card->legal, $matches)) error('Missing chaos ability from legal text: ' . $card->title);
		$this->drawLegalAndFlavorText($canvas, $settings['text.top'], $settings['text.left'], $settings['text.bottom'], $settings['text.right'], $matches[1], null, $this->font('text'), 0);
		$this->drawLegalAndFlavorText($canvas, $settings['chaos.top'], $settings['chaos.left'], $settings['chaos.bottom'], $settings['chaos.right'], $matches[2], null, $this->font('text'), 0);

		// Artist and copyright.
		// The artist color is white if the frame behind it is black.
		$footerColor = '255,255,255';
		if ($card->artist) {
			if ($settings['card.artist.gears']) {
				$artistSymbol = '{gear}';
			} else {
				$artistSymbol = '{brush}';
			}
			$this->drawText($canvas, $settings['artist.x'], $settings['artist.y'], null, $artistSymbol . $card->artist, $this->font('artist', 'color:' . $footerColor));
		}
		if ($card->copyright) $this->drawText($canvas, $settings['copyright.x'], $settings['copyright.y'], null, $card->copyright, $this->font('copyright', 'color:' . $footerColor));

		echo "\n";
		return $canvas;
	}
开发者ID:GarikRC,项目名称:arcane,代码行数:57,代码来源:PlaneRenderer.php

示例2: render

 public function render()
 {
     global $config;
     echo $this->card . '...';
     $card = $this->card;
     $settings = $this->getSettings();
     $costColors = Card::getCostColors($card->cost);
     $white = '255,255,255';
     $useMulticolorFrame = strlen($costColors) == 2;
     $canvas = imagecreatetruecolor(736, 1050);
     // Art image.
     $this->drawArt($canvas, $card->artFileName, $settings['art.top'], $settings['art.left'], $settings['art.bottom'], $settings['art.right'], !$config['art.keep.aspect.ratio']);
     echo '.';
     // Background image.
     $borderImage = null;
     $greyTitleAndTypeOverlay = null;
     if ($card->isArtefact()) {
         $bgImage = @imagecreatefrompng('images/eighth/leveler/cards/Art.png');
     } else {
         if ($useMulticolorFrame || $card->isDualManaCost()) {
             // Multicolor frame.
             if ($settings['card.multicolor.gold.frame']) {
                 $bgImage = @imagecreatefrompng("images/eighth/leveler/cards/Gld{$costColors}" . ".png");
             } else {
                 $bgImage = @imagecreatefrompng("images/eighth/leveler/cards/{$costColors}" . ".png");
             }
             if (!$bgImage) {
                 error("Background image not found for color: {$costColors}");
             }
         } else {
             // Mono color frame.
             $bgImage = @imagecreatefrompng('images/eighth/leveler/cards/' . $card->color . '.png');
             if (!$bgImage) {
                 error('Background image not found for color "' . $card->color . '"');
             }
         }
     }
     imagecopy($canvas, $bgImage, 0, 0, 0, 0, 736, 1050);
     imagedestroy($bgImage);
     // Casting cost.
     $costLeft = $this->drawCastingCost($canvas, $card->getCostSymbols(), $card->isDualManaCost() ? $settings['cost.top.dual'] : $settings['cost.top'], $settings['cost.right'], $settings['cost.size'], true);
     echo '.';
     // Set and rarity.
     $rarityLeft = $this->drawRarity($canvas, $card->rarity, $card->set, $settings['rarity.right'], $settings['rarity.center.y'], $settings['rarity.height'], $settings['rarity.width'], false);
     // Card title.
     $this->drawText($canvas, $settings['title.x'], $settings['title.y'], $costLeft - $settings['title.x'], $card->getDisplayTitle(), $this->font('title'));
     echo '.';
     // Type.
     $this->drawText($canvas, $settings['type.x'], $settings['type.y'], $rarityLeft - $settings['type.x'], $card->type, $this->font('type'));
     // Legal text.
     if (!preg_match_all('/(.*?)\\r?\\n(.*?) ([0-9\\-\\+]+?)\\r?\\n([0-9\\*\\-\\+\\/]{3,})\\r?\\n(.*?)\\r?\\n?((?<=\\n)[^\\s]*?(?=\\s)) ([0-9\\-\\+]+?)\\r?\\n([0-9\\*\\-\\+\\/]{3,})\\r?\\n?(.*?)$/s', $card->legal, $matches)) {
         error('Wrong format for legal text: ' . $card->title);
     }
     //1
     $this->drawText($canvas, $settings['pt.1.center.x'], $settings['pt.1.center.y'], $settings['pt.1.width'], $card->pt, $this->font('pt'));
     $this->drawLegalAndFlavorText($canvas, $settings['text.1.top'], $settings['text.1.left'], $settings['text.1.bottom'], $settings['text.1.right'], $matches[1][0], null, $this->font('text'), 0);
     //2
     $this->drawText($canvas, $settings['pt.2.center.x'], $settings['pt.2.center.y'], $settings['pt.2.width'], $matches[4][0], $this->font('pt'));
     $this->drawText($canvas, $settings['name.2.center.x'], $settings['name.2.center.y'], $settings['name.2.width'], $matches[2][0], $this->font('pt', 'glow:true'));
     $this->drawText($canvas, $settings['level.2.center.x'], $settings['level.2.center.y'], $settings['level.2.width'], $matches[3][0], $this->font('pt', 'glow:true'));
     $this->drawLegalAndFlavorText($canvas, $settings['text.2.top'], $settings['text.2.left'], $settings['text.2.bottom'], $settings['text.2.right'], $matches[5][0], null, $this->font('text'), 0);
     //3
     $this->drawText($canvas, $settings['pt.3.center.x'], $settings['pt.3.center.y'], $settings['pt.3.width'], $matches[8][0], $this->font('pt'));
     $this->drawText($canvas, $settings['name.3.center.x'], $settings['name.3.center.y'], $settings['name.3.width'], $matches[6][0], $this->font('pt', 'glow:true'));
     $this->drawText($canvas, $settings['level.3.center.x'], $settings['level.3.center.y'], $settings['level.3.width'], $matches[7][0], $this->font('pt', 'glow:true'));
     $this->drawLegalAndFlavorText($canvas, $settings['text.3.top'], $settings['text.3.left'], $settings['text.3.bottom'], $settings['text.3.right'], $matches[9][0], null, $this->font('text'), 10);
     // Artist and copyright.
     // The artist color is white if the frame behind it is black.
     $footerColor = '0,0,0';
     if ($card->isLand()) {
         $footerColor = '255,255,255';
     } else {
         if ($card->color == 'B' && !$card->isArtefact()) {
             $footerColor = '255,255,255';
         } else {
             if ($costColors == 'B' && !$card->isArtefact()) {
                 $footerColor = '255,255,255';
             } else {
                 if (stripos($card->englishType, 'Eldrazi') !== false) {
                     $footerColor = '255,255,255';
                 } else {
                     if ($useMulticolorFrame) {
                         // Only multicolor frames with a bottom left color of black should use a white footer.
                         if (strlen($costColors) <= 2 && substr($costColors, 0, 1) == 'B' || strlen($costColors) >= 3 && substr($costColors, 2, 1) == 'B') {
                             $footerColor = '255,255,255';
                         }
                     }
                 }
             }
         }
     }
     if ($card->artist) {
         if ($settings['card.artist.gears']) {
             $artistSymbol = '{gear}';
         } else {
             $artistSymbol = '{brush}';
         }
         $this->drawText($canvas, $settings['artist.x'], $settings['artist.y'], null, $artistSymbol . $card->artist, $this->font('artist', 'color:' . $footerColor));
     }
     if ($card->copyright) {
//.........这里部分代码省略.........
开发者ID:kyuumeitai,项目名称:cardgen,代码行数:101,代码来源:LevelRenderer.php

示例3: __construct

	public function __construct ($mwsFileName) {
		$mwsFile = fopen_utf8($mwsFileName, 'rb');
		if (!$mwsFile) error('Unable to open masterbase CSV file: ' . $mwsFileName);
		
		echo "Processing MWS masterbase...";

		// windows-1252
		//$csv = new CSV(';', "\r\n", '"'); // Cell separator, row separator, value enclosure.

		//$csv->setContent(file_get_contents($mwsFileName, false , null)); // Parse the string content.

		//$rows = $csv->getArray();
		$i = 0;
		while (($row = fgetcsv($mwsFile, 6000, ';', '"')) !== FALSE) {
		//foreach($rows as $row){
			if($i++ == 0) continue; //skip first line
			if ($i++ % 50 == 0) echo '.';

			// Extract.
			$title = (string)trim($row[0]);
			$set = (string)trim($row[1]);
			$color = (string)trim($row[4]);
			$type = (string)trim($row[6]);
			$p = (string)trim($row[8]);
			$t = (string)trim($row[9]);
			$flavor = (string)trim($row[10]);
			$rarity = (string)trim($row[11]);
			$cost = (string)trim($row[5]);
			$legal = trim($row[7]);
			$pic = (string)trim($row[2]);
			$artist = (string)trim($row[12]);
			$collectorNumber = (string)trim($row[13]);

			// Title.
			if ($set == 'VG') $title = 'Avatar: ' . $title;

			// Casting cost.
			$cost = $this->replaceDualManaSymbols($cost);
			$cost = preg_replace('/([0-9]+)/', '{\\1}', $cost); //
			$cost = preg_replace('/([WUBRGXYZ])/', '{\\1}', $cost);
			$cost = preg_replace('/{{([0-9XYZWUBRG])}{([WUBRG])}}/', '{\\1\\2}', $cost);

			// Color.
			if ($color == 'Z/Z') {
				// Determine split card colors.
				$cost1 = substr($cost, 0, strpos($cost, '/'));
				$colors = Card::getCostColors($cost1);
				$color = strlen($colors) == 1 ? $colors : 'Gld';

				$color .= '/';

				$cost2 = substr($cost, strpos($cost, '/') + 1);
				$colors = Card::getCostColors($cost2);
				$color .= strlen($colors) == 1 ? $colors : 'Gld';
			}

			//php5 fixups
			$flavor = str_replace("\xA0", '', $flavor);
			$flavor = iconv('windows-1250', 'utf-8', $flavor);
			$legal = iconv('windows-1250', 'utf-8' ,$legal);
			$artist = iconv('windows-1250', 'utf-8' ,$artist);
			//convert title and type just in case
			$title = iconv('windows-1250', 'utf-8', $title);
			$type = iconv('windows-1250', 'utf-8' ,$type);

			// Type.
			$type = str_replace(' - ', ' — ', $type);

			// Legal.
			$legal = $this->replaceDualManaSymbols($legal);
			$legal = preg_replace('/\%([0-9]+)/', '{\\1}', $legal);
			$legal = preg_replace('/\%([WUBRGTXYZ])/', '{\\1}', $legal);
			$legal = preg_replace('/\%([C])/', '{Q}', $legal);
			$legal = preg_replace('/#([^#]+)# – /', '\\1 – ', $legal); // Remove italics from ability keywords.
			$legal = str_replace("\r\n----\r\n", "\n-----\n", $legal); // Flip card separator.
			$legal = str_replace('Creature - ', 'Creature — ', $legal);
			$legal = str_replace(' upkeep - ', ' upkeep—', $legal);
			$legal = str_replace(' - ', ' — ', $legal);
			$legal = str_replace('AE', 'Æ', $legal);
			$legal = str_replace(".]", ".)", $legal);
			$legal = str_replace("\r\n", "\n", $legal);
			// Fix vanguard inconsistencies.
			if (preg_match('/Starting & Max[^\+\-]+([\+\-][0-9]+)[^\+\-]+([\+\-][0-9]+)/', $legal, $matches))
				$legal = 'Hand ' . $matches[1] . ', Life ' . $matches[2] . "\n" . substr($legal, 0, strpos($legal, ' Starting & Max'));
			if (preg_match('/Hand Size[^\+\-]+([\+\-][0-9]+)[^\+\-]+([\+\-][0-9]+)\.?/', $legal, $matches))
				$legal = 'Hand ' . $matches[1] . ', Life ' . $matches[2] . "\n" . substr($legal, 0, strpos($legal, 'Hand Size'));
			$legal = trim($legal);

			// Flavor.
			$flavor = str_replace("'", '’', $flavor); // ' to ’
			$flavor = preg_replace('/"([^"]*)"/', '“\\1”', $flavor); // "text" to “text”
			$flavor = preg_replace("/(.*[^.]) '([^']*)'/", "\\1 ‘\\2’", $flavor); // 'text' to ‘text’
			$flavor = preg_replace('/(.*[^.]) ’(.*)’/', '\\1 ‘\\2’', $flavor); // ’text’ to ‘text’
			$flavor = str_replace('”’', '’”', $flavor); // ”’ to ’”
			$flavor = str_replace('‘”', '”‘', $flavor); // ‘” to ”‘
			$flavor = str_replace('“’', '“‘', $flavor); // “’ to “‘
			$flavor = str_replace(',’', '’,', $flavor); // ,’ to ’,
			$flavor = preg_replace("/\r\n- ?/", "\n—", $flavor); // - to —
			$flavor = preg_replace("/\r\n#- ?/", "\n#—", $flavor);
			$flavor = preg_replace("/ - /", "—", $flavor);
//.........这里部分代码省略.........
开发者ID:GarikRC,项目名称:arcane,代码行数:101,代码来源:MasterBase.php

示例4: render

 public function render()
 {
     global $config;
     echo $this->card . '...';
     $card = $this->card;
     $settings = $this->getSettings();
     $costColors = Card::getCostColors($card->cost);
     $useMulticolorFrame = strlen($costColors) == 2 && strpos($settings['card.multicolor.frames'], strval(strlen($costColors))) !== false;
     $canvas = imagecreatetruecolor(736, 1050);
     // Art image.
     $this->drawArt($canvas, $card->artFileName, $settings['art.top'], $settings['art.left'], $settings['art.bottom'], $settings['art.right'], !$config['art.keep.aspect.ratio']);
     echo '.';
     $cards = explode("\n-----\n", $card->legal);
     $legal1 = $cards[0];
     if (preg_match("/(.*?)\n(.*?)\n(.*?)\n(.*)/s", $cards[1], $matches)) {
         $title2 = $matches[1];
         $type2 = $matches[2];
         $pt2 = $matches[3];
         $legal2 = $matches[4];
     } else {
         preg_match("/(.*?)\n(.*?)\n(.*)/s", $cards[1], $matches);
         $title2 = $matches[1];
         $type2 = $matches[2];
         $pt2 = '';
         $legal2 = $matches[3];
     }
     // Background image, border image, and grey title/type image.
     $borderImage = null;
     $greyTitleAndTypeOverlay = null;
     if ($card->isLand()) {
         // Land frame.
         $landColors = @$this->writer->titleToLandColors[strtolower($card->title)];
         if (!$landColors) {
             error('Land color missing for card: ' . $card->title);
         }
         if (strlen($landColors) > 1) {
             $useMulticolorLandFrame = strpos($settings['card.multicolor.land.frames'], strval(strlen($landColors))) !== false;
             if (!$useMulticolorLandFrame) {
                 $landColors = 'A';
             }
         }
         $bgImage = @imagecreatefrompng("images/eighth/flip/land/{$landColors}.png");
         if (!$bgImage) {
             error('Background image not found for land color "$landColors": ' . $card->title);
         }
         // Grey title/type image.
         if (strlen($landColors) >= 2 && $settings['card.multicolor.grey.title.and.type']) {
             $greyTitleAndTypeOverlay = @imagecreatefrompng('images/eighth/flip/cards/C-overlay.png');
             if (!$greyTitleAndTypeOverlay) {
                 error('Image not found: C-overlay.png');
             }
         }
     } else {
         if ($useMulticolorFrame || $card->isDualManaCost()) {
             // Multicolor frame.
             $bgImage = @imagecreatefrompng("images/eighth/flip/cards/{$costColors}.png");
             if (!$bgImage) {
                 error("Background image not found for color: {$costColors}");
             }
             // Grey title/type image.
             if ($settings['card.multicolor.grey.title.and.type']) {
                 $greyTitleAndTypeOverlay = @imagecreatefrompng('images/eighth/flip/cards/C-overlay.png');
                 if (!$greyTitleAndTypeOverlay) {
                     error('Image not found: C-overlay.png');
                 }
             }
         } else {
             // Mono color frame.
             $bgImage = @imagecreatefrompng('images/eighth/flip/cards/' . $card->color . '.png');
             if (!$bgImage) {
                 error('Background image not found for color "' . $card->color . '" in frame dir: flips');
             }
             // Border image.
             if (strlen($costColors) == 2 && $settings['card.multicolor.dual.borders']) {
                 $borderImage = @imagecreatefrompng("images/eighth/flips/borders/{$costColors}.png");
             }
         }
     }
     imagecopy($canvas, $bgImage, 0, 0, 0, 0, 736, 1050);
     imagedestroy($bgImage);
     if ($borderImage) {
         imagecopy($canvas, $borderImage, 0, 0, 0, 0, 736, 1050);
         imagedestroy($borderImage);
     }
     if ($greyTitleAndTypeOverlay) {
         imagecopy($canvas, $greyTitleAndTypeOverlay, 0, 0, 0, 0, 736, 1050);
         imagedestroy($greyTitleAndTypeOverlay);
     }
     // Power / toughness.
     if ($card->pt) {
         if ($useMulticolorFrame || $card->isDualManaCost()) {
             $image = @imagecreatefrompng('images/eighth/flip/pt/' . substr($costColors, -1, 1) . 'u.png');
         } else {
             $image = @imagecreatefrompng('images/eighth/flip/pt/' . $card->color . 'u.png');
         }
         if (!$image) {
             error("Power/toughness image not found for color: {$card->color}");
         }
         imagecopy($canvas, $image, 0, 0, 0, 0, 736, 1050);
         imagedestroy($image);
//.........这里部分代码省略.........
开发者ID:kyuumeitai,项目名称:cardgen,代码行数:101,代码来源:EighthFlipRenderer.php

示例5: promptCardInfo

function promptCardInfo ($cardType, $isLastCard = true) {
	global $writer;

	$card = new Card();

	echo "Title:\n";
	$card->title = upperCaseWords(trim(fgets(STDIN)));
	if (!$card->title) error('Invalid title.');

	if ($cardType != 'v' && $cardType != 'l' && $cardType != 'fl' && ($cardType != 'f' || !$isLastCard)) {
		echo "Casting cost (ex: 4R, {4}{R}, 1RWU, {10}{WU}):\n";
		$cost = trim(fgets(STDIN));
		if (strpos($cost, '{') === false) {
			$newCost = '';
			for ($i = 0, $n = strlen($cost); $i < $n; $i++)
				$newCost .= '{' . $cost[$i] . '}';
			$cost = $newCost;
		}
		$card->cost = $cost;

		$colors = Card::getCostColors($cost);
		$colorCount = strlen($colors);
		if ($colorCount == 1)
			$card->color = $colors;
		else if ($colorCount > 1)
			$card->color = 'Gld';
		else if ($card->cost)
			$card->color = 'Art';
	}

	if ($cardType == 'v') {
		$card->color = 'Art';
		$card->set = 'VG';
	}

	if ($cardType == 'l' || ($cardType == 'fl' && !$isLastCard)) {
		$card->color = 'Lnd';
		echo "Mana color(s) land can produce (ex: W, R, C, A, RG, RGW, WUBRG):\n";
		$writer->titleToLandColors[strtolower($card->title)] = Card::getCostColors(trim(fgets(STDIN)));
		if (!$writer->titleToLandColors[strtolower($card->title)]) error('Invalid land mana color(s).');
	}

	if (($cardType != 'f' && $cardType != 'fl') || !$isLastCard) {
		echo "Art (URL or local file path):\n";
		$card->artFileName = trim(fgets(STDIN));
	}

	if ($cardType != 'v') {
		echo "Type (ex: Creature - Human):\n";
		$card->type = str_replace('-', '&#8211;', upperCaseWords(trim(fgets(STDIN))));

		if ($cardType != 'l' && $cardType != 'fl') {
			echo "Power/toughness (ex: 3/4):\n";
			$card->pt = trim(fgets(STDIN));
		}
	}

	echo "Legal text (ex: {T}: Add {G} to your mana pool. #(This is italic.)#):\n";
	$text = '';
	while (true) {
		$input = trim(fgets(STDIN));
		if ($input == '') break;
		if ($text) $text .= "\n";
		$text .= $input;
	}
	$text = str_replace('-', '&#8211;', $text);
	$card->legal = $text;

	if ($cardType != 'f' && $cardType != 'fl') {
		echo "Flavor text:\n";
		$text = '';
		while (true) {
			$input = trim(fgets(STDIN));
			if ($input == '') break;
			if ($text) $text .= "\n";
			$text .= $input;
		}
		$card->flavor = str_replace('-', '&#8212;', $text);
	}
	
	if ($cardType == 'v') {
		echo "Starting & max hand size (ex: +1, -3, +10):\n";
		$hand = trim(fgets(STDIN));
		if (substr($hand, 0, 1) != '+' && substr($hand, 0, 1) != '-') error('Invalid starting & max hand size.');

		echo "Starting life (ex: +5, -12, +0):\n";
		$life = trim(fgets(STDIN));
		if (substr($life, 0, 1) != '+' && substr($life, 0, 1) != '-') error('Invalid starting life.');

		$card->legal = "Hand $hand, Life $life\n" . $card->legal;
	}

	if (($cardType != 'f' && $cardType != 'fl') || !$isLastCard) {
		echo "Artist:\n";
		$card->artist = trim(fgets(STDIN));

		echo "Copyright (ex: (tm) & (c) 2006 Lizards on a Post, Inc. 42/175):\n";
		$card->copyright = trim(fgets(STDIN));
		$card->copyright = str_replace('(tm)', '&#8482;', $card->copyright);
		$card->copyright = str_replace('(c)', '&#169;', $card->copyright);
//.........这里部分代码省略.........
开发者ID:GarikRC,项目名称:arcane,代码行数:101,代码来源:createCard.php

示例6: render

 public function render()
 {
     global $config;
     echo $this->card . '...';
     $card = $this->card;
     $settings = $this->getSettings();
     $frameDir = $this->getFrameDir($card->title, $card->set, $settings);
     $costColors = Card::getCostColors($card->cost);
     $useMulticolorFrame = strlen($costColors) > 1 && strpos($settings['card.multicolor.frames'], strval(strlen($costColors))) !== false || $card->isDualManaCost() && (strpos($settings['card.multicolor.frames'], strval(strlen($costColors))) !== false || strlen($costColors) == 2);
     switch ($frameDir) {
         case "timeshifted":
             $useMulticolorFrame = false;
             break;
         case "transform-day":
             $useMulticolorFrame = false;
             $pts = explode("|", $card->pt);
             $card->pt = $pts[0];
             break;
         case "transform-night":
             $useMulticolorFrame = false;
             break;
     }
     $canvas = imagecreatetruecolor(736, 1050);
     // Art image.
     if ($card->isEldrazi() && $card->isArtefact()) {
         $this->drawArt($canvas, $card->artFileName, 0, 0, 1050, 736, !$config['art.keep.aspect.ratio']);
     } else {
         $this->drawArt($canvas, $card->artFileName, $settings['art.top'], $settings['art.left'], $settings['art.bottom'], $settings['art.right'], !$config['art.keep.aspect.ratio']);
     }
     echo '.';
     // Background image, border image, and grey title/type image.
     $borderImage = null;
     $greyTitleAndTypeOverlay = null;
     if ($card->isLand()) {
         // Land frame.
         $landColors = @$this->writer->titleToLandColors[strtolower($card->title)];
         if ($settings['card.multicolor.fetch.land.frames']) {
             switch (strtolower($card->title)) {
                 case 'flooded strand':
                     $landColors = 'WU';
                     break;
                 case 'bloodstained mire':
                     $landColors = 'BR';
                     break;
                 case 'wooded foothills':
                     $landColors = 'RG';
                     break;
                 case 'polluted delta':
                     $landColors = 'UB';
                     break;
                 case 'windswept heath':
                     $landColors = 'GW';
                     break;
                 case 'flood plain':
                     $landColors = 'WU';
                     break;
                 case 'rocky tar pit':
                     $landColors = 'BR';
                     break;
                 case 'mountain valley':
                     $landColors = 'RG';
                     break;
                 case 'bad river':
                     $landColors = 'UB';
                     break;
                 case 'grasslands':
                     $landColors = 'GW';
                     break;
             }
         }
         switch (strtolower($card->title)) {
             case 'arid mesa':
                 $landColors = 'RW';
                 break;
             case 'marsh flats':
                 $landColors = 'WB';
                 break;
             case 'misty rainforest':
                 $landColors = 'GU';
                 break;
             case 'scalding tarn':
                 $landColors = 'UR';
                 break;
             case 'verdant catacombs':
                 $landColors = 'BG';
                 break;
         }
         if (!$landColors) {
             error('Land color missing for card: ' . $card->title);
         }
         if (strlen($landColors) > 1) {
             $useMulticolorLandFrame = strpos($settings['card.multicolor.land.frames'], strval(strlen($landColors))) !== false;
             if (!$useMulticolorLandFrame) {
                 $landColors = 'A';
             }
         }
         $bgImage = @imagecreatefrompng("images/eighth/{$frameDir}/land/{$landColors}.png");
         if (!$bgImage) {
             error("Background image not found for land color \"{$landColors}\": " . $card->title);
         }
//.........这里部分代码省略.........
开发者ID:kyuumeitai,项目名称:cardgen,代码行数:101,代码来源:EighthRenderer.php

示例7: __construct

 public function __construct($mwsFileName)
 {
     $mwsFile = fopen_utf8($mwsFileName, 'rb');
     if (!$mwsFile) {
         error('Unable to open masterbase CSV file: ' . $mwsFileName);
     }
     echo "Processing MWS masterbase...";
     // windows-1252
     //$csv = new CSV(';', "\r\n", '"'); // Cell separator, row separator, value enclosure.
     //$csv->setContent(file_get_contents($mwsFileName, false , null)); // Parse the string content.
     //$rows = $csv->getArray();
     $i = 0;
     while (($row = fgetcsv($mwsFile, 6000, ';', '"')) !== FALSE) {
         //foreach($rows as $row){
         if ($i++ == 0) {
             continue;
         }
         //skip first line
         if ($i++ % 50 == 0) {
             echo '.';
         }
         // Extract.
         $title = (string) trim($row[0]);
         $set = (string) trim($row[1]);
         $color = (string) trim($row[4]);
         $type = (string) trim($row[6]);
         $p = (string) trim($row[8]);
         $t = (string) trim($row[9]);
         $flavor = (string) trim($row[10]);
         $rarity = (string) trim($row[11]);
         $cost = (string) trim($row[5]);
         $legal = trim($row[7]);
         $pic = (string) trim($row[2]);
         $artist = (string) trim($row[12]);
         $collectorNumber = (string) trim($row[13]);
         // Title.
         if ($set == 'VG') {
             $title = 'Avatar: ' . $title;
         }
         // Casting cost.
         $cost = $this->replaceDualManaSymbols($cost);
         $cost = $this->replacePhyrexiaSymbols($cost);
         $cost = preg_replace('/([0-9]+)/', '{\\1}', $cost);
         //
         $cost = preg_replace('/([WUBRGXYZ])/', '{\\1}', $cost);
         $cost = preg_replace('/{{([0-9XYZWUBRG])}{([WUBRG])}}/', '{\\1\\2}', $cost);
         $cost = preg_replace('/{([P]){([WUBRG])}}/', '{\\1\\2}', $cost);
         // Color.
         if ($color == 'Z/Z' || strpos($title, '/') !== FALSE && $p == "" && $t == "") {
             // Determine split card colors.
             $cost1 = substr($cost, 0, strpos($cost, '/'));
             $colors = Card::getCostColors($cost1);
             $color = strlen($colors) == 1 ? $colors : 'Gld';
             $color .= '/';
             $cost2 = substr($cost, strpos($cost, '/') + 1);
             $colors = Card::getCostColors($cost2);
             $color .= strlen($colors) == 1 ? $colors : 'Gld';
         }
         if (strpos($title, "/") !== FALSE && ($p != "" && $t != "" || $set == 'DKA' || $set == 'ISD')) {
             // flip cards fixes
             $title1 = substr($title, 0, strpos($title, '/'));
             $title2 = substr($title, strpos($title, '/') + 1);
             $title = $title1;
             $type1 = substr($type, 0, strpos($type, '/'));
             $type2 = substr($type, strpos($type, '/') + 1);
             $type = $type1;
             $pt = "";
             if (strpos($t, '|') !== FALSE) {
                 $t1 = substr($t, 0, strpos($t, '|'));
                 $pt = substr($t, strpos($t, '|') + 1);
                 $t = $t1;
             } else {
                 if (strpos($p, '|') !== FALSE) {
                     $p1 = substr($p, 0, strpos($p, '|'));
                     $pt = substr($p, strpos($p, '|') + 1) . '/' . $t;
                     $p = $p1;
                     $t = '';
                     if ($pt == '#/') {
                         //maybe need something more generic for dual planeswalkers later
                         $pt = '';
                         $p .= '#';
                     }
                 }
             }
             $insertPosition = strpos($legal, "//");
             $insertString = "\n" . $title2 . "\n" . $type2 . ($pt != "" ? "\n" . $pt : "");
             $legalTmp = substr_replace($legal, $insertString, $insertPosition + 2, 0);
             $legal = $legalTmp;
         }
         //php5 fixups
         $flavor = str_replace("�", '', $flavor);
         $flavor = iconv('windows-1250', 'utf-8', $flavor);
         $legal = iconv('windows-1250', 'utf-8', $legal);
         $artist = iconv('windows-1250', 'utf-8', $artist);
         //convert title and type just in case
         $title = iconv('windows-1250', 'utf-8', $title);
         $type = iconv('windows-1250', 'utf-8', $type);
         // Type.
         $type = str_replace(' - ', ' — ', $type);
         // Legal.
//.........这里部分代码省略.........
开发者ID:kyuumeitai,项目名称:cardgen,代码行数:101,代码来源:MasterBase.php

示例8: render

	public function render () {
		global $config;

		echo $this->card . '...';
		$card = $this->card;

		$settings = $this->getSettings();
		$costColors = Card::getCostColors($card->cost);
		$canvas = imagecreatetruecolor(736, 1050);

		// Art image.
		$this->drawArt($canvas, $card->artFileName, $settings['art.top'], $settings['art.left'], $settings['art.bottom'], $settings['art.right'], !$config['art.keep.aspect.ratio']);

		echo '.';

		// Background image.
		if ($card->isLand()) {
			// Land frame.
			$landColors = @$this->writer->titleToLandColors[strtolower($card->title)];
			$notBasicFrame = '';
			if ($settings['card.multicolor.fetch.land.frames']) {
				switch (strtolower($card->title)) {
				case 'flooded strand': $landColors = 'WU'; break;
				case 'bloodstained mire': $landColors = 'BR'; break;
				case 'wooded foothills': $landColors = 'RG'; break;
				case 'polluted delta': $landColors = 'UB'; break;
				case 'windswept heath': $landColors = 'GW'; break;
				case 'flood plain': $landColors = 'WU'; break;
				case 'rocky tar pit': $landColors = 'BR'; break;
				case 'mountain valley': $landColors = 'RG'; break;
				case 'bad river': $landColors = 'UB'; break;
				case 'grasslands': $landColors = 'GW'; break;
				}
			}
			if (!$landColors) error('Land color missing for card: ' . $card->title);
			if (strlen($landColors) > 1) {
				$useMulticolorLandFrame = strpos($settings['card.multicolor.land.frames'], strval(strlen($landColors))) !== false;
				if (strlen($landColors) > 2 || !$useMulticolorLandFrame) $landColors = 'A';
			}
			else if(!$card->isBasicLand() && $landColors != 'A' && $landColors != 'C')
				$notBasicFrame = 'C';
			$bgImage = @imagecreatefrompng("images/preEighth/land/$notBasicFrame$landColors.png");
			if (!$bgImage) error("Background image not found for land color \"$notBasicFrame$landColors\": " . $card->title);
		} else {
			// Mono color frame.
			$bgImage = @imagecreatefrompng('images/preEighth/cards/' . $card->color . '.png');
			if (!$bgImage) error('Background image not found for mono color: ' . $card->color);
		}
		imagecopy($canvas, $bgImage, 0, 0, 0, 0, 736, 1050);

		// Power / toughness.
		if ($card->pt) $this->drawText($canvas, $settings['pt.center.x'], $settings['pt.center.y'], $settings['pt.width'], $card->pt, $this->font('pt'));

		// Casting cost.
		$costLeft = $this->drawCastingCost($canvas, $card->getCostSymbols(), $settings['cost.top'], $settings['cost.right'], $settings['cost.size']);

		echo '.';

		// Set and rarity.
		if (!$card->isBasicLand() || $settings['card.basic.land.set.symbols']) {
			$rarityMiddle = $settings['rarity.center.y'];
			if ($card->isLand()) $rarityMiddle += 2; // Rarity on pre8th lands is slightly lower.
			$rarityLeft = $this->drawRarity($canvas, $card->rarity, $card->set, $settings['rarity.right'], $rarityMiddle, $settings['rarity.height'], $settings['rarity.width'], true, $settings['card.rarity.fallback']);
		} else
			$rarityLeft = $settings['rarity.right'];

		// Tombstone sign.
		if ($settings['card.tombstone']) {
			if (strpos($card->legal, 'Flashback') !=false || strpos($card->type, 'Incarnation') !=false || $card->title == 'Riftstone Portal' || $card->title == 'Ichorid') {
				list($image, $width, $height) = getPNG('images/preEighth/tombstone.png', 'Tombstone image not found.');
				imagecopy($canvas, $image, $settings["tombstone.left"], $settings["tombstone.top"], 0, 0, $width, $height);
			}
		}

		// Card title.
		$this->drawText($canvas, $settings['title.x'], $settings['title.y'], $costLeft - $settings['title.x'], $card->getDisplayTitle(false), $this->font('title'));

		echo '.';

		// Type.
		$typeBaseline = $settings['type.y'];
		if ($card->isLand()) $typeBaseline += 2; // Type on pre8th lands is slightly lower.
		$this->drawText($canvas, $settings['type.x'], $typeBaseline, $rarityLeft - $settings['type.x'], $card->type, $this->font('type'));

		if ($card->isBasicLand()) {
			// Basic land symbol instead of legal text.
			list($image, $width, $height) = getPNG("images/symbols/land/$landColors.png", "Basic land image not found for: images/symbols/land/$landColors.png");
			imagecopy($canvas, $image, 373 - ($width / 2), 640, 0, 0, $width, $height);
		} else if ($card->isLand() && strlen($landColors) == 2 && !$card->legal) {
			// Dual land symbol instead of legal text.
			if ($settings['card.dual.land.symbols'] == 1) {
				// Single hybrid symbol.
				list($image, $width, $height) = getPNG("images/symbols/land/$landColors.png", "Dual symbol image not found for: $landColors");
				imagecopy($canvas, $image, 368 - ($width / 2), 667, 0, 0, $width, $height);
			} else if ($settings['card.dual.land.symbols'] == 2) {
				// One of each basic symbol.
				$landColor = substr($landColors, 0, 1);
				list($image, $width, $height) = getPNG("images/symbols/land/$landColor.png", 'Basic land image not found for: ' . $card->title);
				imagecopy($canvas, $image, 217 - ($width / 2), 640, 0, 0, $width, $height);

//.........这里部分代码省略.........
开发者ID:GarikRC,项目名称:arcane,代码行数:101,代码来源:PreEighthRenderer.php

示例9: render

 public function render()
 {
     global $config;
     echo $this->card . '...';
     $card = $this->card;
     $settings = $this->getSettings();
     $costColors = Card::getCostColors($card->cost);
     $white = '255,255,255';
     $useMulticolorFrame = strlen($costColors) == 2;
     $canvas = imagecreatetruecolor(736, 1050);
     // Art image.
     $this->drawArt($canvas, $card->artFileName, $settings['art.top'], $settings['art.left'], $settings['art.bottom'], $settings['art.right'], !$config['art.keep.aspect.ratio']);
     echo '.';
     // Background image.
     $borderImage = null;
     $greyTitleAndTypeOverlay = null;
     if ($card->isArtefact()) {
         $bgImage = @imagecreatefrompng('images/planeswalker/regular/cards/Art4.png');
     } else {
         if ($useMulticolorFrame || $card->isDualManaCost()) {
             // Multicolor frame.
             if ($settings['card.multicolor.gold.frame']) {
                 $bgImage = @imagecreatefrompng("images/planeswalker/regular/cards/Gld{$costColors4}.png");
             } else {
                 $bgImage = @imagecreatefrompng("images/planeswalker/regular/cards/{$costColors4}.png");
             }
             if (!$bgImage) {
                 error("Background image not found for color: {$costColors}");
             }
         } else {
             // Mono color frame.
             $bgImage = @imagecreatefrompng('images/planeswalker/regular/cards/' . $card->color . '4.png');
             if (!$bgImage) {
                 error('Background image not found for color "' . $card->color . '"');
             }
         }
     }
     imagecopy($canvas, $bgImage, 0, 0, 0, 0, 736, 1050);
     imagedestroy($bgImage);
     // Loyalty
     if ($card->pt) {
         $image = @imagecreatefrompng('images/planeswalker/loyalty/LoyaltyBegin.png');
         if (!$image) {
             error("Loyalty image not found");
         }
         imagecopy($canvas, $image, 605, 940, 0, 0, 127, 82);
         imagedestroy($image);
         $card->pt = (string) str_replace('/', '', $card->pt);
         $this->drawText($canvas, $settings['loyalty.starting.center.x'], $settings['loyalty.starting.center.y'], $settings['loyalty.starting.width'], $card->pt, $this->font('loyalty.starting', 'color:' . $white));
     }
     // Casting cost.
     $costLeft = $this->drawCastingCost($canvas, $card->getCostSymbols(), $card->isDualManaCost() ? $settings['cost.top.dual'] : $settings['cost.top'], $settings['cost.right'], $settings['cost.size'], true);
     echo '.';
     // Set and rarity.
     $rarityLeft = $this->drawRarity($canvas, $card->rarity, $card->set, $settings['rarity.right'], $settings['rarity.center.y'], $settings['rarity.height'], $settings['rarity.width'], false);
     // Card title.
     $this->drawText($canvas, $settings['title.x'], $settings['title.y'], $costLeft - $settings['title.x'], $card->getDisplayTitle(), $this->font('title'));
     echo '.';
     // Type.
     $this->drawText($canvas, $settings['type.x'], $settings['type.y'], $rarityLeft - $settings['type.x'], $card->type, $this->font('type'));
     // Legal text.
     if (!preg_match_all('/(\\+|-)?([0-9XYZ]+): (.*?)(?=$|[-|\\+]?[0-9XYZ]+:)/s', $card->legal, $matches)) {
         error('Missing legality change from legal text: ' . $card->title);
     }
     //print_r($matches);
     $logaltyImage = null;
     $loyalty = array();
     //1
     $this->loyaltyIcon($matches[1][0], 1, $logaltyImage, $loyalty);
     imagecopy($canvas, $logaltyImage, $loyalty['x'], $loyalty['y'], 0, 0, $loyalty['w'], $loyalty['h']);
     imagedestroy($logaltyImage);
     $this->drawText($canvas, $settings['loyalty.1.center.x'], $settings['loyalty.1.center.y'], $settings['loyalty.1.center.width'], preg_replace('/([+|-])/', '{\\1}', $matches[1][0]) . $matches[2][0], $this->font('loyalty.change', 'color:' . $white));
     $this->drawLegalAndFlavorText($canvas, $settings['text.1.top'], $settings['text.1.left'], $settings['text.1.bottom'], $settings['text.1.right'], $matches[3][0], null, $this->font('text'), 0);
     //2
     $this->loyaltyIcon($matches[1][1], 2, $logaltyImage, $loyalty);
     imagecopy($canvas, $logaltyImage, $loyalty['x'], $loyalty['y'], 0, 0, $loyalty['w'], $loyalty['h']);
     imagedestroy($logaltyImage);
     $this->drawText($canvas, $settings['loyalty.2.center.x'], $settings['loyalty.2.center.y'], $settings['loyalty.2.center.width'], preg_replace('/([+|-])/', '{\\1}', $matches[1][1]) . $matches[2][1], $this->font('loyalty.change', 'color:' . $white));
     $this->drawLegalAndFlavorText($canvas, $settings['text.2.top'], $settings['text.2.left'], $settings['text.2.bottom'], $settings['text.2.right'], $matches[3][1], null, $this->font('text'), 0);
     //3
     $this->loyaltyIcon($matches[1][2], 3, $logaltyImage, $loyalty);
     imagecopy($canvas, $logaltyImage, $loyalty['x'], $loyalty['y'], 0, 0, $loyalty['w'], $loyalty['h']);
     imagedestroy($logaltyImage);
     $this->drawText($canvas, $settings['loyalty.3.center.x'], $settings['loyalty.3.center.y'], $settings['loyalty.3.center.width'], preg_replace('/([+|-])/', '{\\1}', $matches[1][2]) . $matches[2][2], $this->font('loyalty.change', 'color:' . $white));
     $this->drawLegalAndFlavorText($canvas, $settings['text.3.top'], $settings['text.3.left'], $settings['text.3.bottom'], $settings['text.3.right'], $matches[3][2], null, $this->font('text'), 10);
     //4
     $this->loyaltyIcon($matches[1][3], 4, $logaltyImage, $loyalty);
     imagecopy($canvas, $logaltyImage, $loyalty['x'], $loyalty['y'], 0, 0, $loyalty['w'], $loyalty['h']);
     imagedestroy($logaltyImage);
     $this->drawText($canvas, $settings['loyalty.4.center.x'], $settings['loyalty.4.center.y'], $settings['loyalty.4.center.width'], preg_replace('/([+|-])/', '{\\1}', $matches[1][3]) . $matches[2][3], $this->font('loyalty.change', 'color:' . $white));
     $this->drawLegalAndFlavorText($canvas, $settings['text.4.top'], $settings['text.4.left'], $settings['text.4.bottom'], $settings['text.4.right'], $matches[3][3], null, $this->font('text'), 10);
     // Artist and copyright.
     // The artist color is white if the frame behind it is black.
     $footerColor = '255,255,255';
     if ($card->artist) {
         if ($settings['card.artist.gears']) {
             $artistSymbol = '{gear}';
         } else {
             $artistSymbol = '{brush}';
         }
//.........这里部分代码省略.........
开发者ID:kyuumeitai,项目名称:cardgen,代码行数:101,代码来源:PlanesWalker4Renderer.php


注:本文中的Card::getCostColors方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。