Просмотр файла element_arena_tvt_battle_2.php

Размер файла: 26.5Kb
<?php
require_once './element_options/element_options.php';
	if (!$user) { header('Location: /'); exit; }

	// Кэш юзера, массив с айди команды, и прочей информацией
	$cache_u = readcache('element_users'.$user['lost_id'].'_arena_tvt_info');	
	if (!$cache_u) { header('Location: /arena?tvt'); exit; }
	
	// Кэш команды
	$arena = readcache('element_arena_tvt_teamid'.$cache_u['id_team']);
	if (!$arena) { 
		deletecache('element_users'.$user['lost_id'].'_arena_tvt_info');
		header('Location: /arena?tvt');
		exit; 
	}
	
	// Функция определения игры пользователя
	function status_game_arena($count_team_1, $count_team_2, $time_start) {
		if ($time_start > time()) return 0; // Ожидаем начала боя
		else if ($count_team_1 == 0 OR $count_team_2 == 0) return 1; // Результат боя
		else return 2; // Тут бой
	}
	
	function new_microtime() {
		$explode = explode(' ', microtime());
		$explode1 = explode('.', $explode[0]);
		$explode[1] = $explode[1] - 127064063;
		return $explode[1].$explode1[1];
	}
	
	// Считаем сколько юзеров у какой команды, записываем в массив
	$count_team = array('team_1' => count($arena['team_1']), 'team_2' => count($arena['team_2']));
	
	// Вытаскиваем статус игры пользователя
	$status_game = status_game_arena($count_team['team_1'], $count_team['team_2'], $arena['time_start']);
	
	$u_team = $cache_u['user_team']; 							// Моя команда
	$n_team = ($u_team == 'team_1') ? 'team_2' : 'team_1';		// Не моя команда
	
	// Журнал боя. Общий
	$journal = readcache('element_arena_tvt_teamid'.$cache_u['id_team'].'journal');
	
	// Ведем бой
	if ($status_game == 2) {
	$title = 'Арена: Лига стихий'; 
	require_once './element_include/element_head.php';
	require_once './element_function/element_function_battle.php';
	echo '<body><div class="p5">';
	echo '<div class="small mb5 cntr yellow1">';
	echo '<img src="/images/icons/arena_team_1.gif"> Наши: '.$count_team[$u_team].' ';
	echo '<img src="/images/icons/arena_team_2.gif"> Враги:  '.$count_team[$n_team].' ';
	echo '<img src="/images/icons/clock.gif"> '.date("i:s", mktime(0, 0, (time() - $arena['time_start'])));
	echo '</div>';
	
		// Живой. Веди бой
		if ($cache_u['user_game'] == 1) {
			if (empty($cache_u['target'])) {
				$rand_user = array_rand($arena[$n_team]);		// Случайный игрок	
				$target_user = cache_user($rand_user);			// Кэш игрока
				$cache_u['target'] = $rand_user;				// Запись в мой таргейт
				writecache('element_users'.$user['lost_id'].'_arena_tvt_info', $cache_u);
			} else $target_user = cache_user($cache_u['target']);
			
			$cache_n = readcache('element_users'.$cache_u['target'].'_arena_tvt_info');
				if ($cache_n['user_game'] != 1) {
				header('Location: /arena/tvt/battle');
				exit;
				}
			
			$no_journal = readcache('element_arena_tvt_user_'.$target_user['lost_id'].'journal');
				if (!is_array($no_journal)) $no_journal = array();
			
			
			$abilities_ogon = explode(':', $user['lost_abilities_ogon']);
			$abilities_voda = explode(':', $user['lost_abilities_voda']);
			$abilities_zeml = explode(':', $user['lost_abilities_zemlya']);
			$abilities_vosd = explode(':', $user['lost_abilities_vozduh']);
			$abilities_zeml_t = explode(':', $target_user['lost_abilities_zemlya']);
			$abil_zeml = abilities_race_zemlya(0, $abilities_zeml[2], $abilities_zeml[1], $abilities_zeml[3], $abilities_zeml[4], 0);
			
			//echo 'lost_abilities_ogon -> '.$user['lost_abilities_ogon'].'<br/>';
			//echo 'lost_abilities_voda -> '.$user['lost_abilities_voda'].'<br/>';
			//echo 'lost_abilities_zemlya -> '.$user['lost_abilities_zemlya'].'<br/>';
			//echo 'lost_abilities_vozduh -> '.$user['lost_abilities_vozduh'].'<br/>';
			
		if ($go == 'attaka') {
		$to = (isset($_GET['to'])) ? addslashes(htmlspecialchars($_GET['to'])) : false;
	
			if ($to == 'target') {
				$rand_user = array_rand($arena[$n_team]);		// Случайный игрок	
				$target_user = cache_user($rand_user);			// Кэш игрока
				$cache_u['target'] = $rand_user;				// Запись в мой таргейт
				writecache('element_users'.$user['lost_id'].'_arena_tvt_info', $cache_u);
			}
	
			if ($to == 'abilities_ogon' AND $abilities_ogon[2] <= time()) {
				$abilities_ogon[2] = time() + ($abilities_ogon[3] + $abilities_ogon[4]);
				$user['lost_abilities_ogon'] = implode(':', $abilities_ogon);
				writecache('element_users_id_'.$user['lost_id'],$user);	
				$image_ogon = quality_item_name($abilities_ogon[0]);
				$journal[$user['lost_id']][new_microtime()] = '<span class="small admin">'.ikonka_user($user['lost_race'], 'online').' '.$user['lost_login'].' активировал <span class="bold yellow1">'.$image_ogon['image'].' огненную силу</span></span>';
				$journal[$target_user['lost_id']][new_microtime()] = '<span class="small admin">'.ikonka_user($user['lost_race'], 'online').' '.$user['lost_login'].' активировал <span class="bold yellow1">'.$image_ogon['image'].' огненную силу</span></span>';
			}

			if ($to == 'abilities_voda' AND $abilities_voda[1] <= time()) {
				$abilities_voda[1] = time() + ($abilities_voda[2] + $abilities_voda[3]);
				$user['lost_abilities_voda'] = implode(':', $abilities_voda);
				writecache('element_users_id_'.$user['lost_id'],$user);	
				$image_voda = quality_item_name($abilities_voda[0]);
				$journal[$user['lost_id']][new_microtime()] = '<span class="small admin">'.ikonka_user($user['lost_race'], 'online').' '.$user['lost_login'].' активировал <span class="bold yellow1">'.$image_voda['image'].' водяной крит</span></span>';
				$journal[$target_user['lost_id']][new_microtime()] = '<span class="small admin">'.ikonka_user($user['lost_race'], 'online').' '.$user['lost_login'].' активировал <span class="bold yellow1">'.$image_voda['image'].' водяной крит</span></span>';
			}	
			
			if ($to == 'abilities_zemlya' AND $abilities_zeml[2] <= time()) {
				$abilities_zeml[2] = time() + ($abilities_zeml[3] + $abilities_zeml[4]);
				$user['lost_abilities_zemlya'] = implode(':', $abilities_zeml);
				writecache('element_users_id_'.$user['lost_id'],$user);	
				$image_zeml = quality_item_name($abilities_zeml[0]);
				$journal[$user['lost_id']][new_microtime()] = '<span class="small admin">'.ikonka_user($user['lost_race'], 'online').' '.$user['lost_login'].' активировал <span class="bold yellow1">'.$image_zeml['image'].' земляной щит</span></span>';
				$journal[$target_user['lost_id']][new_microtime()] = '<span class="small admin">'.ikonka_user($user['lost_race'], 'online').' '.$user['lost_login'].' активировал <span class="bold yellow1">'.$image_zeml['image'].' земляной щит</span></span>';
				$abil_zeml = abilities_race_zemlya(0, $abilities_zeml[2], $abilities_zeml[1], $abilities_zeml[3], $abilities_zeml[4], 0);
			}
			
			if ($to == 'abilities_vozduh' AND $abilities_vosd[2] <= time()) {
				$abilities_vosd[2] = time() + $abilities_vosd[3];
				$user['lost_abilities_vozduh'] = implode(':', $abilities_vosd);
				writecache('element_users_id_'.$user['lost_id'],$user);	
				$image_vosd = quality_item_name($abilities_vosd[0]);
				$journal[$user['lost_id']][new_microtime()] = '<span class="small admin">'.ikonka_user($user['lost_race'], 'online').' '.$user['lost_login'].' активировал <span class="bold yellow1">'.$image_vosd['image'].' ловушку ветра</span></span>';
				$journal[$target_user['lost_id']][new_microtime()] = '<span class="small admin">'.ikonka_user($user['lost_race'], 'online').' '.$user['lost_login'].' активировал <span class="bold yellow1">'.$image_vosd['image'].' ловушку ветра</span></span>';
				$abil_vozduh = abilities_race_vozduh($abilities_vosd[1], $arena[$n_team][$cache_u['target']]['hp'], ($target_user['lost_params_heatpoints'] * 5), $arena[$u_team][$user['lost_id']]['hp'], ($user['lost_params_heatpoints'] * 5));
					if ($abil_vozduh[0] == 1) {
						$arena[$n_team][$cache_u['target']]['hp'] = $abil_vozduh[1];
						$arena[$u_team][$user['lost_id']]['hp'] = $abil_vozduh[2];
						$journal[$user['lost_id']][new_microtime()] = '<span class="small admin">Вы забрали у '.ikonka_user($target_user['lost_race'], 'online').' '.$target_user['lost_login'].' <span class="bold">'.$abil_vozduh[3].'</span> здоровья</span>';
						$journal[$target_user['lost_id']][new_microtime()] = '<span class="small red">'.ikonka_user($user['lost_race'], 'online').' '.$user['lost_login'].' забрал у Вас <span class="bold">'.$abil_vozduh[3].'</span> здоровья</span>';
					}
			} else $abil_vozduh[0] = 0;
			
			$protection = Protection($target_user['lost_params_protection'], element_settings_game('lost_max_protection'));
			$user_uron = GenerateUron($user['lost_params_strlen'],$arena[$u_team][$user['lost_id']]['time_udar'],$protection);
			$abit_ogon = abilities_race_ogon($user_uron, $abilities_ogon[2], $abilities_ogon[1], $abilities_ogon[3], $abilities_ogon[4], 1);
			$abit_voda = abilities_race_voda($abit_ogon[0], $abilities_voda[1], $abilities_voda[2], $abilities_voda[3], 1);
			$n_abit_zemlya = abilities_race_zemlya($abit_voda[0], $abilities_zeml_t[2], $abilities_zeml_t[1], $abilities_zeml_t[3], $abilities_zeml_t[4], 1);
			$user_uron = $n_abit_zemlya[0];
				
			if ($abil_vozduh[0] == 1) $user_uron = $user_uron + $abil_vozduh[3];	
				
			$arena[$n_team][$cache_u['target']]['hp'] = $arena[$n_team][$cache_u['target']]['hp'] - $user_uron;
			$arena[$u_team][$user['lost_id']]['time_udar'] = microtime();	
				
			$journal[$user['lost_id']][new_microtime()] = '<span class="yellow1">Вы ударили '.ikonka_user($target_user['lost_race'], 'online').' '.$target_user['lost_login'].' на <span class="bold">'.$user_uron.'</span> урон '.(($abit_voda[1]) ? 'крит' : '').'</span>';
			$journal[$target_user['lost_id']][new_microtime()] = '<span class="red">'.ikonka_user($user['lost_race'], 'online').' '.$user['lost_login'].' ударил Вас на <span class="bold">'.$user_uron.'</span> урон '.(($abit_voda[1]) ? 'крит' : '').'</span>';

			$arena[$n_team][$cache_u['target']]['uron'] = $arena[$n_team][$cache_u['target']]['uron'] + $user_uron;
	
			if ($arena[$n_team][$cache_u['target']]['hp'] < 0) {	
				$cache_n['user_game'] = 2;
				$arena[$n_team.'_kick'][$cache_u['target']] = $arena[$n_team][$cache_u['target']];
				unset($arena[$n_team][$cache_u['target']]);
				$journal['other'][new_microtime()] = '<span class="lngreen">'.ikonka_user($user['lost_race'], 'online').' '.$user['lost_login'].' убил '.ikonka_user($target_user['lost_race'], 'online').' '.$target_user['lost_login'].'</span>';
				writecache('element_arena_tvt_teamid'.$cache_u['id_team'].'journal', $journal);

				if (count($arena[$n_team]) == 0) {
					$fearch = $arena[$n_team.'_kick'] + $arena[$u_team] + $arena[$u_team.'_kick'];
					$for_u_team = $arena[$u_team] + $arena[$u_team.'_kick'];
					$for_n_team = $arena[$n_team] + $arena[$n_team.'_kick'];
					
					foreach ($for_u_team as $id_user => $value) {
						$cache_user = cache_user($id_user);
						$cache_user['lost_arena_tvt_rating'] = $cache_user['lost_arena_tvt_rating'] + 1;
						update_money_exp($cache_user, 0, 0, 1, 0);
						
						$user_quests = user_quests($cache_user['lost_id']);
						$count_quests = quests_id_count('arena_tvt_5');
							if ($user_quests['arena_tvt_5'] < $count_quests) {
								$user_quests['arena_tvt_5'] = $user_quests['arena_tvt_5'] + 1;
								if ($user_quests['arena_tvt_5'] == $count_quests) $user_quests['lost_new'] = $user_quests['lost_new'] + 1;
								writecache('element_quests_user'.$cache_user['lost_id'], $user_quests);	
								quests_list_update($cache_user['lost_id']);
						}
						
						$cache_n = readcache('element_users'.$id_user.'_arena_tvt_info');	
						$cache_n['user_game'] = 0;
						writecache('element_users'.$id_user.'_arena_tvt_info', $cache_n);
					}
					
					foreach ($for_n_team as $id_user => $value) {
						$cache_user = cache_user($id_user);
						$cache_user['lost_arena_tvt_rating'] = $cache_user['lost_arena_tvt_rating'] - 1;
						writecache('element_users_id_'.$id_user,$cache_user);
						user_list_update($id_user);
						
						$user_quests = user_quests($cache_user['lost_id']);
						$count_quests = quests_id_count('arena_tvt_5');
							if ($user_quests['arena_tvt_5'] < $count_quests) {
								$user_quests['arena_tvt_5'] = $user_quests['arena_tvt_5'] + 1;
								if ($user_quests['arena_tvt_5'] == $count_quests) $user_quests['lost_new'] = $user_quests['lost_new'] + 1;
								writecache('element_quests_user'.$cache_user['lost_id'], $user_quests);	
								quests_list_update($cache_user['lost_id']);
						}
						
						$cache_n = readcache('element_users'.$id_user.'_arena_tvt_info');	
						$cache_n['user_game'] = 0;
						writecache('element_users'.$id_user.'_arena_tvt_info', $cache_n);
					}
					
					writecache('element_arena_tvt_teamid'.$cache_u['id_team'], $arena);
				header('Location: /arena/tvt/battle');
				exit;
				}
				
				writecache('element_arena_tvt_teamid'.$cache_u['id_team'], $arena);
				writecache('element_users'.$cache_u['target'].'_arena_tvt_info', $cache_n);
				$cache_u['target'] = '';
				writecache('element_users'.$user['lost_id'].'_arena_tvt_info', $cache_u);
				header('Location: /arena/tvt/battle');
				exit;
			}
			writecache('element_arena_tvt_teamid'.$cache_u['id_team'], $arena);
			writecache('element_arena_tvt_teamid'.$cache_u['id_team'].'journal', $journal);
		} else {
			$user_uron = 0;
			$abit_ogon = abilities_race_ogon(0, $abilities_ogon[2], $abilities_ogon[1], $abilities_ogon[3], $abilities_ogon[4], 0);
			$abit_voda = abilities_race_voda(0, $abilities_voda[1], $abilities_voda[2], $abilities_voda[3], 0);
		}
			
			
			echo '<table><td class="mr5">';
			echo '<img width="50" height="50" src="/images/user_ava_'.$user['lost_race'].'.png"></td>';
			echo '<td class="small w90 ml5" valign="top">';
			echo '<span class="bl ml5 mb5 prg-bar">
			 <span class="bl fl prg-blue" style="width:'.intval(($arena[$u_team][$user['lost_id']]['hp'] / ($user['lost_params_heatpoints'] * 5)) * 100).'%">&nbsp;</span>
			 <span class="bl fl prg-red" style="width:'.(int)(($arena[$u_team][$user['lost_id']]['uron'] / ($user['lost_params_heatpoints'] * 5)) * 100).'%">&nbsp;</span>
			 </span>
			'.(($arena[$u_team][$user['lost_id']]['uron'] > 0) ? '<div class="fr bold"><span class="red">-'.$arena[$u_team][$user['lost_id']]['uron'].'</span></div>' : '').'
			 <span class="ml5 mr5 yellow1 bold">'.ikonka_user($user['lost_race'], 'online').' '.$user['lost_login'].'</span><br/>
			 <span class="ml5 mr5 yellow1 bold"></span>
			 </td></table>';
			 
			echo '<table><td class="mr5">';
			echo '<img width="50" height="50" src="/images/user_ava_'.$target_user['lost_race'].'.png"></td>';
			echo '<td class="small w90 ml5" valign="top">';
			echo '<span class="bl ml5 mb5 prg-bar">
			 <span class="bl fl prg-blue" style="width:'.intval(($arena[$n_team][$target_user['lost_id']]['hp'] / ($target_user['lost_params_heatpoints'] * 5)) * 100).'%">&nbsp;</span>
			 <span class="bl fl prg-red" style="width:'.(int)(($user_uron / ($target_user['lost_params_heatpoints'] * 5)) * 100).'%">&nbsp;</span>
			 </span>
			'.(($user_uron > 0) ? '<div class="fr bold"><span class="red">-'.$user_uron.'</span></div>' : '').'
			 <span class="ml5 mr5 yellow1 bold">'.ikonka_user($target_user['lost_race'], 'online').' '.$target_user['lost_login'].'</span><br/>
			 <span class="ml5 mr5 yellow1 bold"></span>
			 </td></table>';
			
			echo '<div class="nfl p5 mb5 cntr small mlra">';
			
			echo '<span class="inbl w15 mt5 va_t">
				 <a class="atask" href="/arena/tvt/battle?go=attaka&to=target&action='.rand(1000000, 9999999).'">
					<span class="inbl prel">
					<img width="35" height="35" src="/images/equipment/beginner/weapon.png" alt=""/>
					</span><br/><span class="small lngreen mt3">Цель</span>
				 </a></span>';
			
			
			echo '<span class="inbl w15 mt5 va_t">
				 <a class="atask" href="/arena/tvt/battle?go=attaka&action='.rand(1000000, 9999999).'">
					<span class="inbl prel">
					<img width="35" height="35" src="/images/equipment/beginner/weapon.png" alt=""/>
					</span><br/><span class="small lngreen mt3">Бить</span>
				 </a></span>';
				 
			
			echo '<span class="inbl w15 mt5 va_t">
			<a class="atask" href="/arena/tvt/battle?go=attaka&to=abilities_ogon&action='.rand(1000000, 9999999).'">
				<span class="inbl prel">
					<img width="35" height="35" src="/images/fire.png" alt=""/>
				</span><br/>';
		if (!$abit_ogon[1] AND !$abit_ogon[2]) 
			echo '<span class="small lngreen mt3">Гот.</span>';		
		else if ($abit_ogon[1]) echo '<span class="small lngreen mt3">'.$abit_ogon[1].' с</span>';
		else if ($abit_ogon[2]) echo '<span class="small ccc mt3">'.$abit_ogon[2].' с</span>';	
			
	echo'	</a>
		</span>';
		
	echo '<span class="inbl w15 mt5 va_t">
			<a class="atask" href="/arena/tvt/battle?go=attaka&to=abilities_voda&action='.rand(1000000, 9999999).'">
				<span class="inbl prel">
					<img width="35" height="35" src="/images/water.png" alt=""/>
				</span><br/>';
	if (!$abit_voda[1] AND !$abit_voda[2]) 
		echo '<span class="small lngreen mt3">Гот.</span>';		
		else if ($abit_voda[1]) echo '<span class="small lngreen mt3">'.$abit_voda[1].' с</span>';
		else if ($abit_voda[2]) echo '<span class="small ccc mt3">'.$abit_voda[2].' с</span>';
	echo	'</a>
		 </span>';
		//$abil_vozd
		
	echo '<span class="inbl w15 mt5 va_t">
			<a class="atask" href="/arena/tvt/battle?go=attaka&to=abilities_vozduh&action='.rand(1000000, 9999999).'">
				<span class="inbl prel">
					<img width="35" height="35" src="/images/air.png" alt=""/>
				</span><br/>';
			if ($abilities_vosd[2] <= time()) 
				echo '<span class="small lngreen mt3">Гот.</span>';		
			else  
				echo '<span class="small ccc mt3">'.($abilities_vosd[2] - time()).' с</span>';
	
	echo '	</a>
		 </span>';
		 
		//$abil_zeml
	echo '<span class="inbl w15 mt5 va_t">
			<a class="atask" href="/arena/tvt/battle?go=attaka&to=abilities_zemlya&action='.rand(1000000, 9999999).'">
				<span class="inbl prel">
					<img width="35" height="35" src="/images/ground.png" alt=""/>
				</span><br/>';
			if (!$abil_zeml[1] AND !$abil_zeml[2]) 
		echo '<span class="small lngreen mt3">Гот.</span>';		
		else if ($abil_zeml[1]) echo '<span class="small lngreen mt3">'.$abil_zeml[1].' с</span>';
		else if ($abil_zeml[2]) echo '<span class="small ccc mt3">'.$abil_zeml[2].' с</span>';
	echo '	</a>
		  </span>';
		
			echo '</div>';
		$arena[$u_team][$user['lost_id']]['uron'] = 0;
		writecache('element_arena_tvt_teamid'.$cache_u['id_team'], $arena);
		
		$user_journal = $journal['other'] + $journal[$user['lost_id']];
		krsort($user_journal);
	
		if (count($user_journal) > 0) {
			echo '<div class="nfl p5 mb5 small mlra">';
				foreach (array_slice($user_journal, 0, 10, true) as $value) {
					echo '<span>'.$value.'<span><br/>';
				}
			echo '</div>';
		}
		
		require_once './element_include/element_foot_user_battle_true.php';
		exit;
		
		}
	
		// Мертвый. Жду окончания боя
		if ($cache_u['user_game'] == 2) {
			echo '<div class="red mb5 p5 small cntr">К сожалению Вы погибли. Ждите окончания боя';
	echo '<br/><a class="button w40 mt5" href="/arena/tvt/battle">Обновить</a></div>';
	
	echo '<div class="yellow1 mb5 mt5 small cntr">Моя команда:</div>';
	echo '<div class="nfl p5 mb5 mt5 small mlra">';
		
		$i = 1;
		foreach($arena[$u_team] as $user_id => $value) {
			$odd = (($i % 2) ? ' odd' : '');
			$cache_user = cache_user($user_id);
			echo '<div class="ml5 mr5">
					<a class="bl p5 block'.$odd.'" href="/user?id='.$user_id.'">
					<span class="yellow1 small fr"><img src="/images/icons/heatpoints.png"> <span class="yellow1 bold">'.$value['hp'].'</span></span>
					<span class="small mb5 yellow1"><span class="white">'.$i.'.</span> '.ikonka_user($cache_user['lost_race'], ((!empty($online[$user_id])) ? 'online' : 'offline')).' '.$cache_user['lost_login'].'</span></span>
					</a>
				  </div>';
			$i++;	  
		}
		
	echo '</div>';
	
	echo '<div class="yellow1 mb5 mt5 small cntr">Противники:</div>';
	echo '<div class="nfl p5 mb5 mt5 small mlra">';
		$i = 1;
		foreach($arena[$n_team] as $user_id => $value) {
			$odd = (($i % 2) ? ' odd' : '');
			$cache_user = cache_user($user_id);
			echo '<div class="ml5 mr5">
					<a class="bl p5 block'.$odd.'" href="/user?id='.$user_id.'">
					<span class="yellow1 small fr"><img src="/images/icons/heatpoints.png"> <span class="yellow1 bold">'.$value['hp'].'</span></span>
					<span class="small mb5 yellow1"><span class="white">'.$i.'.</span> '.ikonka_user($cache_user['lost_race'], ((!empty($online[$user_id])) ? 'online' : 'offline')).' '.$cache_user['lost_login'].'</span></span>
					</a>
				  </div>';
			$i++;	  
		}
	echo '</div>';
		
		$user_journal = $journal['other'] + $journal[$user['lost_id']];
		krsort($user_journal);
	
		if (count($user_journal) > 0) {
			echo '<div class="nfl p5 mb5 small mlra">';
				foreach (array_slice($user_journal, 0, 10, true) as $value) {
					echo '<span>'.$value.'<span><br/>';
				}
			echo '</div>';
		}
		
		require_once './element_include/element_foot_user_true.php';
		exit;
		}
	}
	
	// Ожидание начала боя
	if ($status_game == 0) {
		$title = 'Арена: Лига стихий'; 
		require_once './element_include/element_head.php';
		echo '<body><div class="p5">';
	
		echo '<div class="yellow1 mb5 p5 small cntr">Бой начнется через '.($arena['time_start'] - time()).' секунд';
		echo '<br/><a class="button w40 mt5" href="/arena/tvt/battle">Обновить</a></div>';
	
		echo '<div class="yellow1 mb5 mt5 small cntr">Моя команда:</div>';
		echo '<div class="nfl p5 mb5 mt5 small mlra">';
		
		$i = 1;
			
			foreach($arena[$u_team] as $user_id => $value) {
				$odd = (($i % 2) ? ' odd' : '');
				$cache_user = cache_user($user_id);
				// lost_arena_tvt_rating
				echo '<div class="ml5 mr5">
						<a class="bl p5 block'.$odd.'" href="/user?id='.$user_id.'">
						<span class="moderator small fr">Рейтинг: <span class="bold">'.$cache_user['lost_arena_tvt_rating'].'</span></span>
						<span class="small mb5 yellow1"><span class="white">'.$i.'.</span> 
						'.ikonka_user($cache_user['lost_race'], ((!empty($online[$user_id])) ? 'online' : 'offline')).' 
						'.$cache_user['lost_login'].'</span>
						</a>
					  </div>';
				$i++;	  
			}
		
	echo '</div>';
	
	echo '<div class="yellow1 mb5 mt5 small cntr">Противники:</div>';
	echo '<div class="nfl p5 mb5 mt5 small mlra">';
		
		$i = 1;
		
		foreach($arena[$n_team] as $user_id => $value) {
				$odd = (($i % 2) ? ' odd' : '');
				$cache_user = cache_user($user_id);
				
				echo '<div class="ml5 mr5">
						<a class="bl p5 block'.$odd.'" href="/user?id='.$user_id.'">
						<span class="moderator small fr">Рейтинг: <span class="bold">'.$cache_user['lost_arena_tvt_rating'].'</span></span>
						<span class="small mb5 yellow1"><span class="white">'.$i.'.</span> 
						'.ikonka_user($cache_user['lost_race'], ((!empty($online[$user_id])) ? 'online' : 'offline')).' 
						'.$cache_user['lost_login'].'</span>
						</a>
					  </div>';
				$i++;	  
			}
			
	echo '</div>';
	
	require_once './element_include/element_foot_user_battle_true.php';
	exit;
	
	}
	
	if ($status_game == 1) {
	deletecache('element_users_battle'.$user['lost_id']);
	$title = 'Арена: Лига стихий';  
	require_once './element_include/element_head.php';
	require_once './element_include/element_header_user_true.php';
	echo '<div class="nfl p5 mb5 mt5 small mlra">';
	echo '<div class="cntr bold">'.(($count_team[$u_team] == 0) ? '<span class="red">Ваша команда проиграла!</span>' : '<span class="lngreen">Ваша команда победила!</span>').'</div>';
	echo '<div class="cntr"><a class="button w50 mt5" href=/arena?tvt>На арену</a></div>';
	
	echo '<div class="yellow1 mb5 mt5 small cntr">Победители:</div>';
		echo '<div class="nfl p5 mb5 mt5 small mlra">';
		
		$i = 1;
		if ($count_team['team_1'] == 0) { $losse = 'team_1'; $wins = 'team_2'; } else { $losse = 'team_2'; $wins = 'team_1';  }
			
			foreach(($arena[$wins] + $arena[$wins.'_kick']) as $user_id => $value) {
				$odd = (($i % 2) ? ' odd' : '');
				$cache_user = cache_user($user_id);
				// lost_arena_tvt_rating
				echo '<div class="ml5 mr5">
						<a class="bl p5 block'.$odd.'" href="/user?id='.$user_id.'">
						<span class="moderator small fr">Рейтинг: <span class="bold">'.$cache_user['lost_arena_tvt_rating'].', <img src="/images/icons/irridyi.png">+1</span></span>
						<span class="small mb5 yellow1"><span class="white">'.$i.'.</span> 
						'.ikonka_user($cache_user['lost_race'], ((!empty($online[$user_id])) ? 'online' : 'offline')).' 
						'.$cache_user['lost_login'].'</span>
						</a>
					  </div>';
				$i++;	  
			}
		
	echo '</div>';
	
	echo '<div class="yellow1 mb5 mt5 small cntr">Проигравшие:</div>';
	echo '<div class="nfl p5 mt5 small mlra">';
		
		$i = 1;
		
		foreach(($arena[$losse] + $arena[$losse.'_kick']) as $user_id => $value) {
				$odd = (($i % 2) ? ' odd' : '');
				$cache_user = cache_user($user_id);
				
				echo '<div class="ml5 mr5">
						<a class="bl p5 block'.$odd.'" href="/user?id='.$user_id.'">
						<span class="red small fr">Рейтинг: <span class="bold">'.$cache_user['lost_arena_tvt_rating'].'</span></span>
						<span class="small mb5 yellow1"><span class="white">'.$i.'.</span> 
						'.ikonka_user($cache_user['lost_race'], ((!empty($online[$user_id])) ? 'online' : 'offline')).' 
						'.$cache_user['lost_login'].'</span>
						</a>
					  </div>';
				$i++;	  
			}
			
	echo '</div>';
	
	
	echo '</div>';
	
	
	$user_journal = $journal['other'] + $journal[$user['lost_id']];
	
		if (count($user_journal) > 0) {
		krsort($user_journal);
			echo '<div class="nfl p5 mb5 small mlra">';
				foreach (array_slice($user_journal, 0, 10, true) as $value) {
					echo '<span>'.$value.'<span><br/>';
				}
			echo '</div>';
		}
	
	require_once './element_include/element_foot_user_true.php';
	exit;
	}