2018-01-28 16:40:49 +00:00
< ? php
2021-08-26 14:44:14 +00:00
use Battles\GameLogs ;
use Battles\Nick ;
2020-10-29 23:30:05 +00:00
if ( $_SESSION [ 'uid' ] == null ) {
header ( " Location: index.php " );
exit ;
}
$vip = mysql_fetch_array ( mysql_query ( 'SELECT `id`, `klan`, `unclone` FROM `abils_klan` WHERE `klan` = "' . $user [ 'klan' ] . '" LIMIT 1' ));
2018-01-28 16:40:49 +00:00
2020-10-29 23:30:05 +00:00
if ( $user [ 'battle' ] == 0 ) {
echo " Это боевая магия... " ;
2018-01-28 16:40:49 +00:00
} else {
2020-10-29 23:30:05 +00:00
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 " ));
2018-01-28 16:40:49 +00:00
2020-10-29 23:30:05 +00:00
if ( $bot ) {
$prototype = mysql_fetch_array ( mysql_query ( 'SELECT `id`, `intel` FROM `users` WHERE `id` = "' . $bot [ 'prototype' ] . '" LIMIT 1' ));
}
if ( $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 ]);
}
2018-01-28 16:40:49 +00:00
2020-10-29 23:30:05 +00:00
foreach ( $battle [ $user [ 'id' ]] as $k => $v ) {
$battle [ $k ][ $bot ] = [ 0 , 0 , time ()];
}
2018-01-28 16:40:49 +00:00
2020-10-29 23:30:05 +00:00
$t1 = explode ( " ; " , $bd [ 't1' ]);
$t2 = explode ( " ; " , $bd [ 't2' ]);
2018-01-28 16:40:49 +00:00
2020-10-29 23:30:05 +00:00
foreach ( $t1 as $k => $v ) {
if ( $v == $bot ) {
unset ( $t1 [ $k ]);
}
}
2018-01-28 16:40:49 +00:00
2020-10-29 23:30:05 +00:00
foreach ( $t2 as $k => $v ) {
if ( $v == $bot ) {
unset ( $t2 [ $k ]);
}
}
2018-01-28 16:40:49 +00:00
2020-10-29 23:30:05 +00:00
if ( in_array ( $user [ 'id' ], $t1 )) {
$ttt = 1 ;
$t1 [] = $bot ;
} else {
$ttt = 2 ;
$t2 [] = $bot ;
}
2018-01-28 16:40:49 +00:00
2020-10-29 23:30:05 +00:00
$t1 = implode ( " ; " , $t1 );
$t2 = implode ( " ; " , $t2 );
2021-08-26 14:44:14 +00:00
GameLogs :: addBattleLog ( $user [ 'battle' ], '<span class=date>' . date ( " H:i " ) . '</span> ' . Nick :: id ( $user [ 'id' ]) -> short () . ' переманил клона ' . Nick :: id ( $bot ) -> short () . ' на свою сторону<BR>' );
2020-10-29 23:30:05 +00:00
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 " Вы переманили клона " ;
$vip [ 'unclone' ] -= 1 ;
mysql_query ( 'UPDATE `abils_klan` SET `unclone` = "' . $vip [ 'unclone' ] . '" WHERE `klan` = "' . $vip [ 'klan' ] . '" LIMIT 1' );
} else {
echo " Нет такого клона " ;
}
2018-01-28 16:40:49 +00:00
} else {
2020-10-29 23:30:05 +00:00
echo " Свиток рассыпался в ваших руках... " ;
}
2018-01-28 16:40:49 +00:00
}