2018-01-28 16:40:49 +00:00
< ? php
2021-08-26 14:44:14 +00:00
use Battles\GameLogs ;
use Battles\Nick ;
2020-09-30 12:30:00 +00:00
if ( empty ( $_SESSION [ 'uid' ])) {
2020-09-30 12:01:33 +00:00
header ( " Location: index.php " );
exit ;
}
2018-01-28 16:40:49 +00:00
if ( $user [ 'battle' ] == 0 ) {
2020-10-29 23:30:05 +00:00
echo " ќто боеваЯ магиЯ... " ;
2018-01-28 16:40:49 +00:00
} else {
2020-10-29 23:30:05 +00:00
$magic = mysql_fetch_array ( mysql_query ( " SELECT `chanse` FROM `magic` WHERE `id` = '17' ; " ));
if ( $user [ 'intel' ] >= 3 ) {
$int = $magic [ 'chanse' ] + ( $user [ 'intel' ] - 3 ) * 3 ;
if ( $int > 98 ) {
$int = 99 ;
}
} else {
$int = 0 ;
}
if ( rand ( 1 , 100 ) < $int ) {
$bot = mysql_fetch_array ( mysql_query ( " SELECT * FROM `bots` WHERE `name` = ' " . $_POST [ 'target' ] . " '; " ));
if ( $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 ] = [ 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 );
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' ] . ' ;' );
mysql_query ( " UPDATE `battle` SET `to1` = ' " . time () . " ', `to2` = ' " . time () . " ' WHERE `id` = " . $user [ 'battle' ] . " LIMIT 1; " );
mysql_query ( " UPDATE bots set 'owner'=' " . $user [ 'id' ] . " ' WHERE `name` = ' " . $_POST [ 'target' ] . " '; " );
2018-01-28 16:40:49 +00:00
2020-10-29 23:30:05 +00:00
$bet = 1 ;
echo " ‚ы переманили клона " ;
} else {
echo " Ќет такого клона " ;
}
} else {
echo " свиток рассыпалсЯ в ваших руках... " ;
$bet = 1 ;
}
2018-01-28 16:40:49 +00:00
}