2022-06-06 21:30:34 +00:00
< ? php
2023-04-15 19:52:33 +00:00
use User\UserIp ;
2022-12-19 18:26:14 +00:00
const GAME = true ;
require_once ( '_incl_data/__config.php' );
require_once ( '_incl_data/class/__db_connect.php' );
define ( 'IP' , UserIp :: get ());
2022-06-06 21:30:34 +00:00
class battleNew {
}
2023-01-06 14:57:25 +00:00
$user = mysql_fetch_array ( mysql_query ( 'SELECT `id`,`battle` FROM `users` WHERE `login` = "' . mysql_real_escape_string ( $_COOKIE [ 'login' ]) . '"' ));
2022-06-06 21:30:34 +00:00
if ( isset ( $user [ 'id' ]) && $user [ 'battle' ] > 0 ) {
$stats = mysql_fetch_array ( mysql_query ( ' SELECT
`id` , `team` , `enemy` ,
`tactic1` , `tactic2` , `tactic3` , `tactic4` , `tactic5` , `tactic6` , `tactic7` ,
`battle_yron` , `priems` , `priems_z` , `priemslot`
FROM `stats` WHERE `id` = " '. $user['id'] .' " LIMIT 1 ' ));
if ( $stats [ 'hpNow' ] > $stats [ 'hpAll' ] ) {
$stats [ 'hpNow' ] = $stats [ 'hpAll' ];
}
if ( $stats [ 'mpNow' ] > $stats [ 'mpAll' ] ) {
$stats [ 'mpNow' ] = $stats [ 'mpAll' ];
}
2023-01-10 16:29:32 +00:00
//Получаем данные о поединке
2022-06-06 21:30:34 +00:00
$r = '' ;
2023-01-10 16:29:32 +00:00
//Проверяем размен с текущим противником
2022-06-06 21:30:34 +00:00
$bot_go = false ;
$rd = '' ;
$sp = mysql_query ( 'SELECT `id`,`uid1`,`uid2`,`time` FROM `battle_act` WHERE ( `uid1` = "' . $user [ 'id' ] . '" OR `uid2` = "' . $user [ 'id' ] . '" ) AND `battle` = "' . $user [ 'battle' ] . '" ORDER BY `time` ASC' );
while ( $pl = mysql_fetch_array ( $sp ) ) {
$rd .= ',[' . $pl [ 'id' ] . ',' . $pl [ 'uid1' ] . ',' . $pl [ 'uid2' ] . ',' . ( $pl [ 'time' ] - time () + $bt [ 'timeout' ]) . ']' ;
//
if ( $pl [ 'uid1' ] == $user [ 'id' ] && $bot_go == false ) {
$bot_test = mysql_fetch_array ( mysql_query ( 'SELECT `id` FROM `stats` WHERE `id` = "' . $pl [ 'uid2' ] . '" LIMIT 1' ));
if ( isset ( $bot_test [ 'id' ])) {
$bot_go = true ;
}
}
//
}
$rd = ltrim ( $rd , ',' );
$r .= ',"act":[' . $rd . ']' ;
unset ( $sp , $pl , $rd );
2023-01-10 16:29:32 +00:00
//Удары ботов
2022-06-06 21:30:34 +00:00
if ( $bot_go == true ) {
2023-01-10 16:29:32 +00:00
$error = 'Обычное обновление!' ;
2022-06-06 21:30:34 +00:00
}
if ( isset ( $_GET [ 'global' ])) {
$bt = mysql_fetch_array ( mysql_query ( 'SELECT `id`,`timeout`,`hod` FROM `battle` WHERE `id` = "' . $user [ 'battle' ] . '" LIMIT 1' ));
if ( isset ( $bt [ 'id' ])) {
2023-01-10 16:29:32 +00:00
//Получение инф. о пользователях в бою
2022-06-06 21:30:34 +00:00
$rd = '' ;
$sp = mysql_query ( 'SELECT `id`,`login`,`level`,`align`,`clan` FROM `users` WHERE `battle` = "' . $bt [ 'id' ] . '"' );
while ( $pl = mysql_fetch_array ( $sp ) ) {
$st = mysql_fetch_array ( mysql_query ( 'SELECT `hpNow`,`mpNow`,`hpAll`,`mpAll`,`team` FROM `stats` WHERE `id` = "' . $pl [ 'id' ] . '" LIMIT 1' ));
$rd .= '[' . ( 0 + $pl [ 'id' ]) . ',' . ( 0 + $st [ 'hpNow' ]) . ',' . ( 0 + $st [ 'mpNow' ]) . ',' . ( 0 + $st [ 'hpAll' ]) . ',' . ( 0 + $st [ 'mpAll' ]) . '],' ;
}
$rd = rtrim ( $rd , ',' );
$r .= ',"u":[' . $rd . ']' ;
} else {
2023-01-10 16:29:32 +00:00
$error = 'Поединок не найден...' ;
2022-06-06 21:30:34 +00:00
}
2023-01-10 16:29:32 +00:00
//Эффекты текущего персонажа и противника
2022-06-06 21:30:34 +00:00
$r .= ',"eff_me":[' ;
$i = 0 ;
$sp = mysql_query ( 'SELECT * FROM `eff_users` WHERE ( `uid` = "' . $user [ 'id' ] . '" OR `uid` = "' . $stats [ 'enemy' ] . '" ) AND `delete` = "0" ORDER BY `id` DESC' );
while ( $pl = mysql_fetch_array ( $sp ) ) {
if ( $pl [ 'v1' ] == 'priem' ) {
$prm = mysql_fetch_array ( mysql_query ( 'SELECT * FROM `priems` WHERE `id` = "' . $pl [ 'v2' ] . '" LIMIT 1' ));
if ( $user [ 'id' ] == $pl [ 'uid' ] || $prm [ 'neg' ] > 0 ) {
if ( $i == 0 ) {
$i ++ ;
} else {
$r .= ',' ;
}
$r .= '[' . $pl [ 'uid' ] . ',' . $pl [ 'id' ] . ',' . $pl [ 'id_eff' ] . ',"' . $pl [ 'name' ] . '","' . $prm [ 'img' ] . '.gif","14"]' ;
}
} else {
if ( $user [ 'id' ] == $pl [ 'uid' ] ) {
if ( $i == 0 ) {
$i ++ ;
} else {
$r .= ',' ;
}
$eff = mysql_fetch_array ( mysql_query ( 'SELECT * FROM `eff_main` WHERE `id2` = "' . $pl [ 'id_eff' ] . '" LIMIT 1' ));
$r .= '[' . $pl [ 'uid' ] . ',' . $pl [ 'id' ] . ',' . $pl [ 'id_eff' ] . ',"' . $pl [ 'name' ] . '","' . $eff [ 'img' ] . '","' . $eff [ 'type1' ] . '"]' ;
}
}
}
$r .= ']' ;
//
} elseif ( isset ( $_GET [ 'loading' ])) {
2023-01-10 16:29:32 +00:00
//Загрузда дополнительных данных
2022-06-06 21:30:34 +00:00
if ( isset ( $_GET [ 'uload' ]) && $_GET [ 'uload' ] != '0' ) {
2023-01-10 16:29:32 +00:00
//Загрузка пользователей
2022-06-06 21:30:34 +00:00
$ex = explode ( ',' , $_GET [ 'uload' ]);
$i = 1 ;
$rd = '' ;
while ( $i < count ( $ex ) ) {
if ( $ex [ $i ] > 0 ) {
//
$us = mysql_fetch_array ( mysql_query ( ' SELECT
`id` , `login` , `level` , `clan` , `align` , `obraz`
FROM `users` WHERE `battle` = " '. $user['battle'] .' " AND `id` = " '.mysql_real_escape_string( $ex[$i] ).' " LIMIT 1 ' ));
if ( isset ( $us [ 'id' ])) {
$ss = mysql_fetch_array ( mysql_query ( ' SELECT
`hpNow` , `mpNow` , `hpAll` , `mpAll` , `team`
FROM `stats` WHERE `id` = " '. $us['id'] .' " LIMIT 1 ' ));
if ( $ss [ 'hpNow' ] > $ss [ 'hpAll' ] ) {
$ss [ 'hpNow' ] = $ss [ 'hpAll' ];
}
if ( $ss [ 'mpNow' ] > $ss [ 'mpAll' ] ) {
$ss [ 'mpNow' ] = $ss [ 'mpAll' ];
}
$rd .= ',{' ;
//
$rd .= ' "id":' . ( 0 + ( int ) $ex [ $i ] );
$rd .= ',"login":"' . $us [ 'login' ] . '"' ;
$rd .= ',"level":"' . $us [ 'level' ] . '"' ;
$rd .= ',"align":"' . $us [ 'align' ] . '"' ;
$rd .= ',"clan":"' . $us [ 'clan' ] . '"' ;
$rd .= ',"team":"' . $ss [ 'team' ] . '"' ;
$rd .= ',"hp":' . ( 0 + $ss [ 'hpNow' ] ) . '' ;
$rd .= ',"mp":' . ( 0 + $ss [ 'mpNow' ] ) . '' ;
$rd .= ',"hpAll":' . ( 0 + $ss [ 'hpAll' ] ) . '' ;
$rd .= ',"mpAll":' . ( 0 + $ss [ 'mpAll' ] ) . '' ;
$rd .= ',"sex":' . ( 0 + $us [ 'sex' ] ) . '' ;
$rd .= ',"obraz":"' . $us [ 'obraz' ] . '"' ;
//
2023-01-10 16:29:32 +00:00
//Предметы
2022-06-06 21:30:34 +00:00
$ri = '' ;
$sp = mysql_query ( 'SELECT `id`,`item_id`,`inOdet`,`magic_inc` FROM `items_users` WHERE `uid` = "' . $us [ 'id' ] . '" AND `delete` = 0 AND `inOdet` > 0' );
while ( $pl = mysql_fetch_array ( $sp ) ) {
//
$im = mysql_fetch_array ( mysql_query ( 'SELECT `id`,`name`,`img`,`magic_inci` FROM `items_main` WHERE `id` = "' . $pl [ 'item_id' ] . '" LIMIT 1' ));
//
$ccv = '' ;
if ( $pl [ 'magic_inc' ] == '' ) {
$pl [ 'magic_inc' ] = $im [ 'magic_inci' ];
}
if ( $pl [ 'magic_inc' ] != '' ) {
$mgi = mysql_fetch_array ( mysql_query ( 'SELECT * FROM `eff_main` WHERE `id2` = "' . $pl [ 'magic_inc' ] . '" AND `type1` = "12345" LIMIT 1' ));
if ( isset ( $mgi [ 'id2' ])) {
$ccv .= 'top.useMagicBattle(\'' . $mgi [ 'mname' ] . '\',' . $pl [ 'id' ] . ',\'' . $mgi [ 'img' ] . '\',1,2);' ;
}
}
//
$ri .= ',[' . $pl [ 'id' ] . ',' . $pl [ 'item_id' ] . ',' . $pl [ 'inOdet' ] . ',"' . $im [ 'name' ] . '","' . $im [ 'img' ] . '","' . $ccv . '"]' ;
}
$ri = ltrim ( $ri , ',' );
$rd .= ',"itm":[' . $ri . ']' ;
//
2023-01-10 16:29:32 +00:00
//Эффекты (не требуется кэширование)
2022-06-06 21:30:34 +00:00
$ri = '' ;
$ri = ltrim ( $ri , ',' );
$rd .= ',"eff":[' . $ri . ']' ;
//
//
$rd .= ' }' ;
}
}
$i ++ ;
}
$rd = ltrim ( $rd , ',' );
$r .= ',"ul":[' . $rd . ']' ;
unset ( $rd , $ri );
//
}
//
if ( isset ( $_GET [ 'pload' ]) && $_GET [ 'pload' ] != '0' ) {
2023-01-10 16:29:32 +00:00
//Загрузка приемов
2022-06-06 21:30:34 +00:00
$ex = explode ( ',' , $_GET [ 'pload' ]);
$i = 1 ;
$rd = '' ;
while ( $i < count ( $ex ) ) {
if ( $ex [ $i ] > 0 ) {
//
$pl = mysql_fetch_array ( mysql_query ( ' SELECT
`id` , `name` , `img` , `type` , `onUser` , `team`
FROM `priems` WHERE `id` = " '.mysql_real_escape_string( $ex[$i] ).' " LIMIT 1 ' ));
if ( isset ( $pl [ 'id' ])) {
//
$rd .= ',{' ;
//
$rd .= ' "id":' . ( 0 + ( int ) $ex [ $i ] );
$rd .= ',"name":"' . $pl [ 'name' ] . '"' ;
$rd .= ',"img":"' . $pl [ 'img' ] . '"' ;
$rd .= ',"type":"' . $pl [ 'type' ] . '"' ;
$rd .= ',"onUser":"' . $pl [ 'onUser' ] . '"' ;
$rd .= ',"team":"' . $pl [ 'team' ] . '"' ;
//
$rd .= ' }' ;
//
}
}
$i ++ ;
}
$rd = ltrim ( $rd , ',' );
$r .= ',"pl":[' . $rd . ']' ;
unset ( $sp , $pl , $rd );
//
}
//
}
} else {
2023-01-10 16:29:32 +00:00
$error = 'Пользователь в бою не найден...' ;
2022-06-06 21:30:34 +00:00
}
echo '{ "btl":"' . ( 0 + $bt [ 'id' ]) . '" , "hod":"' . ( 0 + $bt [ 'hod' ]) . '" , "you":"' . ( 0 + $user [ 'id' ]) . '" , "enemy":"' . ( 0 + $stats [ 'enemy' ]) . '" , "pr": [ "' . $stats [ 'priems' ] . '" , "' . $stats [ 'priems_z' ] . '" , ' . ( 0 + $stats [ 'priemslot' ]) . ' ] , "dm":"' . floor ( $stats [ 'battle_yron' ]) . '" , "to":"' . round ( $bt [ 'timeout' ] / 60 , 2 ) . '" , "r":{ ' . ltrim ( $r , ',' ) . ' } , "e":"' . $error . '" , "t1":"' . $stats [ 'tactic1' ] . '" , "t2":"' . $stats [ 'tactic2' ] . '" , "t3":"' . $stats [ 'tactic3' ] . '" , "t4":"' . $stats [ 'tactic4' ] . '" , "t5":"' . $stats [ 'tactic5' ] . '" , "t6":"' . $stats [ 'tactic6' ] . '" , "t7":"' . $stats [ 'tactic7' ] . '" }' ;