battles/magic/clones.php
2018-01-28 18:40:49 +02:00

39 lines
1.8 KiB
PHP

<?php
if($_SESSION['uid'] == null) { header("Location: index.php"); }
$int = 100;
if($user['battle'] == 0) {
echo "Это боевая магия...";
} else {
if(rand(1, 100) < $int) {
if($user['invis'] == 1) { $user['login'] = 'невидимка'; }
$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).")', '".$user['id']."', '".$user['battle']."', '".$user['hp']."')");
$bot = mysql_insert_id();
$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[$bot] as $k => $v) {
$battle[$k][$bot] = array(0, 0, time());
}
$t1 = explode(";", $bd['t1']);
if(in_array($user['id'], $t1)) {
$ttt = 1;
} else {
$ttt = 2;
}
if($user['invis'] == 1) { $lo = '<i><b>невидимка</b></i>'; } else { $lo = nick5($user['id'], "B".$ttt); }
if($user['invis'] == 1) { $los = '<i><b>невидимка</b></i>'; } else { $los = nick5($bot, "B".$ttt); }
addlog($user['battle'], '<span class=date>'.date("H:i").'</span> '.$lo.' породил своего клона '.$los.'.<BR>');
mysql_query('UPDATE `battle` SET `teams` = \''.serialize($battle).'\', `t'.$ttt.'` = CONCAT(`t'.$ttt.'`,\';'.$bot.'\') WHERE `id` = "'.$user['battle'].'" LIMIT 1');
mysql_query("UPDATE `battle` SET `to1` = '".time()."', `to2` = '".time()."' WHERE `id` = ".$user['battle']." LIMIT 1");
echo "Клон создан";
$bet = 1;
} else {
echo "Свиток рассыпался в ваших руках...";
$bet = 1;
}
}
?>