<?php

require_once("connect.inc.php");

/* ------------------------------------------------------------------------------------
getOpponentCharInfos

Recupere les informations detaillees sur un mimichant ennemi d'id "cid"
------------------------------------------------------------------------------------ */

function getOpponentCharInfos( $cid )
{
	global $connexion;
	$html = '';
	$req = 'SELECT * FROM characters WHERE char_id='.$cid;
	$res = pg_query($connexion, $req) or die( pg_last_error().'<br />'.$req );
	$c = pg_fetch_array($res);
	
	$req2 = 'SELECT * FROM getinfoscase('.$c['user_id'].');';
	$res2 = pg_query($connexion, $req2) or die( pg_last_error().'<br />'.$req2 );
	$u = pg_fetch_array($res2);
	

	// -> !! a passer en RECORD au lieu de type PG
	$user_name    = $u['login'];
	$masterId     = $u['masterId'];
	$guild_name   = $u['guildname'];
	$guild_emblem = $u['guildemblem'];
	
	if( $masterId == $c['user_id'] ) $user_name .= ' (ma&icirc;tre de guilde)';
	if($guild_emblem!=null) $emblem = ' <img src="'.$guild_emblem.'" alt="embl&ecirc;me" />'; else $emblem = '';
	
	if ( $c['char_sex']=='t' ) $sex='male'; else $sex='female';
	$src   = 'chars/t'.$c['char_head'].'o'.$c['char_ears'].'c'.$c['char_corps'].'q'.$c['char_tail'].'c'.$c['char_skincolor'].'.gif';
	$imgs  = '<img src="'.$src.'">'.$emblem.'<img src="img/'.$sex.'.gif"/>';
	$html .= $imgs.'<br/>';
	
	$html .= 'N: '.$c['char_name'].'<br/>';
	$html .= 'P: '.$user_name.'<br/>';
	$html .= 'G: '.$guild_name;
	echo $html;
}
//getOpponentCharInfos( 11 );
getOpponentCharInfos( $_GET['cid'] );
?>