<?php

//creeMimichant($idqueue,$idcorps,$idtete,$idoreille,$colorHexa);

// ////////////////////////////////////////////////////////////////// //
//             creeMimichant pendant le jeu                           //
//(car ces fonctions sont utilisé par 2 fichier différents en include //
//          - dans main/get/getChars.php                              //
//          - dans main/get/getGroundCharInfo.php                     //
//          - dans incription/inscription.php                         //
// ////////////////////////////////////////////////////////////////// //

function createMimichant($idqueue,$idcorps,$idtete,$idoreille,$colorHexa){
	
	$image_source = imagecreate(103,153);
	$trans_source=ImageColorAllocate($image_source,125,125,125);
	
	$entete_nom = "../../mimichants/";
	$nom = "t".$idtete."o".$idoreille."c".$idcorps."q".$idqueue."c".$colorHexa.".gif";
	$nom_destination=$entete_nom.$nom;
	
	if (!file_exists($nom_destination)){

		sscanf($colorHexa, "%2x%2x%2x", $red, $green, $blue);

		switch($idqueue)
		{
		case 1: $queue = imagecreatefromgif("../../charsprites/qrenard.gif");
			break;
		case 2: $queue = imagecreatefromgif("../../charsprites/qcochon.gif");
			break;
		case 3: $queue = imagecreatefromgif("../../charsprites/qsinge.gif");
			break;
		case 4: $queue = imagecreatefromgif("../../charsprites/qecureuil.gif");
			break;
		case 5: $queue = imagecreatefromgif("../../charsprites/qcanard.gif");
			break;
		case 6: $queue = imagecreatefromgif("../../charsprites/vide.gif");
			break;
		default : $queue = imagecreatefromgif("../../charsprites/qrenard.gif");
		}
	
		switch($idcorps)
		{
		case 1: $corps = imagecreatefromgif("../../charsprites/crenard.gif");
			break;
		case 2: $corps = imagecreatefromgif("../../charsprites/ccochon.gif");
			break;
		case 3: $corps = imagecreatefromgif("../../charsprites/csinge.gif");
			break;
		case 4: $corps = imagecreatefromgif("../../charsprites/cecureuil.gif");
			break;
		case 5: $corps = imagecreatefromgif("../../charsprites/ccanard.gif");
			break;
		case 6: $corps = imagecreatefromgif("../../charsprites/clapin.gif");
			break;
		case 7: $corps = imagecreatefromgif("../../charsprites/cpingouin.gif");
			break;
		case 8: $corps = imagecreatefromgif("../../charsprites/cgrenouille.gif");
			break;
		default : $corps = imagecreatefromgif("../../charsprites/crenard.gif");
		}
		
		switch($idtete)
		{
		case 1: $tete = imagecreatefromgif("../../charsprites/trenard.gif");
			break;
		case 2: $tete = imagecreatefromgif("../../charsprites/tcochon.gif");
			break;
		case 3: $tete = imagecreatefromgif("../../charsprites/tsinge.gif");
			break;
		case 4: $tete = imagecreatefromgif("../../charsprites/tecureuil.gif");
			break;
		case 5: $tete = imagecreatefromgif("../../charsprites/tcanard.gif");
			break;
		case 6: $tete = imagecreatefromgif("../../charsprites/tlapin.gif");
			break;
		case 7: $tete = imagecreatefromgif("../../charsprites/tpingouin.gif");
			break;
		case 8: $tete = imagecreatefromgif("../../charsprites/tgrenouille.gif");
			break;
		default : $tete = imagecreatefromgif("../../charsprites/trenard.gif");
		}
		
		switch($idoreille)
		{
		case 1: $oreille = imagecreatefromgif("../../charsprites/orenard.gif");
			break;
		case 2: $oreille = imagecreatefromgif("../../charsprites/ocochon.gif");
			break;
		case 3: $oreille = imagecreatefromgif("../../charsprites/osinge.gif");
			break;
		case 4: $oreille = imagecreatefromgif("../../charsprites/oecureuil.gif");
			break;
		case 5: $oreille = imagecreatefromgif("../../charsprites/olapin.gif");
			break;
		case 6: $oreille = imagecreatefromgif("../../charsprites/vide.gif");
			break;
		default : $oreille = imagecreatefromgif("../../charsprites/orenard.gif");
		}

		
		/******************colorisation de la queue*****************/
		$queue_interm = imagecreate(103,153);
		$color_qmimichant=ImageColorAllocate($queue_interm,$red,$green,$blue);
		$trans_queue=ImageColorAllocate($queue_interm,125,125,125);
		imageFilledRectangle($queue_interm,0,0,103,153,$color_qmimichant);
		imagecopymerge($queue_interm, $queue, 0, 0,0,0, 103, 153, 100);
		imagecolortransparent($queue_interm, $trans_queue);
		
		/******************colorisation des oreilles*****************/
		$oreille_interm = imagecreate(103,153);
		$color_omimichant=ImageColorAllocate($oreille_interm,$red,$green,$blue);
		$trans_oreille=ImageColorAllocate($oreille_interm,125,125,125);
		ImageFilledRectangle($oreille_interm,0,0,103,153,$color_omimichant);
		imagecopymerge($oreille_interm, $oreille, 0, 0,0,0, 103, 153, 100);
		imagecolortransparent($oreille_interm, $trans_oreille);
		
		/******************colorisation des oreilles*****************/
		$corps_interm = imagecreate(103,153);
		$color_cmimichant=ImageColorAllocate($corps_interm,$red,$green,$blue);
		$trans_corps=ImageColorAllocate($corps_interm,125,125,125);
		ImageFilledRectangle($corps_interm,0,0,103,153,$color_cmimichant);
		imagecopymerge($corps_interm, $corps, 0, 0,0,0, 103, 153, 100);
		imagecolortransparent($corps_interm, $trans_corps);
		
		/******************colorisation des oreilles*****************/
		$tete_interm = imagecreate(103,153);
		$color_tmimichant=ImageColorAllocate($tete_interm,$red,$green,$blue);
		$trans_tete=ImageColorAllocate($tete_interm,125,125,125);
		ImageFilledRectangle($tete_interm,0,0,103,153,$color_tmimichant);
		imagecopymerge($tete_interm, $tete, 0, 0,0,0, 103, 153, 100);
		imagecolortransparent($tete_interm, $trans_tete);
		
		imagecopymerge($image_source, $queue_interm, 0, 0,0,0, 103, 153, 100);
		imagecopymerge($image_source, $corps_interm, 0, 0,0,0, 103, 153, 100);
		imagecopymerge($image_source, $oreille_interm, 0, 0,0,0, 103, 153, 100);
		imagecopymerge($image_source, $tete_interm, 0, 0,0,0, 103, 153, 100);
		imagecolortransparent($image_source, $trans_source);
		
		$image_destination=imagecreate (46, 65);
		imagecopyresized($image_destination, $image_source, 0, 0, 0, 0, 46, 65, 103, 153);
		imagecolortransparent($image_destination, $trans_source);
		imagegif ($image_destination,$nom_destination);
		
		
		$nom_mini=$entete_nom."mini".$nom;
		$image_mini=imagecreate (30,49);
		imagecopyresized($image_mini, $image_source, 0, 0, 0, 0, 30, 49, 103, 153);
		imagecolortransparent($image_mini, $trans_source);
		imagegif ($image_mini,$nom_mini);
		
		$nom_gros=$entete_nom."gros".$nom;
		$image_gros=imagecreate (103,153);
		imagecopyresized($image_gros, $image_source, 0, 0, 0, 0, 103, 153, 103, 153);
		imagecolortransparent($image_gros, $trans_source);
		imagegif ($image_gros,$nom_gros);
		
	}
	
}

// ////////////////////////////////////////////////////////////////// //
//             creeMimichant a l'inscription                          //
//(car ces fonctions sont utilisé par 2 fichier différents en include //
//          - dans main/get/getChars.php                              //
//          - dans main/get/getGroundCharInfo.php                     //
//          - dans incription/inscription.php                         //
// ////////////////////////////////////////////////////////////////// //
function creeMimichant($idqueue,$idcorps,$idtete,$idoreille,$colorHexa){
	
	$image_source = imagecreate(103,153);
	$trans_source=ImageColorAllocate($image_source,125,125,125);
	
	$entete_nom = "../mimichants/";
	$nom = "t".$idtete."o".$idoreille."c".$idcorps."q".$idqueue."c".$colorHexa.".gif";
	$nom_destination=$entete_nom.$nom;
	
	if (!file_exists($nom_destination)){

		sscanf($colorHexa, "%2x%2x%2x", $red, $green, $blue);

		switch($idqueue)
		{
		case 1: $queue = imagecreatefromgif("../charsprites/qrenard.gif");
			break;
		case 2: $queue = imagecreatefromgif("../charsprites/qcochon.gif");
			break;
		case 3: $queue = imagecreatefromgif("../charsprites/qsinge.gif");
			break;
		case 4: $queue = imagecreatefromgif("../charsprites/qecureuil.gif");
			break;
		case 5: $queue = imagecreatefromgif("../charsprites/qcanard.gif");
			break;
		case 6: $queue = imagecreatefromgif("../charsprites/vide.gif");
			break;
		default : $queue = imagecreatefromgif("../charsprites/qrenard.gif");
		}
	
		switch($idcorps)
		{
		case 1: $corps = imagecreatefromgif("../charsprites/crenard.gif");
			break;
		case 2: $corps = imagecreatefromgif("../charsprites/ccochon.gif");
			break;
		case 3: $corps = imagecreatefromgif("../charsprites/csinge.gif");
			break;
		case 4: $corps = imagecreatefromgif("../charsprites/cecureuil.gif");
			break;
		case 5: $corps = imagecreatefromgif("../charsprites/ccanard.gif");
			break;
		case 6: $corps = imagecreatefromgif("../charsprites/clapin.gif");
			break;
		case 7: $corps = imagecreatefromgif("../charsprites/cpingouin.gif");
			break;
		case 8: $corps = imagecreatefromgif("../charsprites/cgrenouille.gif");
			break;
		default : $corps = imagecreatefromgif("../charsprites/crenard.gif");
		}
		
		switch($idtete)
		{
		case 1: $tete = imagecreatefromgif("../charsprites/trenard.gif");
			break;
		case 2: $tete = imagecreatefromgif("../charsprites/tcochon.gif");
			break;
		case 3: $tete = imagecreatefromgif("../charsprites/tsinge.gif");
			break;
		case 4: $tete = imagecreatefromgif("../charsprites/tecureuil.gif");
			break;
		case 5: $tete = imagecreatefromgif("../charsprites/tcanard.gif");
			break;
		case 6: $tete = imagecreatefromgif("../charsprites/tlapin.gif");
			break;
		case 7: $tete = imagecreatefromgif("../charsprites/tpingouin.gif");
			break;
		case 8: $tete = imagecreatefromgif("../charsprites/tgrenouille.gif");
			break;
		default : $tete = imagecreatefromgif("../charsprites/trenard.gif");
		}
		
		switch($idoreille)
		{
		case 1: $oreille = imagecreatefromgif("../charsprites/orenard.gif");
			break;
		case 2: $oreille = imagecreatefromgif("../charsprites/ocochon.gif");
			break;
		case 3: $oreille = imagecreatefromgif("../charsprites/osinge.gif");
			break;
		case 4: $oreille = imagecreatefromgif("../charsprites/oecureuil.gif");
			break;
		case 5: $oreille = imagecreatefromgif("../charsprites/olapin.gif");
			break;
		case 6: $oreille = imagecreatefromgif("../charsprites/vide.gif");
			break;
		default : $oreille = imagecreatefromgif("../charsprites/orenard.gif");
		}

		
		/******************colorisation de la queue*****************/
		$queue_interm = imagecreate(103,153);
		$color_qmimichant=ImageColorAllocate($queue_interm,$red,$green,$blue);
		$trans_queue=ImageColorAllocate($queue_interm,125,125,125);
		imageFilledRectangle($queue_interm,0,0,103,153,$color_qmimichant);
		imagecopymerge($queue_interm, $queue, 0, 0,0,0, 103, 153, 100);
		imagecolortransparent($queue_interm, $trans_queue);
		
		/******************colorisation des oreilles*****************/
		$oreille_interm = imagecreate(103,153);
		$color_omimichant=ImageColorAllocate($oreille_interm,$red,$green,$blue);
		$trans_oreille=ImageColorAllocate($oreille_interm,125,125,125);
		ImageFilledRectangle($oreille_interm,0,0,103,153,$color_omimichant);
		imagecopymerge($oreille_interm, $oreille, 0, 0,0,0, 103, 153, 100);
		imagecolortransparent($oreille_interm, $trans_oreille);
		
		/******************colorisation des oreilles*****************/
		$corps_interm = imagecreate(103,153);
		$color_cmimichant=ImageColorAllocate($corps_interm,$red,$green,$blue);
		$trans_corps=ImageColorAllocate($corps_interm,125,125,125);
		ImageFilledRectangle($corps_interm,0,0,103,153,$color_cmimichant);
		imagecopymerge($corps_interm, $corps, 0, 0,0,0, 103, 153, 100);
		imagecolortransparent($corps_interm, $trans_corps);
		
		/******************colorisation des oreilles*****************/
		$tete_interm = imagecreate(103,153);
		$color_tmimichant=ImageColorAllocate($tete_interm,$red,$green,$blue);
		$trans_tete=ImageColorAllocate($tete_interm,125,125,125);
		ImageFilledRectangle($tete_interm,0,0,103,153,$color_tmimichant);
		imagecopymerge($tete_interm, $tete, 0, 0,0,0, 103, 153, 100);
		imagecolortransparent($tete_interm, $trans_tete);
		
		imagecopymerge($image_source, $queue_interm, 0, 0,0,0, 103, 153, 100);
		imagecopymerge($image_source, $corps_interm, 0, 0,0,0, 103, 153, 100);
		imagecopymerge($image_source, $oreille_interm, 0, 0,0,0, 103, 153, 100);
		imagecopymerge($image_source, $tete_interm, 0, 0,0,0, 103, 153, 100);
		imagecolortransparent($image_source, $trans_source);
		
		$image_destination=imagecreate (46, 65);
		imagecopyresized($image_destination, $image_source, 0, 0, 0, 0, 46, 65, 103, 153);
		imagecolortransparent($image_destination, $trans_source);
		imagegif ($image_destination,$nom_destination);
		
		
		$nom_mini=$entete_nom."mini".$nom;
		$image_mini=imagecreate (30,49);
		imagecopyresized($image_mini, $image_source, 0, 0, 0, 0, 30, 49, 103, 153);
		imagecolortransparent($image_mini, $trans_source);
		imagegif ($image_mini,$nom_mini);
		
		$nom_gros=$entete_nom."gros".$nom;
		$image_gros=imagecreate (103,153);
		imagecopyresized($image_gros, $image_source, 0, 0, 0, 0, 103, 153, 103, 153);
		imagecolortransparent($image_gros, $trans_source);
		imagegif ($image_gros,$nom_gros);
		
	}
	
}
?>
