54 lines
2.1 KiB
PHP
54 lines
2.1 KiB
PHP
<?php
|
|
|
|
if ($_SESSION['uid'] == null) header("Location: index.php");
|
|
|
|
if ($user['battle'] == 0) {
|
|
echo "Это боевая магия...";
|
|
} else {
|
|
$magic = mysql_fetch_array(mysql_query("SELECT `chanse` FROM `magic` WHERE `id` = '16' ;"));
|
|
if ($user['intel'] >= 8) {
|
|
$int=$magic['chanse'] + ($user['intel'] - 8)*3;
|
|
if ($int>98){$int=99;}
|
|
}
|
|
else {$int=0;}
|
|
|
|
if (rand(1,100) < $int) {
|
|
$nb = mysql_fetch_array(mysql_query("SELECT count(`id`) FROM `bots` WHERE `name` LIKE '".$user['login']." (Элементаль Земли - враг%';"));
|
|
mysql_query("INSERT INTO `bots` (`name`,`prototype`,`battle`,`hp`) values ('".$user['login']." (Элементаль Земли - враг ".($nb[0]+1).")','1244','".$user['battle']."','2500');");
|
|
$bot = mysql_insert_id();
|
|
|
|
$bd = mysql_fetch_array(mysql_query ('SELECT * FROM `battle` WHERE `id` = '.$user['battle'].' LIMIT 1;'));
|
|
$battle = unserialize($bd['teams']);
|
|
|
|
$t1 = explode(";",$bd['t1']);
|
|
if(in_array ($user['id'],$t1)) $bot_marker=$t2[0];
|
|
else $bot_marker=$t1[0];
|
|
|
|
$battle[$bot] = $battle[$bot_marker];
|
|
foreach($battle[$bot] as $k => $v) {
|
|
$battle[$k][$bot] = array(0,0,time());
|
|
}
|
|
|
|
// проставляем кто-где
|
|
if (in_array ($bot_marker,$t1)) {
|
|
$ttt = 1;
|
|
} else {
|
|
$ttt = 2;
|
|
}
|
|
//mysql_query('UPDATE `logs` SET `log` = CONCAT(`log`,\'<span class=date>'.date("H:i").'</span> '.nick5($user['id'],"B".$ttt).' породил своего клона '.nick5($bot,"B".$ttt).'<BR>\') WHERE `id` = '.$user['battle'].';');
|
|
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).'\', `t'.$ttt.'`=CONCAT(`t'.$ttt.'`,\';'.$bot.'\') WHERE `id` = '.$user['battle'].' ;');
|
|
|
|
mysql_query("UPDATE `battle` SET `to1` = '".time()."', `to2` = '".time()."' WHERE `id` = ".$user['battle']." LIMIT 1;");
|
|
|
|
$bet=1;
|
|
echo "Элементаль вызван";
|
|
|
|
} else {
|
|
echo "Свиток рассыпался в ваших руках...";
|
|
$bet=1;
|
|
}
|
|
}
|
|
|
|
?>
|