<?php
if(!defined('INDEX')) { header('Location: ../'); exit; }
$page = 'arbre';
$titre = 'Arbre des technologies';

if (empty($_GET['q'])) $_GET['q'] = '';
$template->assign('defaut',$_GET['q']);
if (empty($_GET['r']) || ($_GET['r'] != 'humain' && $_GET['r'] != 'covenant')) $_GET['r'] = $queryUser['race'];

$race = $_GET['r'];
if ($race != $queryUser['race']) include(_FCORE."../game/noms.php");
$template->assign('raceAff', $race);

$TEMP_batiments = array();
$nb = count($batiment);
for ($id=0 ; $id<$nb ; $id++) {
	if (!empty($batiment[$id])) $TEMP_batiments[] = array(
			'id' => $id,
			'nom' => $batiment[$id],
			'niveau' => $planete->batiments[$id],
			'etat' => readDeblok($batimentTECH[$id], $planete)
		);
}
$template->assign('batiments',$TEMP_batiments);

$TEMP_technologies = array();
$nb = count($technolo);
for ($id=0 ; $id<$nb ; $id++) {
	if (!empty($technolo[$id])) $TEMP_technologies[] = array(
			'id' => $id,
			'nom' => $technolo[$id],
			'niveau' => $queryUser[$technoloVAR[$id]],
			'etat' => readDeblok($technoloTECH[$id], $planete)
		);
}
$template->assign('technologies',$TEMP_technologies);

$TEMP_terrestre = array();
$nb=count($casernen);
for ($id=0 ; $id<$nb ; $id++) {
	if (!empty($casernen[$id])) $TEMP_terrestre[] = array(
			'id' => $id,
			'nom' => $casernen[$id],
			'niveau' => $planete->casernes[$id],
			'etat' => readDeblok($casernenTECH[$id], $planete)
		);
}
$template->assign('caserne',$TEMP_terrestre);

$TEMP_terrestre = array();
$nb=count($nomterrn);
for ($id=0 ; $id<$nb ; $id++) {
	if (!empty($nomterrn[$id])) $TEMP_terrestre[] = array(
			'id' => $id,
			'nom' => $nomterrn[$id],
			'niveau' => $planete->terrestres[$id],
			'etat' => readDeblok($nomterrnTECH[$id], $planete)
		);
}
$template->assign('unites',$TEMP_terrestre);

$TEMP_vaisseaux = array();
$nb=count($nomvaisn);
for ($id=0 ; $id<$nb ; $id++) {
	if (!empty($nomvaisn[$id])) $TEMP_vaisseaux[] = array(
			'id' => $id,
			'nom' => $nomvaisn[$id],
			'niveau' => $planete->vaisseaux[$id],
			'etat' => readDeblok($nomvaisnTECH[$id], $planete)
		);
}
$template->assign('vaisseaux',$TEMP_vaisseaux);
?>