72 lines
2.6 KiB
PHP
72 lines
2.6 KiB
PHP
<?php
|
|
if($_SESSION['uid'] == null) { header("Location: index.php"); }
|
|
$vip = mysql_fetch_array(mysql_query('SELECT `id`, `uid`, `unclone` FROM `abils_user` WHERE `uid` = "'.$user['id'].'" LIMIT 1'));
|
|
|
|
if($user['battle'] == 0) {
|
|
echo "Это боевая магия...";
|
|
} else {
|
|
if($vip['unclone'] >= 1) {
|
|
$bot = mysql_fetch_array(mysql_query("SELECT * FROM `bots` WHERE `name` = '".mysql_real_escape_string($_POST['target'])."' AND `battle` = '".$user['battle']."' LIMIT 1"));
|
|
|
|
if($bot) {
|
|
$prototype = mysql_fetch_array(mysql_query('SELECT `id`, `intel` FROM `users` WHERE `id` = "'.$bot['prototype'].'" LIMIT 1'));
|
|
}
|
|
|
|
if($bot['hp'] <= 0) {
|
|
echo 'Мертвых переманивать нельзя ... '.$bot['id'].'='.$bot['hp'];
|
|
} elseif($prototype['intel'] > $user['intel']) {
|
|
echo 'Ваш противник имеет более высокий интелект ...';
|
|
} elseif($bot && strpos($_POST['target'], "клон")) {
|
|
$bot = $bot[0];
|
|
$bd = mysql_fetch_array(mysql_query('SELECT * FROM `battle` WHERE `id` = "'.$user['battle'].'" LIMIT 1'));
|
|
$battle = unserialize($bd['teams']);
|
|
$battle[$bot] = $battle[$user['id']];
|
|
foreach($battle as $k => $v) {
|
|
unset($battle[$k][$bot]);
|
|
}
|
|
|
|
foreach($battle[$user['id']] as $k => $v) {
|
|
$battle[$k][$bot] = array(0, 0, time());
|
|
}
|
|
|
|
$t1 = explode(";", $bd['t1']);
|
|
$t2 = explode(";", $bd['t2']);
|
|
|
|
foreach($t1 as $k => $v) {
|
|
if($v == $bot) {
|
|
unset($t1[$k]);
|
|
}
|
|
}
|
|
|
|
foreach($t2 as $k => $v) {
|
|
if($v == $bot) {
|
|
unset($t2[$k]);
|
|
}
|
|
}
|
|
|
|
if(in_array($user['id'], $t1)) {
|
|
$ttt = 1;
|
|
$t1[] = $bot;
|
|
} else {
|
|
$ttt = 2;
|
|
$t2[] = $bot;
|
|
}
|
|
|
|
$t1 = implode(";", $t1);
|
|
$t2 = implode(";", $t2);
|
|
|
|
addlog($user['battle'],'<span class=date>'.date("H:i").'</span> '.nick5($user['id'], "B".$ttt).' переманил клона '.nick5($bot, "B".$ttt).' на свою сторону.<BR>');
|
|
mysql_query('UPDATE `battle` SET `teams` = \''.serialize($battle).'\', `t1` = \''.$t1.'\', `t2` = \''.$t2.'\' WHERE `id` = "'.$user['battle'].'" LIMIT 1');
|
|
mysql_query("UPDATE `battle` SET `to1` = '".time()."', `to2` = '".time()."' WHERE `id` = '".$user['battle']."' LIMIT 1");
|
|
echo mysql_error();
|
|
echo "Вы переманили клона";
|
|
$vip['unclone'] -= 1;
|
|
mysql_query('UPDATE `abils_user` SET `unclone` = "'.$vip['unclone'].'" WHERE `id` = "'.$vip['id'].'" LIMIT 1');
|
|
} else {
|
|
echo "Нет такого клона";
|
|
}
|
|
} else {
|
|
echo "Свиток рассыпался в ваших руках...";
|
|
}
|
|
}
|
|
?>
|