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

Размер файла: 17.15Kb
<?php
require_once './element_options/element_options.php';
if (!$user) { header('Location: /'); exit; }
	if (readcache('element_user_mesto'.$user['lost_id']) != 'Лабиринт') writecache('element_user_mesto'.$user['lost_id'], 'Лабиринт');

	// Подключаем функции лабиринта
	require_once './element_function/element_function_labirint.php';

	// 0 - Время, 1 - Играю/Не играю, 2 - Этап, 3 - Заблуждение, 4 - Дух, 5 - Кристаллы, 6 - Опыт, 7 - Золото, 8 - ГО
	$labirint = explode(':', $user['lost_labirint']);
	
	// Статус игры: 0 - можно начинать, 1 - играю, 2 - вход закрыт
	$status_game = Element_Status_Labirint($labirint[0], $labirint[1]);
	
	$status_labirint = false;
	
$title = 'Лабиринт';
require_once './element_include/element_head.php';
require_once './element_include/element_header_user_true.php';
	
	// Мы в лабиринте, играем.
	if ($status_game == 1) {
		
		if ($labirint[2] < 9) {
			
			if ($labirint[3] > 0) {			// Если я в заблуждении
				$timel = $labirint[3] - time();
				$time2 = date("H:i:s", mktime(0, 0, $timel));
				
				if ($timel <= 0) {
					$labirint[2] = $labirint[2] + 1;
					$labirint[3] = 0;
					$user['lost_labirint'] = implode(':', $labirint);

					writecache('element_users_id_'.$user['lost_id'], $user);
					user_list_update($user['lost_id']);
					header('Location: /labirint?go=duh&etap='.$labirint[2]);
					exit;
				}
				
				if ($go == 'back') {
					$labirint[2] = $labirint[2] - 1;
					$labirint[3] = 0;
					
					$user['lost_labirint'] = implode(':', $labirint);

					writecache('element_users_id_'.$user['lost_id'], $user);
					user_list_update($user['lost_id']);
					header('Location: /labirint?go=duh&etap='.$labirint[2]);
					exit;
				}
				
				echo '<div class="nfl p5 mb5 mt5 mlra">';
				echo '<div class="cntr"><img width="100%" height="90"  src="/images/icons/labirint.jpg"></div>';	
				echo '<div class="cntr moderator small">';
				
				echo 'Вы находитесь на <span class="bold">'.$labirint[2].'</span> этапе';
				
				echo '<div class="admin mt5 mb5">Лабиринт ввел Вас в заблуждение. Вы можете подождать, пока эффект заблуждения закончиться, или вернуться на предыдущий этап</div>';
				echo '<div class="admin mt5 mb5">Осталось: '.$time2.'</div>';
				echo '<a class="button mt5 mb5 w50" href="/labirint?go=back">Вернуться!</a><br/>';
				echo '<a class="button mt5 mb5 w50" href="/labirint">Обновить</a><br/>';
				echo '</div></div>';
			} 
			else if ($labirint[4] == 1) {	// Если встретил духа
				
				$battle_duh = readcache('element_labirint_duh_user'.$user['lost_id']);
				if ($battle_duh) { header('Location: /labirint/battle'); exit; }
				
				// Начинаем бой с духом
				if ($go == 'start') {
					require_once './element_function/element_function_battle.php';
					$chanse = Element_Chance($labirint[2], 0);	// База шансов
					$duh_str = (int)(($user['lost_params_strlen'] / 100) * $chanse[5]);		// Сила духа
					$duh_hp = (int)(($user['lost_params_heatpoints'] / 100) * $chanse[5]);	// Здоровье духа
					$duh_pr = (int)(($user['lost_params_protection'] / 100) * $chanse[5]);	// Броня духа
					
					$bot_hp = GenerationMaxHeatpoints($duh_hp);
					$myy_hp = GenerationMaxHeatpoints($user['lost_params_heatpoints']);
					ResetAbilitiesUser($user['lost_id']);
					$exp_time = explode(' ', microtime());
					$exp_time[1] = $exp_time[1] - 2;
					$time_udar = implode(' ', $exp_time);
					
					$cache = array('duh' => array('str' => $duh_str,
												  'hp' => $bot_hp,
												  'pr' => $duh_pr,
												  'other_hp' => $bot_hp,
												  'time_udar' => $time_udar,
												  'name' => 'Реальный дух'),
								   'user' => array('hp' => $myy_hp,
												   'other_hp' => $myy_hp,
												   'time_udar' => false),
								   'other' => array('time' => time(),
													'etap' => $labirint[2],
													'img'  => 'duh.gif'));
						
					writecache('element_labirint_journal'.$user['lost_id'], array('<span class="lngreen bold">Бой начался!</span>'));	
					writecache('element_users_battle'.$user['lost_id'], '/labirint/battle');								
					writecache('element_labirint_duh_user'.$user['lost_id'], $cache);
					header('Location: /labirint/battle'); 
					exit;
				}
				
				echo '<div class="nfl p5 mb5 mt5 mlra">';
				echo '<div class="cntr"><img width="100%" height="90"  src="/images/icons/labirint.jpg"></div>';	
					
				echo '<div class="cntr moderator small">';
				echo 'Вы находитесь на <span class="bold">'.$labirint[2].'</span> этапе';
				
				echo '<div class="ccc mt5 mb5"><img src="/images/icons/duh.gif"><br/>На своем пути Вы встретили духа. Победите его, чтобы пройти на следующий этап!</div>';
				echo '<a class="button mt5 mb5 w50" href="/labirint?go=start">Начать бой!</a>';
				echo '</div>';
				echo '</div>';
			} 
			else {							// Иначе просто идем дальше
					
					if ($go == 'forward' AND $id) {
						$chanse = Element_Chance($labirint[2], 0);	// База шансов
						if ($chanse[0] >= rand(1,100)) $forward = true; else $forward = false;
						
							if ($forward) {
								$exp = handler_expoint($chanse[3], $user['lost_add_user_exp'], $user['lost_add_town_exp']);
								$crst = handler_cristalls($chanse[2], $user_blessing['nagrada']);
								
								$labirint[2] = $labirint[2] + 1;			// Переходим на +1 этап
								$labirint[5] = $labirint[5] + $crst;	// Добавляем кристаллы
								$labirint[6] = $labirint[6] + $exp['user'];	// Добавляем личный опыт
								$labirint[8] = $labirint[8] + $exp['town'];	// Добавляем городской опыт
								
								// Шанс 5%. Если повезет, добавляем золото
								if (5 >= rand(1,100)) {
									$labirint[7] = $labirint[7] + $chanse[4];
									$gold = $chanse[4];
								} else $gold = 0;
									
								$user['lost_labirint'] = implode(':', $labirint);

								writecache('element_users_id_'.$user['lost_id'], $user);
								user_list_update($user['lost_id']);
								echo '<div class="nfl p5 mb5 cntr small lngreen mlra bold">';
								echo (($gold > 0) ? 'Золото: <img src="/images/icons/gold.png">'.$gold.'<br/>' : '').'Кристаллы: <img src="/images/icons/cristall.png">'.$chanse[2].'<br/> Опыт: <img width="13" height="14" src="/images/icons/experience.png">'.$exp['user'].'<br/>';
								echo 'Вы успешно перешли на '.$labirint[2].' этап';
								echo '</div>';
							} else {
								
								// Если шанс меньше 70, включаем духа, иначе вводим в заблуждение
								if (rand(0,100) <= 70) {
									$labirint[4] = 1;	// Показываем системе, что нужно биться с духом
									$user['lost_labirint'] = implode(':', $labirint);
									writecache('element_users_id_'.$user['lost_id'], $user);
									user_list_update($user['lost_id']);
									header('Location: /labirint');
									exit;
								} else {
									$labirint[3] = time() + 180;	// Вводим игрока в заблуждение
									$user['lost_labirint'] = implode(':', $labirint);
									writecache('element_users_id_'.$user['lost_id'], $user);
									user_list_update($user['lost_id']);
									header('Location: /labirint');
									exit;
								}
							
							}
						
						
					
					}
					
				if ($go == 'duh') {
					$get_etap = (isset($_GET['etap']) AND is_numeric($_GET['etap'])) ? (int)$_GET['etap'] : false;
					
					if ($get_etap) {
						echo '<div class="nfl p5 mb5 cntr small lngreen mlra bold">';
						echo (($get_gold > 0) ? 'Золото: <img src="/images/icons/gold.png">'.$gold.'<br/>' : '');
						echo (($get_cristall > 0) ? 'Кристаллы: <img src="/images/icons/cristall.png">'.$get_cristall.'<br/>' : '');
						echo (($get_expoint > 0) ? 'Опыт: <img width="13" height="14" src="/images/icons/experience.png">'.$get_expoint.'<br/>' : '');
						echo 'Вы успешно перешли на <span class="bold">'.$get_etap.'</span>этап!';
						echo '</div>';
					}
				}

				echo '<div class="nfl p5 mb5 mt5 mlra">';
				echo '<div class="cntr"><img width="100%" height="90"  src="/images/icons/labirint.jpg"></div>';	
					
				echo '<div class="cntr moderator small">';
				echo 'Вы находитесь на <span class="bold">'.$labirint[2].'</span> этапе';
				
				echo '<div class="p5">';
				echo '<span class="ccc">На своем пути Вы можете встретить духа, или лабиринт может ввести Вас в заблуждение<br/>Выберите дальнейший путь:</span><br/>';
				echo '<span class="inbl mt5 w30 va_t">
						<a class="atask" href="/labirint?go=forward&id=1">
							<span class="inbl prel">
							<img width="60" height="80" src="/images/labirint.png" alt=""/>
							</span><br/>
							<span class="small mt3">Иду налево</span>
						</a>
					  </span>';
				echo '<span class="inbl mt5 w30 va_t">
						<a class="atask" href="/labirint?go=forward&id=2">
							<span class="inbl prel">
							<img width="60" height="80" src="/images/labirint.png" alt=""/>
							</span><br/>
							<span class="small mt3">Иду вперед</span>
						</a>
					  </span>';
				echo '<span class="inbl mt5 w30 va_t">
						<a class="atask" href="/labirint?go=forward&id=3">
							<span class="inbl prel">
							<img width="60" height="80" src="/images/labirint.png" alt=""/>
							</span><br/>
							<span class="small mt3">Иду направо</span>
						</a>
					  </span>';
				echo '</div>';
				
				echo '<div class="">';
				echo 'На своем пути Вы нашли: <img src="/images/icons/gold.png">'.$labirint[7].', <img src="/images/icons/cristall.png">'.$labirint[5].', <img width="13" height="14" src="/images/icons/experience.png">'.$labirint[6];
				echo '</div>';
				
				echo '</div>';
				echo '</div>';
			}
			
		} else {

			// Начинаем бой с духом
				if ($go == 'start') {
					require_once './element_function/element_function_battle.php';
					$chanse = Element_Chance($labirint[2], 0);	// База шансов
					$duh_str = (int)(($user['lost_params_strlen'] / 100) * $chanse[5]);		// Сила духа
					$duh_hp = (int)(($user['lost_params_heatpoints'] / 100) * $chanse[5]);	// Здоровье духа
					$duh_pr = (int)(($user['lost_params_protection'] / 100) * $chanse[5]);	// Броня духа
					
					$bot_hp = GenerationMaxHeatpoints($duh_hp);
					$myy_hp = GenerationMaxHeatpoints($user['lost_params_heatpoints']);
					ResetAbilitiesUser($user['lost_id']);
					
					$exp_time = explode(' ', microtime());
					$exp_time[1] = $exp_time[1] - 2;
					$time_udar = implode(' ', $exp_time);
					
					$cache = array('duh' => array('str' => $duh_str,
												  'hp' => $bot_hp,
												  'pr' => $duh_pr,
												  'other_hp' => $bot_hp,
												  'time_udar' => $time_udar,
												  'name' => 'Минотавр'),
								   'user' => array('hp' => $myy_hp,
													'other_hp' => $myy_hp,
												   'time_udar' => false),
								   'other' => array('time' => time(),
													'etap' => $labirint[2],
													'img'  => 'duh.gif'));
						
					writecache('element_labirint_journal'.$user['lost_id'], array('<span class="lngreen bold">Бой начался!</span>'));	
					writecache('element_users_battle'.$user['lost_id'], '/labirint/battle');								
					writecache('element_labirint_duh_user'.$user['lost_id'], $cache);
					header('Location: /labirint/battle'); 
					exit;
				}
		
		
			if ($go == 'duh') {
				$get_etap = (isset($_GET['etap']) AND is_numeric($_GET['etap'])) ? (int)$_GET['etap'] : false;
					
				if ($get_etap) {
					echo '<div class="nfl p5 mb5 cntr small lngreen mlra bold">';
					echo (($get_gold > 0) ? 'Золото: <img src="/images/icons/gold.png">'.$get_gold.'<br/>' : '');
					echo (($get_cristall > 0) ? 'Кристаллы: <img src="/images/icons/cristall.png">'.$get_cristall.'<br/>' : '');
					echo (($get_expoint > 0) ? 'Опыт: <img width="13" height="14" src="/images/icons/experience.png">'.$get_expoint.'<br/>' : '');
					echo 'Вы успешно перешли на <span class="bold">'.$get_etap.'</span> этап!';
					echo '</div>';
				}
			}
		
			echo '<div class="nfl p5 mb5 mt5 mlra">';
			echo '<div class="cntr"><img width="100%" height="90"  src="/images/icons/labirint.jpg"></div>';	
					
			echo '<div class="cntr moderator small">';
			echo 'Вы находитесь на <span class="bold">'.$labirint[2].'</span> этапе';
				
			echo '<div class="ccc mt5 mb5"><img width="130" height="150" src="/images/minotaur.png"><br/>На своем пути Вы встретили хранителя лабаритна, минотавра. Чтобы пройти лабиринт, Вам нужно победить его</div>';
			echo '<a class="button mt5 mb5 w50" href="/labirint?go=start">Начать бой!</a>';
			echo '</div>';
			echo '</div>';

	}
		
	}

	// Вход закрыт
	if ($status_game == 2) {
		$timel = $labirint[0] - time();
		$timel = date("H:i:s", mktime(0, 0, $timel));
		
		//$battle_duh = readcache('element_labirint_duh_user'.$user['lost_id']);
		//if ($battle_duh) { header('Location: /labirint/battle'); exit; }
		
		if ($go == 'duh') {
		$get_etap = (isset($_GET['etap']) AND is_numeric($_GET['etap'])) ? (int)$_GET['etap'] : false;
			if (isset($_GET['lose']) AND $get_etap) {
				echo '<div class="nfl p5 mb5 cntr small error1 mlra">';
				echo 'К сожалению Вы не смогли пройти лабиринт.<br/>Вы проиграли на <span class="bold">'.$get_etap.'</span> этапе<br/>';
				echo (($get_gold > 0) ? 'Золото: <img src="/images/icons/gold.png">'.$get_gold.'<br/>' : '');
				echo (($get_cristall > 0) ? 'Кристаллы: <img src="/images/icons/cristall.png">'.$get_cristall.'<br/>' : '');
				echo (($get_expoint > 0) ? 'Опыт: <img width="13" height="14" src="/images/icons/experience.png">'.$get_expoint.'' : '');
				echo '</div>';	
			} else if (isset($_GET['win']) AND $get_etap) {
				echo '<div class="nfl p5 mb5 cntr small lngreen mlra bold">';
				echo (($get_gold > 0) ? 'Золото: <img src="/images/icons/gold.png">'.$get_gold.'<br/>' : '');
				echo (($get_cristall > 0) ? 'Кристаллы: <img src="/images/icons/cristall.png">'.$get_cristall.'<br/>' : '');
				echo (($get_expoint > 0) ? 'Опыт: <img width="13" height="14" src="/images/icons/experience.png">'.$get_expoint.'' : '');
				echo '</div>';	
			}
		}
	
	
		echo '<div class="nfl p5 mb5 mt5 mlra">';
		echo '<div class="cntr"><img width="100%" height="90"  src="/images/icons/labirint.jpg"></div>';
		echo '<div class="cntr error1 small">';
		echo 'Двери великого лабиринта закрыты. Приходите позже, чтобы вновь испытать удачу в поисках сокровищ!<br/><br/>';
		echo 'Двери откроются через: '.$timel;
		echo '<br/><a class="button mt5 mb5 w50" href="/labirint">Обновить</a>';
		echo '</div>';
		echo '</div>';
	}
	

	// Двери открыты. Можно начинать
	if ($status_game == 0) {

		// Запускаем лабиринт
		if ($go == 'start') {
				$labirint[0] = time(); 	// Время
				$labirint[1] = 1;		// Играю
				$labirint[2] = 0;		// Этап 0
				$labirint[3] = 0;		// Заблуждения нет
				$labirint[4] = 0;		// Духа нет
				$labirint[5] = 0;		// Духа нет
				$labirint[6] = 0;		// Духа нет
				$labirint[7] = 0;		// Духа нет
				$labirint[8] = 0;		// Духа нет
				$user['lost_labirint'] = implode(':', $labirint);
				writecache('element_users_id_'.$user['lost_id'], $user);
				user_list_update($user['lost_id']);
				header('Location: /labirint');
				exit;
		}
	
    $ttime = mktime();
    
	echo '<div class="nfl p5 mb5 mt5 mlra">';
	echo '<div class="cntr"><img width="100%" height="90"  src="/images/icons/labirint.jpg"></div>';
	echo '<div class="cntr mt5 moderator small">';
	echo 'Вы в древнем лабиринте.<br/> Пройдите все 10 этапов и получите награду, но будьте осторожны, ловушки подстерегают Вас на каждом шагу';
	echo '<div class="yellow1 mt5 p5">';
	echo '<a class="button mt5 mb5 w60" href="/labirint?go=start">Войти в лабиринт</a>';
	echo '</div>';

	echo '</div>';
	echo '</div>';
	}
	
require_once './element_include/element_foot_user_true.php';
?>