Файл: mobs.php
Строк: 160
<?php
include_once('./inc/head.php');
include_once('./inc/prov.php');
title('Мобы');
if($uinf['id'] == $profil['id'] or $uinf['adm'] == '1')
$new_msg = mysql_result(mysql_query("SELECT COUNT(*) FROM `ferm_privat` WHERE `komu` = '".$uinf['login']."' and `view` = '1'"), 0);
echo '<div class="title"><b>'.$uinf['login'].' <a href="./privat.php?privat=vhod"><img src="http://144.76.127.94/view/image/icons/post.png" height="15" width="15" align="top" alt="ic">'.$new_msg.'</a> | '.$uinf['hp'].'<img src="http://warbk.com/graph/ico/hp.png" width="16" height="16" > | <img src="http://warbk.com/img/lvl.png" width="16" height="16" > '.$uinf['lvl'].'</b> | <b>Золото: </b> '.$uinf['zoloto'].' <img src="./theme/gold.png" height="16" width="16" align="top" alt="ic"> | <b>Рубли: </b> '.$uinf['rub'].' <img src="http://144.76.127.94/view/image/icons/buy_gold.png" height="16" width="16" align="top" alt="ic"></div>';
$mobs_var = $_GET['mobs'];
switch(htmlspecialchars($mobs_var)) {
default;
$s_mobs = mysql_result(mysql_query("SELECT COUNT(*) FROM `mobs`"), 0);
$view_bots = mysql_query("SELECT * FROM `mobs` ORDER BY `id` ASC LIMIT $start, $kmess");
while($v_b = mysql_fetch_assoc($view_bots)) {
echo '<div class="user"><img src="'.$v_b['img'].'" align="top"></div>';
echo '<div class="content"><b>'.$v_b['name'].'</b><br/>(<font size="1">Уровень: '.$v_b['lvl'].' Здоровье: '.$v_b['hp'].'%</font>)</div>';
echo '<div class="menulink"><a href="?mobs=war&id='.$v_b['id'].'">Атаковать</a></div>';
}
if ($s_mobs > $kmess) {
echo '<div class="content"><center>';
echo '' . pagenav('./mobs.php?&', $start, $s_mobs, $kmess) . '';
echo '</center></div>';
}
break;
case 'war':
if(!empty($_SESSION['time_pauze'])) {
echo '<div class="yes">'.$_SESSION['time_pauze'].'</div>';
session_destroy();
}
$id = htmlspecialchars(intval($_GET['id']));
$chek_id = mysql_num_rows(mysql_query("SELECT `id` FROM `mobs` WHERE `id` = '".$id."'"));
if($chek_id != '0') {
$mob_info = mysql_fetch_assoc(mysql_query("SELECT * FROM `mobs` WHERE `id` = '".$id."'"));
echo '<div class="content">';
echo '<img src="http://warbk.com/img/ico/character-man.png" width="150" height="150" ><br>';
echo 'Имя: '.$mob_info['name'].'<br/>';
echo '<img src="http://warbk.com/img/lvl.png" width="16" height="16" >Уровень: '.$mob_info['lvl'].'<br/>';
echo '<img src="http://warbk.com/graph/ico/hp.png" width="16" height="16" ><font color="red">Здоровье: '.$mob_info['hp'].'<br/></font></font>';
echo '<img src="http://warbk.com/graph/ico/sp.png" width="16" height="16" >Баллы: '.($mob_info['balls'] * $uinf['x']).'<br/>';
echo '</div>';
echo '<div class="menulink"><a href="?mobs=war&mod=udar&id='.$id.'"><center>Простые Удары</center></a></div>';
echo '<div class="menulink"><a href="?mobs=war&mod=udar&id='.$id.'"><center><font color="fire"><b>Sun strike</b></font></center></a></div>';
echo '<div class="menulink"><a href="?mobs=war&mod=udar&id='.$id.'"><center>Chaos meteor</center></a></div>';
echo '<div class="user"><center>Лог боя</center></div>';
echo '<div class="content">';
echo $_SESSION['log_user'].'';
echo $_SESSION['log_mob'].'';
echo '</div>';
if($mob_info['hp'] <= '0') {
if($uinf['id_clan'] != '0') {
$opits = ($mob_info['oput']/$mob_info['lvl']/$uinf['lvl']/4);
$oput = round($opits - ($opits/100*15));
$oput_clan = round(($opits/100)*15);
$ball = $mob_info['balls'] * $uinf['x'];
$ballss = round($ball + ($ball/100)*($uclan['lvl_clan']*5));
$up_clanoput = mysql_query("UPDATE `clan` SET `oput` = `oput` + $oput_clan WHERE `id` = '".$uclan['id']."'");
} else {
$oput = round(($mob_info['oput']/$mob_info['lvl']/$uinf['lvl'])/4);
$ballss = $mob_info['balls'] * $uinf['x'];
}
$up_hpm = mysql_query("UPDATE `mobs` SET `hp` = '100' WHERE `id` = '".$id."'");
$randoms = rand(1, 4);
if($randoms == 3) {
$explode = explode(":", $mob_info['zoloto']);
$plus_zoloto = rand($explode['0'], $explode['1']);
$up_golds = mysql_query("UPDATE `users` SET `zoloto` = `zoloto` + $plus_zoloto WHERE `id` = '".$uinf['id']."'");
$_SESSION['pl_gold'] = ' и <img src="./theme/gold.png" height="12" width="12" align="top" alt="ic"> '.$plus_zoloto.' золота';
}
$balls_up = mysql_real_escape_string(mysql_query("INSERT INTO `stats_day` VALUES(0, '".$uinf['id']."', '".$ballss."', '".time()."')")); // Добавление баллов
$up_useroput = mysql_query("UPDATE `users` SET `oput` = `oput` + $oput WHERE `id` = '".$uinf['id']."'"); //добавляем опыт
$_SESSION['result'] = 'Вы победили! <font color="lime">+'.$ballss.' баллов, '.$oput.' опыта '.$_SESSION['pl_gold'].'!</font><br/><a href="./mobs.php">Вернуться</a>';
header("Location: http://warbk.com/start.php?start=result");
}
if($uinf['hp'] <= '0') {
$_SESSION['result'] = 'Вы проиграли!';
header("Location: http://warbk.com/start.php?start=result");
$up_user = mysql_query("UPDATE `users` SET `hp` = 0 WHERE `id` = '".$uinf['id']."'");
}
if(htmlspecialchars($_GET['mod']) == 'udar') {
if(empty($_SESSION['time'])) {
$_SESSION['time'] = time();
} else {
if(time() - $_SESSION['time'] < '3') {
$_SESSION['time_pauze'] = 'Соблюдайте интервал между ударами в 3 сек!<br/>';
header("Location: ./mobs=war&id=$id");
exit;
} else {
$_SESSION['time'] = time();
}
}
$pers_udar = rand($uinf['ataka'], $uinf['ataka']+5);
$mob_udar = rand($mob_info['ataka'], $mob_inf['ataka']+5);
if($pers_udar >= $mob_info['zashita']) {
$min_mob = $pers_udar - $mob_info['zashita']; //отнимаем хп у моба
} else {
$min_mob = '0';
}
if($mob_udar >= $uinf['zashita']) {
$min_user = $mob_udar - $uinf['zashita']; //отнимаем хп у пользователя
} else {
$min_user = '0';
}
$uarr = array('1' => 'Вы ударили противника <b>Chaos meteor</b> <img src="http://warbk.com/graph/ico/img.jpg" width="50" height="50" -', '2' => 'Вы решительно ударили '.$mob_info['name'].' и отняли -', '3' => 'Вы прицельно ранили '.$mob_info['name'].' и отняли -', '4' => 'Вы нанесли противнику <b>Sun Strike</b> <img src="http://warbk.com/graph/ico/images.jpg" width="50" height="50" и отняли -');
$marr = array('1' => ''.$mob_info['name'].' смело ударил Вас и отнял -', '2' => ''.$mob_info['name'].' со злости ударил Вас и отнял -');
$u_5 = 'Ваш удар оказался слаб';
$m_3 = 'Противник оказался слаб против Вас';
if($min_mob != '0')
{
$log_u = $uarr[rand(1, 4)];
} else {
$log_u = $u_5;
}
if($min_user != '0')
{
$log_m = $marr[rand(1, 2)];
} else {
$log_m = $m_3;
}
$_SESSION['log_user'] = '<b>'.$log_u.' '.$min_mob.' здоровья!</b><br/>';
$_SESSION['log_mob'] = '<b>'.$log_m.' '.$min_user.' здоровья!</b><br/>';
$update_moba = mysql_query("UPDATE `mobs` SET `hp` = `hp` - $min_mob WHERE `id` = '".$id."'"); //меняем хп моба
$update_user = mysql_query("UPDATE `users` SET `hp` = `hp` - $min_user WHERE `id` = '".$uinf['id']."'"); //меняем хп пользователя
header("Location: ?mobs=war&id=$id");
}
}
break;
}
include_once('./inc/foot.php');
?>