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` = '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`,`owner`) values (' " . $user [ 'login' ] . " (Элементаль Огня - союзник " . ( $nb [ 0 ] + 1 ) . " )','1241',' " . $user [ 'battle' ] . " ','1000',' " . $user [ 'id' ] . " '); " );
$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 ] = [ 0 , 0 , time ()];
}
$t1 = explode ( " ; " , $bd [ 't1' ]);
// проставляем кто-где
if ( in_array ( $user [ 'id' ], $t1 )) {
$ttt = 1 ;
} else {
$ttt = 2 ;
}
//mysql_query('UPDATE `logs` SET `log` = CONCAT(`log`,\'<span class=date>'.date("H:i").'</span> '.nick::id($user['id'])->short().' породил своего клона '.nick::id($bot)->short().'<BR>\') WHERE `id` = '.$user['battle'].';');
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 ) . '\', `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 ;
}
2018-01-28 16:40:49 +00:00
}